@zenky/storefront-vue 0.9.47 → 0.10.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.
Files changed (94) hide show
  1. package/LICENSE.md +2 -2
  2. package/README.md +163 -6
  3. package/dist/cart/index.d.ts +559 -0
  4. package/dist/cart/index.js +13 -0
  5. package/dist/cart/index.js.map +1 -0
  6. package/dist/catalog/index.d.ts +73 -0
  7. package/dist/catalog/index.js +4 -0
  8. package/dist/catalog/index.js.map +1 -0
  9. package/dist/chunk-2OD7CLKD.js +102 -0
  10. package/dist/chunk-2OD7CLKD.js.map +1 -0
  11. package/dist/chunk-4MJKN7PL.js +111 -0
  12. package/dist/chunk-4MJKN7PL.js.map +1 -0
  13. package/dist/chunk-5QCUH3FF.js +15 -0
  14. package/dist/chunk-5QCUH3FF.js.map +1 -0
  15. package/dist/chunk-AL5W5JSD.js +41 -0
  16. package/dist/chunk-AL5W5JSD.js.map +1 -0
  17. package/dist/chunk-BIGTKVC6.js +38 -0
  18. package/dist/chunk-BIGTKVC6.js.map +1 -0
  19. package/dist/chunk-BWUKMWHL.js +45 -0
  20. package/dist/chunk-BWUKMWHL.js.map +1 -0
  21. package/dist/chunk-DKWDKVXQ.js +91 -0
  22. package/dist/chunk-DKWDKVXQ.js.map +1 -0
  23. package/dist/chunk-EMGQXBU3.js +3 -0
  24. package/dist/chunk-EMGQXBU3.js.map +1 -0
  25. package/dist/chunk-EYRCAUUP.js +45 -0
  26. package/dist/chunk-EYRCAUUP.js.map +1 -0
  27. package/dist/chunk-GW2QNTAD.js +327 -0
  28. package/dist/chunk-GW2QNTAD.js.map +1 -0
  29. package/dist/chunk-IGDDWGS4.js +557 -0
  30. package/dist/chunk-IGDDWGS4.js.map +1 -0
  31. package/dist/chunk-OQLU7FSR.js +1841 -0
  32. package/dist/chunk-OQLU7FSR.js.map +1 -0
  33. package/dist/chunk-PJ2LEKW6.js +229 -0
  34. package/dist/chunk-PJ2LEKW6.js.map +1 -0
  35. package/dist/chunk-PWHIDGKW.js +97 -0
  36. package/dist/chunk-PWHIDGKW.js.map +1 -0
  37. package/dist/chunk-RO25KNM5.js +36 -0
  38. package/dist/chunk-RO25KNM5.js.map +1 -0
  39. package/dist/chunk-V3VVDQIR.js +27 -0
  40. package/dist/chunk-V3VVDQIR.js.map +1 -0
  41. package/dist/chunk-VL3T36VM.js +386 -0
  42. package/dist/chunk-VL3T36VM.js.map +1 -0
  43. package/dist/chunk-XUGXLJZB.js +14 -0
  44. package/dist/chunk-XUGXLJZB.js.map +1 -0
  45. package/dist/chunk-Z3IW4ODZ.js +36 -0
  46. package/dist/chunk-Z3IW4ODZ.js.map +1 -0
  47. package/dist/index.d.ts +26 -0
  48. package/dist/index.js +21 -0
  49. package/dist/index.js.map +1 -0
  50. package/dist/layout/index.d.ts +54 -0
  51. package/dist/layout/index.js +102 -0
  52. package/dist/layout/index.js.map +1 -0
  53. package/dist/money/index.d.ts +26 -0
  54. package/dist/money/index.js +3 -0
  55. package/dist/money/index.js.map +1 -0
  56. package/dist/order/index.d.ts +34 -0
  57. package/dist/order/index.js +209 -0
  58. package/dist/order/index.js.map +1 -0
  59. package/dist/pagination/index.d.ts +87 -0
  60. package/dist/pagination/index.js +97 -0
  61. package/dist/pagination/index.js.map +1 -0
  62. package/dist/ports/index.d.ts +124 -0
  63. package/dist/ports/index.js +3 -0
  64. package/dist/ports/index.js.map +1 -0
  65. package/dist/products/index.d.ts +105 -0
  66. package/dist/products/index.js +7 -0
  67. package/dist/products/index.js.map +1 -0
  68. package/dist/promotions/index.d.ts +10 -0
  69. package/dist/promotions/index.js +7 -0
  70. package/dist/promotions/index.js.map +1 -0
  71. package/dist/schedule-Dd3zwHEb.d.ts +27 -0
  72. package/dist/seo/index.d.ts +91 -0
  73. package/dist/seo/index.js +289 -0
  74. package/dist/seo/index.js.map +1 -0
  75. package/dist/snippets/index.d.ts +17 -0
  76. package/dist/snippets/index.js +3 -0
  77. package/dist/snippets/index.js.map +1 -0
  78. package/dist/snippets-BC5bkSjm.d.ts +23 -0
  79. package/dist/stores/index.d.ts +196 -0
  80. package/dist/stores/index.js +8 -0
  81. package/dist/stores/index.js.map +1 -0
  82. package/dist/theme/index.d.ts +60 -0
  83. package/dist/theme/index.js +3 -0
  84. package/dist/theme/index.js.map +1 -0
  85. package/dist/utils/index.d.ts +66 -0
  86. package/dist/utils/index.js +4 -0
  87. package/dist/utils/index.js.map +1 -0
  88. package/dist/website-settings/index.d.ts +38 -0
  89. package/dist/website-settings/index.js +3 -0
  90. package/dist/website-settings/index.js.map +1 -0
  91. package/package.json +121 -47
  92. package/dist/cjs/index.cjs +0 -3742
  93. package/dist/esm/index.mjs +0 -3642
  94. package/dist/zenky.d.ts +0 -10377
