npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@altazion/commerce-sdk-core

v26.611.8299

Published

Altazion Commerce SDK — Core client (fetch natif, cache SharedWorker, offline queue)

Downloads

2,642

Readme

@altazion/commerce-sdk-core

Client HTTP universel pour l'API Altazion Commerce. Fonctionne dans tous les environnements JavaScript (navigateur, Node.js, SSR) sans dépendances tierces — uniquement fetch natif.

Installation

npm install @altazion/commerce-sdk-core

Utilisation rapide

import { CommerceClient } from '@altazion/commerce-sdk-core'

const client = new CommerceClient({
  baseUrl: 'https://votre-api.altazion.com',
  siteUrl: 'https://votre-site.com',
})

// Récupérer la session courante
const session = await client.session.getSession()

// Récupérer le panier
const cart = await client.cart.getCart()

// Rechercher des produits
const results = await client.catalog.search({ q: 'chaussures', offset: 0, length: 20 })

Modules disponibles

| Module | Description | |---|---| | client.session | Session utilisateur / kiosque | | client.cart | Panier (ajout, modification, suppression, coupons) | | client.catalog | Produits, catégories, recherche, suggestions | | client.shipping | Modes de livraison, points relais | | client.stores | Magasins physiques et horaires | | client.marketing | Contenus marketing personnalisés |

Fonctionnalités

  • Cache SharedWorker + IndexedDB — mise en cache des réponses, stratègies configurables (cache-first, network-first, network-only)
  • ConnectivityManager — détection de connectivité en temps réel avec API d'abonnement
  • Dual session — bascule automatiquement en mode kiosque si le user-agent est Altazion Device Shell
  • TypeScript — types complets générés depuis la spécification OpenAPI

Options de configuration

const client = new CommerceClient({
  baseUrl: 'https://votre-api.altazion.com', // obligatoire
  siteUrl: 'https://votre-site.com',          // URL canonique du site
  defaultCacheStrategy: 'cache-first',        // stratégie de cache par défaut
})

Mode CDN (sans bundler)

<script src="https://cdn.jsdelivr.net/npm/@altazion/commerce-sdk-core/dist/index.iife.js"></script>
<script>
  const client = new AltazionCommerceCore.CommerceClient({
    baseUrl: 'https://votre-api.altazion.com'
  })
</script>

Gestion des erreurs

import { AltazionApiError, OfflineError } from '@altazion/commerce-sdk-core'

try {
  await client.cart.addItem('REF-001', 1)
} catch (err) {
  if (err instanceof OfflineError) {
    // Le terminal est hors ligne : les mutations sont refusées immédiatement
  } else if (err instanceof AltazionApiError) {
    console.error(err.status, err.problem)
  }
}

Résumé panier local

Le module cart maintient désormais un résumé local dérivé du panier complet.

  • client.cart.peekSummary() retourne le dernier snapshot en mémoire sans I/O ;
  • client.cart.getSummary() retourne le snapshot mémoire ou persistant, puis lance un lazy reload si le résumé est périmé ;
  • client.cart.refreshSummary() force une relecture du panier et régénère le résumé.

Le résumé expose notamment :

  • le total TTC global ;
  • la quantité totale ;
  • le nombre de références principales ;
  • un détail par contentType avec total TTC, nombre de références principales, nombre de lignes principales et quantité principale.
const summary = await client.cart.getSummary()

console.log(summary?.totalAmountWithTax)
console.log(summary?.contents)

Bridge host borne

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é.

import { CommerceClient, PeripheralTpe } from '@altazion/commerce-sdk-core'

const client = new CommerceClient({
  baseUrl: 'https://votre-api.altazion.com',
})

client.devices.initialize()

const tpe = client.devices.findPeripheralByType('TPE')[0] as PeripheralTpe | undefined

tpe?.on((notification) => {
  console.log(notification.kind, notification.getNormalizedPayload())
})

tpe?.onSuccess((type, orderGuid, notification) => {
  console.log(type, orderGuid, notification.getNormalizedPayload())
})

tpe?.makePayment('order-guid', 'CMD123', 'mrg-guid', 42.5, 'EUR')

Capacités couvertes dans cette première reprise :

  • découverte des périphériques remontés par le host via DeviceManager.Init ;
  • dispatch des notifications TPE:*, BARCODE:* et des mises à jour d'état ;
  • normalisation des payloads host via notification.getNormalizedPayload() pour absorber les variantes anciennes ;
  • commandes shell shell.state-change et app.status-update ;
  • mode mock pour les templates et les développements hors borne.

Licence

Propriétaire — © Altazion SAS. Tous droits réservés.