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

exlibris-request

v1.0.0

Published

CREBP-SRA tool to request papers, books or other materials via ExLibris (Alma, Primo etc.)

Downloads

6

Readme

SRA-Exlibris-Request

This module is part of the Bond University Centre for Research in Evidence-Based Practice Systematic Review Assistant suite of tools.

This module forms the reference request tool.

var exlibrisRequest = require('sra-exlibis-request');

new sraExlibrisRequest()
	.set({
		exlibris: {
			apiKey: 'YOUR API KEY'
		},
		user: {
			email: 'someone@somewhere', // User making request
		},
	})
	.set('request.source', 'SRA') // Set some extra request fields
	.set('request.note', 'SRA')
	.set('validator', (ref, eref) => { // Custom validator code
		if (!ref.type) return 'No reference type specified';
		if (ref.type == 'book') {
			if (!eref.title) return 'Missing book title';
			if (!eref.journal) return 'Missing journal';
			eref.pickup_location = 'MAIN',
			eref.format = 'PHYSICAL';
			eref.citation_type = 'BK';
		}
		return true;
	})
	.requestAll(refs, function(err, res) { // Request a bunch of references (maybe use reflib - https://github.com/hash-bang/Reflib-Node - to read in a library?)
		expect(err).to.be.not.ok;
		done();
	})

See the testkits for more examples.

API

ExlibrisRequest (class)

The main ExlibrisRequest class is used to setup the instance with initial settings and provide an API.

Supported Settings:

| Setting | Type | Default | Description | |--------------------------------------|----------|-------------|--------------------------------------------------------------------------------------------------------------------------------| | exlibris | Object | See below | Settings passed onto the Exlibris NPM module | | exlibris.region | String | "eu" | What Exlibris region server the place the request with | | exlibris.apiKey | String | none | Your Exlibris API key | | exlibris.resourceRequestRetry | Number | 10 | How many times to retry a single request if it fails | | exlibris.resourceRequestRetryDelay | Function | See code | How to calculate how long to wait between requests. Default behaviour is to pick a random millisecond delay between 0 and 2000 | | exlibris.threads | Number | 2 | How many requests to place simultaneously | | user | Object | See below | Information about the user to place the request against | | user.email | String | none | The users email to link the request against | | request | Object | {} | Additional fields to provide in the request | | validator | Function | ()=> true | Validator function used to verify that a reference can be submitted. Should return either a boolean or a string (error message). Note, this occurs AFTER the field translation stage, so the fields are Exlibris and NOT Reflib spec. If you are mutating the object, mutate the Exlibris object (eRef) | | debug | Object | See below | Debug flags | | debug.execRequest | Boolean | false | Whether to actually place requests. User details and all other validation stages are applied except the final submission | | debug.titleMangle | String | title => title | How to mutate the citation title before submission. Override this function to specify a prefix / suffix | | cache | Object | See below | Caching details, the cache is used only on this instance and can significantly speed up requests if working in batches | | cache.enabled | Boolean | true | Whether to use caching | | cache.cacheGet | Function | See code | Uses simple memory caching | | cache.cacheSet | Function | See code | Uses simple memory caching |

Notes:

  • The debug.execRequest flag is disabled by default. Set this to true to make the library submit requests, although you should test without this enabled first
  • All functions are chainable

ExlibrisRequest.set(config, [value])

Used to quickly set one or more config values. See the main constructor for a list of settings.

ExlibrisRequest
	.set('key1', 'value1')
	.set('key2', 'value2')
	.set('key3.subKey1', 'value3')

ExlibrisRequest.set({
	key1: 'value1',
	key2: 'value2',
	key3: {
		subKey1: 'value3',
	},
})

ExlibrisRequest.request(ref, [options], [cb])

Make a citation request to Exlibris.

The reference should be in the reflib format.

Options can be specified to override the defaults. Callback is optional.

ExlibrisRequest.requestAll(refs, [options], [cb])

Similar to request() but places requests in batch.

See the request function for details.

Events

The ExlibrisRequest instance can also fire events.

| Event | Parameters | Description | |------------------|-------------------------------------|-----------------------------------------------------------| | requestSucceed | (ref, attempt) | Fired when a request succeeded | | requestRetry | (ref, attempt, tryagainInTimeout) | Fired when a request fails but will be retried | | requestFailed | (ref, attempts) | Fired when a request failed after retrying | | requestError | (ref, err) | Fired when a request is completely rejected by the server |