package/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
- The MIT License (MIT)
1
+ MIT License
2
2
 
3
- Copyright (c) 2022 Zenky
3
+ Copyright (c) 2026 Zenky
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,15 +1,172 @@
1
- # Zenky Storefront Package for Vue 3
1
+ # @zenky/storefront-vue
2
+
3
+ Headless storefront engine for Zenky — Vue 3 + Pinia, no framework lock-in.
4
+
5
+ One engine behind many storefronts. The cart, order building, checkout, catalog resolution, delivery slots, SEO/JSON-LD, theme, and store/profile state all live here as framework-agnostic composables and Pinia stores. The consumer — a Nuxt site, a QR-code menu, a new template — brings the framework glue (cookies, config, toasts, HTTP transport, `useHead`) and draws its own UI on top.
6
+
7
+ The design is Ports & Adapters: the core declares small ports for everything it needs from the outside world, the consumer provides adapters once, and every composable reads them through `useRuntime()`. The core never imports `useCookie`, `useRoute`, `useHead`, `$fetch`, or anything Nuxt-specific.
2
8
 
3
9
  ## Installation
4
10
 
5
- ```shell
6
- npm i --save @zenky/storefront-vue
11
+ ```bash
12
+ npm install @zenky/storefront-vue
13
+ ```
14
+
15
+ Peer dependencies (the consumer already has these):
16
+
17
+ ```jsonc
18
+ {
19
+ "vue": "^3.5.0",
20
+ "pinia": "^3.0.0",
21
+ "@zenky/storefront-api": ">=0.0.64",
22
+ "@zenky/integrations-sdk": ">=0.1.3"
23
+ }
24
+ ```
25
+
26
+ ## Quick Start
27
+
28
+ Assemble the runtime once at your composition root and install it as a Vue plugin. After that, core composables just work.
29
+
30
+ ```ts
31
+ import { createStorefront } from '@zenky/storefront-vue'
32
+
33
+ app.use(
34
+ createStorefront({
35
+ sdk, // ZenkyStorefront instance (one per app)
36
+ config: { baseUrl, baseAuthUrl },
37
+ storage: { // where order id/token, settings, etc. persist
38
+ get: (key) => readCookie(key),
39
+ set: (key, value, opts) => writeCookie(key, value, opts),
40
+ remove: (key, opts) => deleteCookie(key, opts),
41
+ },
42
+ notifier: { // user-facing messages
43
+ error: (m) => toast.error(m),
44
+ success: (m) => toast.success(m),
45
+ warning: (m) => toast.warning(m),
46
+ message: (title, opts) => toast(title, opts),
47
+ },
48
+ activity: { // busy indicators for long operations
49
+ begin: (kind) => busy.begin(kind),
50
+ end: (kind) => busy.end(kind),
51
+ },
52
+ }),
53
+ )
54
+ ```
55
+
56
+ Then, anywhere in a component or composable:
57
+
58
+ ```ts
59
+ import { useStorefrontCart } from '@zenky/storefront-vue/cart'
60
+
61
+ const cart = useStorefrontCart()
62
+
63
+ await cart.initializeOrder()
64
+ await cart.addToCart({ productId, productVariantId, quantity: 1 })
65
+
66
+ cart.itemCount.value // reactive
67
+ cart.totalPrice.value
68
+ ```
69
+
70
+ ## Runtime Ports
71
+
72
+ `createStorefront(runtime)` takes one object. Five ports are required; the rest are optional — omit an optional port and the feature that needs it is simply skipped.
73
+
74
+ | Port | Required | What the consumer provides |
75
+ | --- | --- | --- |
76
+ | `sdk` | yes | A `ZenkyStorefront` instance (`@zenky/storefront-api`). |
77
+ | `config` | yes | `{ baseUrl, baseAuthUrl, salesChannelId? }`. |
78
+ | `storage` | yes | Key/value persistence — cookies, `localStorage`, memory. |
79
+ | `notifier` | yes | Toasts: `error` / `success` / `warning` / `message`. |
80
+ | `activity` | yes | `begin(kind)` / `end(kind)` for busy state. |
81
+ | `events` | no | Lazy `{ get() }` provider for `ZenkyIntegrationsSDK`; resolve on every event. |
82
+ | `realtime` | no | Lazy `{ get() }` provider for the WebSocket adapter (`subscribe` / `unsubscribe` / `isReady`). |
83
+ | `catalogReloader` | no | Reloads the catalog when the stock changes. |
84
+ | `rum` | no | Performance marks (`mark` / `measure`). |
85
+ | `commerceEvents` | no | Commerce-event tracking (`trackAddedToCart`, `getIdentity`, …). |
86
+
87
+ Types for every port live in the `ports` subpath, alongside no-op defaults and an in-memory storage helper for SSR/tests:
88
+
89
+ ```ts
90
+ import {
91
+ type StorefrontRuntime,
92
+ type StorageAdapter,
93
+ NOOP_NOTIFIER,
94
+ NOOP_ACTIVITY_REPORTER,
95
+ createMemoryStorage,
96
+ } from '@zenky/storefront-vue/ports'
97
+ ```
98
+
99
+ ## Subpath Imports
100
+
101
+ Each public domain is its own entry point, so bundlers only pull in what you import.
102
+
103
+ ```ts
104
+ import { minorToMajor } from '@zenky/storefront-vue/money'
105
+ import { buildCssVariableMap, THEME_PRESETS } from '@zenky/storefront-vue/theme'
106
+ import { getRemoteCatalog, findCategoryByShortId } from '@zenky/storefront-vue/catalog'
107
+ import { useStorefrontCart, useCheckoutSubmit } from '@zenky/storefront-vue/cart'
108
+ import { generateFreeTimeGroups } from '@zenky/storefront-vue/order'
109
+ import { buildProductSchema, buildOgTags } from '@zenky/storefront-vue/seo'
110
+ import { useHeaderData, useFooterData } from '@zenky/storefront-vue/layout'
111
+ import { usePaginatedList } from '@zenky/storefront-vue/pagination'
112
+ ```
113
+
114
+ Available subpaths: `ports`, `money`, `utils`, `theme`, `stores`, `products`, `catalog`, `cart`, `order`, `promotions`, `seo`, `layout`, `pagination`, `snippets`, `website-settings`.
115
+
116
+ ## Pinia Stores
117
+
118
+ The `stores` subpath exposes setup-style Pinia stores (ids namespaced `zenky-*`): cart, order settings, store profile, catalog, products, auth, promotions. They are plain state containers — no API calls, no UI logic — and they are the reactive backbone the composables read from. Install Pinia before mounting the storefront plugin.
119
+
120
+ ```ts
121
+ import { useCartStore, useStoreProfileStore } from '@zenky/storefront-vue/stores'
122
+ ```
123
+
124
+ ## Money
125
+
126
+ Prices are stored and computed in minor units (kopecks) everywhere. Convert only at the API boundary.
127
+
128
+ ```ts
129
+ import { minorToMajor, minorToMajorString, majorToMinor } from '@zenky/storefront-vue/money'
130
+
131
+ minorToMajor(65000, 'RUB') // 650 — numbers for bill/amount fields
132
+ minorToMajorString(65000, 'RUB') // "650.00" — strings where the API expects them
133
+ majorToMinor(650, 'RUB') // 65000 — user input back into the store
134
+ ```
135
+
136
+ ## Development
137
+
138
+ ```bash
139
+ npm run dev # tsup --watch
140
+ npm run build # ESM + .d.ts to dist/
141
+ npm run typecheck # tsc --noEmit
142
+ npm test # vitest
143
+ npm run check:exports # publint + are-the-types-wrong (esm-only profile)
144
+ ```
145
+
146
+ ### Local linking with yalc
147
+
148
+ Until the package is published, link it into a consumer app with [yalc](https://github.com/wclr/yalc):
149
+
150
+ ```bash
151
+ # in this package, after a build:
152
+ npx yalc publish
153
+
154
+ # in the consumer app:
155
+ npx yalc add @zenky/storefront-vue
156
+
157
+ # after each change here:
158
+ npm run build && npx yalc push
7
159
  ```
8
160
 
9
- ## Usage
161
+ ## Package Scripts
10
162
 
11
- Coming soon.
163
+ - `build` — bundle the multi-entry ESM package with tsup.
164
+ - `dev` — rebuild on change.
165
+ - `test` / `test:watch` — run the Vitest suite.
166
+ - `typecheck` — type-only compile.
167
+ - `check:exports` — validate the exports map and published types.
168
+ - `prepublishOnly` — typecheck → test → build → check:exports.
12
169
 
13
170
  ## License
14
171
 
15
- This project is released under The MIT License (see LICENSE.md).
172
+ MIT