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

bugzilla

v3.1.2

Published

A NodeJS module to access Bugzilla instances through the REST API.

Downloads

77

Readme

Bugzilla | npm version Build codecov

Typesafe access to Bugzilla's REST API.

Very early work in progress, getting info from a bug or searching bugs is the main priority right now.

Tests

Some basic tests now exist. yarn test will run the main tests. yarn run itest will run some integration tests against a real Bugzilla instance however you must have docker installed in order to run these.

API

Creating the API instance

import BugzillaAPI from "bugzilla";

let api = new BugzillaAPI("https://bugzilla.mozilla.org", "<api key>");
await api.version();

Or for username/password authentication:

import BugzillaAPI from "bugzilla";

let api = new BugzillaAPI(
  "https://bugzilla.mozilla.org",
  "<username>",
  "<password>",
);
await api.version();

Retrieving bugs by ID

let bugs = await api.getBugs([123456, 123457]);

Querying bugs

You can use a quicksearch string:

let bugs = await api.quicksearch("severity:blocker,critical");

Or any advanced search which can be passed in a number of ways:

// You can just pass a full advanced search url:
let bugs = await api.advancedSearch(
  "https://bugzilla.mozilla.org/buglist.cgi?email1=dtownsend%40mozilla.com&emailassigned_to1=1&resolution=---&emailtype1=exact&list_id=15603348",
);

// Or just the query string part:
let bugs = await api.advancedSearch(
  "email1=dtownsend%40mozilla.com&emailassigned_to1=1&resolution=---&emailtype1=exact&list_id=15603348",
);

// Or as a record:
let bugs = await api.advancedSearch({
  email1: "[email protected]",
  emailassigned_to1: "1",
  resolution: "---",
  emailtype1: "exact",
});

Filtering bug fields

To reduce bandwidth or improve performance it is possible to filter the fields returned by functions that return bugs:

// To only retrieve certain fields.
let bug = await api.getBugs([123456]).include(["id", "product", "component"]);

// Or to filter out certain fields.
let bug = await api.getBugs([123456]).exclude(["cc_detail"]);

Assuming you use a static array the returned types will correctly reflect to available fields.

Currently the _all, _default, _extra and _custom special field shortcuts are not currently supported.

Custom fields are not currently returned.

Retrieving comments by ID

// .getComment() accepts one parameter, ID of comment, as number
let comment = await api.getComment(123456);

Return value is Comment object.

Retrieving all comments of bug

// .getBugComments() accepts one parameter, ID of bug, as number
let comments = await api.getBugComments(123456);

Return value is array of Comment objects.

Creating comments

let comment = await api.createComment(
  123456,
  "This is new comment on bug #123456",
  { is_private: false },
);

Returned value is ID of the newly-created comment.

Creating bugs

let bug = await api.createBug({
  product: "TestProduct",
  component: "TestComponent",
  version: "unspecified",
  summary: "'This is a test bug - please disregard",
  alias: "SomeAlias",
  op_sys: "All",
  priority: "P1",
  rep_platform: "All",
});

Returned value is ID of the newly-created bug.

Updating bugs

Example of adding email address on cc list of bug #123456:

let response = await api.updateBug(123456, {
  id_or_alias: 123456,
  cc: { add: "[email protected]" },
});

Returned value is same as described in Bugzilla docs.

Retrieving attachments by ID

// .getAttachment() accepts one parameter, ID of attachment, as number
let attachment = await api.getAttachment(123456);

Return value is Attachment object.

Retrieving all attachments of bug

// .getBugsAttachments() accepts one parameter, ID of bug, as number
let attachments = await api.getBugAttachments(123456);

Return value is array of Attachment objects.

Creating attachments

let attachment = await api.createAttachment(123456, {
  ids: [123456, 123457],
  data:  Buffer.from('Attachment content'),
  file_name: "Attachment name",
  summary: "Attachment summary",
  content_type: "text/plain",
  is_private?: false,
});

Returned value is an array of IDs of the newly-created attachments.

Updating attachments

Example of changing content type of attachment #123456:

let response = await api.updateAttachment(123456, {
  attachment_id: 123456,
  content_type: "text/plain",
});

Returned value is same as described in Bugzilla docs.