@soma-vertical-web/multi-lib 0.0.28 → 0.0.30
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/catalog/index.d.ts +3 -0
- package/data/api/catalog/kit/index.d.ts +11 -0
- package/data/api/catalog/product/info/index.d.ts +10 -0
- package/data/api/catalog/product/similars/index.d.ts +11 -22
- package/data/api/checkout/address/index.d.ts +1 -1
- package/data/api/checkout/order-form/attachments/index.d.ts +1 -1
- package/data/api/checkout/order-form/attachments/marketing-data/index.d.ts +1 -1
- package/data/api/checkout/order-form/attachments/open-text-field/index.d.ts +1 -1
- package/data/api/checkout/order-form/coupon/index.d.ts +1 -1
- package/data/api/checkout/order-form/custom-data/index.d.ts +1 -1
- package/data/api/checkout/order-form/items/remove-all/index.d.ts +1 -1
- package/data/api/checkout/order-form/items/update/index.d.ts +1 -1
- package/data/api/checkout/order-form/messages/remove-all/index.d.ts +1 -1
- package/data/api/checkout/order-form/offerings/index.d.ts +1 -1
- package/data/api/checkout/order-form/orderform/index.d.ts +1 -1
- package/data/api/checkout/order-form/profile/index.d.ts +1 -1
- package/data/api/checkout/order-form/seller-code/index.d.ts +1 -1
- package/data/api/checkout/order-form/shipping/index.d.ts +1 -1
- package/data/api/checkout/order-form/shipping/update/index.d.ts +1 -1
- package/data/api/checkout/region/index.d.ts +1 -1
- package/data/api/checkout/simulation/index.d.ts +1 -1
- package/data/api/fetchVtex.d.ts +2 -1
- package/data/helpers/catalog/index.d.ts +38 -0
- package/index2.js +1 -1
- package/index2.mjs +504 -338
- package/package.json +1 -1
- package/server.d.ts +11 -155
- package/types/data/api/catalog/kit/index.d.ts +0 -0
- package/types/data/api/catalog/portal/index.d.ts +26 -0
- package/types/data/api/catalog/product/index.d.ts +50 -0
- package/types/data/api/index.d.ts +3 -6
- package/types/layout/team-components/FreightCalculation/index.d.ts +6 -24
- package/types/layout/team-components/ProductCard/Selectors/index.d.ts +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FetchFunctionsProps } from '../../../../types/data/api';
|
|
2
|
+
|
|
3
|
+
import * as yup from 'yup';
|
|
4
|
+
declare const schema: yup.ObjectSchema<{
|
|
5
|
+
skuId: string | undefined;
|
|
6
|
+
}, yup.AnyObject, {
|
|
7
|
+
skuId: undefined;
|
|
8
|
+
}, "">;
|
|
9
|
+
type SchemaType = yup.InferType<typeof schema>;
|
|
10
|
+
export declare function getCatalogKitProducts({ apiUrl, body, fetchOptions }: FetchFunctionsProps<SchemaType>): Promise<any>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FetchFunctionsProps } from '../../../../../types/data/api';
|
|
2
|
+
import * as yup from 'yup';
|
|
3
|
+
declare const schema: yup.ObjectSchema<{
|
|
4
|
+
ids: string[];
|
|
5
|
+
}, yup.AnyObject, {
|
|
6
|
+
ids: "";
|
|
7
|
+
}, "">;
|
|
8
|
+
type SchemaType = yup.InferType<typeof schema>;
|
|
9
|
+
export declare function getCatalogProducts({ apiUrl, body, fetchOptions }: FetchFunctionsProps<SchemaType>): Promise<any>;
|
|
10
|
+
export {};
|
|
@@ -1,22 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
13
|
-
}>;
|
|
14
|
-
images: Array<{
|
|
15
|
-
imageLabel: string;
|
|
16
|
-
imageUrl: string;
|
|
17
|
-
imageText: string;
|
|
18
|
-
}>;
|
|
19
|
-
}>;
|
|
20
|
-
productId: string;
|
|
21
|
-
linkText: string;
|
|
22
|
-
}
|
|
1
|
+
import { FetchFunctionsProps } from '../../../../../types/data/api';
|
|
2
|
+
|
|
3
|
+
import * as yup from 'yup';
|
|
4
|
+
declare const schema: yup.ObjectSchema<{
|
|
5
|
+
productId: number;
|
|
6
|
+
}, yup.AnyObject, {
|
|
7
|
+
productId: undefined;
|
|
8
|
+
}, "">;
|
|
9
|
+
type SchemaType = yup.InferType<typeof schema>;
|
|
10
|
+
export declare function getCatalogSimilars({ apiUrl, body, fetchOptions }: FetchFunctionsProps<SchemaType>): Promise<any>;
|
|
11
|
+
export {};
|
|
@@ -17,5 +17,5 @@ type SchemaType = yup.InferType<typeof schemaAddress>;
|
|
|
17
17
|
* @returns Address information corresponding to the provided postal code and country.
|
|
18
18
|
* This request is useful for implementing auto-complete functionality when a customer needs to fill in an address.
|
|
19
19
|
*/
|
|
20
|
-
export declare function postOrderformAddress({ apiUrl, body, fetchOptions }: FetchFunctionsProps<SchemaType>): Promise<
|
|
20
|
+
export declare function postOrderformAddress({ apiUrl, body, fetchOptions }: FetchFunctionsProps<SchemaType>): Promise<any>;
|
|
21
21
|
export {};
|
|
@@ -13,5 +13,5 @@ type SchemaType = yup.InferType<typeof schemaAttachments>;
|
|
|
13
13
|
/**
|
|
14
14
|
* Attach marketing and open text field data to a shopping cart.
|
|
15
15
|
*/
|
|
16
|
-
export declare function postOrderFormAttachOrderFormData({ apiUrl, body, fetchOptions }: FetchFunctionsProps<SchemaType>): Promise<
|
|
16
|
+
export declare function postOrderFormAttachOrderFormData({ apiUrl, body, fetchOptions }: FetchFunctionsProps<SchemaType>): Promise<any>;
|
|
17
17
|
export {};
|
|
@@ -17,5 +17,5 @@ type SchemaType = yup.InferType<typeof schemaMarketingData>;
|
|
|
17
17
|
* @returns A list of sellers that cater to the specified region or address.
|
|
18
18
|
* This endpoint provides flexibility in accessing seller information based on region or address, allowing you to choose between path parameters or query parameters.
|
|
19
19
|
*/
|
|
20
|
-
export declare function postOrderFormAttachmentsMarketingData({ apiUrl, body, fetchOptions }: FetchFunctionsProps<SchemaType>): Promise<
|
|
20
|
+
export declare function postOrderFormAttachmentsMarketingData({ apiUrl, body, fetchOptions }: FetchFunctionsProps<SchemaType>): Promise<any>;
|
|
21
21
|
export {};
|
|
@@ -14,5 +14,5 @@ type SchemaType = yup.InferType<typeof schemaOpenTextField>;
|
|
|
14
14
|
* Use this request to include open text field information to a given shopping cart.
|
|
15
15
|
* https://developers.vtex.com/docs/api-reference/checkout-api#post-/api/checkout/pub/orderForm/-orderFormId-/attachments/openTextField
|
|
16
16
|
*/
|
|
17
|
-
export declare function postOrderFormAttachmentsOpenTextField({ apiUrl, body, fetchOptions, }: FetchFunctionsProps<SchemaType>): Promise<
|
|
17
|
+
export declare function postOrderFormAttachmentsOpenTextField({ apiUrl, body, fetchOptions, }: FetchFunctionsProps<SchemaType>): Promise<any>;
|
|
18
18
|
export {};
|
|
@@ -11,5 +11,5 @@ type SchemaType = yup.InferType<typeof schemaCoupon>;
|
|
|
11
11
|
/**
|
|
12
12
|
* Add a coupon to a given shopping cart.
|
|
13
13
|
*/
|
|
14
|
-
export declare function postOrderFormAddCoupon({ apiUrl, body, fetchOptions, }: FetchFunctionsProps<SchemaType>): Promise<
|
|
14
|
+
export declare function postOrderFormAddCoupon({ apiUrl, body, fetchOptions, }: FetchFunctionsProps<SchemaType>): Promise<any>;
|
|
15
15
|
export {};
|
|
@@ -13,5 +13,5 @@ type SchemaType = yup.InferType<typeof schemaCustomData>;
|
|
|
13
13
|
/**
|
|
14
14
|
* Update custom data for an order form app.
|
|
15
15
|
*/
|
|
16
|
-
export declare function putOrderFormCustomData({ apiUrl, body, fetchOptions, }: FetchFunctionsProps<SchemaType>): Promise<
|
|
16
|
+
export declare function putOrderFormCustomData({ apiUrl, body, fetchOptions, }: FetchFunctionsProps<SchemaType>): Promise<any>;
|
|
17
17
|
export {};
|
|
@@ -9,5 +9,5 @@ type SchemaType = yup.InferType<typeof schemaItems>;
|
|
|
9
9
|
/**
|
|
10
10
|
* Remove all items from the shopping cart.
|
|
11
11
|
*/
|
|
12
|
-
export declare function postOrderFormRemoveAllItems({ apiUrl, body, fetchOptions, }: FetchFunctionsProps<SchemaType>): Promise<
|
|
12
|
+
export declare function postOrderFormRemoveAllItems({ apiUrl, body, fetchOptions, }: FetchFunctionsProps<SchemaType>): Promise<any>;
|
|
13
13
|
export {};
|
|
@@ -39,5 +39,5 @@ type SchemaType = yup.InferType<typeof schemaItems>;
|
|
|
39
39
|
/**
|
|
40
40
|
* Update items in the shopping cart.
|
|
41
41
|
*/
|
|
42
|
-
export declare function postOrderFormUpdateItems({ apiUrl, body, fetchOptions, }: FetchFunctionsProps<SchemaType>): Promise<
|
|
42
|
+
export declare function postOrderFormUpdateItems({ apiUrl, body, fetchOptions, }: FetchFunctionsProps<SchemaType>): Promise<any>;
|
|
43
43
|
export {};
|
|
@@ -9,5 +9,5 @@ type SchemaType = yup.InferType<typeof schemaMessage>;
|
|
|
9
9
|
/**
|
|
10
10
|
* Remove all messages from the orderForm messages field.
|
|
11
11
|
*/
|
|
12
|
-
export declare function postOrderFormClearMessages({ apiUrl, body, fetchOptions, }: FetchFunctionsProps<SchemaType>): Promise<
|
|
12
|
+
export declare function postOrderFormClearMessages({ apiUrl, body, fetchOptions, }: FetchFunctionsProps<SchemaType>): Promise<any>;
|
|
13
13
|
export {};
|
|
@@ -15,5 +15,5 @@ type SchemaType = yup.InferType<typeof schemaOffering>;
|
|
|
15
15
|
/**
|
|
16
16
|
* Add or remove a service (offering) to a specific item in the shopping cart.
|
|
17
17
|
*/
|
|
18
|
-
export declare function updateOrderFormOffering({ apiUrl, body, fetchOptions }: FetchFunctionsProps<SchemaType>): Promise<
|
|
18
|
+
export declare function updateOrderFormOffering({ apiUrl, body, fetchOptions }: FetchFunctionsProps<SchemaType>): Promise<any>;
|
|
19
19
|
export {};
|
|
@@ -10,5 +10,5 @@ type SchemaType = yup.InferType<typeof schemaOrderForm>;
|
|
|
10
10
|
* Retrieves all information associated with a given shopping cart.
|
|
11
11
|
* https://developers.vtex.com/docs/api-reference/checkout-api#get-/api/checkout/pub/orderForm/-orderFormId-
|
|
12
12
|
*/
|
|
13
|
-
export declare function getOrderForm({ apiUrl, body, fetchOptions, extraData, }: FetchFunctionsProps<SchemaType>): Promise<
|
|
13
|
+
export declare function getOrderForm({ apiUrl, body, fetchOptions, extraData, }: FetchFunctionsProps<SchemaType>): Promise<any>;
|
|
14
14
|
export {};
|
|
@@ -21,5 +21,5 @@ type SchemaType = yup.InferType<typeof schemaProfile>;
|
|
|
21
21
|
/**
|
|
22
22
|
* Attach client profile data to a shopping cart.
|
|
23
23
|
*/
|
|
24
|
-
export declare function postOrderFormAttachClientProfileData({ apiUrl, body, fetchOptions, }: FetchFunctionsProps<SchemaType>): Promise<
|
|
24
|
+
export declare function postOrderFormAttachClientProfileData({ apiUrl, body, fetchOptions, }: FetchFunctionsProps<SchemaType>): Promise<any>;
|
|
25
25
|
export {};
|
|
@@ -9,5 +9,5 @@ type SchemaType = yup.InferType<typeof schemaSellerCode>;
|
|
|
9
9
|
/**
|
|
10
10
|
* Fetch seller code data from VTEX data entities.
|
|
11
11
|
*/
|
|
12
|
-
export declare function getMasterDataSellerCode({ apiUrl, body, fetchOptions, }: FetchFunctionsProps<SchemaType>): Promise<
|
|
12
|
+
export declare function getMasterDataSellerCode({ apiUrl, body, fetchOptions, }: FetchFunctionsProps<SchemaType>): Promise<any>;
|
|
13
13
|
export {};
|
|
@@ -13,5 +13,5 @@ type SchemaType = yup.InferType<typeof schemaShipping>;
|
|
|
13
13
|
/**
|
|
14
14
|
* Attach shipping data to a shopping cart.
|
|
15
15
|
*/
|
|
16
|
-
export declare function postOrderFormAttachShippingData({ apiUrl, body, fetchOptions, }: FetchFunctionsProps<SchemaType>): Promise<
|
|
16
|
+
export declare function postOrderFormAttachShippingData({ apiUrl, body, fetchOptions, }: FetchFunctionsProps<SchemaType>): Promise<any>;
|
|
17
17
|
export {};
|
|
@@ -32,5 +32,5 @@ type SchemaType = yup.InferType<typeof schemaShipping>;
|
|
|
32
32
|
/**
|
|
33
33
|
* Attach shipping data with options and addresses to a shopping cart.
|
|
34
34
|
*/
|
|
35
|
-
export declare function postOrderFormUpdateShippingData({ apiUrl, body, fetchOptions }: FetchFunctionsProps<SchemaType>): Promise<
|
|
35
|
+
export declare function postOrderFormUpdateShippingData({ apiUrl, body, fetchOptions }: FetchFunctionsProps<SchemaType>): Promise<any>;
|
|
36
36
|
export {};
|
|
@@ -29,5 +29,5 @@ type SchemaType = yup.InferType<typeof schemaRegion>;
|
|
|
29
29
|
* @returns A list of sellers that cater to the specified region or address.
|
|
30
30
|
* This endpoint provides flexibility in accessing seller information based on region or address, allowing you to choose between path parameters or query parameters.
|
|
31
31
|
*/
|
|
32
|
-
export declare function postOrderFormRegion({ apiUrl, body, fetchOptions }: FetchFunctionsProps<SchemaType>): Promise<
|
|
32
|
+
export declare function postOrderFormRegion({ apiUrl, body, fetchOptions }: FetchFunctionsProps<SchemaType>): Promise<any>;
|
|
33
33
|
export {};
|
|
@@ -26,5 +26,5 @@ type SchemaType = yup.InferType<typeof schemaSimulation>;
|
|
|
26
26
|
* @returns All information about the cart, including selling price of each item, pricing and promotion data, payment and logistics info.
|
|
27
27
|
* This request is useful whenever you need to know the availability of fulfilling an order for a specific cart setting, since the API response will let you know the updated price, inventory, and shipping data.
|
|
28
28
|
*/
|
|
29
|
-
export declare function postOrderFormFreightSimulation({ apiUrl, body, fetchOptions }: FetchFunctionsProps<SchemaType>): Promise<
|
|
29
|
+
export declare function postOrderFormFreightSimulation({ apiUrl, body, fetchOptions }: FetchFunctionsProps<SchemaType>): Promise<any>;
|
|
30
30
|
export {};
|
package/data/api/fetchVtex.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { FetchOptions } from '../../types/data/api';
|
|
2
2
|
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const fetchVtexOrderForm: (url: string, options?: FetchOptions) => Promise<Record<string, any>>;
|
|
4
|
+
export declare const fetchVtex: (url: string, options?: FetchOptions) => Promise<any>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { CreateEmptySeoCategoryProps, CreateSeoCategoryProps, FindCategoryProps, SimilarsResponseData, SimilarType } from '../../../types/data/api/catalog/product';
|
|
2
|
+
import { CollectionPageType } from '../../../types/data/api/catalog/portal';
|
|
3
|
+
import { ProductType_APICatalog } from '../../../types/global/product';
|
|
4
|
+
import { TEXTURE_IMAGEType } from '../../../types/constants';
|
|
5
|
+
|
|
6
|
+
export declare const createEmptySeoCategory: ({ canonical, seo, slug }: CreateEmptySeoCategoryProps) => {
|
|
7
|
+
id: number;
|
|
8
|
+
Title: string;
|
|
9
|
+
MetaTagDescription: string;
|
|
10
|
+
name: string;
|
|
11
|
+
hasChildren: boolean;
|
|
12
|
+
url: string;
|
|
13
|
+
children: never[];
|
|
14
|
+
};
|
|
15
|
+
export declare const createSeoCategory: ({ canonical, category, previousImages, seo }: CreateSeoCategoryProps) => {
|
|
16
|
+
category: string;
|
|
17
|
+
title: string;
|
|
18
|
+
description: string;
|
|
19
|
+
alternates: {
|
|
20
|
+
canonical: string;
|
|
21
|
+
};
|
|
22
|
+
openGraph: {
|
|
23
|
+
type: string;
|
|
24
|
+
title: string;
|
|
25
|
+
description: string;
|
|
26
|
+
images: any[];
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export declare const findCategory: ({ items, parent, apiUrl, find }: FindCategoryProps) => import('../../../types/data/api/catalog/product').CategoryTree | undefined;
|
|
30
|
+
export declare const notFindCategoryError: (error: Error) => void;
|
|
31
|
+
export declare const isCollectionPageType: (x: any) => x is CollectionPageType;
|
|
32
|
+
export declare const responseAdapter: (data: ProductType_APICatalog) => {
|
|
33
|
+
collection: string[];
|
|
34
|
+
categoryId: string;
|
|
35
|
+
current_collection: string[];
|
|
36
|
+
items: import('../../../types/global/product').ItemType_APICatalog[];
|
|
37
|
+
};
|
|
38
|
+
export declare const formattedSimilars: (data: SimilarsResponseData[], filterTexture: TEXTURE_IMAGEType) => SimilarType[];
|
package/index2.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const O=require("yup");function R(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const o in t)if(o!=="default"){const n=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(e,o,n.get?n:{enumerable:!0,get:()=>t[o]})}}return e.default=t,Object.freeze(e)}const r=R(O),l=async(t,e={})=>{const{method:o="GET",body:n,headers:a={},priority:s="auto"}=e;return fetch(t,{method:o,headers:{...a,Accept:"application/json","Content-Type":"application/json"},priority:s,...n?{body:JSON.stringify(n)}:{}}).then(i=>i.json()).catch(i=>{console.error("[ERROR FETCH VTEX]",i)})},I=r.object({country:r.string().length(3,"Country code must be 3 characters long").required("Country is required"),postalCode:r.string().nullable()});async function y({apiUrl:t,body:e,fetchOptions:o}){if(!e){console.error("[ERROR FETCHING] Body is required");return}await I.validate(e);const{country:n,postalCode:a}=e;return await l(`${t}/api/checkout/pub/postal-code/${n}/${a}`,{method:"POST",body:e,...o})}const $=r.object({orderFormId:r.string().nullable(),sellerCode:r.string().nullable(),sellerName:r.string().nullable()});async function b({apiUrl:t,body:e,fetchOptions:o}){if(!e){console.error("[ERROR FETCHING] Body is required");return}await $.validate(e);const{orderFormId:n,sellerCode:a,sellerName:s}=e,i=a?`${a.trim()} - ${s}`:null;return l(`${t}/api/checkout/pub/orderForm/${n}/attachments/openTextField`,{method:"POST",body:{value:i},...o})}const q=r.object({orderFormId:r.string().nullable(),sellerCode:r.string().nullable(),marketingData:r.object()});async function F({apiUrl:t,body:e,fetchOptions:o}){if(!e){console.error("[ERROR FETCHING] Body is required");return}await q.validate(e);const{orderFormId:n,sellerCode:a,marketingData:s}=e,i=a?{utmCampaign:a?a.toUpperCase():"",utmiCampaign:a?"codigodavendedora":"semcodigo"}:{};return l(`${t}/api/checkout/pub/orderForm/${n}/attachments/marketingData`,{method:"POST",body:{...s,...i},...o})}const T=r.object({orderFormId:r.string().nullable(),sellerCode:r.string().nullable(),sellerName:r.string().nullable()});async function v({apiUrl:t,body:e,fetchOptions:o}){if(!e){console.error("[ERROR FETCHING] Body is required");return}const n=await b({apiUrl:t,body:e,fetchOptions:o});return F({apiUrl:t,body:{...e,marketingData:n==null?void 0:n.marketingData},fetchOptions:o})}const S=r.object({orderFormId:r.string().nullable(),coupon:r.string().nullable()});async function E({apiUrl:t,body:e,fetchOptions:o}){if(!e){console.error("[ERROR FETCHING] Body is required");return}await S.validate(e);const{coupon:n="",orderFormId:a}=e;return l(`${t}/api/checkout/pub/orderForm/${a}/coupons`,{method:"POST",body:{text:n},...o})}const j=r.object({appId:r.string().required("App ID is required"),orderFormId:r.string().nullable(),key:r.array().of(r.string())});async function A({apiUrl:t,body:e,fetchOptions:o}){if(!e){console.error("[ERROR FETCHING] Body is required");return}await j.validate(e);const{appId:n="faststore",orderFormId:a,key:s}=e;return l(`${t}/api/checkout/pub/orderForm/${a}/customData/${n}/${s}`,{method:"PUT",...o})}const w=r.object({orderFormId:r.string().nullable()});async function k({apiUrl:t,body:e,fetchOptions:o}){if(!e){console.error("[ERROR FETCHING] Body is required");return}await w.validate(e);const{orderFormId:n}=e;return l(`${t}/api/checkout/pub/orderForm/${n}/items/removeAll`,{method:"POST",...o})}const N=r.object().shape({name:r.string().required("Attachment name is required"),content:r.object().nullable()});var f;const C=r.object().shape({attachments:(f=r.array().of(N))==null?void 0:f.nullable(),id:r.string().required("ID of SKU is required"),index:r.number().integer().nullable(),quantity:r.number().integer().nullable(),seller:r.string().required("Seller is required"),price:r.number().integer()}),P=r.object({orderFormId:r.string().nullable(),orderItems:r.array().of(C)});async function D({apiUrl:t,body:e,fetchOptions:o}){if(!e){console.error("[ERROR FETCHING] Body is required");return}await P.validate(e);const{orderFormId:n,orderItems:a}=e;return l(`${t}/api/checkout/pub/orderForm/${n}/items/update`,{method:"POST",body:{orderItems:a},...o})}const G=r.object({orderFormId:r.string().nullable()});async function _({apiUrl:t,body:e,fetchOptions:o}){if(!e){console.error("[ERROR FETCHING] Body is required");return}await G.validate(e);const{orderFormId:n}=e;return l(`${t}/api/checkout/pub/orderForm/${n}/messages/clear`,{method:"POST",...o})}const H=r.object({id:r.string().nullable(),itemIndex:r.number().nullable(),orderFormId:r.string().nullable(),remove:r.boolean().nullable()});async function B({apiUrl:t,body:e,fetchOptions:o}){if(!e){console.error("[ERROR FETCHING] Body is required");return}await H.validate(e);const{itemIndex:n,orderFormId:a,id:s,remove:i}=e,d=i?`/${s}/remove`:"",m=`${t}/api/checkout/pub/orderForm/${a}/items/${n}/offerings${d}`;return l(m,{method:"POST",body:{id:s},...o})}const M=r.object({orderFormId:r.string().nullable()});async function U({apiUrl:t,body:e,fetchOptions:o,extraData:n}){var i;if(!e){console.error("[ERROR FETCHING] Body is required");return}await M.validate(e);const a=new URLSearchParams({refreshOutdatedData:"true"}),s=e.orderFormId&&((i=n.orderFormPurchaseId)==null?void 0:i.value)!==e.orderFormId?`${t}/api/checkout/pub/orderForm/${e.orderFormId}?${String(a)}`:`${t}/api/checkout/pub/orderForm`;return l(s,{method:"GET",...o})}const z=r.object({orderFormId:r.string().nullable(),email:r.string().email().required(),firstName:r.string().required(),lastName:r.string().required(),documentType:r.string().required(),document:r.string().required(),phone:r.string().matches(/^\+\d{1,3}\d{10,11}$/)});async function L({apiUrl:t,body:e,fetchOptions:o}){if(!e){console.error("[ERROR FETCHING] Body is required");return}await z.validate(e);const{orderFormId:n,...a}=e;return l(`${t}/api/checkout/pub/orderForm/${n}/attachments/clientProfileData`,{method:"POST",body:{...a},...o})}const x=r.object({sellerCode:r.string().nullable()});async function V({apiUrl:t,body:e,fetchOptions:o}){if(!e){console.error("[ERROR FETCHING] Body is required");return}await x.validate(e);const{sellerCode:n=""}=e;return l(`${t}/api/dataentities/VD/search?_fields=id,cod,name,ativo&cod=${n}`,{method:"GET",headers:{Accept:"application/vnd.vtex.ds.v10+json"},...o})}const J=r.object().shape({country:r.string().length(3,"Country code must be 3 characters long").required("Country is required"),orderFormId:r.string().nullable(),postalCode:r.string().nullable()});async function K({apiUrl:t,body:e,fetchOptions:o}){if(!e){console.error("[ERROR FETCHING] Body is required");return}await J.validate(e);const{country:n,orderFormId:a,postalCode:s}=e,i=s?{address:{addressType:"residential",postalCode:s,country:n}}:{logisticsInfo:[],clearAddressIfPostalCodeNotFound:!0};return l(`${t}/api/checkout/pub/orderForm/${a}/attachments/shippingData`,{method:"POST",body:i,...o})}const Y=r.object().shape({orderFormId:r.string().nullable(),options:r.array().of(r.object().shape({itemIndex:r.number(),selectedDeliveryChannel:r.string(),selectedSla:r.string()})),selectedAddresses:r.array().of(r.object().shape({addressId:r.string().required(),addressType:r.string().required(),city:r.string().nullable(),complement:r.string().nullable(),country:r.string().required().length(3),geoCoordinates:r.array().of(r.number()).required().min(0),isDisposable:r.boolean().required(),neighborhood:r.string().nullable(),number:r.string().nullable(),postalCode:r.string().required(),receiverName:r.string().nullable(),reference:r.string().nullable(),state:r.string().nullable(),street:r.string().nullable()}))});async function Q({apiUrl:t,body:e,fetchOptions:o}){if(!e){console.error("[ERROR FETCHING] Body is required");return}await Y.validate(e);const{orderFormId:n,options:a,selectedAddresses:s}=e;return l(`${t}/api/checkout/pub/orderForm/${n}/attachments/shippingData`,{method:"POST",body:{selectedAddresses:s,clearAddressIfPostalCodeNotFound:!1,logisticsInfo:a},...o})}const X=r.object({country:r.string().length(3,"Country code must be 3 characters long").required("Country is required"),postalCode:r.string().nullable(),geoCoordinates:r.object().shape({longitude:r.number().required(),latitude:r.number().required()})});async function W({apiUrl:t,body:e,fetchOptions:o}){if(!e){console.error("[ERROR FETCHING] Body is required");return}await X.validate(e);const{country:n="",geoCoordinates:a,postalCode:s=""}=e,i=new URLSearchParams({country:String(n)});return s?i.append("postalCode",s):i.append("geoCoordinates",`${a==null?void 0:a.longitude};${a==null?void 0:a.latitude}`),await l(`${t}/api/checkout/pub/regions/?${i.toString()}`,{method:"GET",...o})}const Z=r.object({id:r.string().required("ID of SKU is required"),quantity:r.number().integer().required("Quantity of item is required"),seller:r.string()}),ee=r.object({items:r.array().of(Z),country:r.string().length(3,"Country code must be 3 characters long").required("Country is required"),postalCode:r.string().nullable(),geoCoordinates:r.array().nullable().of(r.number()).length(2)});async function re({apiUrl:t,body:e,fetchOptions:o}){if(!e){console.error("[ERROR FETCHING] Body is required");return}return await ee.validate(e),l(`${t}/api/checkout/pub/orderForms/simulation`,{method:"POST",body:e,...o})}const te=Object.freeze(Object.defineProperty({__proto__:null,getMasterDataSellerCode:V,getOrderForm:U,postOrderFormAddCoupon:E,postOrderFormAttachClientProfileData:L,postOrderFormAttachOrderFormData:v,postOrderFormAttachShippingData:K,postOrderFormAttachmentsMarketingData:F,postOrderFormAttachmentsOpenTextField:b,postOrderFormClearMessages:_,postOrderFormFreightSimulation:re,postOrderFormRegion:W,postOrderFormRemoveAllItems:k,postOrderFormUpdateItems:D,postOrderFormUpdateShippingData:Q,postOrderformAddress:y,putOrderFormCustomData:A,schemaAddress:I,schemaAttachments:T,schemaItem:C,updateOrderFormOffering:B},Symbol.toStringTag,{value:"Module"})),oe=r.object({skuId:r.string()});async function ne({apiUrl:t,body:e,fetchOptions:o}){if(!e){console.error("[ERROR FETCHING] Body is required");return}await oe.validate(e);const{skuId:n}=e;return l(`${t}/api/catalog/pvt/stockkeepingunitkit?parentSkuId=${n}`,{...o})}const se=r.object({ids:r.array().of(r.string().required("ID are required")).required("IDs are required")});async function ae({apiUrl:t,body:e,fetchOptions:o}){if(!e){console.error("[ERROR FETCHING] Body is required");return}await se.validate(e);const{ids:n}=e;return l(`${t}/api/catalog_system/pub/products/search?fq=${n.map(a=>`productId:${a}`).join("&fq=")}`,{...o})}const ie=r.object({productId:r.number().required("Product ID is required")});async function le({apiUrl:t,body:e,fetchOptions:o}){if(!e){console.error("[ERROR FETCHING] Body is required");return}await ie.validate(e);const{productId:n}=e;return l(`${t}/api/catalog_system/pub/products/crossselling/similars/${n.toString()}`,{...o})}const de=Object.freeze(Object.defineProperty({__proto__:null,getCatalogKitProducts:ne,getCatalogProducts:ae,getCatalogSimilars:le},Symbol.toStringTag,{value:"Module"})),ce=(t="")=>t.charAt(0).toUpperCase()+t.slice(1),h=(t,e=" ")=>!t||typeof t=="string"&&t.length===0?t:(Array.isArray(t)?t:t.split("-")).map(ce).join(e),ue=({canonical:t,seo:e,slug:o})=>{const n=Array.isArray(o)?o.join(", "):o;return{id:0,Title:`${Array.isArray(o)?o.map(s=>h(s)).join(","):h(o)} - ${e.title}`,MetaTagDescription:e.description,name:n,hasChildren:!1,url:t,children:[]}},me=({canonical:t,category:e,previousImages:o,seo:n})=>({category:String(e==null?void 0:e.id),title:(e==null?void 0:e.Title)??n.title,description:(e==null?void 0:e.MetaTagDescription)??n.description,alternates:{canonical:t},openGraph:{type:"website",title:(e==null?void 0:e.Title)??n.title,description:(e==null?void 0:e.MetaTagDescription)??n.description,images:Array.isArray(o)?[...o]:[]}}),pe=({items:t,parent:e,apiUrl:o,find:n})=>{const a=t.find(i=>i.url.replace(o,"")===decodeURIComponent(e.toLowerCase()));return(a==null?void 0:a.children.find(i=>i.name.toLowerCase()===decodeURIComponent(String(n))))??a},ge=t=>{t instanceof Error?(console.error(`[ERROR CATEGORY INFO]: ${t.message}`),console.error(t.stack)):console.error("[ERROR CATEGORY INFO]: Unknown error",t)},he=new Set(["brand","category","department","subcategory","collection","cluster"]),fe=t=>typeof(t==null?void 0:t.pageType)=="string"&&he.has(t==null?void 0:t.pageType.toLowerCase()),Ie=t=>({collection:t.Coleção,categoryId:t.categoryId,current_collection:t["Coleção Atual"],items:t.items}),be=(t,e)=>t.reduce((o,n)=>{if(n.items.filter(i=>i.sellers.find(d=>d.commertialOffer.IsAvailable)).length===0||(o==null?void 0:o.find(i=>(i==null?void 0:i.productId)===(n==null?void 0:n.productId)))!==void 0)return o;const s=n.items[0].images.find(i=>e.includes(i.imageLabel));return o.push({slug:`/${n.linkText}/p`,productId:n==null?void 0:n.productId,textureImage:(s==null?void 0:s.imageUrl)??"",textureAlt:(s==null?void 0:s.imageText)??""}),o},[]),Fe=Object.freeze(Object.defineProperty({__proto__:null,createEmptySeoCategory:ue,createSeoCategory:me,findCategory:pe,formattedSimilars:be,isCollectionPageType:fe,notFindCategoryError:ge,responseAdapter:Ie},Symbol.toStringTag,{value:"Module"}));async function Ce({contentType:t,documents:e,NextCookies:o,CMS_PROJECT_NAME:n,storeId:a}){var i;const s=JSON.parse(((i=o().get("cms_preview_data"))==null?void 0:i.value)??"{}");if(s&&(s==null?void 0:s.contentType)===t){const d=s.documentId&&s.documentId.length?`/${s.documentId}`:"",m=s!=null&&s.versionId&&(s!=null&&s.versionId.length)?`?versionId=${s==null?void 0:s.versionId}`:"",p=await(await fetch(`https://${a}.myvtex.com/_v/cms/api/${n}/${t}${d}${m}`,{cache:"no-store"})).json(),c=e.filter(u=>p.id!==u.documentId);return c.unshift(p),c}return e}async function Oe({contentType:t,NextCookies:e,CMS_PROJECT_NAME:o,storeId:n}){var g,p;const a=JSON.parse(((g=e().get("cms_preview_data"))==null?void 0:g.value)??"{}"),s=[];let i=1,d=0,m=!0;try{do{const u=await(await fetch(`https://${n}.myvtex.com/_v/cms/api/${o}/${t}?page=${i}`)).json();i===1&&(d=u.totalItems),(p=u==null?void 0:u.data)!=null&&p.length&&s.push(...u.data),m=u.hasNextPage,i++}while(m&&s.length<d);if(a.previewMode&&s.length){const c=await Ce({contentType:t,documents:s,NextCookies:e,CMS_PROJECT_NAME:o,storeId:n});return{status:c.length>0?200:404,data:c??[]}}return{status:s.length?200:404,data:s}}catch(c){return{status:"error",data:[],error:c}}}const Re=Object.freeze(Object.defineProperty({__proto__:null,getContentType:Oe},Symbol.toStringTag,{value:"Module"})),ye={checkout:te,catalog:de,cms:Re},$e={catalog:Fe};exports.serverAPIs=ye;exports.serverHelpers=$e;
|