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

servicemeow

v3.2.0

Published

A Javascript client for the ServiceNOW REST API.

Downloads

161

Readme

CI Coverage Status

ServiceMeow

A Node.js client for the ServiceNOW REST API.

Installation

Run npm install servicemeow to install the package.

Basic Usage

const ServiceMeow = require('servicemeow');

const sm = new ServiceMeow('https://<INSTANCE>.service-now.com','<USERNAME>','<PASSWORD>');

const record = await sm.getSingleRecord('<TABLE_NAME>', <SYS_ID>);

Supported Actions

// returns JSON of record
getSingleRecord('<TABLE_NAME>', '<SYS_ID>');

// returns sys_id of created record
createRecord('<TABLE_NAME>', { /* <JSON_RECORD_BODY> */ });

// returns true if success, false otherwise
deleteSingleRecord('<TABLE_NAME>', '<SYS_ID_OF_RECORD_TO_BE_DELETED>');

// returns sys_id of updated record
updateSingleRecord('<TABLE_NAME>', { /* <JSON_RECORD_BODY> */ }, '<SYS_ID_OF_RECORD_TO_BE_DELETED>');

// Returns JSON of list of record(s). Use query builder for building advanced serviceNOW  encoded query
getRecords('<TABLE_NAME>', '<ENCODED_QUERY>');

// returns count of records matching given query
getRecordCount('<TABLE_NAME>', '<ENCODED_QUERY>');

Example Usage of Above Actions

const record = await sm.getSingleRecord('<TABLE_NAME>', '<SYS_ID>');

const id = await sm.createRecord('<TABLE_NAME>', {'endpoint': 'published'});

const deleted = await sm.deleteSingleRecord('<TABLE_NAME>', '<SYS_ID>');

const id = await servicenowClient.updateSingleRecord('<TABLE_NAME>', { /* <JSON_RECORD_BODY> */ }, '<SYS_ID>');

// Consider using QueryBuilder to create encoded queries
const records = await servicenowClient.getRecords('<TABLE_NAME>', '<ENCODED_QUERY>');

const count = await sm.getRecordCount('<TABLE_NAME>', '<ENCODED_QUERY>');

Query Builder Example Usage

const { QueryBuilder } = require('servicemeow');
const queryBuilder = new QueryBuilder();

// Less than '<'
const query = queryBuilder.field('sys_created_on').lessThan('2019-02-15 14:30:18');

// Less than using Date object
const query = queryBuilder.field('sys_created_on').lessThan(new Date());

// Greater than using Date object
const query = queryBuilder.field('sys_created_on').lessThan(new Date());

// compound query using and, lessThan, greaterThan
const query = queryBuilder.field('number').greaterThan('S').and().field('sys_created_on').lessThan(new Date());

// Between two dates, numbers, Strings 
const query = queryBuilder.field('sys_created_on').between('2015-02-15 14:30:18', '2019-02-18 14:30:18');
const query = queryBuilder.field('risk_score').between(47, 52);
const query = queryBuilder.field('number').between('A', 'Z');

// Empty String query
const query = queryBuilder.field('description').isEmptyString();

// Example of 'IN' operator
const query = queryBuilder.field('number').isOneOf(['INC0010122','INC0010120']);

// Example of 'NOT IN' operator
const query = queryBuilder.field('foo').isNoneOf(['bar', 'baz']);

// Is anything operator
const query = queryBuilder.field('number').isAnything();

// Contains operator
const query = queryBuilder.field('number').contains('<YOUR_STRING>');

// Order ascending/descending
const query = queryBuilder.field('number').contains('<YOUR_STRING>').or().contains('<OTHER_STRING>').orderAscending();

// Multiple conditions on a single field
const query = queryBuilder.field('number').contains('<YOUR_STRING>').and().contains('<OTHER_STRING>').orderDescending();

// Ends with operator
const query = queryBuilder.field('number').endsWith('<YOUR_STRING>');

// Does not contain
const query = queryBuilder.field('number').doesNotContain('<YOUR_STRING>');

// equals
const query = queryBuilder.field('number').equals('<YOUR_STRING>/<ARRAY>');

// isEmpty
const query = queryBuilder.field('number').isEmpty();

// isNotEmpty
const query = queryBuilder.field('number').isNotEmpty();

// Example of 'SAMEAS' operator
const query = queryBuilder.field('left').isSameAs('middle');

// Example of 'NSAMEAS' operator
const query = queryBuilder.field('left').isNotSameAs('right');

// Example of 'GT_FIELD' operator
const query = queryBuilder.field('foo').greaterThanField('bar');

// Example of 'GT_OR_EQUALS_FIELD' operator
const query = queryBuilder.field('foo').greaterThanOrEqualsField('bar');

// Example of 'LT_FIELD' operator
const query = queryBuilder.field('foo').lessThanField('bar');

// Example of 'LT_OR_EQUALS_FIELD' operator
const query = queryBuilder.field('foo').lessThanOrEqualsField('bar');

// Example of 'RELATIVEGT' operator
const query = queryBuilder.field('sys_updated_on').since(1, 'hour');

// Example of 'RELATIVELT' operator
const query = queryBuilder.field('sys_updated_on').notSince(10, 'minute');

// Example of 'MORETHAN' operator
const query = queryBuilder.field('sys_created_on').isMoreThan(1, 'year').before('sys_updated_on');

// Example of 'LESSTHAN' operator
const query = queryBuilder.field('sys_created_on').isLessThan(12, 'hour').before('sys_updated_on');

Typings

Typings are automatically generated from the JSDoc comments prior to npm publish. As such, declaration files are included in the npm package distribution but not committed to git.

Acknowledgements

ServiceMeow was forked from ServiceNOW-Client by Kaushal Shah.