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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@rsc-labs/medusa-price-history

v0.0.3

Published

The plugins which provides price history for variants. E.g. useful for Omnibus directive in EU

Downloads

185

Readme

Medusa Price History

What is it?

Medusa Price History provides functionality which stores older prices for variants. It can be used to fulfill Omnibus Directive in EU or other scenarios.

Installation

TODO

Database migration

Medusa Price History introduces new models in database. To have it working, you need to firstly execute migrations:

npx medusa db:migrate

Overview

The plugin drops calculated price at defined schedule for every variant. Then you are able to fetch such data through new Store API.

NOTE: While the calculated price can be different for every customer (the price might have many different rules), this plugin only calculates a price for a common use case. The only context which it gets is the region. It does not check customer groups, sales etc.

Configuration

Update schedule

Plugin uses scheduled job to update the prices. By default it uses 0 0 * * * cron expression which means every day at midnight. It means, that every day the price is dropped into database with the current date, so you have a history of price split per day.

You can update such schedule using environment variable MEDUSA_PRICE_HISTORY_UPDATE_SCHEDULE, for instance: export MEDUSA_PRICE_HISTORY_UPDATE_SCHEDULE="* * * * *" will update price history every minute.

Delete schedule

Plugin uses scheduled job to clean up the old entries in price histories. It uses two configuration variables:

  • age in days - this can be setup through options under module in medusa-config. It means how old in days price history shall be to be deleted in the next execution. By default plugin uses 30 days, so every price history older than 30 days will be deleted.
{
  resolve: "@rsc-labs/medusa-price-history"
  options:
    ageInDays: 30
}
  • schedule - you can configure also a schedule execution. By default plugin uses 0 0 * * * cron expression which means every day at midnight. It means, that every day job is executed to check if you have price history older than age in days. If yes, then it will delete it.

You can update such schedule using environment variable MEDUSA_PRICE_HISTORY_DELETE_SCHEDULE, for instance: export MEDUSA_PRICE_HISTORY_DELETE_SCHEDULE="* * * * *" will check price history for deletion every minute (for instance it does not make sense to make every minute, because it looks for older entries in days).

API

After storing price histories in database, you can fetch them for variants. Plugin exposes one new API - store/products/[id]/price-history. After calling this API you will get list of variants with their price histories. Details are here: Store API