@uappi/public-sdk 1.2.9 → 1.2.10
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/.gitlab-ci.yml +43 -0
- package/.vscode/extensions.json +4 -4
- package/.vscode/settings.json +6 -6
- package/README.md +67 -0
- package/components/Animations/ExpandTransition.ts +89 -89
- package/components/Animations/index.ts +1 -1
- package/components/ColorTheme/ColorTheme.ts +80 -80
- package/components/ColorTheme/index.ts +1 -1
- package/components/ColorTheme/types.ts +18 -18
- package/components/SocialAuth/FacebookAuth/types.ts +2 -2
- package/components/SocialAuth/GoogleAuth/types.ts +2 -2
- package/components/SocialAuth/index.ts +1 -1
- package/components/index.ts +2 -2
- package/main.ts +4 -4
- package/modules/Api/README.md +469 -469
- package/modules/Api/endpoints/CommonComposable.ts +24 -24
- package/modules/Api/endpoints/CouponComposable.ts +18 -18
- package/modules/Api/endpoints/LoggoutComposable.ts +8 -8
- package/modules/Api/endpoints/MFAComposable.ts +43 -43
- package/modules/Api/endpoints/PaymentComposable.ts +14 -14
- package/modules/Api/endpoints/PublicComposable.ts +8 -8
- package/modules/Api/endpoints/TemplateComposable.ts +7 -7
- package/modules/Api/endpoints/ThirdPartyComposable.ts +13 -13
- package/modules/Api/endpoints/UpsellComposable.ts +17 -17
- package/modules/Api/endpoints/VerifyComposable.ts +7 -7
- package/modules/Api/endpoints/WalletComposable.ts +36 -36
- package/modules/Api/paramsSerializer/encodeWafNormalizer.ts +7 -7
- package/modules/Api/types/endpoints/cart/cart.interfaces.ts +161 -161
- package/modules/Api/types/endpoints/cart/cart.types.ts +27 -27
- package/modules/Api/types/endpoints/common/common.interfaces.ts +21 -21
- package/modules/Api/types/endpoints/country/country.types.ts +7502 -7502
- package/modules/Api/types/endpoints/coupon/coupon.interfaces.ts +13 -13
- package/modules/Api/types/endpoints/discounts/discounts.interfaces.ts +9 -9
- package/modules/Api/types/endpoints/mfa/mfa.interfaces.ts +51 -51
- package/modules/Api/types/endpoints/payment/payment.interfaces.ts +103 -103
- package/modules/Api/types/endpoints/payment/payment.types.ts +27 -27
- package/modules/Api/types/endpoints/price/price.interfaces.ts +21 -21
- package/modules/Api/types/endpoints/template/template.interfaces.ts +29 -29
- package/modules/Api/types/endpoints/third-party/oauth.interfaces.ts +5 -5
- package/modules/Api/types/endpoints/upsell/upsell.interfaces.ts +12 -12
- package/modules/Api/types/endpoints/wallet/wallet-obsearch.ts +8 -8
- package/modules/Api/types/endpoints/wallet/wallet.interfaces.ts +57 -57
- package/modules/Api/types/endpoints/zipcode/zipcode.interfaces.ts +23 -23
- package/modules/Api/types/index.ts +504 -504
- package/modules/Tracking/endpoints/CartComposable.ts +75 -75
- package/modules/Tracking/endpoints/CustomerComposable.ts +71 -71
- package/modules/Tracking/endpoints/types.ts +11 -11
- package/modules/Tracking/events/actions/addPaymentInfo.ts +31 -31
- package/modules/Tracking/events/actions/addShippingInfo.ts +27 -27
- package/modules/Tracking/events/actions/addToCart.ts +35 -35
- package/modules/Tracking/events/actions/beginCheckout.ts +28 -28
- package/modules/Tracking/events/actions/customerProfile.ts +36 -36
- package/modules/Tracking/events/actions/generateLead.ts +12 -12
- package/modules/Tracking/events/actions/login.ts +8 -8
- package/modules/Tracking/events/actions/purchase.ts +42 -42
- package/modules/Tracking/events/actions/removeFromCart.ts +52 -52
- package/modules/Tracking/events/actions/search.ts +8 -8
- package/modules/Tracking/events/actions/selectItem.ts +64 -64
- package/modules/Tracking/events/actions/selectPromotion.ts +24 -24
- package/modules/Tracking/events/actions/shippingCalculation.ts +7 -7
- package/modules/Tracking/events/actions/signup.ts +8 -8
- package/modules/Tracking/events/actions/upsertToCart.ts +62 -62
- package/modules/Tracking/events/views/viewCart.ts +28 -28
- package/modules/Tracking/events/views/viewHome.ts +5 -5
- package/modules/Tracking/events/views/viewItem.ts +31 -31
- package/modules/Tracking/events/views/viewItemList.ts +65 -65
- package/modules/Tracking/events/views/viewNotFound.ts +5 -5
- package/modules/Tracking/events/views/viewOther.ts +5 -5
- package/modules/Tracking/events/views/viewPayment.ts +7 -7
- package/modules/Tracking/events/views/viewPromotion.ts +28 -28
- package/modules/Tracking/events/views/viewShipping.ts +7 -7
- package/modules/Tracking/index.ts +84 -84
- package/modules/Tracking/publicApiTracking.ts +35 -35
- package/modules/Tracking/types/actions/add-payment-info.interfaces.ts +12 -12
- package/modules/Tracking/types/actions/add-shipping-info.interfaces.ts +11 -11
- package/modules/Tracking/types/actions/add-to-cart.interfaces.ts +10 -10
- package/modules/Tracking/types/actions/begin-checkout.interfaces.ts +12 -12
- package/modules/Tracking/types/actions/customer-profile.interfaces.ts +19 -19
- package/modules/Tracking/types/actions/file-download.interfaces.ts +4 -4
- package/modules/Tracking/types/actions/generate-lead.interfaces.ts +12 -12
- package/modules/Tracking/types/actions/login.interfaces.ts +4 -4
- package/modules/Tracking/types/actions/purchase.interfaces.ts +18 -18
- package/modules/Tracking/types/actions/remove-from-cart.interfaces.ts +10 -10
- package/modules/Tracking/types/actions/search.interfaces.ts +4 -4
- package/modules/Tracking/types/actions/select-item.interfaces.ts +16 -16
- package/modules/Tracking/types/actions/select-promotion.interfaces.ts +8 -8
- package/modules/Tracking/types/actions/share.interfaces.ts +4 -4
- package/modules/Tracking/types/actions/shipping-calculation.interfaces.ts +3 -3
- package/modules/Tracking/types/actions/signup.interfaces.ts +4 -4
- package/modules/Tracking/types/event.types.ts +54 -54
- package/modules/Tracking/types/index.ts +37 -37
- package/modules/Tracking/types/item.interfaces.ts +30 -30
- package/modules/Tracking/types/views/view-cart.interfaces.ts +11 -11
- package/modules/Tracking/types/views/view-home.interfaces.ts +3 -3
- package/modules/Tracking/types/views/view-item-list.interfaces.ts +11 -11
- package/modules/Tracking/types/views/view-item.interfaces.ts +15 -15
- package/modules/Tracking/types/views/view-not-found.interfaces.ts +3 -3
- package/modules/Tracking/types/views/view-other.interfaces.ts +3 -3
- package/modules/Tracking/types/views/view-payment.interfaces.ts +3 -3
- package/modules/Tracking/types/views/view-promotion.interfaces.ts +8 -8
- package/modules/Tracking/types/views/view-shipping.interfaces.ts +3 -3
- package/modules/Tracking/utils/cart.ts +100 -100
- package/modules/Tracking/utils/pushDatalayer.ts +7 -7
- package/modules/index.ts +1 -1
- package/package.json +1 -1
- package/scripts/release.sh +34 -0
|
@@ -1,100 +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
|
-
}
|
|
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
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Event } from '../types';
|
|
2
|
-
|
|
3
|
-
export function pushDatalayer(event: Event) {
|
|
4
|
-
if (!window.dataLayer) return;
|
|
5
|
-
|
|
6
|
-
window.dataLayer.push(event);
|
|
7
|
-
}
|
|
1
|
+
import type { Event } from '../types';
|
|
2
|
+
|
|
3
|
+
export function pushDatalayer(event: Event) {
|
|
4
|
+
if (!window.dataLayer) return;
|
|
5
|
+
|
|
6
|
+
window.dataLayer.push(event);
|
|
7
|
+
}
|
package/modules/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default as Api } from './Api';
|
|
1
|
+
export { default as Api } from './Api';
|
|
2
2
|
export { default as Tracking } from './Tracking';
|
package/package.json
CHANGED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
|
|
5
|
+
if [ -z "$LAST_TAG" ]; then
|
|
6
|
+
echo "Nenhuma tag encontrada. Crie a tag inicial uma unica vez antes do primeiro release automatico:"
|
|
7
|
+
echo " git tag v$(node -p "require('./package.json').version") && git push origin --tags"
|
|
8
|
+
exit 1
|
|
9
|
+
fi
|
|
10
|
+
echo "Ultima tag: ${LAST_TAG}"
|
|
11
|
+
|
|
12
|
+
COMMITS=$(git log "${LAST_TAG}..HEAD" --pretty=format:"%s%n%b")
|
|
13
|
+
|
|
14
|
+
BUMP="patch"
|
|
15
|
+
if echo "$COMMITS" | grep -qE "BREAKING CHANGE|^[a-z]+(\(.+\))?!:"; then
|
|
16
|
+
BUMP="major"
|
|
17
|
+
elif echo "$COMMITS" | grep -qE "^feat(\(.+\))?:"; then
|
|
18
|
+
BUMP="minor"
|
|
19
|
+
fi
|
|
20
|
+
echo "Tipo de bump detectado: ${BUMP}"
|
|
21
|
+
|
|
22
|
+
npm version "$BUMP" --no-git-tag-version
|
|
23
|
+
NEW_VERSION=$(node -p "require('./package.json').version")
|
|
24
|
+
echo "Nova versao: ${NEW_VERSION}"
|
|
25
|
+
|
|
26
|
+
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
|
|
27
|
+
npm publish --access public
|
|
28
|
+
rm -f .npmrc
|
|
29
|
+
|
|
30
|
+
git add package.json package-lock.json
|
|
31
|
+
git commit -m "chore(release): v${NEW_VERSION} [skip ci]"
|
|
32
|
+
git tag "v${NEW_VERSION}"
|
|
33
|
+
git push origin HEAD:main
|
|
34
|
+
git push origin "v${NEW_VERSION}"
|