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

youtrack-rest-client

v1.6.0

Published

Client library for accessing the youtrack REST api

Downloads

820

Readme

logo

youtrack-rest-client

Client library for the youtrack rest api

📦 Build & Test Maintainability npm NpmLicense

Install

npm install youtrack-rest-client
yarn add youtrack-rest-client

Usage

Authentication

With your permanent token (see Manage-Permanent-Token):

import {Youtrack} from "youtrack-rest-client";

const config = {
    baseUrl: "http://example.myjetbrains.com", 
    token: "perm:your-token"
};
const youtrack = new Youtrack(config);

With username/password
The current REST API does not support logging in with username/password anymore, if you require this you need to use the legacy REST API (youtrack-rest-client version 0.3.x).

Users


// get the current user
youtrack.users.current().then((user: User) => {
    console.log({user});
});

// get all users
youtrack.users.all().then((users: ReducedUser[]) => {
    console.log({users});
});

// get a user by id
youtrack.users.byId('1-1').then((user: User) => {
    console.log({user});
});

Projects


// get all projects
youtrack.projects.all().then((projects: ReducedProject[]) => {
    console.dir(projects);
});

// get a project by its id
youtrack.projects.byId('0-0').then((project: Project) => {
    console.dir(project);
});

Issues

// search/list issues
youtrack.issues.search('project: T1').then((issues: ReducedIssue[]) => {
    console.log({issues});
});
// get issue by id
youtrack.issues.byId('T1-2').then((issue: Issue) => {
    console.log({issue});
});
// delete an issue
youtrack.issues.delete('2-2').then(() => {
    console.log('issue deleted');
});
// create a new issue
youtrack.issues.create({
    summary: 'lorem ipsum',
    description: 'created using rest api',
    project: {
        id: '0-0'
    }
}).then(issue => {
    console.log({issue});
});
// update an issue
youtrack.issues.update({
    id: 'T1-2',
    summary: "updated summary"
}).then(issue => {
    console.log({issue});
});

Commands

// execute command for issue(s) (internal id is used)
youtrack.issues.executeCommand({
    query: 'for me',
    issues: [
        {
            id: '2-6'
        }
    ]
}).then(response => {
    console.log({response});
});
// execute command for issue(s) and add a comment
youtrack.issues.executeCommand({
    query: 'for me',
    comment: 'gonna solve this real quick',
    issues: [
        {
            id: '2-6'
        }
    ]
}).then(response => {
    console.log({response});
});

WorkItems (Time-Tracking)

// get the configured workitem types for the project
youtrack.projects.getWorkItemTypes('0-0').then((workItemTypes: WorkItemType[]) => {
    console.log({workItemTypes});
});
// list the workitems of a project
youtrack.workItems.all('T1-2').then((workItems: WorkItem[]) => {
    console.log({workItems});
});
// add new workitem to project
youtrack.workItems.create('T1-2', {
    duration: {
        presentation: '30m'
    },
    text: 'fixed bug',
    type: {
        name: 'Development',
        id: '77-0'
    }
}).then(workItem => {
    console.log({workItem});
});
// update workitem
youtrack.workItems.update('T1-2', {
    id: '116-3',
    duration: {
        presentation: '45m'
    }
}).then(workItem => {
    console.log({workItem});
});
// delete work item
youtrack.workItems.delete('T1-2', '116-3').then(() => {
    console.log('workitem deleted.');
});

Issue Comments

// list comments of an issue
youtrack.comments.all('T1-2').then((comments: IssueComment[]) => {
    console.log({comments});
});
// add comment to issue
youtrack.comments.create('T1-2', {
    text: 'issue comment'
}).then(comment => {
    console.log({comment});
});
// update comment
youtrack.comments.update('T1-2', {
    id: '4-1',
    text: 'updated issue comment'
}).then(comment => {
    console.log({comment});
});
// delete a comment
youtrack.comments.delete('T1-2', '4-1').then(() => {
    console.log('comment deleted.');
});

Issue Tags


// get all tags
youtrack.tags.all().then((tags: IssueTag[]) => {
    console.log({tags});
});

// get tag by id
youtrack.tags.byId('6-0').then((tag: IssueTag) => {
    console.log({tag});
});

Issue Links


// get issue links of issue
youtrack.issues.byId('P1-1').then((issue: Issue) => {
    console.log({links: issue.links});
});

// update issue link(s)
youtrack.issues.update({
    id: 'P1-1',
    links: [
            {
                issues: [
                    {
                        id: '2-3'
                    }
                ],
                id: '92-1s',
            }
        ]
}).then((issue: Issue) => {
    console.log({links: issue.links});
});

Agiles


// get all agile boards
youtrack.agiles.all().then((agiles: ReducedAgile[]) => {
    console.log({agiles});
});

// get specific agile board by id
youtrack.agiles.byId('104-0').then((agile: Agile) => {
    console.log({agile});
});

// create new agile board
youtrack.agiles.create({
    name: '19-15',
    projects: [{ id: '0-0' }]
}).then((agile: Agile) => {
    console.log({agile});
});

// delete an agile board 
youtrack.agiles.delete('104-1').then(() => {
    console.log('agile deleted.');
});

// update an agile board
youtrack.agiles.update({ id: '104-0', projects: [{ id: '0-0' }] }).then((agile: Agile) => {
    console.log({agile});
});

Sprints


const agileId = '104-0';

// get all sprints of an agile board
youtrack.sprints.all(agileId).then((sprints: ReducedSprint[]) => {
    console.log({sprints});
});

// get agile sprint by id
youtrack.sprints.byId(agileId, '105-0').then((sprint: Sprint) => {
    console.log({sprint});
});

// create new sprint
youtrack.sprints.create(agileId, { name: 'my sprint' }).then((sprint: Sprint) => {
    console.log({sprint});
});

// update a sprint
youtrack.sprints.update(agileId, { id: '105-3', name: 'my sprint 3' }).then((sprint: Sprint) => {
    console.log({sprint});
});

// delete a sprint
youtrack.sprints.delete(agileId, '105-2').then(() => {
    console.log('sprint deleted.');
});

Contributing

If you encounter any missing features or bugs, you're welcome to open an Issue! PRs are welcome too ;-)

  1. Fork it ( https://github.com/shanehofstetter/youtrack-rest-client/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request