@altazion/commerce-sdk-core 26.512.7969 → 26.601.8195
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/README.md +56 -0
- package/dist/index.cjs +854 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +122 -1
- package/dist/index.iife.js +854 -4
- package/dist/index.iife.js.map +1 -1
- package/dist/index.js +855 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -83,6 +83,62 @@ try {
|
|
|
83
83
|
}
|
|
84
84
|
```
|
|
85
85
|
|
|
86
|
+
## Résumé panier local
|
|
87
|
+
|
|
88
|
+
Le module `cart` maintient désormais un résumé local dérivé du panier complet.
|
|
89
|
+
|
|
90
|
+
- `client.cart.peekSummary()` retourne le dernier snapshot en mémoire sans I/O ;
|
|
91
|
+
- `client.cart.getSummary()` retourne le snapshot mémoire ou persistant, puis lance un lazy reload si le résumé est périmé ;
|
|
92
|
+
- `client.cart.refreshSummary()` force une relecture du panier et régénère le résumé.
|
|
93
|
+
|
|
94
|
+
Le résumé expose notamment :
|
|
95
|
+
|
|
96
|
+
- le total TTC global ;
|
|
97
|
+
- la quantité totale ;
|
|
98
|
+
- le nombre de références principales ;
|
|
99
|
+
- un détail par `contentType` avec total TTC, nombre de références principales, nombre de lignes principales et quantité principale.
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
const summary = await client.cart.getSummary()
|
|
103
|
+
|
|
104
|
+
console.log(summary?.totalAmountWithTax)
|
|
105
|
+
console.log(summary?.contents)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Bridge host borne
|
|
109
|
+
|
|
110
|
+
Le package core expose aussi un bridge léger vers le host WebView des bornes pour piloter les périphériques remontés par le shell embarqué.
|
|
111
|
+
|
|
112
|
+
```ts
|
|
113
|
+
import { CommerceClient, PeripheralTpe } from '@altazion/commerce-sdk-core'
|
|
114
|
+
|
|
115
|
+
const client = new CommerceClient({
|
|
116
|
+
baseUrl: 'https://votre-api.altazion.com',
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
client.devices.initialize()
|
|
120
|
+
|
|
121
|
+
const tpe = client.devices.findPeripheralByType('TPE')[0] as PeripheralTpe | undefined
|
|
122
|
+
|
|
123
|
+
tpe?.on((notification) => {
|
|
124
|
+
console.log(notification.kind, notification.getNormalizedPayload())
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
tpe?.onSuccess((type, orderGuid, notification) => {
|
|
128
|
+
console.log(type, orderGuid, notification.getNormalizedPayload())
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
tpe?.makePayment('order-guid', 'CMD123', 'mrg-guid', 42.5, 'EUR')
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Capacités couvertes dans cette première reprise :
|
|
135
|
+
|
|
136
|
+
- découverte des périphériques remontés par le host via `DeviceManager.Init` ;
|
|
137
|
+
- dispatch des notifications `TPE:*`, `BARCODE:*` et des mises à jour d'état ;
|
|
138
|
+
- normalisation des payloads host via `notification.getNormalizedPayload()` pour absorber les variantes anciennes ;
|
|
139
|
+
- commandes shell `shell.state-change` et `app.status-update` ;
|
|
140
|
+
- mode mock pour les templates et les développements hors borne.
|
|
141
|
+
|
|
86
142
|
## Licence
|
|
87
143
|
|
|
88
144
|
Propriétaire — © Altazion SAS. Tous droits réservés.
|