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

priority-tsdk

v2.0.0

Published

Priority ERP Typescript SDK

Downloads

8

Readme

Priority ERP Typescript SDK

Description

This repository serves as a base for code and documentation relating to Priority ERP Development for third parties. It should be used along with the documentation.

Install

npm i priority-tsdk

Examples

Filtering a collection with logic operators:

const Client = require("priority-tsdk");

const apiClient = new Client({ url, username, password });

// URL : {{baseUrl}}/LOGPART?$filter=TYPE eq 'P' and LASTPRICE gt 200

const data = await apiClient
  .screen("LOGPART")
  .where({ TYPE: "P": LASTPRICE: ["gt", 200] })
  .get();

Fetch a collection along with its related subform:

const Client = require('priority-tsdk');

const apiClient = new Client({ url, username, password });

// URL : {{baseUrl}}/ORDERS?$expand=ORDERITEMS_SUBFORM

const data = await apiClient
  .screen('ORDERS')
  .where({ CUSTNAME: 'T000001' })
  .withRelated(['ORDERITEMS_SUBFORM'])
  .get();

Paginate a collection:

const Client = require('priority-tsdk');

const apiClient = new Client({ url, username, password });

// URL : {{baseUrl}}/LOGPART?$top={{size}}&$skip${{offset}}

const data = await apiClient.screen('LOGPART').paginate(page, size);

Combining the operators for a complex query:

const Client = require('priority-tsdk');

const apiClient = new Client({ url, username, password });

// URL: {{baseUrl}}/ORDERS?$filter=CUSTNAME+eq+'T000001'&$expand=ORDERITEMS_SUBFORM($filter=PRICE+gt+3;$select=KLINE,PARTNAME,PDES,TQUANT,PRICE;$expand=ORDISTATUSLOG_SUBFORM),SHIPTO2_SUBFORM,ORDERSTEXT_SUBFORM&$select=CUSTNAME,CDES,ORDNAME

const data = await apiClient
  .screen('ORDERS')
  .where({ CUSTNAME: 'T000001' })
  .withRelated(['ORDERITEMS_SUBFORM', 'SHIPTO2_SUBFORM', 'ORDERSTEXT_SUBFORM'])
  .modifyRelated('ORDERITEMS_SUBFORM', queryBuilder => {
    queryBuilder
      .where({ PRICE: ['gt', 3] })
      .select(['KLINE', 'PARTNAME', 'PDES', 'TQUANT', 'PRICE'])
      .withRelated(['ORDISTATUSLOG_SUBFORM']);
  })
  .select(['CUSTNAME', 'CDES', 'ORDNAME'])
  .get();

API

Methods

  • (constructor)(< string >url, < string >username, < string >password) - Creates and returns a new Priority client instance.

  • screen(< string >screenName) - (< PriorityClient >) - Sets the screen(collection) where the resources are fetched.

  • subform(< string >subformName) - (< PriorityClient >) - Sets the related subform(sub-collection) where the resources are fetched.

  • findOne(< object >identifier) - (< PriorityClient >) - Fetches only ONE entity from the related collection.

  • where(< object >filters) - (< PriorityClient >) - Filters entities that match the filters in the collection

    The filters are a key-value object where the value can be a string || number or an array with a logic operator as the first element and the value as the second:

    const filters = { PRICE: 50 }; // PRICE+eq+50
    const logicalFilters = { PRICE: ['gt', 50] }; // PRICE+gt+50
  • withRelated(< string[] >subforms) - (< PriorityClient >) - Includes subform data inside the related collection data

  • modifyRelated(< string >subformName, modifierFunction) - (< PriorityClient >) - Modifies a subform that was included in the URL

  • select(< string[] >fieldsToSelect) - (< PriorityClient >) - Selects the fields fetched

  • since(< string >time) - (< PriorityClient >) - Fetches items created after a certain date

  • orderBy(< string >field, < string >order) - (< PriorityClient >) - Sorts the entities fetched. The order can be: "desc" | "asc"

  • get() - (Promise< any >) - Makes a GET request

  • post() - (Promise< any >) - Makes a POST request

  • patch() - (Promise< any >) - Makes a PATCH request

  • request(< string >method, data) - (Promise< any >) - Makes a request with the provided method and data.

  • paginate(< number >page, < number >size) - (Promise< any[] >) - Paginates the response from the API

  • paginateAction(< number >page, < number >size, callback, limit) - (Promise< any[] >) - Paginates the response from the API and calls the callback passing the response as params. The limit is used to set the collective maximum number of entities that should fetched from the API: defaults to Infinity.