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

@codefusion-cc/commerce-marketplaces

v0.2.1

Published

Marketplaces for a CodeFusion shop, run from its catalog: what a marketplace's client is given at the root, and one entry per marketplace (./allegro: the account connected by the device flow, rotating tokens saved at once, offers, price and stock, the ord

Readme

@codefusion-cc/commerce-marketplaces

The marketplaces a CodeFusion shop sells on, run from its catalog. The catalog is the source of truth: prices and stock go out from it, and orders come into the panel. Allegro comes first. Empik (Mirakl) and InPost Von Halsky follow (ROADMAP).

npm install @codefusion-cc/commerce-marketplaces

Entry points

A shop imports only the marketplaces it sells on, so its Worker bundles no other marketplace's code (the rule for every commerce kind: ROADMAP.md, Commerce).

| Entry | Holds | | --- | --- | | @codefusion-cc/commerce-marketplaces | What every marketplace's client is given (MarketplaceContext). No marketplace. | | …/allegro | Allegro's client and everything of ./allegro/browser. | | …/allegro/browser | Allegro's definition (allegroDef), allegroEnvironment and an order's fulfillment states (FULFILLMENT), without the client. | | …/testing | A fake of Allegro. |

There is no ./browser yet: no marketplace shares anything with the pages.

Allegro

import { allOffers, getOffer, orderEvents, setOfferPrice, setOfferStock, startDeviceAuthorization, pollDeviceAuthorization } from '@codefusion-cc/commerce-marketplaces/allegro'

// The Allegro plugin's context (@codefusion-cc/commerce) as it is: config (mode: sandbox | production, client_id),
// secrets (client_secret, and the account's tokens once connected), fetch and saveSecrets.
const ctx = await store.enabledContext(env, site, 'allegro')

// Connect the seller's account from the panel: show the link, poll until the owner confirms on Allegro.
const { verification_uri_complete, device_code, interval } = await startDeviceAuthorization(ctx)
await pollDeviceAuthorization(ctx, device_code) // 'pending' | 'slower' | 'connected' | 'denied' | 'expired'

for await (const offer of allOffers(ctx)) {} // import: page by page, 1000 at a time
const details = await getOffer(ctx, id) // images, description as HTML, parameters, EAN, handling time
await setOfferPrice(ctx, id, 4050) // grosze, from the channel's price list
await setOfferStock(ctx, id, 2) // after a sale anywhere
const events = await orderEvents(ctx, lastEventId) // new orders since the last check

// The panel's page: the definition, without the client.
import { allegroDef } from '@codefusion-cc/commerce-marketplaces/allegro/browser'
  • Tokens. Allegro's refresh tokens rotate on every refresh, and the old one stops working within a minute. So the new one is saved at once, through saveSecrets (the store's updateSecrets, sealed). If that fails, the account has to be connected again. Requests at the same moment share one refresh, even with contexts of their own.
  • Errors. Errors are a ProviderError (@codefusion-cc/commerce). An access token that Allegro calls expired (401) is refreshed once. A rate limit carries retryAfter. No answer, or a 5xx, is uncertain: check the offer before changing it again.
  • The device flow needs no return address on the shop. The confirmation link must be on Allegro's own domain.

A new marketplace

A marketplace is an entry of this package: src/<marketplace>/index.ts (its client, taking a MarketplaceContext) and src/<marketplace>/browser.ts (its definition), both listed in exports; what two marketplaces share moves into the root. It becomes a package of its own (@codefusion-cc/commerce-marketplaces-<marketplace>) only when it needs a heavy dependency, is maintained by someone else, or needs its own release pace.

Testing

fakeAllegroApi({ offers }) from @codefusion-cc/commerce-marketplaces/testing plays Allegro: client allegro-id / allegro-secret. The kind's fakes stay in this one entry (tests never reach a Worker's bundle).

  • Refresh tokens rotate.
  • confirm() makes the owner confirm the device flow.
  • buy(offerId, qty) makes a buyer buy: an order, its event, and less stock (a sold-out offer ends).
  • state.rateLimited answers 429.