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

@ritani/shopify-ring-builder

v1.5.3

Published

Library for building complete rings from shopify diamonds and settings

Downloads

5

Readme

About

This package was built for use in the Ritani Shopify store. It takes 3 from the Shopify GraphQL API: a diamondId, settingId, and a settingVariant. It then fetches those products, processes and combines their data into a new complete ring product.

The goal of this package is to ensure consistency in the ring building process accross all applications. Currently, this package is used in customer ring building, PLA ring building for Google shopping feeds, and the Ring Recommender.

Built With

This section should list any major frameworks that you built your project using. Leave any add-ons/plugins for the acknowledgements section. Here are a few examples.

Getting Started

To get a local copy up and running follow these simple example steps.

Prerequisites

Install node 12.x (Erbium)

Local Installation

  1. Clone the repo
git clone https://github.com/NEWECX/shopify-ring-builder.git
  1. Install packages
yarn install
  1. Create .env and add credentials
SHOPIFY_STORE_URL=*your store url*
SHOPIFY_ACCESS_TOKEN=*your shopify api password*

Project Installation

To add the package to another project, run:

yarn add @ritani/shopify-ring-builder

This will also install the dotenv package. Then create a .env file and add the following:

SHOPIFY_STORE_URL=*your store url*
SHOPIFY_ACCESS_TOKEN=*your shopify api password*

Usage

There are 2 exposed functions and exposed type definition in this package:

const { buildRingById, buildRingByJSON, TYPES } = require("@ritani/shopify-ring-builder")

Constant TYPES

This is a set of product type definitions for Shopify. These definitions ensure consistency of product types in any new applications using this package.

export const CUSTOMER_COMPLETE_RING = "Customer Complete Rings";
export const PLA_EARTH_COMPLETE_RINGS = "PLA Earth Complete Rings";
export const PLA_LAB_COMPLETE_RINGS = "PLA Lab Complete Rings";
export const RING_RECOMMENDER_COMPLETE_RINGS = "Ring Recommender Complete Rings";
export const TEST_COMPLETE_RING = "TEST Complete Ring";

To access:

const { TYPES } = require("@ritani/shopify-ring-builder")
const productType = TYPES.CUSTOMER_COMPLETE_RING

Function buildRingById

This function will get the diamond and setting in the complete ring and generate the complete ring product end to end. The easiet way to build a complete ring.

It accepts an object as an argument:

buildRingById {
    diamondId!: string;
    settingId!: string;
    settingVariant?: string OR array of string variant options;
    productType!: TYPE;
    additionalInputFields?: object;
    additionalMedia?: array,
}
  • diamondId - Required type of string. In the Shopify GraphQL ID format.
  • settingId - Required type of string. In the Shopify GraphQL ID format.
  • settingVariant - Optional type of string OR array of string
    • STRING - In the Shopify GraphQL ID format
    • ARRAY OF STRINGS - Up to 3 variant option string: EX) ["18kt White Gold", "Cushion"]
    • If ommited, defaults to first setting variant
  • productType - Required one of TYPE definitions found in the TYPES section
  • additionalInputFields - Optional object with shape of productCreate in API docs
    • When populated, this will be merged from the complete ring generator functions that combine the selected diamond and setting
  • addtionalMedia - Optional array of objects with shape of CreateMediaInput
    • When populated, this will be merged with the media array created by the complete ring generator functions

Function buildRingByJSON

If you don't need to fetch the diamond and the setting, then use buildRingByJSON.

buildRingByJSON {
    diamond!: object;
    setting!: object;
    settingVariant?: string OR array of string variant options;
    productType!: TYPE;
    additionalInputFields?: object;
    additionalMedia?: array,
}
  • diamond - Required type of object with shape get GraphQL query under the diamond namespace
  • setting - Required type of object with shape get GraphQL query under the setting namespace
  • settingVariant - Optional type of string OR array of string
    • STRING - In the Shopify GraphQL ID format
    • ARRAY OF STRINGS - Up to 3 variant option string: EX) ["18kt White Gold", "Cushion"]
    • If ommited, defaults to first setting variant* productType - Required one of TYPE definitions found in the TYPES section
  • additionalInputFields - Optional object with shape of productCreate in API docs
    • When populated, this will be merged from the complete ring generator functions that combine the selected diamond and setting
  • addtionalMedia - Optional array of objects with shape of CreateMediaInput
    • When populated, this will be merged with the media array created by the complete ring generator functions

This function has additional validators that ensure that the input diamond and setting are in the correct shape before the ring is created.