@zenky/storefront-vue 0.10.7 → 0.10.9
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 +10 -0
- package/README.md +4 -18
- package/dist/cart/index.d.ts +167 -160
- package/dist/cart/index.js +7 -7
- package/dist/catalog/index.d.ts +18 -21
- package/dist/catalog/index.js +2 -2
- package/dist/{chunk-RO25KNM5.js → chunk-2Y6QTHXI.js} +2 -2
- package/dist/chunk-2Y6QTHXI.js.map +1 -0
- package/dist/{chunk-5YD4AIY2.js → chunk-46FNHMWC.js} +4 -4
- package/dist/chunk-46FNHMWC.js.map +1 -0
- package/dist/{chunk-Z3IW4ODZ.js → chunk-6QCFHSLX.js} +2 -2
- package/dist/chunk-6QCFHSLX.js.map +1 -0
- package/dist/{chunk-2SMSLZ6G.js → chunk-AVES4WJZ.js} +15 -11
- package/dist/chunk-AVES4WJZ.js.map +1 -0
- package/dist/{chunk-4IFPVEO7.js → chunk-BUNI6MGH.js} +3 -3
- package/dist/chunk-BUNI6MGH.js.map +1 -0
- package/dist/{chunk-PTMSPB34.js → chunk-FXKG5TFQ.js} +3 -3
- package/dist/chunk-FXKG5TFQ.js.map +1 -0
- package/dist/{chunk-MOG6UMFM.js → chunk-GILJFP55.js} +2 -2
- package/dist/chunk-GILJFP55.js.map +1 -0
- package/dist/{chunk-2CI4RW7V.js → chunk-GLQXTMVW.js} +2 -2
- package/dist/{chunk-2CI4RW7V.js.map → chunk-GLQXTMVW.js.map} +1 -1
- package/dist/{chunk-MZ66ARDL.js → chunk-GXDTRTUT.js} +2 -2
- package/dist/chunk-GXDTRTUT.js.map +1 -0
- package/dist/{chunk-E3G7NGCH.js → chunk-KFCO46RB.js} +2 -2
- package/dist/{chunk-E3G7NGCH.js.map → chunk-KFCO46RB.js.map} +1 -1
- package/dist/{chunk-VFMVQR6Y.js → chunk-QZ3S3NN3.js} +5 -3
- package/dist/chunk-QZ3S3NN3.js.map +1 -0
- package/dist/{chunk-B3UU7HF5.js → chunk-RF4ML3Q3.js} +47 -7
- package/dist/chunk-RF4ML3Q3.js.map +1 -0
- package/dist/{chunk-NG7RUIWW.js → chunk-RK5CGOM7.js} +2 -2
- package/dist/chunk-RK5CGOM7.js.map +1 -0
- package/dist/{chunk-Z247QRDJ.js → chunk-XULHV6SS.js} +3 -3
- package/dist/chunk-XULHV6SS.js.map +1 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +14 -14
- package/dist/money/index.d.ts +8 -8
- package/dist/money/index.js +1 -1
- package/dist/order/index.d.ts +3 -3
- package/dist/order/index.js.map +1 -1
- package/dist/pagination/index.d.ts +29 -37
- package/dist/pagination/index.js.map +1 -1
- package/dist/ports/index.d.ts +23 -22
- package/dist/ports/index.js +1 -1
- package/dist/products/index.d.ts +20 -9
- package/dist/products/index.js +3 -3
- package/dist/promotions/index.d.ts +5 -5
- package/dist/promotions/index.js +3 -3
- package/dist/seo/index.d.ts +14 -12
- package/dist/seo/index.js +5 -5
- package/dist/seo/index.js.map +1 -1
- package/dist/snippets/index.js +1 -1
- package/dist/stores/index.d.ts +4 -5
- package/dist/stores/index.js +4 -4
- package/dist/theme/index.d.ts +3 -3
- package/dist/theme/index.js +1 -1
- package/dist/utils/index.d.ts +16 -16
- package/dist/utils/index.js +1 -1
- package/docs/architecture.md +84 -0
- package/docs/consumer-setup.md +13 -54
- package/docs/ports.md +12 -13
- package/package.json +1 -1
- package/dist/chunk-2SMSLZ6G.js.map +0 -1
- package/dist/chunk-4IFPVEO7.js.map +0 -1
- package/dist/chunk-5YD4AIY2.js.map +0 -1
- package/dist/chunk-B3UU7HF5.js.map +0 -1
- package/dist/chunk-MOG6UMFM.js.map +0 -1
- package/dist/chunk-MZ66ARDL.js.map +0 -1
- package/dist/chunk-NG7RUIWW.js.map +0 -1
- package/dist/chunk-PTMSPB34.js.map +0 -1
- package/dist/chunk-RO25KNM5.js.map +0 -1
- package/dist/chunk-VFMVQR6Y.js.map +0 -1
- package/dist/chunk-Z247QRDJ.js.map +0 -1
- package/dist/chunk-Z3IW4ODZ.js.map +0 -1
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, getCartErrorCode, getCartErrorHttpCode, getCartErrorMessage, getCashDenominationsMinor, getDefaultRoundStepsMinor, getValidationErrors, logCartError, 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-
|
|
3
|
-
import '../chunk-
|
|
4
|
-
import '../chunk-
|
|
5
|
-
import '../chunk-
|
|
1
|
+
export { CASH_DENOMINATIONS_MAJOR, DEFAULT_ROUND_STEPS_MAJOR, ORDER_EVENTS, ORDER_WITH, buildCartLineKey, buildCashChangePresets, buildMainPaymentRequest, getCartErrorCode, getCartErrorHttpCode, getCartErrorMessage, getCashDenominationsMinor, getDefaultRoundStepsMinor, getValidationErrors, logCartError, 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-AVES4WJZ.js';
|
|
2
|
+
export { useCartCredentials } from '../chunk-46FNHMWC.js';
|
|
3
|
+
import '../chunk-XULHV6SS.js';
|
|
4
|
+
import '../chunk-KFCO46RB.js';
|
|
5
|
+
import '../chunk-2Y6QTHXI.js';
|
|
6
6
|
import '../chunk-5QCUH3FF.js';
|
|
7
|
-
import '../chunk-
|
|
8
|
-
import '../chunk-
|
|
7
|
+
import '../chunk-6QCFHSLX.js';
|
|
8
|
+
import '../chunk-QZ3S3NN3.js';
|
|
9
9
|
//# sourceMappingURL=index.js.map
|
|
10
10
|
//# sourceMappingURL=index.js.map
|
package/dist/catalog/index.d.ts
CHANGED
|
@@ -1,35 +1,33 @@
|
|
|
1
1
|
import { NestedCategory, Product, Store, City, Stock, RemoteCatalog, ZenkyStorefront, CollectionsListRequest, ProductsCollection } from '@zenky/storefront-api';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Recursively searches the category tree by `short_id`.
|
|
5
5
|
*
|
|
6
|
-
* `NestedCategory[]`
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* нужно рекурсивно обойти все ветки.
|
|
6
|
+
* `NestedCategory[]` is a tree: root categories at the top level, nested ones
|
|
7
|
+
* inside `children[]`. A plain `tree.find()` only reaches root categories, so
|
|
8
|
+
* nested ones (e.g. "Jackets" inside "Men" inside "Clothing") need a recursive walk.
|
|
10
9
|
*
|
|
11
|
-
*
|
|
10
|
+
* Returns the first match (DFS pre-order).
|
|
12
11
|
*/
|
|
13
12
|
declare function findCategoryByShortId(tree: NestedCategory[], shortId: string): NestedCategory | null;
|
|
14
13
|
/**
|
|
15
|
-
*
|
|
14
|
+
* Finds a category's root ancestor by `parent_id`.
|
|
16
15
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
16
|
+
* For nested "Jackets" (parent: "Men"), returns "Clothing" (the root of the branch).
|
|
17
|
+
* For root "Clothing", returns itself.
|
|
19
18
|
*
|
|
20
|
-
*
|
|
21
|
-
* находится на вложенной категории.
|
|
19
|
+
* Used in `CategoryTabs` to highlight the root tab when the user is on a nested category.
|
|
22
20
|
*/
|
|
23
21
|
declare function findRootAncestor(tree: NestedCategory[], category: NestedCategory): NestedCategory | null;
|
|
24
|
-
/**
|
|
22
|
+
/** Recursive search by `id` (not `short_id`). Used by findRootAncestor. */
|
|
25
23
|
declare function findCategoryById(tree: NestedCategory[], id: string): NestedCategory | null;
|
|
26
24
|
/**
|
|
27
|
-
*
|
|
25
|
+
* Returns the path from the root category down to the target (inclusive).
|
|
28
26
|
*
|
|
29
|
-
*
|
|
30
|
-
* → [
|
|
27
|
+
* Example for "Jackets" in the branch "Clothing → Men → Jackets":
|
|
28
|
+
* → [Clothing, Men, Jackets]
|
|
31
29
|
*
|
|
32
|
-
*
|
|
30
|
+
* Used to build breadcrumbs.
|
|
33
31
|
*/
|
|
34
32
|
declare function getCategoryPath(tree: NestedCategory[], target: NestedCategory): NestedCategory[];
|
|
35
33
|
|
|
@@ -49,12 +47,11 @@ declare function getStock(city: City, stockId?: string | null): Stock | null;
|
|
|
49
47
|
declare function getRemoteCatalog(store: Store, city: City, stock: Stock | null): RemoteCatalog | null;
|
|
50
48
|
|
|
51
49
|
/**
|
|
52
|
-
*
|
|
53
|
-
* Pure composable — SDK передаётся параметром (DI), Nuxt не нужен.
|
|
50
|
+
* Pure composable — the SDK is passed in as a parameter (DI), no Nuxt needed.
|
|
54
51
|
*
|
|
55
|
-
* NOTE:
|
|
56
|
-
*
|
|
57
|
-
*
|
|
52
|
+
* NOTE: the storefront API has no single `getCollection(id)`; use
|
|
53
|
+
* `GET /products?collection_id=...` to get a collection's products.
|
|
54
|
+
* To get a collection's metadata, look it up in the list via `loadCollections`.
|
|
58
55
|
*/
|
|
59
56
|
declare function useCollections(sdk: ZenkyStorefront): {
|
|
60
57
|
loadCollections: (storeId: string, request?: CollectionsListRequest) => Promise<ProductsCollection[]>;
|
package/dist/catalog/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { collectDescendantIds, findCategoryById, findCategoryByShortId, findRootAncestor, getCategoryPath, groupProductsBySubcategory, useCollections } from '../chunk-
|
|
2
|
-
export { getCity, getRemoteCatalog, getStock } from '../chunk-
|
|
1
|
+
export { collectDescendantIds, findCategoryById, findCategoryByShortId, findRootAncestor, getCategoryPath, groupProductsBySubcategory, useCollections } from '../chunk-RK5CGOM7.js';
|
|
2
|
+
export { getCity, getRemoteCatalog, getStock } from '../chunk-KFCO46RB.js';
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -32,5 +32,5 @@ function minorToMajorString(value, currency = "RUB") {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
export { asMajor, asMinor, formatPrice, majorToMinor, minorToMajor, minorToMajorString };
|
|
35
|
-
//# sourceMappingURL=chunk-
|
|
36
|
-
//# sourceMappingURL=chunk-
|
|
35
|
+
//# sourceMappingURL=chunk-2Y6QTHXI.js.map
|
|
36
|
+
//# sourceMappingURL=chunk-2Y6QTHXI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/money/money.ts"],"names":[],"mappings":";AAmBO,IAAM,OAAA,GAAU,CAAC,KAAA,KAAyB;AAC1C,IAAM,OAAA,GAAU,CAAC,KAAA,KAAyB;AAQjD,SAAS,eAAe,QAAA,EAA0B;AAC9C,EAAA,MAAM,cAAA,GACF,IAAI,IAAA,CAAK,YAAA,CAAa,IAAA,EAAM;AAAA,IACxB,KAAA,EAAO,UAAA;AAAA,IACP;AAAA,GACH,CAAA,CAAE,eAAA,EAAgB,CAAE,qBAAA,IAAyB,CAAA;AAClD,EAAA,OAAO,EAAA,IAAM,cAAA;AACjB;AAMA,IAAM,cAAA,GAAiB,OAAA;AAKhB,SAAS,WAAA,CACZ,KAAA,EACA,QAAA,GAAW,KAAA,EACX,SAAiB,cAAA,EACX;AACN,EAAA,IAAI,CAAC,KAAA,IAAS,KAAA,KAAU,CAAA,EAAG;AACvB,IAAA,OAAO,EAAA;AAAA,EACX;AAEA,EAAA,OAAO,IAAI,IAAA,CAAK,YAAA,CAAa,MAAA,EAAQ;AAAA,IACjC,KAAA,EAAO,UAAA;AAAA,IACP,QAAA;AAAA,IACA,qBAAA,EAAuB;AAAA,GAC1B,CAAA,CAAE,MAAA,CAAO,KAAA,GAAQ,cAAA,CAAe,QAAQ,CAAC,CAAA;AAC9C;AAGO,SAAS,YAAA,CAAa,KAAA,EAAe,QAAA,GAAW,KAAA,EAAe;AAClE,EAAA,OAAO,KAAA,GAAQ,eAAe,QAAQ,CAAA;AAC1C;AAGO,SAAS,YAAA,CAAa,KAAA,EAAe,QAAA,GAAW,KAAA,EAAe;AAClE,EAAA,OAAO,IAAA,CAAK,KAAA,CAAM,KAAA,GAAQ,cAAA,CAAe,QAAQ,CAAC,CAAA;AACtD;AAMO,SAAS,kBAAA,CAAmB,KAAA,EAAe,QAAA,GAAW,KAAA,EAAe;AACxE,EAAA,MAAM,MAAA,GAAS,eAAe,QAAQ,CAAA;AACtC,EAAA,MAAM,QAAQ,KAAA,GAAQ,MAAA;AACtB,EAAA,OAAO,KAAA,CAAM,OAAA,CAAQ,IAAA,CAAK,KAAA,CAAM,MAAM,CAAC,CAAA;AAC3C","file":"chunk-2Y6QTHXI.js","sourcesContent":["// Money units. Zenky's golden rule:\n// • store and compute in MINOR units (kopecks/tyins/…) — that's what the API returns;\n// • send MAJOR units (rubles) to some API endpoints, as a number or a string.\n//\n// The compat functions below share their signatures with app/storefront/utils/price.ts —\n// a drop-in replacement that doesn't break call sites during the move.\n\n// ── Branded types (opt-in, for new code) ────────────────────────────────────\n// Minor and Major are distinct types — the compiler rejects mixing them up:\n// sendToServer(bill: Minor) ← passing Major is a compile error.\ndeclare const MINOR: unique symbol\ndeclare const MAJOR: unique symbol\n\n/** An amount in minor units (kopecks) — how the API stores and returns it. */\nexport type Minor = number & { readonly [MINOR]: true }\n/** An amount in major units (rubles) — the shape some API endpoints expect. */\nexport type Major = number & { readonly [MAJOR]: true }\n\n/** Marks a raw number from the API as Minor — a zero-cost assertion, not a conversion. */\nexport const asMinor = (value: number): Minor => value as Minor\nexport const asMajor = (value: number): Major => value as Major\n\n// ── Currency helpers ────────────────────────────────────────────────────────\n\n/**\n * Minor-to-major multiplier for a currency's ISO code, via Intl (no hardcoded table):\n * RUB/KZT/THB/EUR/USD = ×100, JPY/KRW = ×1, KWD/BHD/OMR = ×1000.\n */\nfunction getMinorFactor(currency: string): number {\n const fractionDigits =\n new Intl.NumberFormat('en', {\n style: 'currency',\n currency,\n }).resolvedOptions().maximumFractionDigits ?? 2\n return 10 ** fractionDigits\n}\n\n/**\n * Default formatting locale. Affects the separator (1 290 ₽ vs 1,290 ₽).\n * `ru-RU` fits RU/KZ/BY/UA. Pass `locale` explicitly for TH/JP/EN.\n */\nconst DEFAULT_LOCALE = 'ru-RU' as const\n\n// ── Compat API (previous number-based signatures — drop-in) ─────────────────\n\n/** Formats a price from minor units into a readable string (`1 290 ₽`). */\nexport function formatPrice(\n value?: number | null,\n currency = 'RUB',\n locale: string = DEFAULT_LOCALE\n): string {\n if (!value && value !== 0) {\n return ''\n }\n\n return new Intl.NumberFormat(locale, {\n style: 'currency',\n currency,\n minimumFractionDigits: 0,\n }).format(value / getMinorFactor(currency))\n}\n\n/** Raw minor-to-major conversion (kopecks → rubles), no formatting. */\nexport function minorToMajor(value: number, currency = 'RUB'): number {\n return value / getMinorFactor(currency)\n}\n\n/** Raw major-to-minor conversion (rubles → kopecks), rounded to a whole number. */\nexport function majorToMinor(value: number, currency = 'RUB'): number {\n return Math.round(value * getMinorFactor(currency))\n}\n\n/**\n * Minor to major, as a string. The payments/bonuses API expects the amount\n * as a ruble string, e.g. `\"103.50\"`.\n */\nexport function minorToMajorString(value: number, currency = 'RUB'): string {\n const factor = getMinorFactor(currency)\n const major = value / factor\n return major.toFixed(Math.log10(factor))\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useCartStore, usePromotionsStore } from './chunk-
|
|
2
|
-
import { useRuntime, useAuthStore, useStoreProfileStore } from './chunk-
|
|
1
|
+
import { useCartStore, usePromotionsStore } from './chunk-XULHV6SS.js';
|
|
2
|
+
import { useRuntime, useAuthStore, useStoreProfileStore } from './chunk-QZ3S3NN3.js';
|
|
3
3
|
import { ref } from 'vue';
|
|
4
4
|
|
|
5
5
|
var KEY_ORDER_ID = "zenky_order_id";
|
|
@@ -105,5 +105,5 @@ function usePromotionsChecker() {
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
export { useCartCredentials, usePromotionsChecker };
|
|
108
|
-
//# sourceMappingURL=chunk-
|
|
109
|
-
//# sourceMappingURL=chunk-
|
|
108
|
+
//# sourceMappingURL=chunk-46FNHMWC.js.map
|
|
109
|
+
//# sourceMappingURL=chunk-46FNHMWC.js.map
|
|
@@ -0,0 +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,CAAA;AAGpC,IAAM,oBAAA,GAAuB,SAAA;AAoBtB,SAAS,kBAAA,GAAsC;AAClD,EAAA,MAAM,EAAE,OAAA,EAAQ,GAAI,UAAA,EAAW;AAC/B,EAAA,MAAM,YAAY,YAAA,EAAa;AAC/B,EAAA,MAAM,YAAY,YAAA,EAAa;AAC/B,EAAA,MAAM,eAAe,oBAAA,EAAqB;AAE1C,EAAA,MAAM,UAAA,GAAa,GAAA,CAAmB,OAAA,CAAQ,GAAA,CAAI,YAAY,CAAC,CAAA;AAC/D,EAAA,MAAM,aAAA,GAAgB,GAAA,CAAmB,OAAA,CAAQ,GAAA,CAAI,eAAe,CAAC,CAAA;AAErE,EAAA,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A,CAAgB,YAAY,IAAI,CAAA;AAChC,IAAA,eAAA,CAAgB,YAAA,EAAa;AAC7B,IAAA,MAAA,EAAQ,KAAI,EAAG,wBAAA,CAAyB,EAAE,KAAA,EAAO,SAAA,CAAU,OAAO,CAAA;AAElE,IAAA,IAAI;AACA,MAAA,MAAM,KAAA,GAAQ,YAAY,cAAA,EAAe;AACzC,MAAA,MAAM,GAAA,CAAI,MAAA,CAAO,yBAAA,CAA0B,OAAA,EAAS,KAAK,CAAA;AAEzD,MAAA,UAAA,CAAW,MAAM;AACb,QAAA,IAAI,eAAA,CAAgB,QAAA,EAAU,eAAA,CAAgB,WAAA,CAAY,KAAK,CAAA;AAAA,MACnE,GAAG,sBAAsB,CAAA;AAAA,IAC7B,SAAS,CAAA,EAAY;AACjB,MAAA,OAAA,CAAQ,KAAA,CAAM,6BAA6B,CAAC,CAAA;AAC5C,MAAA,eAAA,CAAgB,YAAY,KAAK,CAAA;AAAA,IACrC;AAAA,EACJ;AAEA,EAAA,OAAO,EAAE,aAAA,EAAc;AAC3B","file":"chunk-46FNHMWC.js","sourcesContent":["import { ref, type Ref } from 'vue'\n\nimport type { Order, OrderCredentials } from '@zenky/storefront-api'\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"]}
|
|
@@ -32,5 +32,5 @@ var useCatalogStore = defineStore("zenky-catalog", () => {
|
|
|
32
32
|
});
|
|
33
33
|
|
|
34
34
|
export { useCatalogStore };
|
|
35
|
-
//# sourceMappingURL=chunk-
|
|
36
|
-
//# sourceMappingURL=chunk-
|
|
35
|
+
//# sourceMappingURL=chunk-6QCFHSLX.js.map
|
|
36
|
+
//# sourceMappingURL=chunk-6QCFHSLX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/stores/catalog.ts"],"names":[],"mappings":";;;;AAsBO,IAAM,eAAA,GAAkB,WAAA,CAAY,eAAA,EAAiB,MAAoB;AAC5E,EAAA,MAAM,OAAA,GAAU,GAAA,CAAmB,EAAE,CAAA;AACrC,EAAA,MAAM,WAAA,GAAc,IAAmB,IAAI,CAAA;AAC3C,EAAA,MAAM,SAAA,GAAY,IAAI,KAAK,CAAA;AAC3B,EAAA,MAAM,SAAA,GAAY,IAAI,KAAK,CAAA;AAE3B,EAAA,SAAS,WAAA,CAAY,OAAsB,IAAA,EAA4B;AACnE,IAAA,OAAA,CAAQ,KAAA,GAAQ,KAAA;AAChB,IAAA,WAAA,CAAY,QAAQ,IAAA,IAAQ,IAAA;AAC5B,IAAA,SAAA,CAAU,KAAA,GAAQ,KAAA;AAAA,EACtB;AAEA,EAAA,SAAS,YAAA,GAAqB;AAC1B,IAAA,SAAA,CAAU,KAAA,GAAQ,IAAA;AAAA,EACtB;AAEA,EAAA,SAAS,aAAa,KAAA,EAAsB;AACxC,IAAA,SAAA,CAAU,KAAA,GAAQ,KAAA;AAAA,EACtB;AAEA,EAAA,MAAM,aAAa,QAAA,CAAS,MAAM,OAAA,CAAQ,KAAA,CAAM,SAAS,CAAC,CAAA;AAE1D,EAAA,OAAO;AAAA,IACH,OAAA;AAAA,IACA,WAAA;AAAA,IACA,SAAA;AAAA,IACA,SAAA;AAAA,IACA,WAAA;AAAA,IACA,YAAA;AAAA,IACA,YAAA;AAAA,IACA;AAAA,GACJ;AACJ,CAAC","file":"chunk-6QCFHSLX.js","sourcesContent":["import { defineStore } from 'pinia'\nimport { computed, ref, type ComputedRef, type Ref } from 'vue'\n\nimport type { CatalogItem } from '@zenky/storefront-api'\n\n// Explicit return type (not inferred): otherwise Pinia's inference structurally\n// expands the SDK types in the .d.ts and bloats it. This also satisfies the\n// \"explicit return types\" rule.\nexport interface CatalogStore {\n catalog: Ref<CatalogItem[]>\n currentHash: Ref<string | null>\n reloading: Ref<boolean>\n loadError: Ref<boolean>\n initCatalog: (items: CatalogItem[], hash?: string | null) => void\n setLoadError: () => void\n setReloading: (value: boolean) => void\n hasCatalog: ComputedRef<boolean>\n}\n\n// Setup store (doc 05): id prefixed with zenky-* to avoid colliding with the\n// consumer's own stores. A plain state container — API calls and cookies live in\n// the composables/bootstrap layer, which calls these actions.\nexport const useCatalogStore = defineStore('zenky-catalog', (): CatalogStore => {\n const catalog = ref<CatalogItem[]>([])\n const currentHash = ref<string | null>(null)\n const reloading = ref(false)\n const loadError = ref(false)\n\n function initCatalog(items: CatalogItem[], hash?: string | null): void {\n catalog.value = items\n currentHash.value = hash ?? null\n loadError.value = false\n }\n\n function setLoadError(): void {\n loadError.value = true\n }\n\n function setReloading(value: boolean): void {\n reloading.value = value\n }\n\n const hasCatalog = computed(() => catalog.value.length > 0)\n\n return {\n catalog,\n currentHash,\n reloading,\n loadError,\n initCatalog,\n setLoadError,\n setReloading,\n hasCatalog,\n }\n})\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { useCartCredentials, usePromotionsChecker } from './chunk-
|
|
2
|
-
import { useCartStore, useOrderSettingsStore, usePromotionsStore } from './chunk-
|
|
3
|
-
import { getRemoteCatalog } from './chunk-
|
|
4
|
-
import { minorToMajor, majorToMinor } from './chunk-
|
|
1
|
+
import { useCartCredentials, usePromotionsChecker } from './chunk-46FNHMWC.js';
|
|
2
|
+
import { useCartStore, useOrderSettingsStore, usePromotionsStore } from './chunk-XULHV6SS.js';
|
|
3
|
+
import { getRemoteCatalog } from './chunk-KFCO46RB.js';
|
|
4
|
+
import { minorToMajor, majorToMinor } from './chunk-2Y6QTHXI.js';
|
|
5
5
|
import { createRuntimeState } from './chunk-5QCUH3FF.js';
|
|
6
|
-
import { useCatalogStore } from './chunk-
|
|
7
|
-
import { useRuntime, useStoreProfileStore, useAuthStore } from './chunk-
|
|
6
|
+
import { useCatalogStore } from './chunk-6QCFHSLX.js';
|
|
7
|
+
import { useRuntime, useStoreProfileStore, useAuthStore } from './chunk-QZ3S3NN3.js';
|
|
8
8
|
import { PaymentMethod, OrderAuthenticationMethod, DeliveryMethod, OrderCartCheckerResultAction, RecaptchaAction } from '@zenky/storefront-api';
|
|
9
9
|
import { ref, computed, watch, watchEffect, getCurrentScope, onScopeDispose, toValue } from 'vue';
|
|
10
10
|
import { storeToRefs } from 'pinia';
|
|
@@ -441,7 +441,7 @@ var ORDER_INCLUDES = [
|
|
|
441
441
|
"variants.product.categories",
|
|
442
442
|
"variants.modifiers.modifier",
|
|
443
443
|
"variants.modifiers.modifiers_group",
|
|
444
|
-
//
|
|
444
|
+
// Line restrictions: is_blocking is used for cart messages and to block checkout.
|
|
445
445
|
"variants.restrictions"
|
|
446
446
|
].join(",");
|
|
447
447
|
var ORDER_WITH = { with: ORDER_INCLUDES };
|
|
@@ -1447,7 +1447,8 @@ function useCartOperations(credentials, initialization, sdk, deps) {
|
|
|
1447
1447
|
{
|
|
1448
1448
|
product_variant_id: variantId,
|
|
1449
1449
|
quantity: qty,
|
|
1450
|
-
modifiers: batch.modifiers
|
|
1450
|
+
modifiers: batch.modifiers,
|
|
1451
|
+
...batch.recommendationsBlock ? { recommendations_block: batch.recommendationsBlock } : {}
|
|
1451
1452
|
}
|
|
1452
1453
|
);
|
|
1453
1454
|
rum?.measure(RUM_METRIC_CART_ADD, RUM_MARK_CART_ADD);
|
|
@@ -1516,7 +1517,8 @@ function useCartOperations(credentials, initialization, sdk, deps) {
|
|
|
1516
1517
|
productVariantId: variantId,
|
|
1517
1518
|
quantity: qty,
|
|
1518
1519
|
unitPrice: orderVariant ? minorToMajor(orderVariant.unit_price, currency) : void 0,
|
|
1519
|
-
totalPrice: cartTotal != null ? minorToMajor(cartTotal, currency) : void 0
|
|
1520
|
+
totalPrice: cartTotal != null ? minorToMajor(cartTotal, currency) : void 0,
|
|
1521
|
+
recommendationsBlock: batch.recommendationsBlock
|
|
1520
1522
|
});
|
|
1521
1523
|
} else {
|
|
1522
1524
|
commerceEvents.trackRemovedFromCart(commerceOrderId, {
|
|
@@ -1590,6 +1592,7 @@ function useCartOperations(credentials, initialization, sdk, deps) {
|
|
|
1590
1592
|
if (existing) {
|
|
1591
1593
|
clearTimeout(existing.timer);
|
|
1592
1594
|
existing.delta += delta;
|
|
1595
|
+
existing.recommendationsBlock ??= request.recommendationsBlock;
|
|
1593
1596
|
existing.timer = setTimeout(() => flushBatch(lineKey), BATCH_DELAY);
|
|
1594
1597
|
return;
|
|
1595
1598
|
}
|
|
@@ -1605,6 +1608,7 @@ function useCartOperations(credentials, initialization, sdk, deps) {
|
|
|
1605
1608
|
promotionRewardId: request.promotionRewardId,
|
|
1606
1609
|
productName: request.productName,
|
|
1607
1610
|
variantLabel: request.variantLabel,
|
|
1611
|
+
recommendationsBlock: request.recommendationsBlock,
|
|
1608
1612
|
timer
|
|
1609
1613
|
});
|
|
1610
1614
|
}
|
|
@@ -2007,5 +2011,5 @@ function useVisibleCartVariants() {
|
|
|
2007
2011
|
}
|
|
2008
2012
|
|
|
2009
2013
|
export { CASH_DENOMINATIONS_MAJOR, DEFAULT_ROUND_STEPS_MAJOR, ORDER_EVENTS, ORDER_WITH, buildCartLineKey, buildCashChangePresets, buildMainPaymentRequest, getCartErrorCode, getCartErrorHttpCode, getCartErrorMessage, getCashDenominationsMinor, getDefaultRoundStepsMinor, getValidationErrors, logCartError, 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 };
|
|
2010
|
-
//# sourceMappingURL=chunk-
|
|
2011
|
-
//# sourceMappingURL=chunk-
|
|
2014
|
+
//# sourceMappingURL=chunk-AVES4WJZ.js.map
|
|
2015
|
+
//# sourceMappingURL=chunk-AVES4WJZ.js.map
|