JSPM

jira.js

1.7.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 124846
  • Score
    100M100P100Q160191F
  • License MIT

Package Exports

  • jira.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (jira.js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

JavaScript JIRA API Client

A JavaScript/TypeScript wrapper for the JIRA REST API

npm Downloads Minizipped size dependencies Status devDependencies Status Build Status

Installation

Install with the npm:

npm install jira.js

Install with the yarn:

yarn add jira.js

Examples

Create the JIRA client

// ES5
var { Client } = require("jira.js");

// ES6
import { Client } from "jira.js";

// Initialize
var client = new Client({
  host: "https://jira.somehost.com"
});

Get all projects

// ES5/ES6
client.projects
  .getAllProjects()
  .then(projects => console.log(projects))
  .catch(error => console.log(error));

// ES7
async function getProjects() {
  const projects = await client.projects.getAllProjects();

  console.log(projects);

  return projects;
}

Authorization

Basic authorization

With API token
const client = new Client({
  host: "https://jira.somehost.com",
  authentication: {
    basic: {
      username: "MyUsername",
      apiToken: "API_Token"
    }
  }
});
With password
const client = new Client({
  host: "https://jira.somehost.com",
  authentication: {
    basic: {
      username: "MyUsername",
      password: "MyPassword"
    }
  }
});

JWT authentication

const client = new Client({
  host: 'https://jira.somehost.com',
  authentication: {
    jwt: {
      iss: 'id',
      secret: 'secret key'
    }
  }
});

OAuth2.0 authentication

const client = new Client({
  host: "https://jira.somehost.com",
  authentication: {
    accessToken: "my access token"
  }
});

Base request config

If you want to add headers, timeout, withCredentials or other data for each of the requests that will be called, then pass them to baseRequestConfig.

Full list of properties for baseRequestConfig you can find here: https://github.com/axios/axios#request-config

import { Client } from "jira.js";

const client = new Client({
  host: 'https://jira.somehost.com',
  baseRequestConfig: {
    timeout: 20000,
    headers: {
      'Content-Type': 'application/json',
    },
    timeoutErrorMessage: 'Error message',
    withCredentials: false,
    responseType: 'arraybuffer',
    maxContentLength: 100,
    // and others properties
  },
});

Set middleware for Jira's responses and errors

import { Client } from "jira.js";

const client = new Client({
  host: "https://jira.somehost.com",
  middlewares: {
    onError: (error) => {
      console.error(error);
      throw error;
    },
    onResponse: (data) => {
      console.log(data);
      return data;
    }
  }
});

Documentation

Can't find what you need in the readme? Check out our documentation here: https://mrrefactoring.github.io/jira.js/

Road map

  • Response models
  • Method names reducing

Latest version changelog

1.7.2

  • FIX: console.log removed

1.7.1

  • FIX: Headers fixes

1.7.0

  • IMPROVEMENT: Readme examples updated

  • IMPROVEMENT: Config typings refactored
  • DEPRECATION: Property timeout deprecated in Config

  • FEATURE: Property middlewares added to Config

  • FEATURE: Property baseRequestConfig added to Config

  • FEATURE: Method getOptionsForContext added to IssueCustomFieldOptions Jira documentation
  • FEATURE: Method deleteCustomFieldOption added to IssueCustomFieldOptions Jira documentation


  • FEATURE: Method assignWorkflowSchemeToProject added to WorkflowSchemeProjectAssociations Jira documentation


  • FEATURE: Added models for new endpoints