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

@oak-digital/medusa-plugin-builder

v0.0.5

Published

**NOTE: Only for medusa v2/preview**

Downloads

105

Readme

Medusa "plugin" builder

NOTE: Only for medusa v2/preview

This repository consists of helpers and modules to synchronize products from medusa to builder.io. Since medusa v2 does not support plugins yet, you will have to use the helpers.

Installation

Install this package in your medusa project

npm install @oak-digital/medusa-plugin-builder zod
# or
yarn add @oak-digital/medusa-plugin-builder zod
# or
pnpm install @oak-digital/medusa-plugin-builder zod

Usage

Configure module

In medusa-config.js add the module

// medusa-config.js

module.exports = defineConfig({
  modules: {
    // Your other modules ...
    builderModuleService: {
      resolve: '@oak-digital/medusa-plugin-builder/dist/modules/builder/index.js',
      /** @type {import('@oak-digital/medusa-plugin-builder').BuilderModuleOptions} */
      options: {
        apiKey: process.env.BUILDER_API_KEY,
        models: {
          // ...
        },
      },
    },
  },
});

Models option

For each model that you want synchronized, you should add the model for it in the models option. The purpose of this option is to get validate api responses and for you to transform a medusa product into the shape of your builder product.

product: {
    modelName: 'product', // The model name in builder
    fields: z.object({
        // these are the fields that your builder product has
        medusaId: z.string().nullish(),
        name: z.string().nullish(),
        productDescription: z.string().nullish(),
    }),
    // This function should transform a medusa product to a builder product
    transform: (product) => ({
        medusaId: product.id,
        name: product.title,
        productDescription: product.description,
    }),
}

NOTE: The validation uses zod, so be sure to import z from zod at the top of the file

Setting up subscribers

It is not enough to just configure the module as the module cannot create subscribers. Thus you must create each subscriber in your project.

// src/subscribers/product-to-builder.ts
export { default, config } from '@oak-digital/medusa-plugin-builder/dist/subscribers/product/index';

Custom subscribers

If you do not want to use the provided subscribers, you can trigger the workflows yourself

TODO:

Admin widgets

You should also set up each admin widget

TODO: