@zenky/storefront-vue 0.10.17 → 0.10.18
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/CHANGELOG.md +6 -0
- package/dist/cart/index.js +4 -4
- package/dist/{chunk-L7UQIKDY.js → chunk-2DUKIVKC.js} +4 -4
- package/dist/{chunk-L7UQIKDY.js.map → chunk-2DUKIVKC.js.map} +1 -1
- package/dist/chunk-544USTPB.js +45 -0
- package/dist/chunk-544USTPB.js.map +1 -0
- package/dist/{chunk-U5E6QSUO.js → chunk-6BXHWR5E.js} +5 -5
- package/dist/{chunk-U5E6QSUO.js.map → chunk-6BXHWR5E.js.map} +1 -1
- package/dist/{chunk-F2LJ6TDH.js → chunk-LABBB43Q.js} +10 -5
- package/dist/chunk-LABBB43Q.js.map +1 -0
- package/dist/{chunk-54T72OLR.js → chunk-T52G6JN7.js} +93 -43
- package/dist/chunk-T52G6JN7.js.map +1 -0
- package/dist/{chunk-LUJSF6V7.js → chunk-YTYCSTHP.js} +3 -3
- package/dist/{chunk-LUJSF6V7.js.map → chunk-YTYCSTHP.js.map} +1 -1
- package/dist/index.js +6 -6
- package/dist/products/index.js +2 -2
- package/dist/promotions/index.js +3 -3
- package/dist/seo/index.js +2 -2
- package/dist/stores/index.js +3 -3
- package/package.json +1 -1
- package/dist/chunk-54T72OLR.js.map +0 -1
- package/dist/chunk-F2LJ6TDH.js.map +0 -1
- package/dist/chunk-WTZXTBF6.js +0 -95
- package/dist/chunk-WTZXTBF6.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -184,6 +184,12 @@ All notable changes to this project are documented in this file. The format foll
|
|
|
184
184
|
a dispatch still in flight when the user resets their channel choice could resolve
|
|
185
185
|
afterward and resurrect the very channel they just backed out of (its success handler
|
|
186
186
|
writes `confirmationMethod` from the response, unconditionally).
|
|
187
|
+
- `useProductList.fetchProducts()` now sends `stock_id` (the customer's order's attached
|
|
188
|
+
stock, if any) or `city_id` as a fallback, never both, so category/collection listings
|
|
189
|
+
only show products with positive stock. Previously neither was sent. The stock read is
|
|
190
|
+
`cartStore.order?.stock?.id`, not `profileStore.stock` — the latter defaults to the
|
|
191
|
+
city's first configured stock even with no order at all (`getStock()` in
|
|
192
|
+
`catalogResolver.ts`), which would have made the `city_id` fallback effectively dead.
|
|
187
193
|
|
|
188
194
|
### Security
|
|
189
195
|
|
package/dist/cart/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export { CASH_DENOMINATIONS_MAJOR, DEFAULT_ROUND_STEPS_MAJOR, ORDER_EVENTS, ORDER_WITH, buildCartLineKey, buildCashChangePresets, buildMainPaymentRequest, getCashDenominationsMinor, getDefaultRoundStepsMinor, normalizeAddress, useBonusesReconciliation, useCartAddressSync, useCartCustomerAttachment, useCartDeliveryAttachment, useCartInitialization, useCartMutation, useCartOperations, useCartQuantities, useCartRecalculation, useCartStockWatcher, useCheckoutFlow, useCheckoutSubmit, useCustomerAttach, useOnlinePaymentRetry, useOrderBonuses, useOrderChannel, useOrderDelivery, useOrderPromocode, useOrderSettings, useOrderTotal, usePaymentSelection, useRestrictedAddToCart, useRestrictionGate, useStorefrontCart, useVisibleCartVariants, variantLineKey } from '../chunk-
|
|
2
|
-
export { useCartCredentials } from '../chunk-
|
|
1
|
+
export { CASH_DENOMINATIONS_MAJOR, DEFAULT_ROUND_STEPS_MAJOR, ORDER_EVENTS, ORDER_WITH, buildCartLineKey, buildCashChangePresets, buildMainPaymentRequest, getCashDenominationsMinor, getDefaultRoundStepsMinor, normalizeAddress, useBonusesReconciliation, useCartAddressSync, useCartCustomerAttachment, useCartDeliveryAttachment, useCartInitialization, useCartMutation, useCartOperations, useCartQuantities, useCartRecalculation, useCartStockWatcher, useCheckoutFlow, useCheckoutSubmit, useCustomerAttach, useOnlinePaymentRetry, useOrderBonuses, useOrderChannel, useOrderDelivery, useOrderPromocode, useOrderSettings, useOrderTotal, usePaymentSelection, useRestrictedAddToCart, useRestrictionGate, useStorefrontCart, useVisibleCartVariants, variantLineKey } from '../chunk-6BXHWR5E.js';
|
|
2
|
+
export { useCartCredentials } from '../chunk-2DUKIVKC.js';
|
|
3
3
|
import '../chunk-5QCUH3FF.js';
|
|
4
4
|
export { getCartErrorCode, getCartErrorHttpCode, getCartErrorMessage, getValidationErrors, logCartError } from '../chunk-TE42OCFK.js';
|
|
5
|
-
import '../chunk-
|
|
5
|
+
import '../chunk-544USTPB.js';
|
|
6
6
|
import '../chunk-4JCJHAL3.js';
|
|
7
|
-
import '../chunk-
|
|
7
|
+
import '../chunk-T52G6JN7.js';
|
|
8
8
|
import '../chunk-TIQ7AJLY.js';
|
|
9
9
|
import '../chunk-IOYYCA75.js';
|
|
10
10
|
import '../chunk-FS2UNPTY.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useRuntime, useAuthStore } from './chunk-
|
|
1
|
+
import { usePromotionsStore } from './chunk-544USTPB.js';
|
|
2
|
+
import { useRuntime, useCartStore, useAuthStore } from './chunk-T52G6JN7.js';
|
|
3
3
|
import { useStoreProfileStore } from './chunk-IOYYCA75.js';
|
|
4
4
|
import { ref } from 'vue';
|
|
5
5
|
|
|
@@ -106,5 +106,5 @@ function usePromotionsChecker() {
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
export { useCartCredentials, usePromotionsChecker };
|
|
109
|
-
//# sourceMappingURL=chunk-
|
|
110
|
-
//# sourceMappingURL=chunk-
|
|
109
|
+
//# sourceMappingURL=chunk-2DUKIVKC.js.map
|
|
110
|
+
//# sourceMappingURL=chunk-2DUKIVKC.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cart/useCartCredentials.ts","../src/promotions/usePromotionsChecker.ts"],"names":[],"mappings":";;;;;AASA,IAAM,YAAA,GAAe,gBAAA;AACrB,IAAM,eAAA,GAAkB,mBAAA;AACxB,IAAM,YAAA,GAAe,EAAA,GAAK,EAAA,GAAK,EAAA,GAAK,CA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\n\nimport { useRuntime } from '../ports/runtime'\nimport { useAuthStore } from '../stores/auth'\nimport { useCartStore } from '../stores/cart'\nimport { useStoreProfileStore } from '../stores/store-profile'\n\nconst KEY_ORDER_ID = 'zenky_order_id'\nconst KEY_ORDER_TOKEN = 'zenky_order_token'\nconst WEEK_SECONDS = 60 * 60 * 24 * 7\n\n// App-level enum: OrderStatusKind.Pending = 'pending'.\nconst ORDER_STATUS_PENDING = 'pending'\n\nexport interface CartCredentials {\n orderIdCookie: Ref<string | null>\n orderTokenCookie: Ref<string | null>\n getStoreId: () => string\n getCityId: () => string\n getApiToken: () => string | undefined\n buildCredentials: (orderId: string, orderToken: string) => OrderCredentials\n getCredentials: () => OrderCredentials\n persistCredentials: (savedOrder: Order) => void\n clearPersistedCredentials: () => void\n isOrderActive: (order: Order) => boolean\n}\n\n/**\n * Manages order credentials. Order id/token persistence goes through the `storage`\n * port (the core doesn't know about useCookie). The refs are initialized from\n * storage; persisting writes to both.\n */\nexport function useCartCredentials(): CartCredentials {\n const { storage } = useRuntime()\n const cartStore = useCartStore()\n const authStore = useAuthStore()\n const profileStore = useStoreProfileStore()\n\n const orderIdRef = ref<string | null>(storage.get(KEY_ORDER_ID))\n const orderTokenRef = ref<string | null>(storage.get(KEY_ORDER_TOKEN))\n\n function getStoreId(): string {\n if (!profileStore.store) {\n throw new Error('Store is not initialized.')\n }\n\n return profileStore.store.id\n }\n\n function getCityId(): string {\n if (!profileStore.city) {\n throw new Error('City is not initialized.')\n }\n\n return profileStore.city.id\n }\n\n function getApiToken(): string | undefined {\n return authStore.apiToken\n }\n\n function buildCredentials(orderId: string, orderToken: string): OrderCredentials {\n const credentials: OrderCredentials = {\n id: orderId,\n token: orderToken,\n }\n\n const apiToken = getApiToken()\n\n if (apiToken) {\n credentials.api_token = apiToken\n }\n\n return credentials\n }\n\n function getCredentials(): OrderCredentials {\n if (!cartStore.credentials) {\n throw new Error('Cart has no credentials.')\n }\n\n return buildCredentials(cartStore.credentials.id, cartStore.credentials.token)\n }\n\n function persistCredentials(savedOrder: Order): void {\n orderIdRef.value = savedOrder.id\n orderTokenRef.value = savedOrder.token\n storage.set(KEY_ORDER_ID, savedOrder.id, { maxAge: WEEK_SECONDS })\n storage.set(KEY_ORDER_TOKEN, savedOrder.token, { maxAge: WEEK_SECONDS })\n }\n\n function clearPersistedCredentials(): void {\n orderIdRef.value = null\n orderTokenRef.value = null\n storage.remove(KEY_ORDER_ID)\n storage.remove(KEY_ORDER_TOKEN)\n }\n\n function isOrderActive(existingOrder: Order): boolean {\n if (!existingOrder.status) return true\n\n return String(existingOrder.status.kind) === ORDER_STATUS_PENDING\n }\n\n return {\n orderIdCookie: orderIdRef,\n orderTokenCookie: orderTokenRef,\n getStoreId,\n getCityId,\n getApiToken,\n buildCredentials,\n getCredentials,\n persistCredentials,\n clearPersistedCredentials,\n isOrderActive,\n }\n}\n","import { useRuntime } from '../ports/runtime'\nimport { useCartCredentials } from '../cart/useCartCredentials'\nimport { useCartStore } from '../stores/cart'\nimport { usePromotionsStore } from '../stores/promotions'\nimport { useStoreProfileStore } from '../stores/store-profile'\n\nexport interface PromotionsChecker {\n dispatchCheck: () => Promise<void>\n}\n\n/** Timeout — if the WS never responds, reset the checking flag. */\nconst WS_RESPONSE_TIMEOUT_MS = 5000\n\n/**\n * Checks promotions. Calls dispatchPromotionsChecker after the cart changes.\n * The result arrives over WebSocket (handled in useOrderChannel).\n *\n * Resolve this synchronously in setup, and call only `dispatchCheck` after an\n * await — like any core composable, see \"Call composables and stores\n * synchronously in setup\" in the README.\n *\n * ```ts\n * const { dispatchCheck } = usePromotionsChecker()\n *\n * async function addGift() {\n * await addVariantToOrder()\n * dispatchCheck()\n * }\n * ```\n */\nexport function usePromotionsChecker(): PromotionsChecker {\n const { sdk, events } = useRuntime()\n const cartStore = useCartStore()\n const profileStore = useStoreProfileStore()\n const promotionsStore = usePromotionsStore()\n const credentials = useCartCredentials()\n\n async function dispatchCheck(): Promise<void> {\n if (!cartStore.hasOrder || promotionsStore.checking) return\n\n const storeId = profileStore.store?.id\n if (!storeId) return\n\n promotionsStore.setChecking(true)\n promotionsStore.clearRewards() // Clear old ones — WS will refill with current ones\n events?.get()?.promotionsCheckerStarted({ order: cartStore.order })\n\n try {\n const creds = credentials.getCredentials()\n await sdk.orders.dispatchPromotionsChecker(storeId, creds)\n\n setTimeout(() => {\n if (promotionsStore.checking) promotionsStore.setChecking(false)\n }, WS_RESPONSE_TIMEOUT_MS)\n } catch (e: unknown) {\n console.error('[promotions] check failed', e)\n promotionsStore.setChecking(false)\n }\n }\n\n return { dispatchCheck }\n}\n"]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { defineStore } from 'pinia';
|
|
2
|
+
import { ref, computed } from 'vue';
|
|
3
|
+
|
|
4
|
+
// src/stores/promotions.ts
|
|
5
|
+
var usePromotionsStore = defineStore("zenky-promotions", () => {
|
|
6
|
+
const rewards = ref([]);
|
|
7
|
+
const checking = ref(false);
|
|
8
|
+
function addOrUpdateReward(selection) {
|
|
9
|
+
const index = rewards.value.findIndex((r) => r.promotionId === selection.promotionId);
|
|
10
|
+
if (index >= 0) {
|
|
11
|
+
rewards.value[index] = selection;
|
|
12
|
+
} else {
|
|
13
|
+
rewards.value.push(selection);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function removeRewardByPromotion(promotionId) {
|
|
17
|
+
rewards.value = rewards.value.filter((r) => r.promotionId !== promotionId);
|
|
18
|
+
}
|
|
19
|
+
function clearRewards() {
|
|
20
|
+
rewards.value = [];
|
|
21
|
+
}
|
|
22
|
+
function setChecking(value) {
|
|
23
|
+
checking.value = value;
|
|
24
|
+
}
|
|
25
|
+
const hasRewards = computed(() => rewards.value.length > 0);
|
|
26
|
+
const totalEmptySlots = computed(() => rewards.value.reduce((sum, r) => sum + r.limit, 0));
|
|
27
|
+
const rewardSelection = computed(() => rewards.value[0] ?? null);
|
|
28
|
+
const needsSelection = computed(() => rewards.value.some((r) => r.context !== null));
|
|
29
|
+
return {
|
|
30
|
+
rewards,
|
|
31
|
+
checking,
|
|
32
|
+
addOrUpdateReward,
|
|
33
|
+
removeRewardByPromotion,
|
|
34
|
+
clearRewards,
|
|
35
|
+
setChecking,
|
|
36
|
+
hasRewards,
|
|
37
|
+
totalEmptySlots,
|
|
38
|
+
rewardSelection,
|
|
39
|
+
needsSelection
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
export { usePromotionsStore };
|
|
44
|
+
//# sourceMappingURL=chunk-544USTPB.js.map
|
|
45
|
+
//# sourceMappingURL=chunk-544USTPB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/stores/promotions.ts"],"names":[],"mappings":";;;;AA6BO,IAAM,kBAAA,GAAqB,WAAA,CAAY,kBAAA,EAAoB,MAAuB;AAErF,EAAA,MAAM,OAAA,GAAU,GAAA,CAAuB,EAAE,CAAA;AACzC,EAAA,MAAM,QAAA,GAAW,IAAI,KAAK,CAAA;AAE1B,EAAA,SAAS,kBAAkB,SAAA,EAAkC;AACzD,IAAA,MAAM,KAAA,GAAQ,QAAQ,KAAA,CAAM,SAAA,CAAU,CAAC,CAAA,KAAM,CAAA,CAAE,WAAA,KAAgB,SAAA,CAAU,WAAW,CAAA;AACpF,IAAA,IAAI,SAAS,CAAA,EAAG;AACZ,MAAA,OAAA,CAAQ,KAAA,CAAM,KAAK,CAAA,GAAI,SAAA;AAAA,IAC3B,CAAA,MAAO;AACH,MAAA,OAAA,CAAQ,KAAA,CAAM,KAAK,SAAS,CAAA;AAAA,IAChC;AAAA,EACJ;AAEA,EAAA,SAAS,wBAAwB,WAAA,EAA2B;AACxD,IAAA,OAAA,CAAQ,KAAA,GAAQ,QAAQ,KAAA,CAAM,MAAA,CAAO,CAAC,CAAA,KAAM,CAAA,CAAE,gBAAgB,WAAW,CAAA;AAAA,EAC7E;AAEA,EAAA,SAAS,YAAA,GAAqB;AAC1B,IAAA,OAAA,CAAQ,QAAQ,EAAC;AAAA,EACrB;AAEA,EAAA,SAAS,YAAY,KAAA,EAAsB;AACvC,IAAA,QAAA,CAAS,KAAA,GAAQ,KAAA;AAAA,EACrB;AAEA,EAAA,MAAM,aAAa,QAAA,CAAS,MAAM,OAAA,CAAQ,KAAA,CAAM,SAAS,CAAC,CAAA;AAC1D,EAAA,MAAM,eAAA,GAAkB,QAAA,CAAS,MAAM,OAAA,CAAQ,KAAA,CAAM,MAAA,CAAO,CAAC,GAAA,EAAK,CAAA,KAAM,GAAA,GAAM,CAAA,CAAE,KAAA,EAAO,CAAC,CAAC,CAAA;AAEzF,EAAA,MAAM,kBAAkB,QAAA,CAAiC,MAAM,QAAQ,KAAA,CAAM,CAAC,KAAK,IAAI,CAAA;AACvF,EAAA,MAAM,cAAA,GAAiB,QAAA,CAAS,MAAM,OAAA,CAAQ,KAAA,CAAM,IAAA,CAAK,CAAC,CAAA,KAAM,CAAA,CAAE,OAAA,KAAY,IAAI,CAAC,CAAA;AAEnF,EAAA,OAAO;AAAA,IACH,OAAA;AAAA,IACA,QAAA;AAAA,IACA,iBAAA;AAAA,IACA,uBAAA;AAAA,IACA,YAAA;AAAA,IACA,WAAA;AAAA,IACA,UAAA;AAAA,IACA,eAAA;AAAA,IACA,eAAA;AAAA,IACA;AAAA,GACJ;AACJ,CAAC","file":"chunk-544USTPB.js","sourcesContent":["import { defineStore } from 'pinia'\nimport { computed, ref, type ComputedRef, type Ref } from 'vue'\n\nexport interface RewardSelectionContext {\n type: string\n id: string\n}\n\nexport interface RewardSelection {\n offerId: string\n promotionId: string\n rewardId: string\n context: RewardSelectionContext | null\n limit: number\n}\n\nexport interface PromotionsStore {\n rewards: Ref<RewardSelection[]>\n checking: Ref<boolean>\n addOrUpdateReward: (selection: RewardSelection) => void\n removeRewardByPromotion: (promotionId: string) => void\n clearRewards: () => void\n setChecking: (value: boolean) => void\n hasRewards: ComputedRef<boolean>\n totalEmptySlots: ComputedRef<number>\n rewardSelection: ComputedRef<RewardSelection | null>\n needsSelection: ComputedRef<boolean>\n}\n\nexport const usePromotionsStore = defineStore('zenky-promotions', (): PromotionsStore => {\n /** Available rewards (multiple promotions can be active at the same time). */\n const rewards = ref<RewardSelection[]>([])\n const checking = ref(false)\n\n function addOrUpdateReward(selection: RewardSelection): void {\n const index = rewards.value.findIndex((r) => r.promotionId === selection.promotionId)\n if (index >= 0) {\n rewards.value[index] = selection\n } else {\n rewards.value.push(selection)\n }\n }\n\n function removeRewardByPromotion(promotionId: string): void {\n rewards.value = rewards.value.filter((r) => r.promotionId !== promotionId)\n }\n\n function clearRewards(): void {\n rewards.value = []\n }\n\n function setChecking(value: boolean): void {\n checking.value = value\n }\n\n const hasRewards = computed(() => rewards.value.length > 0)\n const totalEmptySlots = computed(() => rewards.value.reduce((sum, r) => sum + r.limit, 0))\n /** Kept for backward compatibility — the first reward. */\n const rewardSelection = computed<RewardSelection | null>(() => rewards.value[0] ?? null)\n const needsSelection = computed(() => rewards.value.some((r) => r.context !== null))\n\n return {\n rewards,\n checking,\n addOrUpdateReward,\n removeRewardByPromotion,\n clearRewards,\n setChecking,\n hasRewards,\n totalEmptySlots,\n rewardSelection,\n needsSelection,\n }\n})\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { useCartCredentials, usePromotionsChecker } from './chunk-
|
|
1
|
+
import { useCartCredentials, usePromotionsChecker } from './chunk-2DUKIVKC.js';
|
|
2
2
|
import { createRuntimeState } from './chunk-5QCUH3FF.js';
|
|
3
3
|
import { logCartError, getCartErrorHttpCode, getCartErrorCode, getCartErrorMessage } from './chunk-TE42OCFK.js';
|
|
4
|
-
import {
|
|
4
|
+
import { usePromotionsStore } from './chunk-544USTPB.js';
|
|
5
5
|
import { useCatalogStore } from './chunk-4JCJHAL3.js';
|
|
6
|
-
import { useRuntime, useAuthStore } from './chunk-
|
|
6
|
+
import { useRuntime, useCartStore, useAuthStore, useOrderSettingsStore } from './chunk-T52G6JN7.js';
|
|
7
7
|
import { toRequestedMethod } from './chunk-TIQ7AJLY.js';
|
|
8
8
|
import { useStoreProfileStore } from './chunk-IOYYCA75.js';
|
|
9
9
|
import { getRemoteCatalog } from './chunk-FS2UNPTY.js';
|
|
@@ -1950,5 +1950,5 @@ function useVisibleCartVariants() {
|
|
|
1950
1950
|
}
|
|
1951
1951
|
|
|
1952
1952
|
export { CASH_DENOMINATIONS_MAJOR, DEFAULT_ROUND_STEPS_MAJOR, ORDER_EVENTS, ORDER_WITH, buildCartLineKey, buildCashChangePresets, buildMainPaymentRequest, getCashDenominationsMinor, getDefaultRoundStepsMinor, normalizeAddress, useBonusesReconciliation, useCartAddressSync, useCartCustomerAttachment, useCartDeliveryAttachment, useCartInitialization, useCartMutation, useCartOperations, useCartQuantities, useCartRecalculation, useCartStockWatcher, useCheckoutFlow, useCheckoutSubmit, useCustomerAttach, useOnlinePaymentRetry, useOrderBonuses, useOrderChannel, useOrderDelivery, useOrderPromocode, useOrderSettings, useOrderTotal, usePaymentSelection, useRestrictedAddToCart, useRestrictionGate, useStorefrontCart, useVisibleCartVariants, variantLineKey };
|
|
1953
|
-
//# sourceMappingURL=chunk-
|
|
1954
|
-
//# sourceMappingURL=chunk-
|
|
1953
|
+
//# sourceMappingURL=chunk-6BXHWR5E.js.map
|
|
1954
|
+
//# sourceMappingURL=chunk-6BXHWR5E.js.map
|