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

@quable/quable-pim-js

v2.0.2

Published

A Quable PIM API JavaScript library designed to facilitate the interaction with Quable PIM. It enables data retrieval and simplifies the process of creating and managing products for data integration.

Downloads

14

Readme

QUABLE PIM JS

@quable/quable-pim-js

License: MIT

This library offers a convenient method for interacting with the Quable PIM API. It offers a high-level abstraction of the API, simplifying tasks such as creating, reading, updating, and deleting documents, classifications, and other data.

Benefits

  • Easy to use: The client provides a high-level abstraction over the Quable PIM API, simplifying common tasks.

  • Well documented: The client is well-documented, featuring examples and comprehensive documentation for all its features.

  • Complete: The client supports all the major endpoint of the Quable PIM API, including documents, variants, links, assets, classifications, and webhooks.

  • Up-to-date: The client is regularly updated to support the latest features and changes to the Quable PIM API.

  • The PIM Data Aggregator: This module enhances data extraction capabilities by offering advanced methods to extract, format, and aggregate documents on multi-level joins.

Getting started

Requirements

  1. You must download and install Node.js if you don't already have it.

  2. You must have a Quable PIM instance for testing if you don't have one.

Installing

The library can be installed through NPM or Yarn:

yarn  add  @quable/quable-pim-js

or

npm  install  @quable/quable-pim-js

Usage

You must get your <instance-name> from your Quable PIM access URL: https://<instance-name>.quable.com.

For the API Key, you can retrieve it from your PIM in Administration -> API Token.

1 - Initialize the client

Once your client is initialized, you can access either the PimAPI or PDA (Pim Data Aggregator).

import { QuablePimClient } from '@quable/quable-pim-js';

const client = new QuablePimClient({
  instanceName: '<instance-name>',
  apiKey: '<api-key>',
});

2 - PIM API Methods

Get all your document

The provided code snippet demonstrates how to retrieve multiple documents with various filters. This allows you to obtain a collection of documents that meet specific criteria :

const documents = await client.PimApi.Document.getAll({
  limit: 10,
  id: ['10668000', 'PEBYF09B', '10551000-01'],
  active: true,
  dateModified: {
    before: '2023-10-16',
    strictly_after: '2023-12-01',
  },
});

Create new document

The provided code demonstrates the creation of a new document of type product, the document is created with the specified attributes under the classification default_collection.

const createdDocument = await client.PimApi.Document.create({
  classification: {
    id: 'default_collection',
  },
  documentType: {
    id: 'product',
  },
  attributes: {
    product_name: {
      en_US: 'T-shirt',
    },
  },
  id: 'product-t-shirt',
});

Get an asset by its code

The provided code snippet demonstrates how to retrieve an asset by its unique code.

const asset = await client.PimApi.Asset.get('d5caa515-dbdd-4a3b-bc0e-front');

Update an asset

The provided code snippet demonstrates how to update an asset, In this example, the asset is updated by changing its asset_title attribute to Red T-shirt for english locale.

const updatedAsset = await client.PimApi.Asset.update(
  'd5caa515-dbdd-4a3b-bc0e-front',
  {
    attributes: {
      asset_title: {
        en_US: 'Red T-shirt',
      },
    },
  }
);

3 - PDA Methods

Query data aggregation :

The provided code snippet performs a data aggregation query, focusing on specified documents identified by their unique IDs in the documentIds array. This query collects data related to these specific documents and their associated attributes, assets, and other linked data:

const payload = {
  documentType: 'product',
  documentAssetLink: ['article_images_media'],
  secondLevelLink: 'link_type_link_product',
  secondLevelAssetLink: ['article_images_media'],
  thirdLevelLink: '__variants__',
  thirdLevelAssetLink: ['sku_images_media'],
  localeCode: 'fr_FR',
  filters: { documentIds: ['CODE_8397340377410'] },
};

const data = await client.PimDataAggregator.Query.getData(payload);

Query bulk data aggregation:

The provided code snippet performs a bulk data aggregation query to retrieve data related to documents of type product. While it doesn't specify particular document IDs in the documentIds array, it effectively retrieves data for all documents that meet the specified criteria, including the documentType, asset links, locale, and filters:

const payload = {
  documentType: 'product',
  documentAssetLink: ['article_images_media'],
  secondLevelLink: 'link_type_link_product',
  secondLevelAssetLink: ['article_images_media'],
  thirdLevelLink: '__variants__',
  thirdLevelAssetLink: ['sku_images_media'],
  localeCode: 'fr_FR',
};

const { id } = await client.PimDataAggregator.Operation.create(payload);
const { status } = await client.PimDataAggregator.Operation.get(id);

const outputDir = './operation-files';

if (status == 'Completed')
  await client.PimDataAggregator.Operation.downloadAndUnzip(id, outputDir);

Testing the library:

To run tests within the Quable SDK JS, run the following command:

yarn  test

Documentation

Documentation for API endpoints can be found in here.

Author

[email protected]

License

MIT License