@uappi/public-sdk 1.0.0
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/.editorconfig +6 -0
- package/.vscode/extensions.json +5 -0
- package/.vscode/settings.json +7 -0
- package/components/Animations/ExpandTransition.ts +89 -0
- package/components/Animations/index.ts +1 -0
- package/components/Themes/CustomTheme.ts +77 -0
- package/components/Themes/index.ts +1 -0
- package/main.ts +16 -0
- package/modules/Api/README.md +469 -0
- package/modules/Api/endpoints/BannerComposable.ts +31 -0
- package/modules/Api/endpoints/BrandComposable.ts +21 -0
- package/modules/Api/endpoints/CartComposable.ts +121 -0
- package/modules/Api/endpoints/CommonComposable.ts +24 -0
- package/modules/Api/endpoints/CouponComposable.ts +18 -0
- package/modules/Api/endpoints/CustomerComposable.ts +255 -0
- package/modules/Api/endpoints/InterestComposable.ts +11 -0
- package/modules/Api/endpoints/LoggoutComposable.ts +8 -0
- package/modules/Api/endpoints/MenuComposable.ts +25 -0
- package/modules/Api/endpoints/PairOfferComposable.ts +14 -0
- package/modules/Api/endpoints/PaymentComposable.ts +14 -0
- package/modules/Api/endpoints/ProductCommentComposable.ts +51 -0
- package/modules/Api/endpoints/ProductQuoteShipment.ts +20 -0
- package/modules/Api/endpoints/PublicComposable.ts +9 -0
- package/modules/Api/endpoints/ReviewComposable.ts +64 -0
- package/modules/Api/endpoints/SearchComposable.ts +27 -0
- package/modules/Api/endpoints/ShowcaseComposable.ts +45 -0
- package/modules/Api/endpoints/TemplateComposable.ts +8 -0
- package/modules/Api/endpoints/ThirdPartyComposable.ts +14 -0
- package/modules/Api/endpoints/UpsellComposable.ts +18 -0
- package/modules/Api/endpoints/UrlComposable.ts +26 -0
- package/modules/Api/endpoints/VariationComposable.ts +36 -0
- package/modules/Api/endpoints/WalletComposable.ts +36 -0
- package/modules/Api/endpoints/ZipcodeComposable.ts +10 -0
- package/modules/Api/index.ts +194 -0
- package/modules/Api/paramsSerializer/encodeWafNormalizer.ts +7 -0
- package/modules/Api/types/context/api-config.types.ts +68 -0
- package/modules/Api/types/context/api-params.types.ts +74 -0
- package/modules/Api/types/endpoints/attribute/attribute.interfaces.ts +42 -0
- package/modules/Api/types/endpoints/banner/banner.interfaces.ts +45 -0
- package/modules/Api/types/endpoints/brand/brand-field.types.ts +3 -0
- package/modules/Api/types/endpoints/brand/brand.interfaces.ts +23 -0
- package/modules/Api/types/endpoints/cart/cart.interfaces.ts +161 -0
- package/modules/Api/types/endpoints/cart/cart.types.ts +27 -0
- package/modules/Api/types/endpoints/common/common.interfaces.ts +21 -0
- package/modules/Api/types/endpoints/context/context.types.ts +1 -0
- package/modules/Api/types/endpoints/country/country.types.ts +7502 -0
- package/modules/Api/types/endpoints/coupon/coupon.interfaces.ts +13 -0
- package/modules/Api/types/endpoints/customer/customer-erros.ts +13 -0
- package/modules/Api/types/endpoints/customer/customer-obsearch.ts +103 -0
- package/modules/Api/types/endpoints/customer/customer.interfaces.ts +448 -0
- package/modules/Api/types/endpoints/customer/customer.types.ts +3 -0
- package/modules/Api/types/endpoints/description/description.interfaces.ts +30 -0
- package/modules/Api/types/endpoints/discounts/discounts.interfaces.ts +9 -0
- package/modules/Api/types/endpoints/discounts/discounts.types.ts +5 -0
- package/modules/Api/types/endpoints/filters/filter.type.ts +1 -0
- package/modules/Api/types/endpoints/filters/filters.interfaces.ts +26 -0
- package/modules/Api/types/endpoints/interest/interest.interfaces.ts +22 -0
- package/modules/Api/types/endpoints/media/media.interfaces.ts +13 -0
- package/modules/Api/types/endpoints/menu/menu.enums.ts +8 -0
- package/modules/Api/types/endpoints/menu/menu.interfaces.ts +26 -0
- package/modules/Api/types/endpoints/order/order.interfaces.ts +63 -0
- package/modules/Api/types/endpoints/page/page.interfaces.ts +15 -0
- package/modules/Api/types/endpoints/pagination/pagination.interfaces.ts +6 -0
- package/modules/Api/types/endpoints/pair-offer/pair-offer.interfaces.ts +19 -0
- package/modules/Api/types/endpoints/payment/payment.interfaces.ts +103 -0
- package/modules/Api/types/endpoints/payment/payment.types.ts +27 -0
- package/modules/Api/types/endpoints/price/price.interfaces.ts +22 -0
- package/modules/Api/types/endpoints/product/product-obsearch.types.ts +63 -0
- package/modules/Api/types/endpoints/product/product.interfaces.ts +109 -0
- package/modules/Api/types/endpoints/product/product.types.ts +3 -0
- package/modules/Api/types/endpoints/product-comment/product-comment-obsearch.types.ts +24 -0
- package/modules/Api/types/endpoints/product-comment/product-comment.interfaces.ts +32 -0
- package/modules/Api/types/endpoints/redirect/redirect.interfaces.ts +7 -0
- package/modules/Api/types/endpoints/review/review-obsearch.types.ts +18 -0
- package/modules/Api/types/endpoints/review/review.interfaces.ts +34 -0
- package/modules/Api/types/endpoints/seal/seal.interfaces.ts +21 -0
- package/modules/Api/types/endpoints/seal/seal.types.ts +3 -0
- package/modules/Api/types/endpoints/search/search.interfaces.ts +11 -0
- package/modules/Api/types/endpoints/seo/seo.interfaces.ts +11 -0
- package/modules/Api/types/endpoints/shipment/shipment.interfaces.ts +137 -0
- package/modules/Api/types/endpoints/showcase/showcase.enums.ts +8 -0
- package/modules/Api/types/endpoints/showcase/showcase.interfaces.ts +10 -0
- package/modules/Api/types/endpoints/simple-product/simple-product.interfaces.ts +15 -0
- package/modules/Api/types/endpoints/storage/storage.interfaces.ts +16 -0
- package/modules/Api/types/endpoints/template/template.interfaces.ts +30 -0
- package/modules/Api/types/endpoints/third-party/oauth.interfaces.ts +6 -0
- package/modules/Api/types/endpoints/upsell/upsell.interfaces.ts +13 -0
- package/modules/Api/types/endpoints/url/url.interfaces.ts +85 -0
- package/modules/Api/types/endpoints/wallet/wallet-obsearch.ts +8 -0
- package/modules/Api/types/endpoints/wallet/wallet.interfaces.ts +57 -0
- package/modules/Api/types/endpoints/zipcode/zipcode.interfaces.ts +23 -0
- package/modules/Api/types/index.ts +459 -0
- package/modules/Api/usePublicApi.ts +68 -0
- package/modules/Tracking/endpoints/BannerComposable.ts +33 -0
- package/modules/Tracking/endpoints/CartComposable.ts +75 -0
- package/modules/Tracking/endpoints/CustomerComposable.ts +68 -0
- package/modules/Tracking/endpoints/ProductQuoteShipment.ts +14 -0
- package/modules/Tracking/endpoints/SearchComposable.ts +32 -0
- package/modules/Tracking/endpoints/ShowcaseComposable.ts +54 -0
- package/modules/Tracking/endpoints/UrlComposable.ts +41 -0
- package/modules/Tracking/endpoints/types.ts +11 -0
- package/modules/Tracking/events/actions/addPaymentInfo.ts +31 -0
- package/modules/Tracking/events/actions/addShippingInfo.ts +27 -0
- package/modules/Tracking/events/actions/addToCart.ts +35 -0
- package/modules/Tracking/events/actions/beginCheckout.ts +28 -0
- package/modules/Tracking/events/actions/customerProfile.ts +36 -0
- package/modules/Tracking/events/actions/generateLead.ts +12 -0
- package/modules/Tracking/events/actions/login.ts +8 -0
- package/modules/Tracking/events/actions/purchase.ts +42 -0
- package/modules/Tracking/events/actions/removeFromCart.ts +52 -0
- package/modules/Tracking/events/actions/search.ts +8 -0
- package/modules/Tracking/events/actions/selectItem.ts +64 -0
- package/modules/Tracking/events/actions/selectPromotion.ts +24 -0
- package/modules/Tracking/events/actions/shippingCalculation.ts +7 -0
- package/modules/Tracking/events/actions/signup.ts +8 -0
- package/modules/Tracking/events/actions/upsertToCart.ts +62 -0
- package/modules/Tracking/events/views/viewCart.ts +28 -0
- package/modules/Tracking/events/views/viewHome.ts +5 -0
- package/modules/Tracking/events/views/viewItem.ts +31 -0
- package/modules/Tracking/events/views/viewItemList.ts +65 -0
- package/modules/Tracking/events/views/viewNotFound.ts +5 -0
- package/modules/Tracking/events/views/viewOther.ts +5 -0
- package/modules/Tracking/events/views/viewPayment.ts +7 -0
- package/modules/Tracking/events/views/viewPromotion.ts +28 -0
- package/modules/Tracking/events/views/viewShipping.ts +7 -0
- package/modules/Tracking/index.ts +84 -0
- package/modules/Tracking/publicApiTracking.ts +36 -0
- package/modules/Tracking/types/actions/add-payment-info.interfaces.ts +12 -0
- package/modules/Tracking/types/actions/add-shipping-info.interfaces.ts +11 -0
- package/modules/Tracking/types/actions/add-to-cart.interfaces.ts +10 -0
- package/modules/Tracking/types/actions/begin-checkout.interfaces.ts +12 -0
- package/modules/Tracking/types/actions/customer-profile.interfaces.ts +19 -0
- package/modules/Tracking/types/actions/file-download.interfaces.ts +4 -0
- package/modules/Tracking/types/actions/generate-lead.interfaces.ts +12 -0
- package/modules/Tracking/types/actions/login.interfaces.ts +4 -0
- package/modules/Tracking/types/actions/purchase.interfaces.ts +18 -0
- package/modules/Tracking/types/actions/remove-from-cart.interfaces.ts +10 -0
- package/modules/Tracking/types/actions/search.interfaces.ts +4 -0
- package/modules/Tracking/types/actions/select-item.interfaces.ts +16 -0
- package/modules/Tracking/types/actions/select-promotion.interfaces.ts +8 -0
- package/modules/Tracking/types/actions/share.interfaces.ts +4 -0
- package/modules/Tracking/types/actions/shipping-calculation.interfaces.ts +3 -0
- package/modules/Tracking/types/actions/signup.interfaces.ts +4 -0
- package/modules/Tracking/types/event.types.ts +54 -0
- package/modules/Tracking/types/index.ts +37 -0
- package/modules/Tracking/types/item.interfaces.ts +30 -0
- package/modules/Tracking/types/views/view-cart.interfaces.ts +11 -0
- package/modules/Tracking/types/views/view-home.interfaces.ts +3 -0
- package/modules/Tracking/types/views/view-item-list.interfaces.ts +11 -0
- package/modules/Tracking/types/views/view-item.interfaces.ts +15 -0
- package/modules/Tracking/types/views/view-not-found.interfaces.ts +3 -0
- package/modules/Tracking/types/views/view-other.interfaces.ts +3 -0
- package/modules/Tracking/types/views/view-payment.interfaces.ts +3 -0
- package/modules/Tracking/types/views/view-promotion.interfaces.ts +8 -0
- package/modules/Tracking/types/views/view-shipping.interfaces.ts +3 -0
- package/modules/Tracking/utils/cart.ts +100 -0
- package/modules/Tracking/utils/pushDatalayer.ts +7 -0
- package/package.json +27 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type { UpsertTrackingCartRequest } from '../types';
|
|
2
|
+
import type {
|
|
3
|
+
CartResponse,
|
|
4
|
+
Order,
|
|
5
|
+
OrderItem,
|
|
6
|
+
Product,
|
|
7
|
+
} from '../../Api/types';
|
|
8
|
+
|
|
9
|
+
export function getVariant(orderItem: OrderItem | Product) {
|
|
10
|
+
if ('product' in orderItem)
|
|
11
|
+
return orderItem.product.currentAttributes
|
|
12
|
+
.map(attribute => attribute.value.label)
|
|
13
|
+
.join(', ');
|
|
14
|
+
|
|
15
|
+
return orderItem.currentAttributes
|
|
16
|
+
.map(attribute => attribute.value.label)
|
|
17
|
+
.join(', ');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function getAllOrderItems(orders: Array<Order>) {
|
|
21
|
+
return orders.map(order => order.items).flat();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function groupOrderItemById(orders: Array<Order>) {
|
|
25
|
+
const orderItems = getAllOrderItems(orders) || [];
|
|
26
|
+
const uniqOrderItemById: Array<OrderItem> = [];
|
|
27
|
+
|
|
28
|
+
orderItems?.forEach(orderItem => {
|
|
29
|
+
const orderItemIndex = uniqOrderItemById.findIndex(
|
|
30
|
+
uniqOrderItem =>
|
|
31
|
+
uniqOrderItem.product.productId === orderItem.product.productId,
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
if (orderItemIndex === -1) {
|
|
35
|
+
uniqOrderItemById.push(orderItem);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
uniqOrderItemById[orderItemIndex] = {
|
|
40
|
+
...uniqOrderItemById[orderItemIndex],
|
|
41
|
+
quantity: orderItem.quantity + uniqOrderItemById[orderItemIndex].quantity,
|
|
42
|
+
totalValue:
|
|
43
|
+
orderItem.totalValue + uniqOrderItemById[orderItemIndex].totalValue,
|
|
44
|
+
subtotalValue:
|
|
45
|
+
orderItem.subtotalValue +
|
|
46
|
+
uniqOrderItemById[orderItemIndex].subtotalValue,
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
return;
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
return uniqOrderItemById;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function getAddedCartItems(
|
|
56
|
+
cartPayload: CartResponse,
|
|
57
|
+
upsertPayload?: UpsertTrackingCartRequest,
|
|
58
|
+
) {
|
|
59
|
+
return groupOrderItemById(cartPayload.orders)
|
|
60
|
+
.filter(orderItem => {
|
|
61
|
+
if (!upsertPayload) return orderItem;
|
|
62
|
+
|
|
63
|
+
return upsertPayload.items.some(
|
|
64
|
+
upsert => upsert.productId === orderItem.product.productId,
|
|
65
|
+
);
|
|
66
|
+
})
|
|
67
|
+
.map(orderItem => {
|
|
68
|
+
if (!upsertPayload) {
|
|
69
|
+
return {
|
|
70
|
+
...orderItem,
|
|
71
|
+
oldQuantity: 0,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const upsertItem = upsertPayload.items.find(
|
|
76
|
+
upsert => upsert.productId === orderItem.product.productId,
|
|
77
|
+
)!;
|
|
78
|
+
|
|
79
|
+
if (!upsertItem.oldQuantity) {
|
|
80
|
+
return {
|
|
81
|
+
...orderItem,
|
|
82
|
+
oldQuantity: upsertItem.oldQuantity,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return {
|
|
87
|
+
...orderItem,
|
|
88
|
+
oldQuantity: upsertItem.oldQuantity,
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function totalValue(
|
|
94
|
+
cartPayload: CartResponse,
|
|
95
|
+
upsertPayload?: UpsertTrackingCartRequest,
|
|
96
|
+
) {
|
|
97
|
+
return getAddedCartItems(cartPayload, upsertPayload)
|
|
98
|
+
.map(orderItem => orderItem.subtotalValue)
|
|
99
|
+
.reduce((acc, current) => acc + current, 0);
|
|
100
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@uappi/public-sdk",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Pacotes públicos para desenvolvimento do ecossistema Uappi",
|
|
5
|
+
"main": "main.ts",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"publish": "npm publish --access public"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://gitlab.com/agenciawebart/uappi/plataforma/frontend/packages/public/composables/use-public-api.git"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"[\"uappi\"",
|
|
15
|
+
"\"api\"",
|
|
16
|
+
"\"publica\"",
|
|
17
|
+
"\"cliente\"",
|
|
18
|
+
"\"vue3\"",
|
|
19
|
+
"\"typescript\"]"
|
|
20
|
+
],
|
|
21
|
+
"author": "Leonardo Freedy",
|
|
22
|
+
"license": "ISC",
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://gitlab.com/agenciawebart/uappi/plataforma/frontend/packages/public/composables/use-public-api/issues"
|
|
25
|
+
},
|
|
26
|
+
"homepage": "https://gitlab.com/agenciawebart/uappi/plataforma/frontend/packages/public/composables/use-public-api#readme"
|
|
27
|
+
}
|