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

@nypl/sierra-wrapper

v1.1.1

Published

A node wrapper for Innovative's Sierra API v3

Downloads

232

Readme

sierra-wrapper

A basic node wrapper for the III Sierra v3/v6 API

The wrapper currently supports:

  • Authorizing
  • Returning a single, multiple and range Bib records
  • Returning a single, multiple and range Item records
  • Returning item records belonging to a single Bib record

In addition there are general methods that can be used to make any GET POST PUT or DELETE request:

  • get
  • post
  • deleteRequest
  • put

Usage

Load the client as follows:

const wrapper = require('@nypl/sierra-wrapper')

Authenticating

To configure credentials there are three options:

  1. Store credentials in a json file in the format:
{
	"key": "YOURKEY",
	"secret": "YOURSECRET",
	"base": "https://your.domain.name.org/iii/sierra-api/v3/"
}

You then authorize and request by

const wrapper = require('@nypl/sierra-wrapper')

wrapper.config('./path/to/config.json')
  1. You can pass in an options object with the same format as the json above, and pass it in to the same function
wrapper.config(options)
  1. You can also set your credentials via environment variables: SIERRA_KEY, SIERRA_SECRET, SIERRA_BASE

Querying

The following retrieves a bunch of bib ids:

const printBibIds = async () => {
  try {
    const bibs = await wrapper.get('bibs')
    console.log('Got bibs:', bibs.entries.map(b => b.id))
  } catch (e) {
    console.log(e.message)
  }
}

API

config(configOrFile) ⇒ boolean

Loads a config object, passed or from disk Returns: boolean - did it load or not

| Param | Type | Description | | --- | --- | --- | | configOrFile | object | string | The object with the credentials or a path to a json file with the credentials |

authenticate()

Called internally to retrieve an access token before all calls. Requests an auth token from the sierra API and stores it for future use. It automatically reattempts when there is an empty response from Sierra (a not uncommon error).

get(path)

Makes a get request to ${exports.credsBase}${path} and returns the response. It automatically reattempts when there is an empty response from Sierra (a not uncommon error).

resolves to the result:

{"id":1001006,"expirationDate":"2019-01-07","patronType":10,"patronCodes":{"pcode1":"-","pcode2":"-","pcode3":2,"pcode4":0},"homeLibraryCode":"hd","message":{"code":"-","accountMessages":["[email protected]"]}

post(path, data)

Makes a post request to ${exports.credsBase}${path} and returns the response

resolves to the result:

{ code: 132, specificCode: 2, httpStatus: 500, name: 'XCirc error', description: 'XCirc error : Bib record cannot be loaded' }

put(path, data)

Makes a post request to ${exports.credsBase}${path}. The response is just a status code.

deleteRequest(path)

Makes a delete request to ${exports.credsBase}${path}. The response is just a status code.

getSingleBib(bibId)

Requests a single bib data from the API

Return format: [Object]

| Param | Type | Description | | --- | --- | --- | | bibId | string | the bnumber of the bib you want to request |

getRangeBib(bibIdStart, bibIdEnd)

Requests a bib range from the API

Return format: [Object]

| Param | Type | Description | | --- | --- | --- | | bibIdStart | string | the bnumber of the bib you want to request | | bibIdEnd | string | the bnumber of the bib you want to request |

getRangeItem(itemIdStart, itemIdEnd)

Requests an item range from the API

Return format: [Object]

| Param | Type | Description | | --- | --- | --- | | itemIdStart | string | the bnumber of the bib you want to request | | itemIdEnd | string | the bnumber of the bib you want to request |

getBibItems(bibId)

Requests all the items of a specified bib id Return format: [ [Object], [Object] ]

| Param | Type | Description | | --- | --- | --- | | bibId | string | the bnumber of the bib you want to request |

getMultiBibBasic(bibsIds)

Requests multiple bibs, but no orders or locations

Return format: [Object]

| Param | Type | Description | | --- | --- | --- | | bibsIds | array | an array of bib id strings |

getMultiItemBasic(itemIds)

Requests multiple items

Return format: [Object]

| Param | Type | Description | | --- | --- | --- | | itemIds | array | array of item ids |

Contributing

  1. Cut feature branch from master
  2. Before making pull request, run npm version <update_type>, indicating patch, minor, or major changes, according to semantic versioning
  3. After PR is approved, run npm publish
  4. Go to your package page (https://npmjs.com/package/) to check that the package version has been updated

Testing

Run unit tests via:

npm test

See ./test/installation-test for scripts to validate a release before publication.