Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@egman1/youtrack-rest-client

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@egman1/youtrack-rest-client

Client library for accessing the youtrack REST api

  • 1.6.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

logo

youtrack-rest-client

Client library for the youtrack rest api

📦 Build & Test Maintainability npm NpmLicense

Donate

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});
});

// 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

Keywords

FAQs

Package last updated on 18 Jan 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc