@zenky/storefront-vue 0.9.47 → 0.10.3

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 (98) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/LICENSE.md +2 -2
  3. package/README.md +213 -6
  4. package/dist/cart/index.d.ts +588 -0
  5. package/dist/cart/index.js +12 -0
  6. package/dist/cart/index.js.map +1 -0
  7. package/dist/catalog/index.d.ts +73 -0
  8. package/dist/catalog/index.js +4 -0
  9. package/dist/catalog/index.js.map +1 -0
  10. package/dist/chunk-57IOMDAM.js +38 -0
  11. package/dist/chunk-57IOMDAM.js.map +1 -0
  12. package/dist/chunk-5QCUH3FF.js +15 -0
  13. package/dist/chunk-5QCUH3FF.js.map +1 -0
  14. package/dist/chunk-7FRMMCR5.js +93 -0
  15. package/dist/chunk-7FRMMCR5.js.map +1 -0
  16. package/dist/chunk-BWUKMWHL.js +45 -0
  17. package/dist/chunk-BWUKMWHL.js.map +1 -0
  18. package/dist/chunk-E3G7NGCH.js +45 -0
  19. package/dist/chunk-E3G7NGCH.js.map +1 -0
  20. package/dist/chunk-EMGQXBU3.js +3 -0
  21. package/dist/chunk-EMGQXBU3.js.map +1 -0
  22. package/dist/chunk-FFBZKQRV.js +393 -0
  23. package/dist/chunk-FFBZKQRV.js.map +1 -0
  24. package/dist/chunk-G2X4SBCO.js +2011 -0
  25. package/dist/chunk-G2X4SBCO.js.map +1 -0
  26. package/dist/chunk-GLTOJTZO.js +41 -0
  27. package/dist/chunk-GLTOJTZO.js.map +1 -0
  28. package/dist/chunk-GW2QNTAD.js +327 -0
  29. package/dist/chunk-GW2QNTAD.js.map +1 -0
  30. package/dist/chunk-JLFBAAFT.js +566 -0
  31. package/dist/chunk-JLFBAAFT.js.map +1 -0
  32. package/dist/chunk-MZ66ARDL.js +244 -0
  33. package/dist/chunk-MZ66ARDL.js.map +1 -0
  34. package/dist/chunk-N3NOTJUC.js +111 -0
  35. package/dist/chunk-N3NOTJUC.js.map +1 -0
  36. package/dist/chunk-RO25KNM5.js +36 -0
  37. package/dist/chunk-RO25KNM5.js.map +1 -0
  38. package/dist/chunk-RYYY7MVP.js +102 -0
  39. package/dist/chunk-RYYY7MVP.js.map +1 -0
  40. package/dist/chunk-TEG7EL4N.js +106 -0
  41. package/dist/chunk-TEG7EL4N.js.map +1 -0
  42. package/dist/chunk-V3VVDQIR.js +27 -0
  43. package/dist/chunk-V3VVDQIR.js.map +1 -0
  44. package/dist/chunk-XUGXLJZB.js +14 -0
  45. package/dist/chunk-XUGXLJZB.js.map +1 -0
  46. package/dist/chunk-Z3IW4ODZ.js +36 -0
  47. package/dist/chunk-Z3IW4ODZ.js.map +1 -0
  48. package/dist/index.d.ts +26 -0
  49. package/dist/index.js +21 -0
  50. package/dist/index.js.map +1 -0
  51. package/dist/layout/index.d.ts +54 -0
  52. package/dist/layout/index.js +106 -0
  53. package/dist/layout/index.js.map +1 -0
  54. package/dist/money/index.d.ts +26 -0
  55. package/dist/money/index.js +3 -0
  56. package/dist/money/index.js.map +1 -0
  57. package/dist/order/index.d.ts +34 -0
  58. package/dist/order/index.js +209 -0
  59. package/dist/order/index.js.map +1 -0
  60. package/dist/pagination/index.d.ts +87 -0
  61. package/dist/pagination/index.js +97 -0
  62. package/dist/pagination/index.js.map +1 -0
  63. package/dist/ports/index.d.ts +124 -0
  64. package/dist/ports/index.js +3 -0
  65. package/dist/ports/index.js.map +1 -0
  66. package/dist/products/index.d.ts +105 -0
  67. package/dist/products/index.js +7 -0
  68. package/dist/products/index.js.map +1 -0
  69. package/dist/promotions/index.d.ts +10 -0
  70. package/dist/promotions/index.js +7 -0
  71. package/dist/promotions/index.js.map +1 -0
  72. package/dist/schedule-Dd3zwHEb.d.ts +27 -0
  73. package/dist/seo/index.d.ts +91 -0
  74. package/dist/seo/index.js +289 -0
  75. package/dist/seo/index.js.map +1 -0
  76. package/dist/snippets/index.d.ts +17 -0
  77. package/dist/snippets/index.js +3 -0
  78. package/dist/snippets/index.js.map +1 -0
  79. package/dist/snippets-BC5bkSjm.d.ts +23 -0
  80. package/dist/stores/index.d.ts +196 -0
  81. package/dist/stores/index.js +8 -0
  82. package/dist/stores/index.js.map +1 -0
  83. package/dist/theme/index.d.ts +60 -0
  84. package/dist/theme/index.js +3 -0
  85. package/dist/theme/index.js.map +1 -0
  86. package/dist/utils/index.d.ts +66 -0
  87. package/dist/utils/index.js +4 -0
  88. package/dist/utils/index.js.map +1 -0
  89. package/dist/website-settings/index.d.ts +38 -0
  90. package/dist/website-settings/index.js +3 -0
  91. package/dist/website-settings/index.js.map +1 -0
  92. package/docs/consumer-setup.md +275 -0
  93. package/docs/ports.md +144 -0
  94. package/docs/releasing.md +46 -0
  95. package/package.json +143 -47
  96. package/dist/cjs/index.cjs +0 -3742
  97. package/dist/esm/index.mjs +0 -3642
  98. package/dist/zenky.d.ts +0 -10377
package/CHANGELOG.md ADDED
@@ -0,0 +1,46 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented in this file. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and releases follow
5
+ [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## Unreleased
8
+
9
+ ### Added
10
+
11
+ - Pull-request CI for formatting, linting, types, coverage, tests, package exports,
12
+ Node/runtime compatibility, bundle budgets, and secret scanning.
13
+ - Dependabot updates for npm dependencies and GitHub Actions.
14
+ - Public security, contribution, conduct, runtime-port, and release documentation.
15
+ - Coverage ratchet and regression tests for checkout state and credential-safe logging.
16
+ - Cart composables for evaluating product restrictions, confirming blocking
17
+ restrictions, and reading variants that remain visible after optimistic updates.
18
+
19
+ ### Changed
20
+
21
+ - GitHub Actions are pinned to immutable commits with minimum workflow permissions.
22
+ - QR-code encoding now uses Web Platform APIs and works without Node `Buffer` or browser
23
+ globals, improving Node SSR and edge-runtime compatibility.
24
+ - npm package metadata now includes its homepage, issue tracker, and supported engines.
25
+
26
+ ### Fixed
27
+
28
+ - Empty post-checkout orders no longer trigger a minimum-order-price violation.
29
+
30
+ ### Security
31
+
32
+ - Cart and checkout errors now pass through recursive redaction before being logged.
33
+ - Direct cart logging no longer emits complete order, credentials, request, or API error
34
+ objects.
35
+
36
+ ## 0.10.0 - 2026-07-21
37
+
38
+ ### Added
39
+
40
+ - GitHub release workflow for npm OIDC trusted publishing.
41
+
42
+ ### Changed
43
+
44
+ - Package renamed to `@zenky/storefront-vue`.
45
+ - Storefront runtime state and cart flows were isolated across Vue applications and SSR
46
+ requests.
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,222 @@
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
+ [![CI](https://github.com/zenky/storefront-vue/actions/workflows/ci.yml/badge.svg)](https://github.com/zenky/storefront-vue/actions/workflows/ci.yml)
6
+ [![npm](https://img.shields.io/npm/v/@zenky/storefront-vue.svg)](https://www.npmjs.com/package/@zenky/storefront-vue)
7
+
8
+ 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.
9
+
10
+ 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
11
 
3
12
  ## Installation
4
13
 
5
- ```shell
6
- npm i --save @zenky/storefront-vue
14
+ ```bash
15
+ npm install @zenky/storefront-vue
16
+ ```
17
+
18
+ Peer dependencies (the consumer already has these):
19
+
20
+ ```jsonc
21
+ {
22
+ "vue": "^3.5.0",
23
+ "pinia": "^3.0.0",
24
+ "@zenky/storefront-api": ">=0.0.68",
25
+ "@zenky/integrations-sdk": ">=0.1.3"
26
+ }
27
+ ```
28
+
29
+ ## Quick Start
30
+
31
+ Assemble the runtime once at your composition root and install it as a Vue plugin. After that, core composables just work.
32
+
33
+ ```ts
34
+ import { createStorefront } from '@zenky/storefront-vue'
35
+
36
+ app.use(
37
+ createStorefront({
38
+ sdk, // ZenkyStorefront instance (one per app)
39
+ config: { baseUrl, baseAuthUrl },
40
+ storage: { // where order id/token, settings, etc. persist
41
+ get: (key) => readCookie(key),
42
+ set: (key, value, opts) => writeCookie(key, value, opts),
43
+ remove: (key, opts) => deleteCookie(key, opts),
44
+ },
45
+ notifier: { // user-facing messages
46
+ error: (m) => toast.error(m),
47
+ success: (m) => toast.success(m),
48
+ warning: (m) => toast.warning(m),
49
+ message: (title, opts) => toast(title, opts),
50
+ },
51
+ activity: { // busy indicators for long operations
52
+ begin: (kind) => busy.begin(kind),
53
+ end: (kind) => busy.end(kind),
54
+ },
55
+ }),
56
+ )
57
+ ```
58
+
59
+ Then, anywhere in a component or composable:
60
+
61
+ ```ts
62
+ import { useStorefrontCart } from '@zenky/storefront-vue/cart'
63
+
64
+ const cart = useStorefrontCart()
65
+
66
+ await cart.initializeOrder()
67
+ await cart.addToCart({ productId, productVariantId, quantity: 1 })
68
+
69
+ cart.itemCount.value // reactive
70
+ cart.totalPrice.value
7
71
  ```
8
72
 
9
- ## Usage
73
+ ## Runtime Ports
74
+
75
+ `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.
76
+
77
+ | Port | Required | What the consumer provides |
78
+ | --- | --- | --- |
79
+ | `sdk` | yes | A `ZenkyStorefront` instance (`@zenky/storefront-api`). |
80
+ | `config` | yes | `{ baseUrl, baseAuthUrl, salesChannelId? }`. |
81
+ | `storage` | yes | Key/value persistence — cookies, `localStorage`, memory. |
82
+ | `notifier` | yes | Toasts: `error` / `success` / `warning` / `message`. |
83
+ | `activity` | yes | `begin(kind)` / `end(kind)` for busy state. |
84
+ | `events` | no | Lazy `{ get() }` provider for `ZenkyIntegrationsSDK`; resolve on every event. |
85
+ | `realtime` | no | Lazy `{ get() }` provider for the WebSocket adapter (`subscribe` / `unsubscribe` / `isReady`). |
86
+ | `catalogReloader` | no | Reloads the catalog when the stock changes. |
87
+ | `rum` | no | Performance marks (`mark` / `measure`). |
88
+ | `commerceEvents` | no | Commerce-event tracking (`trackAddedToCart`, `getIdentity`, …). |
89
+
90
+ Types for every port live in the `ports` subpath, alongside no-op defaults and an in-memory storage helper for SSR/tests:
91
+
92
+ ```ts
93
+ import {
94
+ type StorefrontRuntime,
95
+ type StorageAdapter,
96
+ NOOP_NOTIFIER,
97
+ NOOP_ACTIVITY_REPORTER,
98
+ createMemoryStorage,
99
+ } from '@zenky/storefront-vue/ports'
100
+ ```
101
+
102
+ The full public contract, adapter examples, SSR lifecycle, and security boundary are in
103
+ [Runtime Ports](docs/ports.md). For a step-by-step consumer integration and upgrade
104
+ checklist, see [Consumer Setup](docs/consumer-setup.md).
105
+
106
+ ## Subpath Imports
107
+
108
+ Each public domain is its own entry point, so bundlers only pull in what you import.
109
+
110
+ ```ts
111
+ import { minorToMajor } from '@zenky/storefront-vue/money'
112
+ import { buildCssVariableMap, THEME_PRESETS } from '@zenky/storefront-vue/theme'
113
+ import { getRemoteCatalog, findCategoryByShortId } from '@zenky/storefront-vue/catalog'
114
+ import { useStorefrontCart, useCheckoutSubmit } from '@zenky/storefront-vue/cart'
115
+ import { generateFreeTimeGroups } from '@zenky/storefront-vue/order'
116
+ import { buildProductSchema, buildOgTags } from '@zenky/storefront-vue/seo'
117
+ import { useHeaderData, useFooterData } from '@zenky/storefront-vue/layout'
118
+ import { usePaginatedList } from '@zenky/storefront-vue/pagination'
119
+ ```
120
+
121
+ Available subpaths: `ports`, `money`, `utils`, `theme`, `stores`, `products`, `catalog`, `cart`, `order`, `promotions`, `seo`, `layout`, `pagination`, `snippets`, `website-settings`.
122
+
123
+ ## Runtime Compatibility
124
+
125
+ - ESM-only, targeting ES2022.
126
+ - Vue 3.5+ and Pinia 3.
127
+ - Node.js 20.19+ for SSR and package tooling; Node.js 22 is recommended for production and development.
128
+ - Modern browsers and edge runtimes with standard Web Platform APIs.
129
+
130
+ CI imports every public entry in Node SSR and scans the emitted ESM for CommonJS, Node
131
+ built-ins, `Buffer`, and `process`. Browser-only behavior is guarded; for example,
132
+ online-payment retry accepts an explicit `currentUrl` when no `window` is available.
133
+
134
+ For SSR, create a new Vue app, Pinia instance, storefront runtime, and storage adapter per
135
+ request. Never share `createMemoryStorage()` between users.
136
+
137
+ ## Package Size
138
+
139
+ Every domain has a tree-shakeable subpath. CI measures the transitive gzip graph for the
140
+ root, cart, and utils entries plus all emitted JavaScript. The budgets are regression
141
+ ceilings, not size targets; increasing one requires review and a release-note explanation.
142
+
143
+ ```bash
144
+ npm run build
145
+ npm run check:size
146
+ ```
147
+
148
+ ## Pinia Stores
149
+
150
+ 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.
151
+
152
+ ```ts
153
+ import { useCartStore, useStoreProfileStore } from '@zenky/storefront-vue/stores'
154
+ ```
155
+
156
+ ## Money
157
+
158
+ Prices are stored and computed in minor units (kopecks) everywhere. Convert only at the API boundary.
159
+
160
+ ```ts
161
+ import { minorToMajor, minorToMajorString, majorToMinor } from '@zenky/storefront-vue/money'
162
+
163
+ minorToMajor(65000, 'RUB') // 650 — numbers for bill/amount fields
164
+ minorToMajorString(65000, 'RUB') // "650.00" — strings where the API expects them
165
+ majorToMinor(650, 'RUB') // 65000 — user input back into the store
166
+ ```
167
+
168
+ ## Development
169
+
170
+ ```bash
171
+ npm run dev # tsup --watch
172
+ npm run build # ESM + .d.ts to dist/
173
+ npm run lint # Biome lint
174
+ npm run format # Biome format --write
175
+ npm run typecheck # tsc --noEmit
176
+ npm test # vitest
177
+ npm run test:coverage # vitest + V8 coverage report
178
+ npm run check # format + lint + types + tests + build + exports
179
+ npm run check:exports # publint + are-the-types-wrong (esm-only profile)
180
+ npm run check:runtime # import all entries in SSR + reject Node-only output
181
+ npm run check:size # enforce gzip bundle budgets
182
+ ```
183
+
184
+ ### Local linking with yalc
185
+
186
+ Until the package is published, link it into a consumer app with [yalc](https://github.com/wclr/yalc):
187
+
188
+ ```bash
189
+ # in this package, after a build:
190
+ npx yalc publish
191
+
192
+ # in the consumer app:
193
+ npx yalc add @zenky/storefront-vue
194
+
195
+ # after each change here:
196
+ npm run build && npx yalc push
197
+ ```
198
+
199
+ ## Package Scripts
200
+
201
+ - `build` — bundle the multi-entry ESM package with tsup.
202
+ - `dev` — rebuild on change.
203
+ - `test` / `test:watch` — run the Vitest suite.
204
+ - `typecheck` — type-only compile.
205
+ - `check:exports` — validate the exports map and published types.
206
+ - `check:runtime` — verify Node SSR imports and browser/edge-safe ESM output.
207
+ - `check:size` — enforce root/domain/all-output gzip budgets.
208
+ - `check:ci` — quality gate with the V8 coverage ratchet.
209
+ - `prepublishOnly` — run the release quality gate.
210
+
211
+ ## Contributing and Releases
212
+
213
+ Read [CONTRIBUTING.md](CONTRIBUTING.md) before opening a pull request. User-visible changes
214
+ belong in [CHANGELOG.md](CHANGELOG.md); maintainer steps are documented in the
215
+ [release process](docs/releasing.md).
10
216
 
11
- Coming soon.
217
+ Security vulnerabilities must be reported privately according to
218
+ [SECURITY.md](SECURITY.md), never through a public issue.
12
219
 
13
220
  ## License
14
221
 
15
- This project is released under The MIT License (see LICENSE.md).
222
+ MIT