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

emanifest

v0.3.2

Published

API client library, written in TypeScript, for using the EPA e-Manifest/RCRAInfo web services.

Downloads

25

Readme

License: MIT

e-Manifest NPM package

Intro

The emanifest npm package is an API client library. It simplifies the task of using the RCRAInfo/e-Manifest web services by abstracting the authentication process, providing developer friendly API, and exporting TypeScript types. It's built on top of the Axios library, and can be used in both Node and browser runtime environments (EPA has discussed making some public API available that do not need authentication in the near future).

For additional information about e-Manifest, check out the below links

For a python alternative see the emanifest package on PyPI

Installation

  $ npm install emanifest
  or
  $ yarn add emanifest

Basic Usage

The primary export of the emanifest package is the newClient function. A constructor that accepts a configuration object and returns a new RcraClient instance.

import { AxiosResponse } from 'axios';
import { newClient, RCRAINFO_PREPROD, AuthResponse } from 'emanifest';

// The newClient accepts an instance of the RcraClientConfig which follows this interface
// interface RcraClientConfig {
// apiBaseURL?: RcrainfoEnv; // default: RCRAINFO_PREPROD
// apiID?: string;
// apiKey?: string;
// autoAuth?: Boolean; // default: false
// validateInput?: Boolean; // default: false
// }

const rcrainfo = newClient({ apiBaseURL: RCRAINFO_PREPROD, apiID: 'my_api_id', apiKey: 'my_api_key' });
const authResponse: AxiosResponse<AuthResponse> = await rcrainfo.authenticate();
console.log(authResponse.data);

Other Exports

The emanifest package also exports the RCRAINFO_PREPROD and RCRAINFO_PROD constants which can be used to set the apiBaseURL property of the RcraClientConfig object.

Types

The emanifest package exports types/interfaces that can be used in statically typed projects. The types follow the OpenAPI schema definitions that can be found in the USEPA/e-manifest schema directory however, some names have been modified for clarity (for example RcraCode instead of simply Code).

Auto-Authentication

The emanifest package can be explicitly configured to automatically authenticate when needed.

import { AxiosResponse } from 'axios';
import { newClient, RCRAINFO_PREPROD, AuthResponse, RcraClientClass, RcraCode } from 'emanifest';

const rcrainfo = newClient({
  apiBaseURL: RCRAINFO_PREPROD,
  apiID: 'my_api_id',
  apiKey: 'my_api_key',
  autoAuth: true, // Set the RcraClient to automatically authenticate as needed
});

// the authenticate method is NOT explicitly called
const resp: AxtiosResponse<RcraCode> = await rcrainfo.getStateWasteCodes('VA');

console.log(resp.data); // [ { code: 'BCRUSH', description: 'Bulb or Lamp Crusher' } ]

console.log(rcrainfo.isAuthenticated()); // true

Input Validation

The emanifest package can be explicitly configured to provide some simple input validation. This behavior is disabled by default. It must be explicitly enabled by setting the validateInput property of the RcraClientConfig on initiation.

  1. siteID must be a string of length 12
  2. stateCode must be a string of length 2
  3. siteType must be one of the following: ['Generator', 'Tsdf', 'Transporter', 'Rejection_AlternateTsdf']
  4. dateType (a search parameter) must be one of the following: ['CertifiedDate', 'ReceivedDate', 'ShippedDate', 'UpdatedDate']
  5. manifestTrackingNumber must be a string of length 12

Upon validation failure, the RcraClient will throw an error which can be caught and handled the same as an error received from the axios library.

import { newClient } from 'emanifest';

const rcrainfo = newClient({ validateInput: true });

try {
  const resp = await rcrainfo.getSite('VA12345');
} catch (err) {
  console.log(err.message); // "siteID must be a string of length 12"
}

Manifest Attachments

The emanifest NPM package has alpha support for retrieving multipart/mixed content types from the RCRAInfo services. This feature is disabled by default and must be explicitly enabled by passing parseResponse as true in methods that return multipart/mixed content types.

import { AxiosResponse } from 'axios';
import { newClient } from 'emanifest';
import { OutputPart } from 'emanifest-js/src/parse';

const rcrainfo = newClient({ validateInput: true });

const resp: AxiosResponse<OutputPart> = await rcrainfo.getManifestAttachments({
  manifestTrackingNumber: '123456789ELC',
  parseResponse: true,
});
console.log(resp.data);
// {
//  contentType: 'application/json' | 'application/octet-stream';
//  contentDisposition?: string;
//  data: string | Buffer;
// }

Disclaimer

The United States Environmental Protection Agency (EPA) GitHub project code is provided on an "as is" basis and the user assumes responsibility for its use. EPA has relinquished control of the information and no longer has responsibility to protect the integrity, confidentiality, or availability of the information. Any reference to specific commercial products, processes, or services by service mark, trademark, manufacturer, or otherwise, does not constitute or imply their endorsement, recommendation or favoring by EPA. The EPA seal and logo shall not be used in any manner to imply endorsement of any commercial product or activity by EPA or the United States Government.