├── .npmignore ├── test ├── fixtures │ ├── documentTree.ts │ ├── oauth2.ts │ ├── index.ts │ ├── space.ts │ ├── project.ts │ ├── documentAttachments.ts │ ├── document.ts │ └── documents.ts ├── mock.ts └── test.ts ├── .gitignore ├── src ├── index.ts ├── error.ts ├── oauth2.ts ├── types.ts ├── request.ts ├── option.ts ├── entity.ts └── backlog.ts ├── dist └── types │ ├── index.d.ts │ ├── oauth2.d.ts │ ├── request.d.ts │ ├── error.d.ts │ ├── types.d.ts │ ├── option.d.ts │ ├── entity.d.ts │ └── backlog.d.ts ├── tsconfig.json ├── .github └── workflows │ └── nodejs.yml ├── DEVELOPMENT.md ├── package.json ├── README.md └── CHANGELOG.md /.npmignore: -------------------------------------------------------------------------------- 1 | * 2 | !/package.json 3 | !/README.md 4 | !/CHANGELOG.md 5 | !/dist/backlog.js 6 | !/dist/backlog.min.js 7 | !/dist/types/* 8 | -------------------------------------------------------------------------------- /test/fixtures/documentTree.ts: -------------------------------------------------------------------------------- 1 | export const documentTree = { 2 | "id": "01939983409c79d5a06a49859789e38f", 3 | "name": "Home", 4 | "documents": [], 5 | "children": [] 6 | } 7 | -------------------------------------------------------------------------------- /test/fixtures/oauth2.ts: -------------------------------------------------------------------------------- 1 | export const access_token = { 2 | access_token: 'YOUR_ACCESS_TOKEN', 3 | token_type: 'Bearer', 4 | expires_in: 3600, 5 | refresh_token: 'YOUR_REFRESH_TOKEN' 6 | } 7 | -------------------------------------------------------------------------------- /test/fixtures/index.ts: -------------------------------------------------------------------------------- 1 | export * from './oauth2'; 2 | export * from './space'; 3 | export * from './project'; 4 | export * from './document'; 5 | export * from './documents'; 6 | export * from './documentTree'; 7 | export * from './documentAttachments'; 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | npm-debug.log 2 | node_modules 3 | dist/test/ 4 | dist/src/ 5 | coverage 6 | *~ 7 | *.swp 8 | *.swo 9 | tmux-*.log 10 | .env 11 | typings 12 | src/**/*.js 13 | src/**/*.js.map 14 | src/**/*.d.ts 15 | test/**/*.js 16 | test/**/*.js.map 17 | test/**/*.d.ts 18 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import Backlog from './backlog'; 2 | import OAuth2 from './oauth2'; 3 | import * as Option from './option'; 4 | import * as Entity from './entity'; 5 | import * as Types from './types'; 6 | import * as Error from './error'; 7 | export { Backlog, OAuth2, Option, Entity, Types, Error } 8 | -------------------------------------------------------------------------------- /dist/types/index.d.ts: -------------------------------------------------------------------------------- 1 | import Backlog from './backlog'; 2 | import OAuth2 from './oauth2'; 3 | import * as Option from './option'; 4 | import * as Entity from './entity'; 5 | import * as Types from './types'; 6 | import * as Error from './error'; 7 | export { Backlog, OAuth2, Option, Entity, Types, Error }; 8 | -------------------------------------------------------------------------------- /test/fixtures/space.ts: -------------------------------------------------------------------------------- 1 | export const space = { 2 | spaceKey: 'nulab', 3 | name: 'nulab', 4 | ownerId: 99999, 5 | lang: 'ja', 6 | timezone: 'Asia/Tokyo', 7 | reportSendTime: '18:00:00', 8 | textFormattingRule: 'backlog', 9 | created: '2016-05-01T05:45:52Z', 10 | updated: '2016-08-16T02:27:40Z' 11 | } 12 | -------------------------------------------------------------------------------- /test/fixtures/project.ts: -------------------------------------------------------------------------------- 1 | export const projects = [ 2 | { 3 | id: 1, 4 | projectKey: "TEST", 5 | name: "test", 6 | chartEnabled: false, 7 | subtaskingEnabled: false, 8 | projectLeaderCanEditProjectLeader: false, 9 | textFormattingRule: "markdown", 10 | archived: false 11 | } 12 | ] 13 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": ["dom", "es2016"], 5 | "outDir": "dist", 6 | "sourceMap": false, 7 | "noImplicitAny": false, 8 | "noEmitOnError": false 9 | }, 10 | "include": [ 11 | "src/**/*", 12 | "test/**/*" 13 | ], 14 | "exclude": [ 15 | "node_modules" 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /test/fixtures/documentAttachments.ts: -------------------------------------------------------------------------------- 1 | export const documentAttachments = [ 2 | { 3 | "id": 22067, 4 | "name": "test.png", 5 | "size": 8718, 6 | "createdUser": { 7 | "id": 3, 8 | "userId": "user_003", 9 | "name": "User Three", 10 | "roleType": 2, 11 | "lang": "ja", 12 | "mailAddress": "user3@example.com" 13 | }, 14 | "created": "2025-05-29T02:19:54Z" 15 | } 16 | ]; 17 | -------------------------------------------------------------------------------- /.github/workflows/nodejs.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - "**" 7 | 8 | jobs: 9 | test: 10 | 11 | runs-on: ubuntu-latest 12 | 13 | strategy: 14 | matrix: 15 | node-version: [18.x, 20.x, 22.x] 16 | 17 | steps: 18 | - uses: actions/checkout@v3 19 | - name: Use Node.js ${{ matrix.node-version }} 20 | uses: actions/setup-node@v3 21 | with: 22 | node-version: ${{ matrix.node-version }} 23 | - name: Run npm ci 24 | run: npm ci 25 | - name: Run test 26 | run: npm run build && npm test 27 | -------------------------------------------------------------------------------- /dist/types/oauth2.d.ts: -------------------------------------------------------------------------------- 1 | import * as Option from './option'; 2 | import * as Entity from './entity'; 3 | export default class OAuth2 { 4 | private credentials; 5 | private timeout?; 6 | constructor(credentials: Option.OAuth2.Credentials, timeout?: number); 7 | getAuthorizationURL(options: { 8 | host: string; 9 | redirectUri?: string; 10 | state?: string; 11 | }): string; 12 | getAccessToken(options: { 13 | host: string; 14 | code: string; 15 | redirectUri?: string; 16 | }): Promise; 17 | refreshAccessToken(options: { 18 | host: string; 19 | refreshToken: string; 20 | }): Promise; 21 | } 22 | -------------------------------------------------------------------------------- /dist/types/request.d.ts: -------------------------------------------------------------------------------- 1 | export default class Request { 2 | private configure; 3 | constructor(configure: { 4 | host: string; 5 | apiKey?: string; 6 | accessToken?: string; 7 | timeout?: number; 8 | }); 9 | get(path: string, params?: any): Promise; 10 | post(path: string, params?: any): Promise; 11 | put(path: string, params: any): Promise; 12 | patch(path: string, params: any): Promise; 13 | delete(path: string, params?: any): Promise; 14 | request(options: { 15 | method: string; 16 | path: string; 17 | params?: Params | FormData; 18 | }): Promise; 19 | checkStatus(response: Response): Promise; 20 | parseJSON(response: Response): Promise; 21 | private toQueryString; 22 | get webAppBaseURL(): string; 23 | get restBaseURL(): string; 24 | } 25 | export type Params = { 26 | [index: string]: number | string | number[] | string[]; 27 | }; 28 | -------------------------------------------------------------------------------- /test/fixtures/document.ts: -------------------------------------------------------------------------------- 1 | export const document = { 2 | "id": "01939983409c79d5a06a49859789e38f", 3 | "projectId": 1, 4 | "title": "ドキュメント機能へようこそ", 5 | "plain": "hello", 6 | "json": "{}", 7 | "statusId": 1, 8 | "emoji": "🎉", 9 | "attachments": [ 10 | { 11 | "id": 22067, 12 | "name": "test.png", 13 | "size": 8718, 14 | "createdUser": { 15 | "id": 3, 16 | "userId": "user_003", 17 | "name": "User Three", 18 | "roleType": 2, 19 | "lang": "ja", 20 | "mailAddress": "user3@example.com" 21 | }, 22 | "created": "2025-05-29T02:19:54Z" 23 | } 24 | ], 25 | "tags": [ 26 | { 27 | "id": 1, 28 | "name": "Backlog" 29 | } 30 | ], 31 | "createdUser": { 32 | "id": 2, 33 | "userId": "user_002", 34 | "name": "User Two", 35 | "roleType": 1, 36 | "lang": "ja", 37 | "mailAddress": "user2@example.com" 38 | }, 39 | "created": "2024-12-06T01:08:56Z", 40 | "updatedUser": { 41 | "id": 2, 42 | "userId": "user_002", 43 | "name": "User Two", 44 | "roleType": 1, 45 | "lang": "ja", 46 | "mailAddress": "user2@example.com" 47 | }, 48 | "updated": "2025-04-28T01:47:02Z" 49 | }; 50 | -------------------------------------------------------------------------------- /dist/types/error.d.ts: -------------------------------------------------------------------------------- 1 | export declare class BacklogError extends Error { 2 | private _name; 3 | private _url; 4 | private _status; 5 | private _body; 6 | private _response; 7 | constructor(name: BacklogErrorNameType, response: Response, body?: { 8 | errors: BacklogErrorMessage[]; 9 | }); 10 | get name(): BacklogErrorNameType; 11 | get url(): string; 12 | get status(): number; 13 | get body(): { 14 | errors: BacklogErrorMessage[]; 15 | }; 16 | get response(): Response; 17 | } 18 | export declare class BacklogApiError extends BacklogError { 19 | constructor(response: Response, body?: { 20 | errors: BacklogErrorMessage[]; 21 | }); 22 | } 23 | export declare class BacklogAuthError extends BacklogError { 24 | constructor(response: Response, body?: { 25 | errors: BacklogErrorMessage[]; 26 | }); 27 | } 28 | export declare class UnexpectedError extends BacklogError { 29 | constructor(response: Response); 30 | } 31 | export interface BacklogErrorMessage { 32 | message: string; 33 | code: number; 34 | errorInfo: string; 35 | moreInfo: string; 36 | } 37 | export type BacklogErrorNameType = 'BacklogApiError' | 'BacklogAuthError' | 'UnexpectedError'; 38 | -------------------------------------------------------------------------------- /test/fixtures/documents.ts: -------------------------------------------------------------------------------- 1 | export const documents = [ 2 | { 3 | "id": "01939983409c79d5a06a49859789e38f", 4 | "projectId": 1, 5 | "title": "ドキュメント機能へようこそ", 6 | "plain": "hello", 7 | "json": "{}", 8 | "statusId": 1, 9 | "emoji": "🎉", 10 | "attachments": [ 11 | { 12 | "id": 22067, 13 | "name": "test.png", 14 | "size": 8718, 15 | "createdUser": { 16 | "id": 3, 17 | "userId": "user_003", 18 | "name": "User Three", 19 | "roleType": 2, 20 | "lang": "ja", 21 | "mailAddress": "user3@example.com" 22 | }, 23 | "created": "2025-05-29T02:19:54Z" 24 | } 25 | ], 26 | "tags": [ 27 | { 28 | "id": 1, 29 | "name": "Backlog" 30 | } 31 | ], 32 | "createdUser": { 33 | "id": 2, 34 | "userId": "user_002", 35 | "name": "User Two", 36 | "roleType": 1, 37 | "lang": "ja", 38 | "mailAddress": "user2@example.com" 39 | }, 40 | "created": "2024-12-06T01:08:56Z", 41 | "updatedUser": { 42 | "id": 2, 43 | "userId": "user_002", 44 | "name": "User Two", 45 | "roleType": 1, 46 | "lang": "ja", 47 | "mailAddress": "user2@example.com" 48 | }, 49 | "updated": "2025-04-28T01:47:02Z" 50 | } 51 | ]; 52 | -------------------------------------------------------------------------------- /DEVELOPMENT.md: -------------------------------------------------------------------------------- 1 | # For contributers 2 | 3 | ## Before you commit 4 | 5 | * Create your branch from master branch. And your pull requests should head to master branch in general. 6 | * Run `npm run build` to build `dist/*` and commit them. They are **not** `.gitignore`d. 7 | 8 | # For repository owners 9 | 10 | ## Release procedure 11 | 12 | ### 0. Requirements 13 | 14 | * [ghch](https://github.com/Songmu/ghch) 15 | 16 | ### 1. Create new tag 17 | 18 | **Be sure your local master branch is up-to-date.** 19 | 20 | 1. Create a release branch from master branch. 21 | 1. `git switch master && git pull` 22 | 1. `git switch -c ` 23 | 1. Update the change log. 24 | 1. `VERSION= npm run changelog` 25 | 1. Update versions in `package.json` and `package-lock.json`. 26 | 1. Manually 😜 27 | 1. Commit and push. Create a pull request. 28 | 1. `git commit -m ""` 29 | 1. `git push` 30 | 1. Create a pull request in your favourite way. 31 | 1. After the PR is merged, add new tag to the HEAD of master branch. 32 | 1. `git switch master && git pull` 33 | 1. `git tag ` 34 | 1. `git push origin ` 35 | 36 | ### 2. Publish to npm 37 | 38 | 1. `npm login` 39 | 1. Be sure you are logging in to the `nulab` account. 40 | 1. `npm publish --dry-run` 41 | 1. `npm publish` 42 | 1. `npm logout` 43 | 44 | ### 3. Create a release in GitHub 45 | 46 | 1. Push `Draft a new release` button in https://github.com/nulab/backlog-js/releases . 47 | 1. Paste a URL which links to the `CHANGELOG.md`. 48 | 1. e.g. https://github.com/nulab/backlog-js/blob/master/CHANGELOG.md#0120-2021-01-08 49 | -------------------------------------------------------------------------------- /src/error.ts: -------------------------------------------------------------------------------- 1 | export class BacklogError extends Error { 2 | private _name: BacklogErrorNameType; 3 | private _url: string; 4 | private _status: number; 5 | private _body: { errors: BacklogErrorMessage[] }; 6 | private _response: Response; 7 | constructor( 8 | name: BacklogErrorNameType, 9 | response: Response, 10 | body?: { errors: BacklogErrorMessage[] } 11 | ) { 12 | super(response.statusText); 13 | this._name = name; 14 | this._url = response.url; 15 | this._status = response.status; 16 | this._body = body; 17 | this._response = response; 18 | } 19 | get name(): BacklogErrorNameType { 20 | return this._name; 21 | } 22 | get url(): string { 23 | return this._url; 24 | } 25 | get status(): number { 26 | return this._status; 27 | } 28 | get body(): { errors: BacklogErrorMessage[] } { 29 | return this._body; 30 | } 31 | get response(): Response { 32 | return this._response; 33 | } 34 | } 35 | 36 | export class BacklogApiError extends BacklogError { 37 | constructor( 38 | response: Response, 39 | body?: { errors: BacklogErrorMessage[] } 40 | ) { 41 | super('BacklogApiError', response, body); 42 | } 43 | } 44 | 45 | export class BacklogAuthError extends BacklogError { 46 | constructor( 47 | response: Response, 48 | body?: { errors: BacklogErrorMessage[] } 49 | ) { 50 | super('BacklogAuthError', response, body); 51 | } 52 | } 53 | 54 | export class UnexpectedError extends BacklogError { 55 | constructor( 56 | response: Response 57 | ) { 58 | super('UnexpectedError', response); 59 | } 60 | } 61 | 62 | export interface BacklogErrorMessage { 63 | message: string; 64 | code: number; 65 | errorInfo: string; 66 | moreInfo: string; 67 | } 68 | 69 | export type BacklogErrorNameType = 'BacklogApiError' | 'BacklogAuthError' | 'UnexpectedError'; 70 | -------------------------------------------------------------------------------- /src/oauth2.ts: -------------------------------------------------------------------------------- 1 | import Request from './request'; 2 | import * as Option from './option'; 3 | import * as Entity from './entity'; 4 | 5 | export default class OAuth2 { 6 | 7 | public constructor( 8 | private credentials: Option.OAuth2.Credentials, 9 | private timeout?: number 10 | ) { } 11 | 12 | public getAuthorizationURL(options: { 13 | host: string, redirectUri?: string, state?: string 14 | }): string { 15 | const params = { 16 | client_id: this.credentials.clientId, 17 | response_type: 'code', 18 | redirect_uri: options.redirectUri, 19 | state: options.state 20 | }; 21 | return `https://${options.host}/OAuth2AccessRequest.action?` + 22 | Object.keys(params) 23 | .map(key => params[key] ? `${key}=${params[key]}` : '' ) 24 | .filter(x => x.length > 0) 25 | .join('&'); 26 | } 27 | 28 | public getAccessToken(options: { 29 | host: string, code: string, redirectUri?: string 30 | }): Promise { 31 | return new Request({ 32 | host: options.host, timeout: this.timeout 33 | }).post('oauth2/token', { 34 | grant_type: 'authorization_code', 35 | code: options.code, 36 | client_id: this.credentials.clientId, 37 | client_secret: this.credentials.clientSecret, 38 | redirect_uri: options.redirectUri 39 | }); 40 | } 41 | 42 | public refreshAccessToken(options: { 43 | host: string, refreshToken: string 44 | }): Promise { 45 | return new Request({ 46 | host: options.host, timeout: this.timeout 47 | }).post('oauth2/token', { 48 | grant_type: "refresh_token", 49 | client_id: this.credentials.clientId, 50 | client_secret: this.credentials.clientSecret, 51 | refresh_token: options.refreshToken 52 | }); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /dist/types/types.d.ts: -------------------------------------------------------------------------------- 1 | export type TextFormattingRule = "backlog" | "markdown"; 2 | export declare enum ClassicRoleType { 3 | Admin = 1, 4 | User = 2, 5 | Reporter = 3, 6 | Viewer = 4, 7 | GuestReporter = 5, 8 | GuestViewer = 6 9 | } 10 | export declare enum NormalRoleType { 11 | Admin = 1, 12 | MemberOrGuest = 2, 13 | MemberOrGuestForAddIssues = 3, 14 | MemberOrGuestForViewIssues = 4 15 | } 16 | export type RoleType = ClassicRoleType | NormalRoleType; 17 | export type Language = "en" | "ja" | null; 18 | export declare enum ActivityType { 19 | Undefined = -1, 20 | IssueCreated = 1, 21 | IssueUpdated = 2, 22 | IssueCommented = 3, 23 | IssueDeleted = 4, 24 | WikiCreated = 5, 25 | WikiUpdated = 6, 26 | WikiDeleted = 7, 27 | FileAdded = 8, 28 | FileUpdated = 9, 29 | FileDeleted = 10, 30 | SvnCommitted = 11, 31 | GitPushed = 12, 32 | GitRepositoryCreated = 13, 33 | IssueMultiUpdated = 14, 34 | ProjectUserAdded = 15, 35 | ProjectUserRemoved = 16, 36 | NotifyAdded = 17, 37 | PullRequestAdded = 18, 38 | PullRequestUpdated = 19, 39 | PullRequestCommented = 20, 40 | PullRequestMerged = 21, 41 | MilestoneCreated = 22, 42 | MilestoneUpdated = 23, 43 | MilestoneDeleted = 24, 44 | ProjectGroupAdded = 25, 45 | ProjectGroupDeleted = 26 46 | } 47 | export type IssueTypeColor = "#e30000" | "#990000" | "#934981" | "#814fbc" | "#2779ca" | "#007e9a" | "#7ea800" | "#ff9200" | "#ff3265" | "#666665"; 48 | export type ProjectStatusColor = "#ea2c00" | "#e87758" | "#e07b9a" | "#868cb7" | "#3b9dbd" | "#4caf93" | "#b0be3c" | "#eda62a" | "#f42858" | "#393939"; 49 | export declare enum CustomFieldType { 50 | Text = 1, 51 | TextArea = 2, 52 | Numeric = 3, 53 | Date = 4, 54 | SingleList = 5, 55 | MultipleList = 6, 56 | CheckBox = 7, 57 | Radio = 8 58 | } 59 | export type WebhookActivityId = number; 60 | -------------------------------------------------------------------------------- /src/types.ts: -------------------------------------------------------------------------------- 1 | export type TextFormattingRule = "backlog" | "markdown"; 2 | 3 | export enum ClassicRoleType { 4 | Admin = 1, 5 | User = 2, 6 | Reporter = 3, 7 | Viewer = 4, 8 | GuestReporter = 5, 9 | GuestViewer = 6 10 | } 11 | 12 | export enum NormalRoleType { 13 | Admin = 1, 14 | MemberOrGuest = 2, 15 | MemberOrGuestForAddIssues = 3, 16 | MemberOrGuestForViewIssues = 4, 17 | } 18 | 19 | export type RoleType = ClassicRoleType | NormalRoleType; 20 | 21 | export type Language = "en" | "ja" | null; 22 | 23 | export enum ActivityType { 24 | Undefined = -1, 25 | IssueCreated = 1, 26 | IssueUpdated = 2, 27 | IssueCommented = 3, 28 | IssueDeleted = 4, 29 | WikiCreated = 5, 30 | WikiUpdated = 6, 31 | WikiDeleted = 7, 32 | FileAdded = 8, 33 | FileUpdated = 9, 34 | FileDeleted = 10, 35 | SvnCommitted = 11, 36 | GitPushed = 12, 37 | GitRepositoryCreated = 13, 38 | IssueMultiUpdated = 14, 39 | ProjectUserAdded = 15, 40 | ProjectUserRemoved = 16, 41 | NotifyAdded = 17, 42 | PullRequestAdded = 18, 43 | PullRequestUpdated = 19, 44 | PullRequestCommented = 20, 45 | PullRequestMerged = 21, 46 | MilestoneCreated = 22, 47 | MilestoneUpdated = 23, 48 | MilestoneDeleted = 24, 49 | ProjectGroupAdded = 25, 50 | ProjectGroupDeleted = 26, 51 | } 52 | 53 | export type IssueTypeColor = 54 | "#e30000" | 55 | "#990000" | 56 | "#934981" | 57 | "#814fbc" | 58 | "#2779ca" | 59 | "#007e9a" | 60 | "#7ea800" | 61 | "#ff9200" | 62 | "#ff3265" | 63 | "#666665"; 64 | 65 | export type ProjectStatusColor = 66 | "#ea2c00" | 67 | "#e87758" | 68 | "#e07b9a" | 69 | "#868cb7" | 70 | "#3b9dbd" | 71 | "#4caf93" | 72 | "#b0be3c" | 73 | "#eda62a" | 74 | "#f42858" | 75 | "#393939"; 76 | 77 | export enum CustomFieldType { 78 | Text = 1, 79 | TextArea = 2, 80 | Numeric = 3, 81 | Date = 4, 82 | SingleList = 5, 83 | MultipleList = 6, 84 | CheckBox = 7, 85 | Radio = 8 86 | } 87 | 88 | export type WebhookActivityId = number; -------------------------------------------------------------------------------- /test/mock.ts: -------------------------------------------------------------------------------- 1 | import * as qs from "qs"; 2 | import * as nock from "nock"; 3 | import { setGlobalDispatcher, MockAgent, Interceptable } from "undici"; 4 | 5 | const nodeVersion = Number(process.versions.node.split(".")[0]); 6 | const isNativeFetch = nodeVersion >= 18; 7 | let nockScope: nock.Scope; 8 | let undiciInterceptable: Interceptable; 9 | 10 | type BodyMatcher = (body: string | Record) => boolean; 11 | 12 | interface MockParams { 13 | method: "GET" | "POST" | "DELETE"; 14 | path: string; 15 | query?: Record; 16 | body?: BodyMatcher; 17 | status: number; 18 | data: any; 19 | headers?: Record; 20 | times: number; 21 | } 22 | 23 | export const mockRequest = ({ 24 | path, method, query, body, status, data, headers, times 25 | }: MockParams) => { 26 | const queryStr = qs.stringify(query, { arrayFormat: 'brackets' }); 27 | const newPath = `${path}?${queryStr}` 28 | 29 | if (isNativeFetch) { 30 | const interceptor = undiciInterceptable.intercept({ 31 | method, 32 | path: newPath, 33 | }); 34 | 35 | interceptor 36 | .reply(status, data, { headers }) 37 | .times(times); 38 | } else { 39 | let interceptor: nock.Interceptor; 40 | 41 | if (method === "GET") { 42 | interceptor = nockScope.get(newPath); 43 | } else if (method === "POST" ) { 44 | interceptor = nockScope.post(newPath, body); 45 | } else if (method === "DELETE") { 46 | interceptor = nockScope.delete(newPath); 47 | } 48 | 49 | interceptor 50 | .times(times) 51 | .reply(status, data, headers); 52 | } 53 | }; 54 | 55 | export const mockPrepare = (host: string) => { 56 | if (isNativeFetch) { 57 | const mockAgent = new MockAgent(); 58 | setGlobalDispatcher(mockAgent); 59 | undiciInterceptable = mockAgent.get(host); 60 | } else { 61 | nockScope = nock(host); 62 | } 63 | }; 64 | 65 | export const mockCleanup = () => { 66 | if (isNativeFetch) { 67 | undiciInterceptable.close(); 68 | } else { 69 | nock.cleanAll(); 70 | } 71 | }; 72 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "backlog-js", 3 | "version": "0.15.0", 4 | "description": "Backlog API v2 client for browser and node", 5 | "main": "dist/backlog.min.js", 6 | "types": "dist/types/index.d.ts", 7 | "repository": { 8 | "type": "git", 9 | "url": "git://github.com/nulab/backlog-js.git" 10 | }, 11 | "scripts": { 12 | "test": "mocha --timeout 10000 --require espower-typescript/guess test/test*.ts", 13 | "test-cov": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec dist/test/**/test*.js", 14 | "coveralls": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js", 15 | "clean": "/bin/rm -rf dist", 16 | "build": "npm run clean && npm run build-tsc && npm run copy-dts && npm run build-dist && npm run build-minify", 17 | "build-dist": "browserify --standalone Backlog dist/src/index.js -o dist/backlog.js", 18 | "build-minify": "uglifyjs dist/backlog.js -o dist/backlog.min.js", 19 | "build-tsc": "tsc --declaration", 20 | "copy-dts": "mkdir -p dist/types && cp -r dist/src/*.d.ts dist/types", 21 | "changelog": "ghch -w -F markdown -N ${VERSION}" 22 | }, 23 | "author": "vvatanabe", 24 | "license": "MIT", 25 | "dependencies": { 26 | "qs": "^6.12.1" 27 | }, 28 | "devDependencies": { 29 | "@types/dotenv": "^6.1.1", 30 | "@types/empower": "^1.2.35", 31 | "@types/isomorphic-fetch": "0.0.39", 32 | "@types/mocha": "^10.0.7", 33 | "@types/nock": "^10.0.3", 34 | "@types/node": "^18", 35 | "@types/power-assert": "^1.5.12", 36 | "@types/power-assert-formatter": "^1.4.33", 37 | "@types/qs": "^6.9.15", 38 | "browserify": "^17.0.0", 39 | "coveralls": "^3.1.1", 40 | "dotenv": "^16.4.5", 41 | "espower-typescript": "^10.0.1", 42 | "isomorphic-fetch": "^3.0.0", 43 | "isomorphic-form-data": "^2.0.0", 44 | "istanbul": "^0.4.5", 45 | "mocha": "^10.5.2", 46 | "nock": "^13.5.4", 47 | "power-assert": "^1.6.1", 48 | "typescript": "^5.5.2", 49 | "uglify-js": "^3.18.0", 50 | "undici": "^6.19.2" 51 | }, 52 | "keywords": [ 53 | "nulab", 54 | "backlog", 55 | "api" 56 | ] 57 | } 58 | -------------------------------------------------------------------------------- /src/request.ts: -------------------------------------------------------------------------------- 1 | import * as Error from './error'; 2 | import * as qs from 'qs'; 3 | 4 | export default class Request { 5 | 6 | constructor(private configure: { 7 | host: string, apiKey?: string, accessToken?: string, timeout?: number 8 | }) { } 9 | 10 | public get(path: string, params?: any): Promise { 11 | return this.request({ method: 'GET', path, params }).then(this.parseJSON); 12 | } 13 | 14 | public post(path: string, params?: any): Promise { 15 | return this.request({ method: 'POST', path, params }).then(this.parseJSON); 16 | } 17 | 18 | public put(path: string, params: any): Promise { 19 | return this.request({ method: 'PUT', path, params }).then(this.parseJSON); 20 | } 21 | 22 | public patch(path: string, params: any): Promise { 23 | return this.request({ method: 'PATCH', path, params }).then(this.parseJSON); 24 | } 25 | 26 | public delete(path: string, params?: any): Promise { 27 | return this.request({ method: 'DELETE', path, params }).then(this.parseJSON); 28 | } 29 | 30 | public request(options: { 31 | method: string, 32 | path: string, 33 | params?: Params | FormData 34 | }): Promise { 35 | const { method, path, params = {} } = options; 36 | const { apiKey, accessToken, timeout } = this.configure; 37 | const query: Params = apiKey ? { apiKey: apiKey } : {}; 38 | const init: RequestInit = { method: method, headers: {} }; 39 | if (timeout) { 40 | init['timeout'] = timeout; 41 | } 42 | if (!apiKey && accessToken) { 43 | init.headers['Authorization'] = 'Bearer ' + accessToken; 44 | } 45 | if (typeof window !== 'undefined') { 46 | init.mode = 'cors'; 47 | } 48 | if (method !== 'GET') { 49 | if (params instanceof FormData) { 50 | init.body = params 51 | } else { 52 | init.headers['Content-type'] = 'application/x-www-form-urlencoded'; 53 | init.body = this.toQueryString(params); 54 | } 55 | } else { 56 | Object.keys(params).forEach(key => query[key] = params[key]); 57 | } 58 | const queryStr = this.toQueryString(query); 59 | const url = `${this.restBaseURL}/${path}` + (queryStr.length > 0 ? `?${queryStr}` : ''); 60 | return fetch(url, init).then(this.checkStatus); 61 | } 62 | 63 | public checkStatus(response: Response): Promise { 64 | return new Promise((resolve, reject) => { 65 | if (200 <= response.status && response.status < 300) { 66 | resolve(response); 67 | } else { 68 | response.json().then(data => { 69 | if (response.status === 401) { 70 | reject(new Error.BacklogAuthError(response, data)); 71 | } else { 72 | reject(new Error.BacklogApiError(response, data)); 73 | } 74 | }).catch(err => reject(new Error.UnexpectedError(response))); 75 | } 76 | }); 77 | } 78 | 79 | public parseJSON(response: Response): Promise { 80 | if (response.status === 204 || response.headers.get("Content-Length") === "0") { 81 | return Promise.resolve(undefined as unknown as T); 82 | } 83 | 84 | return response.json(); 85 | } 86 | 87 | private toQueryString(params: Params): string { 88 | const formatted: Params = {}; 89 | 90 | Object.keys(params).forEach((key) => { 91 | const value = params[key]; 92 | if (key.startsWith('customField_') && Array.isArray(value)) { 93 | // Backlog API doesn't apply bracket-array syntax for customField_* params, 94 | // so we generate explicit indices: key[0], key[1], ... 95 | value.forEach((v, i) => { 96 | formatted[`${key}[${i}]`] = v; 97 | }); 98 | } else { 99 | formatted[key] = value; 100 | } 101 | }); 102 | 103 | return qs.stringify(formatted, { arrayFormat: 'brackets' }); 104 | } 105 | 106 | public get webAppBaseURL(): string { 107 | return `https://${this.configure.host}`; 108 | } 109 | 110 | public get restBaseURL(): string { 111 | return `${this.webAppBaseURL}/api/v2`; 112 | } 113 | 114 | } 115 | 116 | export type Params = { [index: string]: number|string|number[]|string[]; }; 117 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # backlog-js [![CI](https://github.com/nulab/backlog-js/actions/workflows/nodejs.yml/badge.svg)](https://github.com/nulab/backlog-js/actions/workflows/nodejs.yml) [![npm version](https://badge.fury.io/js/backlog-js.svg)](https://badge.fury.io/js/backlog-js) 2 | Backlog API version 2 client for browser and node. 3 | 4 | ## Required reading 5 | Please check out the [Nulab Backlog API page](https://developer.nulab.com/docs/backlog/). 6 | 7 | ## Installation 8 | npm: 9 | ``` sh 10 | $ npm install --save backlog-js 11 | ``` 12 | 13 | ## Getting started 14 | Append your "API Key" or "OAuth2 Access Token" to requests to the API to return data. 15 | 16 | ``` javascript 17 | import 'isomorphic-form-data'; 18 | import 'isomorphic-fetch'; 19 | import * as backlogjs from 'backlog-js'; 20 | 21 | // 'xxx.backlog.jp' or 'xxx.backlogtool.com' or 'your package host' 22 | const host = 'yourSpaceHost'; 23 | const apiKey = 'yourApiKey'; 24 | const accessToken = 'yourAccessToken'; 25 | 26 | // Use API Key 27 | const backlog = new backlogjs.Backlog({ host, apiKey }); 28 | 29 | // Use OAuth2 Access Token 30 | const backlog = new backlogjs.Backlog({ host, accessToken }); 31 | 32 | // Returns information about your space. 33 | backlog.getSpace().then(data => { 34 | console.log('space:', data); 35 | }).catch(err => { 36 | console.log('error:', err.message); 37 | }); 38 | 39 | ``` 40 | 41 | ### Other Example 42 | 43 | #### Download File 44 | 45 | ``` javascript 46 | // node 47 | backlog.getSpaceIcon().then(data => { 48 | data.body.pipe(fs.createWriteStream(`./${data.filename}`)); 49 | }).catch(err => { 50 | console.log('error:', err.message); 51 | }); 52 | 53 | // browser 54 | backlog.getSpaceIcon().then(data => { 55 | data.blob().then((blob) => { 56 | const objectURL = URL.createObjectURL(blob); 57 | const element = window.document.querySelector('#image'); 58 | element.src = objectURL; 59 | }); 60 | }).catch(err => { 61 | console.log('error:', err.message); 62 | }); 63 | ``` 64 | 65 | #### Upload File 66 | 67 | ``` javascript 68 | // node 69 | const formData = new FormData(); 70 | formData.append("filename", "sample.png"); 71 | formData.append("file", fs.createReadStream("./sample.png")); 72 | 73 | // browser 74 | //
75 | // 76 | //
77 | const $form = window.document.querySelector('#upload_form'); 78 | const formData = new FormData($form); 79 | 80 | backlog.postSpaceAttachment(formData).then(data => { 81 | console.log('success:', data); 82 | }).catch(err => { 83 | console.log('error:', err.message); 84 | }); 85 | ``` 86 | 87 | ## Use OAuth2 for authentication 88 | 89 | Details on the OAuth2 process are available [here](https://developer.nulab-inc.com/docs/backlog/auth#oauth2). 90 | 91 | Here are the basic steps for OAuth2 using the Express: 92 | ```` javascript 93 | import * as express from 'express'; 94 | import * as backlogjs from 'backlog-js'; 95 | 96 | const app = express(); 97 | 98 | const host = 'xxx.backlog.jp'; // or 'xxx.backlogtool.com' or 'your package host' 99 | const clientId = 'yourClientId'; 100 | const clientSecret = 'yourClientSecret'; 101 | const redirectUri = 'https://localhost:3000/callback'; 102 | const state = 'yourState'; 103 | 104 | const credentials = { clientId, clientSecret } 105 | const oauth2 = new backlogjs.OAuth2(credentials); 106 | 107 | const authorizationURL = oauth2.getAuthorizationURL({ host, redirectUri, state }); 108 | 109 | app.get('/auth', (req, res) => { 110 | res.redirect(authorizationURL); 111 | }); 112 | 113 | app.get('/callback', async (req, res) => { 114 | const code = req.query.code; 115 | try { 116 | const accessToken = await oauth2.getAccessToken({ host, code, redirectUri }); 117 | console.log('Access Token:', accessToken); 118 | 119 | // save access token. 120 | 121 | const myself = await new backlogjs.Backlog({ 122 | host, accessToken: accessToken.access_token 123 | }).getMyself(); 124 | console.log('Myself:', myself); 125 | 126 | res.redirect('/'); 127 | } catch (e) { 128 | console.log('Access Token Error', e.message); 129 | res.redirect('/login'); 130 | } 131 | }); 132 | 133 | app.get('/', (req, res) => { 134 | res.send('Hello'); 135 | }); 136 | 137 | app.get('/login', (req, res) => { 138 | res.send('Login with Backlog'); 139 | }); 140 | 141 | app.listen(3000); 142 | 143 | console.log('Express server started on port 3000'); 144 | ```` 145 | 146 | ## License 147 | 148 | MIT License 149 | 150 | * http://www.opensource.org/licenses/mit-license.php 151 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## [0.15.0](https://github.com/nulab/backlog-js/compare/0.14.2...0.15.0) (2025-10-28) 4 | 5 | * Update parameters to add a team [#123](https://github.com/nulab/backlog-js/pull/123) ([gamisachi](https://github.com/gamisachi)) 6 | 7 | ## [0.14.2](https://github.com/nulab/backlog-js/compare/0.14.1...0.14.2) (2025-10-23) 8 | 9 | * Ensure custom-field query parameters use explicit indices [#121](https://github.com/nulab/backlog-js/pull/121) ([trknhr](https://github.com/trknhr)) 10 | 11 | ## [0.14.1](https://github.com/nulab/backlog-js/compare/0.14.0...0.14.1) (2025-09-18) 12 | 13 | * Add `Remove star` [#119](https://github.com/nulab/backlog-js/pull/119) ([katayama8000](https://github.com/katayama8000)) 14 | 15 | ## [0.14.0](https://github.com/nulab/backlog-js/compare/0.13.7...0.14.0) (2025-09-12) 16 | 17 | * Remove deprected methods [#117](https://github.com/nulab/backlog-js/pull/117) ([mmktomato](https://github.com/mmktomato)) 18 | * Bump sha.js from 2.4.11 to 2.4.12 [#116](https://github.com/nulab/backlog-js/pull/116) ([dependabot[bot]](https://github.com/apps/dependabot)) 19 | * Bump cipher-base from 1.0.4 to 1.0.6 [#115](https://github.com/nulab/backlog-js/pull/115) ([dependabot[bot]](https://github.com/apps/dependabot)) 20 | 21 | ## [0.13.7](https://github.com/nulab/backlog-js/compare/0.13.6...0.13.7) (2025-08-21) 22 | 23 | * Add hasDueDate params [#113](https://github.com/nulab/backlog-js/pull/113) ([katayama8000](https://github.com/katayama8000)) 24 | 25 | ## [0.13.6](https://github.com/nulab/backlog-js/compare/0.13.5...0.13.6) (2025-07-01) 26 | 27 | * Bump pbkdf2 from 3.1.1 to 3.1.3 [#110](https://github.com/nulab/backlog-js/pull/110) ([dependabot[bot]](https://github.com/apps/dependabot)) 28 | * Bump undici from 6.21.1 to 6.21.2 [#105](https://github.com/nulab/backlog-js/pull/105) ([dependabot[bot]](https://github.com/apps/dependabot)) 29 | * feat(api): add support for document-related endpoints [#109](https://github.com/nulab/backlog-js/pull/109) ([trknhr](https://github.com/trknhr)) 30 | 31 | ## [0.13.5](https://github.com/nulab/backlog-js/compare/0.13.4...0.13.5) (2025-06-17) 32 | 33 | * Add missing params for watching list [#106](https://github.com/nulab/backlog-js/pull/106) ([takuji](https://github.com/takuji)) 34 | 35 | ## [0.13.4](https://github.com/nulab/backlog-js/compare/0.13.3...0.13.4) (2025-05-07) 36 | 37 | * Bump undici from 6.19.2 to 6.21.1 [#101](https://github.com/nulab/backlog-js/pull/101) ([dependabot[bot]](https://github.com/apps/dependabot)) 38 | * Bump elliptic from 6.6.0 to 6.6.1 [#103](https://github.com/nulab/backlog-js/pull/103) ([dependabot[bot]](https://github.com/apps/dependabot)) 39 | * Bump serialize-javascript and mocha [#102](https://github.com/nulab/backlog-js/pull/102) ([dependabot[bot]](https://github.com/apps/dependabot)) 40 | * Bump elliptic from 6.5.4 to 6.6.0 [#98](https://github.com/nulab/backlog-js/pull/98) ([dependabot[bot]](https://github.com/apps/dependabot)) 41 | * Handle 204 No Content responses safely in parseJSON [#100](https://github.com/nulab/backlog-js/pull/100) ([trknhr](https://github.com/trknhr)) 42 | 43 | ## [0.13.3](https://github.com/nulab/backlog-js/compare/0.13.2...0.13.3) (2024-07-18) 44 | 45 | * Add type annotation for parameters [#93](https://github.com/nulab/backlog-js/pull/93) ([mmktomato](https://github.com/mmktomato)) 46 | 47 | ## [0.13.2](https://github.com/nulab/backlog-js/compare/0.13.1...0.13.2) (2024-07-01) 48 | 49 | * Rename `deleteIssuesCount` to `deleteIssue` [#91](https://github.com/nulab/backlog-js/pull/91) ([mmktomato](https://github.com/mmktomato)) 50 | * Bump undici from 5.19.1 to 5.26.2 [#82](https://github.com/nulab/backlog-js/pull/82) ([dependabot[bot]](https://github.com/apps/dependabot)) 51 | * Bump browserify-sign from 4.2.1 to 4.2.2 [#83](https://github.com/nulab/backlog-js/pull/83) ([dependabot[bot]](https://github.com/apps/dependabot)) 52 | 53 | ## [0.13.1](https://github.com/nulab/backlog-js/compare/0.13.0...0.13.1) (2023-07-21) 54 | 55 | * Fix Issue and PullRequest type #79 [#80](https://github.com/nulab/backlog-js/pull/80) ([mmktomato](https://github.com/mmktomato)) 56 | 57 | ## [0.13.0](https://github.com/nulab/backlog-js/compare/0.12.6...0.13.0) (2023-06-02) 58 | 59 | * add type annotation for response [#77](https://github.com/nulab/backlog-js/pull/77) ([mmktomato](https://github.com/mmktomato)) 60 | * Bump json-schema and jsprim [#76](https://github.com/nulab/backlog-js/pull/76) ([dependabot[bot]](https://github.com/apps/dependabot)) 61 | * Bump minimist and mkdirp [#75](https://github.com/nulab/backlog-js/pull/75) ([dependabot[bot]](https://github.com/apps/dependabot)) 62 | * Bump undici from 5.8.1 to 5.19.1 [#74](https://github.com/nulab/backlog-js/pull/74) ([dependabot[bot]](https://github.com/apps/dependabot)) 63 | * Bump minimatch from 3.0.4 to 3.1.2 [#72](https://github.com/nulab/backlog-js/pull/72) ([dependabot[bot]](https://github.com/apps/dependabot)) 64 | * Add Node.js v18 support to CI [#70](https://github.com/nulab/backlog-js/pull/70) ([mmktomato](https://github.com/mmktomato)) 65 | * Remove es6-promise [#69](https://github.com/nulab/backlog-js/pull/69) ([mmktomato](https://github.com/mmktomato)) 66 | * Bump shell-quote from 1.7.2 to 1.7.3 [#68](https://github.com/nulab/backlog-js/pull/68) ([dependabot[bot]](https://github.com/apps/dependabot)) 67 | * Removed DefinitelyTyped badge [#67](https://github.com/nulab/backlog-js/pull/67) ([mmktomato](https://github.com/mmktomato)) 68 | 69 | ## [0.12.6](https://github.com/nulab/backlog-js/compare/0.12.5...0.12.6) (2022-05-11) 70 | 71 | * Bump ansi-regex from 5.0.0 to 5.0.1 [#62](https://github.com/nulab/backlog-js/pull/62) ([dependabot[bot]](https://github.com/apps/dependabot)) 72 | * Maintain CI's node versions [#64](https://github.com/nulab/backlog-js/pull/64) ([mmktomato](https://github.com/mmktomato)) 73 | * Bump dependencies [#61](https://github.com/nulab/backlog-js/pull/61) ([mmktomato](https://github.com/mmktomato)) 74 | * Distribute .d.ts files [#59](https://github.com/nulab/backlog-js/pull/59) ([mmktomato](https://github.com/mmktomato)) 75 | 76 | ## [0.12.5](https://github.com/nulab/backlog-js/compare/0.12.4...0.12.5) (2022-01-28) 77 | 78 | * Bump cached-path-relative from 1.0.2 to 1.1.0 [#56](https://github.com/nulab/backlog-js/pull/56) ([dependabot[bot]](https://github.com/apps/dependabot)) 79 | * Bump node-fetch from 2.6.1 to 2.6.7 [#55](https://github.com/nulab/backlog-js/pull/55) ([dependabot[bot]](https://github.com/apps/dependabot)) 80 | * No npx in scripts [#54](https://github.com/nulab/backlog-js/pull/54) ([mmktomato](https://github.com/mmktomato)) 81 | * Remove unnecessary namespace (global) [#53](https://github.com/nulab/backlog-js/pull/53) ([mmktomato](https://github.com/mmktomato)) 82 | * Use minified script [#52](https://github.com/nulab/backlog-js/pull/52) ([mmktomato](https://github.com/mmktomato)) 83 | * Generate d.ts automatically [#51](https://github.com/nulab/backlog-js/pull/51) ([mmktomato](https://github.com/mmktomato)) 84 | * Bump path-parse from 1.0.6 to 1.0.7 [#49](https://github.com/nulab/backlog-js/pull/49) ([dependabot[bot]](https://github.com/apps/dependabot)) 85 | 86 | ## [0.12.4](https://github.com/nulab/backlog-js/compare/0.12.3...0.12.4) (2021-08-10) 87 | 88 | * Add return type [#47](https://github.com/nulab/backlog-js/pull/47) ([ohyama](https://github.com/ohyama)) 89 | 90 | ## [0.12.3](https://github.com/nulab/backlog-js/compare/0.12.2...0.12.3) (2021-07-08) 91 | 92 | * string and number for IdOrKey parameters [#44](https://github.com/nulab/backlog-js/pull/44) ([mmktomato](https://github.com/mmktomato)) 93 | * Fix type bugs [#43](https://github.com/nulab/backlog-js/pull/43) ([mmktomato](https://github.com/mmktomato)) 94 | 95 | ## [0.12.2](https://github.com/nulab/backlog-js/compare/0.12.1...0.12.2) (2021-05-31) 96 | 97 | * Add GET /api/v2/rateLimit [#38](https://github.com/nulab/backlog-js/pull/38) ([mmktomato](https://github.com/mmktomato)) 98 | * Bump handlebars from 4.7.6 to 4.7.7 [#37](https://github.com/nulab/backlog-js/pull/37) ([dependabot[bot]](https://github.com/apps/dependabot)) 99 | * Cleanup published files [#35](https://github.com/nulab/backlog-js/pull/35) ([mmktomato](https://github.com/mmktomato)) 100 | * Remove Travis CI [#34](https://github.com/nulab/backlog-js/pull/34) ([mmktomato](https://github.com/mmktomato)) 101 | 102 | ## [0.12.1](https://github.com/nulab/backlog-js/compare/0.12.0...0.12.1) (2021-04-01) 103 | 104 | * Bump npm libraries [#30](https://github.com/nulab/backlog-js/pull/30) ([mmktomato](https://github.com/mmktomato)) 105 | * Migrate GitHub Action [#27](https://github.com/nulab/backlog-js/pull/27) ([odanado](https://github.com/odanado)) 106 | 107 | ## [0.12.0](https://github.com/nulab/backlog-js/compare/0.11.0...0.12.0) (2021-01-08) 108 | 109 | * Add missing endpoints [#25](https://github.com/nulab/backlog-js/pull/25) ([mmktomato](https://github.com/mmktomato)) 110 | * Fix url and parameter [#24](https://github.com/nulab/backlog-js/pull/24) ([mmktomato](https://github.com/mmktomato)) 111 | * Fix wrong path and params #20 [#21](https://github.com/nulab/backlog-js/pull/21) ([mmktomato](https://github.com/mmktomato)) 112 | 113 | ## [0.11.0](https://github.com/nulab/backlog-js/compare/0.10.0...0.11.0) (2020-10-25) 114 | 115 | * Bump cached-path-relative from 1.0.1 to 1.0.2 [#17](https://github.com/nulab/backlog-js/pull/17) ([dependabot[bot]](https://github.com/apps/dependabot)) 116 | * Bump js-yaml from 3.12.0 to 3.14.0 [#18](https://github.com/nulab/backlog-js/pull/18) ([dependabot[bot]](https://github.com/apps/dependabot)) 117 | * Bump elliptic from 6.4.1 to 6.5.3 [#12](https://github.com/nulab/backlog-js/pull/12) ([dependabot[bot]](https://github.com/apps/dependabot)) 118 | * Bump acorn from 5.7.2 to 5.7.4 [#13](https://github.com/nulab/backlog-js/pull/13) ([dependabot[bot]](https://github.com/apps/dependabot)) 119 | * Bump handlebars from 4.0.11 to 4.7.6 [#14](https://github.com/nulab/backlog-js/pull/14) ([dependabot[bot]](https://github.com/apps/dependabot)) 120 | * Bump lodash from 4.17.10 to 4.17.20 [#15](https://github.com/nulab/backlog-js/pull/15) ([dependabot[bot]](https://github.com/apps/dependabot)) 121 | * Encode arguments [#16](https://github.com/nulab/backlog-js/pull/16) ([mmktomato](https://github.com/mmktomato)) 122 | * Fix conflict: Typescript3 [#10](https://github.com/nulab/backlog-js/pull/10) ([mmktomato](https://github.com/mmktomato)) 123 | * Fix broken link in README.md [#9](https://github.com/nulab/backlog-js/pull/9) ([mongolyy](https://github.com/mongolyy)) 124 | 125 | ## [0.10.0](https://github.com/nulab/backlog-js/compare/0.9.1...0.10.0) (2020-08-29) 126 | 127 | * Bump TypeScript to v2.9 / Use @types/isomorphic-fetch [#8](https://github.com/nulab/backlog-js/pull/8) ([toshimaru](https://github.com/toshimaru)) 128 | * fix typo in README.md [#5](https://github.com/nulab/backlog-js/pull/5) ([inokappa](https://github.com/inokappa)) 129 | * add Content-type: application/x-www-form-urlencoded [#6](https://github.com/nulab/backlog-js/pull/6) ([mdkn](https://github.com/mdkn)) 130 | 131 | ## [0.9.1](https://github.com/nulab/backlog-js/compare/0.9.0...0.9.1) (2016-09-05) 132 | 133 | * Fix repo URL in package.json [#1](https://github.com/nulab/backlog-js/pull/1) ([pdehaan](https://github.com/pdehaan)) 134 | 135 | ## [0.9.0](https://github.com/nulab/backlog-js/compare/a7fd61ed6d08...0.9.0) (2016-09-03) 136 | -------------------------------------------------------------------------------- /test/test.ts: -------------------------------------------------------------------------------- 1 | import * as assert from 'power-assert'; 2 | import * as dotenv from 'dotenv'; 3 | import * as backlogjs from '../src/index'; 4 | import * as Fixtures from './fixtures/index'; 5 | import { mockRequest, mockPrepare, mockCleanup } from './mock'; 6 | import 'isomorphic-form-data'; 7 | import 'isomorphic-fetch'; 8 | import { before, after } from 'mocha'; 9 | 10 | dotenv.config(); 11 | 12 | const host = process.env.BACKLOG_HOST || 'example.backlog.jp'; 13 | const apiKey = process.env.BACKLOG_API_KEY || 'apiKey'; 14 | const clientId = process.env.BACKLOG_CLIENT_ID || 'clientId'; 15 | const clientSecret = process.env.BACKLOG_CLIENT_SECRET || 'clientSecret'; 16 | const redirectUri = process.env.BACKLOG_REDIRECT_URI || 'redirectUri'; 17 | const state = process.env.BACKLOG_STATE || 'state'; 18 | const code = process.env.BACKLOG_CODE || 'code'; 19 | const refreshToken = process.env.BACKLOG_REFRESH_TOKEN || 'refreshToken'; 20 | const accessToken = process.env.BACKLOG_ACCESS_TOKEN || 'accessToken'; 21 | 22 | const configure = { host, apiKey } 23 | const credentials = { clientId, clientSecret } 24 | 25 | describe("OAuth2 API", () => { 26 | let oauth2 = new backlogjs.OAuth2(credentials); 27 | 28 | before(() => { 29 | mockPrepare(`https://${host}`); 30 | }); 31 | 32 | after(() => { 33 | mockCleanup(); 34 | }) 35 | 36 | it('should get web app base url.', done => { 37 | const expected = `https://${host}/OAuth2AccessRequest.action?client_id=${clientId}&response_type=code&redirect_uri=${redirectUri}&state=${state}`; 38 | assert(expected === oauth2.getAuthorizationURL({ host, redirectUri, state })); 39 | done(); 40 | }); 41 | 42 | it('should get access token.', done => { 43 | mockRequest({ 44 | method: "POST", 45 | path: "/api/v2/oauth2/token", 46 | body: body => { 47 | debugger; 48 | return JSON.stringify(body) === JSON.stringify({ 49 | grant_type: 'authorization_code', 50 | code: code, 51 | client_id: clientId, 52 | client_secret: clientSecret, 53 | redirect_uri: redirectUri 54 | }); 55 | }, 56 | status: 200, 57 | data: Fixtures.access_token, 58 | times: 1, 59 | }); 60 | oauth2.getAccessToken({ 61 | host, code, redirectUri 62 | }).then(data => { 63 | assert.deepEqual(data, Fixtures.access_token); 64 | done(); 65 | }).catch(err => { 66 | throw err; 67 | }); 68 | }); 69 | 70 | it('should refresh access token.', done => { 71 | mockRequest({ 72 | method: "POST", 73 | path: "/api/v2/oauth2/token", 74 | body: body => JSON.stringify(body) === JSON.stringify({ 75 | grant_type: 'refresh_token', 76 | client_id: clientId, 77 | client_secret: clientSecret, 78 | refresh_token: refreshToken 79 | }), 80 | status: 200, 81 | data: Fixtures.access_token, 82 | times: 1, 83 | }); 84 | oauth2.refreshAccessToken({ 85 | host, refreshToken 86 | }).then(data => { 87 | assert.deepEqual(data, Fixtures.access_token); 88 | done(); 89 | }).catch(err => { 90 | throw err; 91 | }); 92 | }); 93 | }); 94 | 95 | describe("Backlog API", () => { 96 | let backlog = new backlogjs.Backlog(configure); 97 | 98 | before(() => { 99 | mockPrepare(`https://${host}`); 100 | }); 101 | 102 | after(() => { 103 | mockCleanup(); 104 | }) 105 | 106 | it('should get web app base url.', (done) => { 107 | assert(`https://${configure.host}` === backlog.webAppBaseURL); 108 | done(); 109 | }); 110 | 111 | it('should get rest base url.', (done) => { 112 | assert(`https://${configure.host}/api/v2` === backlog.restBaseURL); 113 | done(); 114 | }); 115 | 116 | it('should convert object to query string.', (done) => { 117 | const query = (backlog as any).toQueryString({ 118 | userId: 'test01', 119 | password: 'pazzword', 120 | name: 'testuser', 121 | mailAddress: 'testuser@example.com', 122 | roleType: backlogjs.Types.NormalRoleType.Admin 123 | }); 124 | assert('userId=test01&password=pazzword&name=testuser&mailAddress=testuser%40example.com&roleType=1' === query); 125 | done(); 126 | }); 127 | 128 | it('should convert object(array) to query string.', (done) => { 129 | const query = (backlog as any).toQueryString({ 130 | activityTypeId: [ 131 | backlogjs.Types.ActivityType.IssueCreated, 132 | backlogjs.Types.ActivityType.IssueUpdated, 133 | backlogjs.Types.ActivityType.IssueCommented 134 | ], 135 | minId: 1, 136 | maxId: 2, 137 | count: 3, 138 | order: 'asc' 139 | }); 140 | assert('activityTypeId%5B%5D=1&activityTypeId%5B%5D=2&activityTypeId%5B%5D=3&minId=1&maxId=2&count=3&order=asc' === query); 141 | done(); 142 | }); 143 | 144 | it('should convert custom field arrays to indexed query string.', (done) => { 145 | const query = (backlog as any).toQueryString({ 146 | customField_123: ['value1', 'value2', 'value3'], 147 | customField_456: ['option1', 'option2'], 148 | customField_456_otherValue: 'option1', 149 | normalField: 'normalValue', 150 | customField_789: 'singleValue', 151 | // The following arrays should remain in default bracket format 152 | activityTypeId: [1, 2, 3], 153 | statusId: ['open', 'in-progress'], 154 | categoryId: [100, 200], 155 | assigneeId: [5, 10], 156 | // Close-but-not-quite prefixes must also use the default behavior 157 | customFields: ['should', 'use', 'brackets'], 158 | custom_field_999: ['not', 'indexed'], 159 | customfield_lower: ['also', 'brackets'] 160 | }); 161 | 162 | // CustomField-prefixed arrays should use numbered indices; everything else keeps bracket format 163 | const expected = 'customField_123%5B0%5D=value1&customField_123%5B1%5D=value2&customField_123%5B2%5D=value3&customField_456%5B0%5D=option1&customField_456%5B1%5D=option2&customField_456_otherValue=option1&normalField=normalValue&customField_789=singleValue&activityTypeId%5B%5D=1&activityTypeId%5B%5D=2&activityTypeId%5B%5D=3&statusId%5B%5D=open&statusId%5B%5D=in-progress&categoryId%5B%5D=100&categoryId%5B%5D=200&assigneeId%5B%5D=5&assigneeId%5B%5D=10&customFields%5B%5D=should&customFields%5B%5D=use&customFields%5B%5D=brackets&custom_field_999%5B%5D=not&custom_field_999%5B%5D=indexed&customfield_lower%5B%5D=also&customfield_lower%5B%5D=brackets'; 164 | assert(expected === query); 165 | done(); 166 | }); 167 | 168 | it('should get space.', (done) => { 169 | mockRequest({ 170 | method: "GET", 171 | path: "/api/v2/space", 172 | query: { apiKey }, 173 | status: 200, 174 | data: Fixtures.space, 175 | times: 1, 176 | }); 177 | backlog.getSpace().then(data => { 178 | assert.deepEqual(data, Fixtures.space); 179 | done(); 180 | }).catch(err => { 181 | throw err 182 | }); 183 | }); 184 | 185 | it('should get projects.', (done) => { 186 | mockRequest({ 187 | method: "GET", 188 | path: "/api/v2/projects", 189 | query: { apiKey }, 190 | status: 200, 191 | data: Fixtures.projects, 192 | times: 1, 193 | }); 194 | backlog.getProjects().then(data => { 195 | assert.deepEqual(data, Fixtures.projects); 196 | done(); 197 | }).catch((err) => { 198 | throw err; 199 | }); 200 | }); 201 | 202 | it('should get space activities.', (done) => { 203 | const query: backlogjs.Option.Space.GetActivitiesParams & { apiKey: string } = { 204 | apiKey, 205 | activityTypeId: [ 206 | backlogjs.Types.ActivityType.IssueCreated, 207 | backlogjs.Types.ActivityType.IssueUpdated, 208 | backlogjs.Types.ActivityType.IssueCommented 209 | ], 210 | minId: 1, 211 | maxId: 10, 212 | count: 5, 213 | order: "desc", 214 | }; 215 | mockRequest({ 216 | method: "GET", 217 | path: "/api/v2/space/activities", 218 | query, 219 | status: 200, 220 | data: [], 221 | times: 1, 222 | }); 223 | backlog.getSpaceActivities(query).then(data => { 224 | done(); 225 | }).catch(err => { 226 | throw err; 227 | }); 228 | }); 229 | it('should mark notification as read (204 No Content)', done => { 230 | const notificationId = 1234; 231 | 232 | mockRequest({ 233 | method: "POST", 234 | path: `/api/v2/notifications/${notificationId}/markAsRead`, 235 | query: { apiKey }, 236 | status: 204, // No Content 237 | data: [], 238 | times: 1, 239 | }); 240 | 241 | backlog.markAsReadNotification(notificationId).then(data => { 242 | // Should resolve without error and without any value 243 | assert(data === undefined); 244 | done(); 245 | }).catch(err => { 246 | throw err; 247 | }); 248 | }); 249 | 250 | it('should get documents.', (done) => { 251 | mockRequest({ 252 | method: "GET", 253 | path: "/api/v2/documents", 254 | query: { apiKey, offset: 0 }, 255 | status: 200, 256 | data: Fixtures.documents, 257 | times: 1, 258 | }); 259 | backlog.getDocuments({ offset: 0 }).then(data => { 260 | assert.deepEqual(data, Fixtures.documents); 261 | done(); 262 | }).catch(err => { 263 | throw err 264 | }); 265 | }); 266 | 267 | it('should get document tree.', (done) => { 268 | const projectIdOrKey = '1'; 269 | mockRequest({ 270 | method: "GET", 271 | path: `/api/v2/documents/tree`, 272 | query: { apiKey, projectIdOrKey }, 273 | status: 200, 274 | data: Fixtures.documentTree, 275 | times: 1, 276 | }); 277 | backlog.getDocumentTree(projectIdOrKey).then(data => { 278 | assert.deepEqual(data, Fixtures.documentTree); 279 | done(); 280 | }).catch(err => { 281 | throw err 282 | }); 283 | }); 284 | 285 | it('should get a document.', (done) => { 286 | const documentId = '01939983409c79d5a06a49859789e38f'; 287 | mockRequest({ 288 | method: "GET", 289 | path: `/api/v2/documents/${documentId}`, 290 | query: { apiKey }, 291 | status: 200, 292 | data: Fixtures.document, 293 | times: 1, 294 | }); 295 | backlog.getDocument(documentId).then(data => { 296 | assert.deepEqual(data, Fixtures.document); 297 | done(); 298 | }).catch(err => { 299 | throw err 300 | }); 301 | }); 302 | 303 | it('should download a document attachment.', (done) => { 304 | const documentId = '01939983409c79d5a06a49859789e38f'; 305 | const attachmentId = 22067; 306 | mockRequest({ 307 | method: "GET", 308 | path: `/api/v2/documents/${documentId}/attachments/${attachmentId}`, 309 | query: { apiKey }, 310 | status: 200, 311 | data: "dummy", 312 | headers: { 313 | "Content-Disposition": "attachment; filename*=UTF-8''test.png" 314 | }, 315 | times: 1, 316 | }); 317 | backlog.downloadDocumentAttachment(documentId, attachmentId).then(data => { 318 | if ('filename' in data) { 319 | assert.deepEqual(data.filename, "test.png"); 320 | } 321 | done(); 322 | }).catch(err => { 323 | throw err 324 | }); 325 | }); 326 | 327 | it('should remove star.', (done) => { 328 | const starId = 123; 329 | mockRequest({ 330 | method: "DELETE", 331 | path: `/api/v2/stars/${starId}`, 332 | query: { apiKey }, 333 | status: 204, 334 | data: [], 335 | times: 1, 336 | }); 337 | backlog.removeStar(starId).then(data => { 338 | // Should resolve without error and without any value 339 | assert(data === undefined); 340 | done(); 341 | }).catch(err => { 342 | throw err; 343 | }); 344 | }); 345 | }); 346 | -------------------------------------------------------------------------------- /dist/types/option.d.ts: -------------------------------------------------------------------------------- 1 | import * as Types from "./types"; 2 | export type Order = "asc" | "desc"; 3 | export declare namespace Notification { 4 | interface GetNotificationsParams { 5 | minId?: number; 6 | maxId?: number; 7 | count?: number; 8 | order?: Order; 9 | } 10 | interface GetNotificationsCountParams { 11 | alreadyRead: boolean; 12 | resourceAlreadyRead: boolean; 13 | } 14 | } 15 | export declare namespace Document { 16 | interface GetDocumentsParams { 17 | projectId?: number[]; 18 | keyword?: string; 19 | sort?: "created" | "updated"; 20 | order?: Order; 21 | offset: number; 22 | count?: number; 23 | } 24 | } 25 | export declare namespace Space { 26 | interface GetActivitiesParams { 27 | activityTypeId?: Types.ActivityType[]; 28 | minId?: number; 29 | maxId?: number; 30 | count?: number; 31 | order?: Order; 32 | } 33 | interface PutSpaceNotificationParams { 34 | content: string; 35 | } 36 | } 37 | export declare namespace User { 38 | interface PostUserParams { 39 | userId: string; 40 | password: string; 41 | name: string; 42 | mailAddress: string; 43 | roleType: Types.RoleType; 44 | } 45 | interface PatchUserParams { 46 | password?: string; 47 | name?: string; 48 | mailAddress?: string; 49 | roleType?: Types.RoleType; 50 | } 51 | interface GetUserActivitiesParams { 52 | activityTypeId?: Types.ActivityType[]; 53 | minId?: number; 54 | maxId?: number; 55 | count?: number; 56 | order?: Order; 57 | } 58 | interface GetUserStarsParams { 59 | minId?: number; 60 | maxId?: number; 61 | count?: number; 62 | order?: Order; 63 | } 64 | interface GetUserStarsCountParams { 65 | since?: string; 66 | until?: string; 67 | } 68 | interface GetRecentlyViewedParams { 69 | order?: Order; 70 | offset?: number; 71 | count?: number; 72 | } 73 | } 74 | export declare namespace WatchingList { 75 | interface GetWatchingListParams { 76 | order?: Order; 77 | sort?: "created" | "updated" | "issueUpdated"; 78 | count?: number; 79 | offset?: number; 80 | resourceAlreadyRead?: boolean; 81 | issueId?: number[]; 82 | } 83 | interface GetWatchingListCountParams { 84 | resourceAlreadyRead?: boolean; 85 | alreadyRead?: boolean; 86 | } 87 | interface PostWatchingListItemParams { 88 | issueIdOrKey: string | number; 89 | note: string; 90 | } 91 | } 92 | export declare namespace Team { 93 | interface GetTeamsParams { 94 | order?: Order; 95 | offset?: number; 96 | count?: number; 97 | } 98 | interface PostTeamParams { 99 | name: string; 100 | members?: number[]; 101 | } 102 | interface PatchTeamParams { 103 | name?: string; 104 | members?: number[]; 105 | } 106 | } 107 | export declare namespace Project { 108 | interface PostProjectParams { 109 | name: string; 110 | key: string; 111 | chartEnabled: boolean; 112 | projectLeaderCanEditProjectLeader?: boolean; 113 | subtaskingEnabled: boolean; 114 | textFormattingRule: Types.TextFormattingRule; 115 | } 116 | interface PatchProjectParams { 117 | name?: string; 118 | key?: string; 119 | chartEnabled?: boolean; 120 | subtaskingEnabled?: boolean; 121 | projectLeaderCanEditProjectLeader?: boolean; 122 | textFormattingRule?: Types.TextFormattingRule; 123 | archived?: boolean; 124 | } 125 | interface GetProjectsParams { 126 | archived?: boolean; 127 | all?: boolean; 128 | } 129 | interface DeleteProjectUsersParams { 130 | userId: number; 131 | } 132 | interface PostProjectAdministrators { 133 | userId: number; 134 | } 135 | interface DeleteProjectAdministrators { 136 | userId: number; 137 | } 138 | interface PostIssueTypeParams { 139 | name: string; 140 | color: Types.IssueTypeColor; 141 | } 142 | interface PatchIssueTypeParams { 143 | name?: string; 144 | color?: Types.IssueTypeColor; 145 | } 146 | interface DeleteIssueTypeParams { 147 | substituteIssueTypeId: number; 148 | } 149 | interface PostCategoriesParams { 150 | name: string; 151 | } 152 | interface PatchCategoriesParams { 153 | name: string; 154 | } 155 | interface PostVersionsParams { 156 | name: string; 157 | description?: string; 158 | startDate?: string; 159 | releaseDueDate?: string; 160 | } 161 | interface PatchVersionsParams { 162 | name: string; 163 | description?: string; 164 | startDate?: string; 165 | releaseDueDate?: string; 166 | archived?: boolean; 167 | } 168 | interface PostCustomFieldParams { 169 | typeId: Types.CustomFieldType; 170 | name: string; 171 | applicableIssueTypes?: number[]; 172 | description?: string; 173 | required?: boolean; 174 | } 175 | interface PostCustomFieldWithNumericParams extends PostCustomFieldParams { 176 | min?: number; 177 | max?: number; 178 | initialValue?: number; 179 | unit?: string; 180 | } 181 | interface PostCustomFieldWithDateParams extends PostCustomFieldParams { 182 | min?: string; 183 | max?: string; 184 | initialValueType?: number; 185 | initialDate?: string; 186 | initialShift?: number; 187 | } 188 | interface PostCustomFieldWithListParams extends PostCustomFieldParams { 189 | items?: string[]; 190 | allowInput?: boolean; 191 | allowAddItem?: boolean; 192 | } 193 | interface PatchCustomFieldParams { 194 | name?: string; 195 | applicableIssueTypes?: number[]; 196 | description?: string; 197 | required?: boolean; 198 | } 199 | interface PatchCustomFieldWithNumericParams extends PatchCustomFieldParams { 200 | min?: number; 201 | max?: number; 202 | initialValue?: number; 203 | unit?: string; 204 | } 205 | interface PatchCustomFieldWithDateParams extends PatchCustomFieldParams { 206 | min?: string; 207 | max?: string; 208 | initialValueType?: number; 209 | initialDate?: string; 210 | initialShift?: number; 211 | } 212 | interface PatchCustomFieldWithListParams extends PatchCustomFieldParams { 213 | items?: string[]; 214 | allowInput?: boolean; 215 | allowAddItem?: boolean; 216 | } 217 | interface PostCustomFieldItemParams { 218 | name: string; 219 | } 220 | interface PatchCustomFieldItemParams { 221 | name: string; 222 | } 223 | interface GetSharedFilesParams { 224 | order?: Order; 225 | offset?: number; 226 | count?: number; 227 | } 228 | interface PostWebhookParams { 229 | name?: string; 230 | description?: string; 231 | hookUrl?: string; 232 | allEvent?: boolean; 233 | activityTypeIds?: Types.WebhookActivityId[]; 234 | } 235 | interface PatchWebhookParams { 236 | name?: string; 237 | description?: string; 238 | hookUrl?: string; 239 | allEvent?: boolean; 240 | activityTypeIds?: number[]; 241 | } 242 | interface PostStarParams { 243 | issueId?: number; 244 | commentId?: number; 245 | wikiId?: number; 246 | pullRequestId?: number; 247 | pullRequestCommentId?: number; 248 | } 249 | interface PostStatusParams { 250 | name: string; 251 | color: Types.ProjectStatusColor; 252 | } 253 | interface PatchStatusParams { 254 | name?: string; 255 | color?: Types.ProjectStatusColor; 256 | } 257 | } 258 | export declare namespace Issue { 259 | interface PostIssueParams { 260 | projectId: number; 261 | summary: string; 262 | priorityId: number; 263 | issueTypeId: number; 264 | parentIssueId?: number; 265 | description?: string; 266 | startDate?: string; 267 | dueDate?: string; 268 | estimatedHours?: number; 269 | actualHours?: number; 270 | categoryId?: number[]; 271 | versionId?: number[]; 272 | milestoneId?: number[]; 273 | assigneeId?: number; 274 | notifiedUserId?: number[]; 275 | attachmentId?: number[]; 276 | [customField_: string]: any; 277 | } 278 | interface PatchIssueParams { 279 | summary?: string; 280 | parentIssueId?: number; 281 | description?: string; 282 | statusId?: number; 283 | resolutionId?: number; 284 | startDate?: string; 285 | dueDate?: string; 286 | estimatedHours?: number; 287 | actualHours?: number; 288 | issueTypeId?: number; 289 | categoryId?: number[]; 290 | versionId?: number[]; 291 | milestoneId?: number[]; 292 | priorityId?: number; 293 | assigneeId?: number; 294 | notifiedUserId?: number[]; 295 | attachmentId?: number[]; 296 | comment?: string; 297 | [customField_: string]: any; 298 | } 299 | interface GetIssuesParams { 300 | projectId?: number[]; 301 | issueTypeId?: number[]; 302 | categoryId?: number[]; 303 | versionId?: number[]; 304 | milestoneId?: number[]; 305 | statusId?: number[]; 306 | priorityId?: number[]; 307 | assigneeId?: number[]; 308 | createdUserId?: number[]; 309 | resolutionId?: number[]; 310 | parentChild?: ParentChildType; 311 | attachment?: boolean; 312 | sharedFile?: boolean; 313 | sort?: SortKey; 314 | order?: Order; 315 | offset?: number; 316 | count?: number; 317 | createdSince?: string; 318 | createdUntil?: string; 319 | updatedSince?: string; 320 | updatedUntil?: string; 321 | startDateSince?: string; 322 | startDateUntil?: string; 323 | dueDateSince?: string; 324 | dueDateUntil?: string; 325 | hasDueDate?: boolean; 326 | id?: number[]; 327 | parentIssueId?: number[]; 328 | keyword?: string; 329 | [customField_: string]: any; 330 | } 331 | enum ParentChildType { 332 | All = 0, 333 | NotChild = 1, 334 | Child = 2, 335 | NotChildNotParent = 3, 336 | Parent = 4 337 | } 338 | type SortKey = "issueType" | "category" | "version" | "milestone" | "summary" | "status" | "priority" | "attachment" | "sharedFile" | "created" | "createdUser" | "updated" | "updatedUser" | "assignee" | "startDate" | "dueDate" | "estimatedHours" | "actualHours" | "childIssue"; 339 | interface GetIssueCommentsParams { 340 | minId?: number; 341 | maxId?: number; 342 | count?: number; 343 | order?: Order; 344 | } 345 | interface PostIssueCommentsParams { 346 | content: string; 347 | notifiedUserId?: number[]; 348 | attachmentId?: number[]; 349 | } 350 | interface PatchIssueCommentParams { 351 | content: string; 352 | } 353 | interface IssueCommentNotifications { 354 | notifiedUserId: number[]; 355 | } 356 | interface LinkIssueSharedFilesParams { 357 | fileId: number[]; 358 | } 359 | } 360 | export declare namespace PullRequest { 361 | interface GetPullRequestsParams { 362 | statusId?: number[]; 363 | assigneeId?: number[]; 364 | issueId?: number[]; 365 | createdUserId?: number[]; 366 | offset?: number; 367 | count?: number; 368 | } 369 | interface PostPullRequestParams { 370 | summary: string; 371 | description: string; 372 | base: string; 373 | branch: string; 374 | issueId?: number; 375 | assigneeId?: number; 376 | notifiedUserId?: number[]; 377 | attachmentId?: number[]; 378 | } 379 | interface PatchPullRequestParams { 380 | summary?: string; 381 | description?: string; 382 | issueId?: number; 383 | assigneeId?: number; 384 | notifiedUserId?: number[]; 385 | comment?: string[]; 386 | } 387 | interface GetPullRequestCommentsParams { 388 | minId?: number; 389 | maxId?: number; 390 | count?: number; 391 | order?: Order; 392 | } 393 | interface PostPullRequestCommentsParams { 394 | content: string; 395 | notifiedUserId?: number[]; 396 | } 397 | interface PatchPullRequestCommentsParams { 398 | content: string; 399 | } 400 | } 401 | export declare namespace Wiki { 402 | interface GetWikiParams { 403 | projectIdOrKey: string | number; 404 | keyword?: string; 405 | } 406 | interface PostWikiParams { 407 | projectId: number; 408 | name: string; 409 | content: string; 410 | mailNotify?: boolean; 411 | } 412 | interface PatchWikiParams { 413 | name?: string; 414 | content?: string; 415 | mailNotify?: boolean; 416 | } 417 | interface GetWikisHistoryParams { 418 | minId?: number; 419 | maxId?: number; 420 | count?: number; 421 | order?: Order; 422 | } 423 | } 424 | export declare namespace OAuth2 { 425 | interface Credentials { 426 | clientId: string; 427 | clientSecret: string; 428 | } 429 | } 430 | -------------------------------------------------------------------------------- /src/option.ts: -------------------------------------------------------------------------------- 1 | import * as Types from "./types"; 2 | 3 | export type Order = "asc" | "desc"; 4 | 5 | export namespace Notification { 6 | 7 | export interface GetNotificationsParams { 8 | minId?: number; 9 | maxId?: number; 10 | count?: number; 11 | order?: Order; 12 | } 13 | 14 | export interface GetNotificationsCountParams { 15 | alreadyRead: boolean; 16 | resourceAlreadyRead: boolean; 17 | } 18 | 19 | } 20 | 21 | export declare namespace Document { 22 | interface GetDocumentsParams { 23 | projectId?: number[]; 24 | keyword?: string; 25 | sort?: "created" | "updated"; 26 | order?: Order; 27 | offset: number; 28 | count?: number; 29 | } 30 | } 31 | 32 | export namespace Space { 33 | 34 | export interface GetActivitiesParams { 35 | activityTypeId?: Types.ActivityType[]; 36 | minId?: number; 37 | maxId?: number; 38 | count?: number; 39 | order?: Order; 40 | } 41 | 42 | export interface PutSpaceNotificationParams { 43 | content: string; 44 | } 45 | 46 | } 47 | 48 | export namespace User { 49 | 50 | export interface PostUserParams { 51 | userId: string; 52 | password: string; 53 | name: string; 54 | mailAddress: string; 55 | roleType: Types.RoleType; 56 | } 57 | 58 | export interface PatchUserParams { 59 | password?: string; 60 | name?: string; 61 | mailAddress?: string; 62 | roleType?: Types.RoleType; 63 | } 64 | 65 | export interface GetUserActivitiesParams { 66 | activityTypeId?: Types.ActivityType[]; 67 | minId?: number; 68 | maxId?: number; 69 | count?: number; 70 | order?: Order; 71 | } 72 | 73 | export interface GetUserStarsParams { 74 | minId?: number; 75 | maxId?: number; 76 | count?: number; 77 | order?: Order; 78 | } 79 | 80 | export interface GetUserStarsCountParams { 81 | since?: string; 82 | until?: string; 83 | } 84 | 85 | export interface GetRecentlyViewedParams { 86 | order?: Order; 87 | offset?: number; 88 | count?: number; 89 | } 90 | 91 | } 92 | 93 | export namespace WatchingList { 94 | 95 | export interface GetWatchingListParams { 96 | order?: Order; 97 | sort?: "created" | "updated" | "issueUpdated"; 98 | count?: number; 99 | offset?: number; 100 | resourceAlreadyRead?: boolean; 101 | issueId?: number[]; 102 | } 103 | 104 | export interface GetWatchingListCountParams { 105 | resourceAlreadyRead?: boolean; 106 | alreadyRead?: boolean; 107 | } 108 | 109 | export interface PostWatchingListItemParams { 110 | issueIdOrKey: string | number; 111 | note: string; 112 | } 113 | } 114 | 115 | export namespace Team { 116 | 117 | export interface GetTeamsParams { 118 | order?: Order; 119 | offset?: number; 120 | count?: number; 121 | } 122 | 123 | export interface PostTeamParams { 124 | name: string; 125 | members?: number[]; 126 | } 127 | 128 | export interface PatchTeamParams { 129 | name?: string; 130 | members?: number[]; 131 | } 132 | 133 | } 134 | 135 | export namespace Project { 136 | 137 | export interface PostProjectParams { 138 | name: string; 139 | key: string; 140 | chartEnabled: boolean; 141 | projectLeaderCanEditProjectLeader?: boolean; 142 | subtaskingEnabled: boolean; 143 | textFormattingRule: Types.TextFormattingRule; 144 | } 145 | 146 | export interface PatchProjectParams { 147 | name?: string; 148 | key?: string; 149 | chartEnabled?: boolean; 150 | subtaskingEnabled?: boolean; 151 | projectLeaderCanEditProjectLeader?: boolean; 152 | textFormattingRule?: Types.TextFormattingRule; 153 | archived?: boolean; 154 | } 155 | 156 | export interface GetProjectsParams { 157 | archived?: boolean; 158 | all?: boolean; 159 | } 160 | 161 | export interface DeleteProjectUsersParams { 162 | userId: number; 163 | } 164 | 165 | export interface PostProjectAdministrators { 166 | userId: number; 167 | } 168 | 169 | export interface DeleteProjectAdministrators { 170 | userId: number; 171 | } 172 | 173 | export interface PostIssueTypeParams { 174 | name: string; 175 | color: Types.IssueTypeColor; 176 | } 177 | 178 | export interface PatchIssueTypeParams { 179 | name?: string; 180 | color?: Types.IssueTypeColor; 181 | } 182 | 183 | export interface DeleteIssueTypeParams { 184 | substituteIssueTypeId: number; 185 | } 186 | 187 | export interface PostCategoriesParams { 188 | name: string; 189 | } 190 | 191 | export interface PatchCategoriesParams { 192 | name: string; 193 | } 194 | 195 | export interface PostVersionsParams { 196 | name: string; 197 | description?: string; 198 | startDate?: string; 199 | releaseDueDate?: string; 200 | } 201 | 202 | export interface PatchVersionsParams { 203 | name: string; 204 | description?: string; 205 | startDate?: string; 206 | releaseDueDate?: string; 207 | archived?: boolean; 208 | } 209 | 210 | export interface PostCustomFieldParams { 211 | typeId: Types.CustomFieldType; 212 | name: string; 213 | applicableIssueTypes?: number[]; 214 | description?: string; 215 | required?: boolean; 216 | } 217 | 218 | export interface PostCustomFieldWithNumericParams extends PostCustomFieldParams { 219 | min?: number; 220 | max?: number; 221 | initialValue?: number; 222 | unit?: string; 223 | } 224 | 225 | export interface PostCustomFieldWithDateParams extends PostCustomFieldParams { 226 | min?: string; 227 | max?: string; 228 | initialValueType?: number; 229 | initialDate?: string; 230 | initialShift?: number; 231 | } 232 | 233 | export interface PostCustomFieldWithListParams extends PostCustomFieldParams { 234 | items?: string[]; 235 | allowInput?: boolean; 236 | allowAddItem?: boolean; 237 | } 238 | 239 | export interface PatchCustomFieldParams { 240 | name?: string; 241 | applicableIssueTypes?: number[]; 242 | description?: string; 243 | required?: boolean; 244 | } 245 | 246 | export interface PatchCustomFieldWithNumericParams extends PatchCustomFieldParams { 247 | min?: number; 248 | max?: number; 249 | initialValue?: number; 250 | unit?: string; 251 | } 252 | 253 | export interface PatchCustomFieldWithDateParams extends PatchCustomFieldParams { 254 | min?: string; 255 | max?: string; 256 | initialValueType?: number; 257 | initialDate?: string; 258 | initialShift?: number; 259 | } 260 | 261 | export interface PatchCustomFieldWithListParams extends PatchCustomFieldParams { 262 | items?: string[]; 263 | allowInput?: boolean; 264 | allowAddItem?: boolean; 265 | } 266 | 267 | export interface PostCustomFieldItemParams { 268 | name: string; 269 | } 270 | 271 | export interface PatchCustomFieldItemParams { 272 | name: string; 273 | } 274 | 275 | export interface GetSharedFilesParams { 276 | order?: Order; 277 | offset?: number; 278 | count?: number; 279 | } 280 | 281 | export interface PostWebhookParams { 282 | name?: string; 283 | description?: string; 284 | hookUrl?: string; 285 | allEvent?: boolean; 286 | activityTypeIds?: Types.WebhookActivityId[]; 287 | } 288 | 289 | export interface PatchWebhookParams { 290 | name?: string; 291 | description?: string; 292 | hookUrl?: string; 293 | allEvent?: boolean; 294 | activityTypeIds?: number[]; 295 | } 296 | 297 | export interface PostStarParams { 298 | issueId?: number; 299 | commentId?: number; 300 | wikiId?: number; 301 | pullRequestId?: number; 302 | pullRequestCommentId?: number; 303 | } 304 | 305 | export interface PostStatusParams { 306 | name: string; 307 | color: Types.ProjectStatusColor; 308 | } 309 | 310 | export interface PatchStatusParams { 311 | name?: string; 312 | color?: Types.ProjectStatusColor; 313 | } 314 | 315 | } 316 | 317 | export namespace Issue { 318 | 319 | export interface PostIssueParams { 320 | projectId: number; 321 | summary: string; 322 | priorityId: number; 323 | issueTypeId: number; 324 | parentIssueId?: number; 325 | description?: string; 326 | startDate?: string; 327 | dueDate?: string; 328 | estimatedHours?: number; 329 | actualHours?: number; 330 | categoryId?: number[]; 331 | versionId?: number[]; 332 | milestoneId?: number[]; 333 | assigneeId?: number; 334 | notifiedUserId?: number[]; 335 | attachmentId?: number[]; 336 | [customField_: string]: any; 337 | } 338 | 339 | export interface PatchIssueParams { 340 | summary?: string; 341 | parentIssueId?: number; 342 | description?: string; 343 | statusId?: number; 344 | resolutionId?: number; 345 | startDate?: string; 346 | dueDate?: string; 347 | estimatedHours?: number; 348 | actualHours?: number; 349 | issueTypeId?: number; 350 | categoryId?: number[]; 351 | versionId?: number[]; 352 | milestoneId?: number[]; 353 | priorityId?: number; 354 | assigneeId?: number; 355 | notifiedUserId?: number[]; 356 | attachmentId?: number[]; 357 | comment?: string; 358 | [customField_: string]: any; 359 | } 360 | 361 | export interface GetIssuesParams { 362 | projectId?: number[]; 363 | issueTypeId?: number[]; 364 | categoryId?: number[]; 365 | versionId?: number[]; 366 | milestoneId?: number[]; 367 | statusId?: number[]; 368 | priorityId?: number[]; 369 | assigneeId?: number[]; 370 | createdUserId?: number[]; 371 | resolutionId?: number[]; 372 | parentChild?: ParentChildType; 373 | attachment?: boolean; 374 | sharedFile?: boolean; 375 | sort?: SortKey; 376 | order?: Order; 377 | offset?: number; 378 | count?: number; 379 | createdSince?: string; 380 | createdUntil?: string; 381 | updatedSince?: string; 382 | updatedUntil?: string; 383 | startDateSince?: string; 384 | startDateUntil?: string; 385 | dueDateSince?: string; 386 | dueDateUntil?: string; 387 | hasDueDate?: boolean; 388 | id?: number[]; 389 | parentIssueId?: number[]; 390 | keyword?: string; 391 | [customField_: string]: any; 392 | } 393 | 394 | export enum ParentChildType { 395 | All = 0, NotChild = 1, Child = 2, NotChildNotParent = 3, Parent = 4 396 | } 397 | 398 | export type SortKey = 399 | "issueType" | 400 | "category" | 401 | "version" | 402 | "milestone" | 403 | "summary" | 404 | "status" | 405 | "priority" | 406 | "attachment" | 407 | "sharedFile" | 408 | "created" | 409 | "createdUser" | 410 | "updated" | 411 | "updatedUser" | 412 | "assignee" | 413 | "startDate" | 414 | "dueDate" | 415 | "estimatedHours" | 416 | "actualHours" | 417 | "childIssue"; 418 | 419 | export interface GetIssueCommentsParams { 420 | minId?: number; 421 | maxId?: number; 422 | count?: number; 423 | order?: Order; 424 | } 425 | 426 | export interface PostIssueCommentsParams { 427 | content: string; 428 | notifiedUserId?: number[]; 429 | attachmentId?: number[]; 430 | } 431 | 432 | export interface PatchIssueCommentParams { 433 | content: string; 434 | } 435 | 436 | export interface IssueCommentNotifications { 437 | notifiedUserId: number[]; 438 | } 439 | 440 | export interface LinkIssueSharedFilesParams { 441 | fileId: number[]; 442 | } 443 | 444 | } 445 | 446 | export namespace PullRequest { 447 | 448 | export interface GetPullRequestsParams { 449 | statusId?: number[]; 450 | assigneeId?: number[]; 451 | issueId?: number[]; 452 | createdUserId?: number[]; 453 | offset?: number; 454 | count?: number; 455 | } 456 | 457 | export interface PostPullRequestParams { 458 | summary: string; 459 | description: string; 460 | base: string; 461 | branch: string; 462 | issueId?: number; 463 | assigneeId?: number; 464 | notifiedUserId?: number[]; 465 | attachmentId?: number[]; 466 | } 467 | 468 | export interface PatchPullRequestParams { 469 | summary?: string; 470 | description?: string; 471 | issueId?: number; 472 | assigneeId?: number; 473 | notifiedUserId?: number[]; 474 | comment?: string[]; 475 | } 476 | 477 | export interface GetPullRequestCommentsParams { 478 | minId?: number; 479 | maxId?: number; 480 | count?: number; 481 | order?: Order; 482 | } 483 | 484 | export interface PostPullRequestCommentsParams { 485 | content: string; 486 | notifiedUserId?: number[]; 487 | } 488 | 489 | export interface PatchPullRequestCommentsParams { 490 | content: string; 491 | } 492 | 493 | } 494 | 495 | export namespace Wiki { 496 | 497 | export interface GetWikiParams { 498 | projectIdOrKey: string | number; 499 | keyword?: string; 500 | } 501 | 502 | export interface PostWikiParams { 503 | projectId: number; 504 | name: string; 505 | content: string; 506 | mailNotify?: boolean; 507 | } 508 | 509 | export interface PatchWikiParams { 510 | name?: string; 511 | content?: string; 512 | mailNotify?: boolean; 513 | } 514 | 515 | export interface GetWikisHistoryParams { 516 | minId?: number; 517 | maxId?: number; 518 | count?: number; 519 | order?: Order; 520 | } 521 | 522 | } 523 | 524 | export namespace OAuth2 { 525 | 526 | export interface Credentials { 527 | clientId: string; 528 | clientSecret: string; 529 | } 530 | 531 | } 532 | -------------------------------------------------------------------------------- /src/entity.ts: -------------------------------------------------------------------------------- 1 | import { PassThrough } from 'stream'; 2 | import * as Types from "./types"; 3 | 4 | export namespace File { 5 | 6 | export type FileData = NodeFileData | BrowserFileData; 7 | 8 | export interface NodeFileData { 9 | body: PassThrough, 10 | url: string, 11 | filename: string 12 | } 13 | 14 | export interface BrowserFileData { 15 | body: any, 16 | url: string, 17 | blob?: () => Promise 18 | } 19 | 20 | export interface FileInfo { 21 | id: number; 22 | name: string; 23 | size: number; 24 | } 25 | 26 | export interface IssueFileInfo extends FileInfo { 27 | createdUser: User.User; 28 | created: string; 29 | } 30 | 31 | export interface WikiFileInfo extends FileInfo { 32 | createdUser: User.User; 33 | created: string; 34 | } 35 | 36 | export interface PullRequestFileInfo extends FileInfo { 37 | createdUser: User.User; 38 | created: string; 39 | } 40 | 41 | export interface DocumentFileInfo extends FileInfo { 42 | createdUser: User.User; 43 | created: string; 44 | } 45 | } 46 | 47 | export namespace OAuth2 { 48 | 49 | export interface AccessToken { 50 | access_token: string; 51 | token_type: string; 52 | expires_in: number; 53 | refresh_token: string; 54 | } 55 | } 56 | 57 | export namespace Space { 58 | 59 | export interface Space { 60 | spaceKey: string; 61 | name: string; 62 | ownerId: number; 63 | lang: string; 64 | timezone: string; 65 | reportSendTime: string; 66 | textFormattingRule: Types.TextFormattingRule; 67 | created: string; 68 | updated: string; 69 | } 70 | 71 | export interface Notification { 72 | content: string; 73 | updated: string; 74 | } 75 | } 76 | 77 | export namespace Project { 78 | export interface Project { 79 | id: number; 80 | projectKey: string; 81 | name: string; 82 | chartEnabled: boolean; 83 | useResolvedForChart: boolean; 84 | subtaskingEnabled: boolean; 85 | projectLeaderCanEditProjectLeader: boolean; 86 | useWiki: boolean; 87 | useFileSharing: boolean; 88 | useWikiTreeView: boolean; 89 | useOriginalImageSizeAtWiki: boolean; 90 | useSubversion: boolean; 91 | useGit: boolean; 92 | textFormattingRule: Types.TextFormattingRule; 93 | archived: boolean; 94 | displayOrder: number; 95 | useDevAttributes: boolean; 96 | } 97 | 98 | export interface RecentlyViewedProject { 99 | project: Project; 100 | updated: string; 101 | } 102 | 103 | export interface ProjectStatus { 104 | id: number; 105 | projectId: number; 106 | name: string; 107 | color: Types.ProjectStatusColor; 108 | displayOrder: number; 109 | } 110 | 111 | export interface Category { 112 | id: number; 113 | projectId: number; 114 | name: string; 115 | displayOrder: number; 116 | } 117 | 118 | export interface Version { 119 | id: number; 120 | projectId: number; 121 | name: string; 122 | description?: string; 123 | startDate?: string; 124 | releaseDueDate?: string; 125 | archived: boolean; 126 | displayOrder: number; 127 | } 128 | 129 | export interface CustomField { 130 | id: number; 131 | projectId: number; 132 | typeId: Types.CustomFieldType; 133 | name: string; 134 | description: string; 135 | required: boolean; 136 | applicableIssueTypes: number[]; 137 | 138 | [key: string]: any; // Depends on `typeId`. 139 | } 140 | 141 | export interface SharedFile { 142 | id: number; 143 | projectId: number; 144 | type: string; 145 | dir: string; 146 | name: string; 147 | size: number; 148 | createdUser: User.User; 149 | created: string; 150 | updatedUser: User.User; 151 | updated: string; 152 | } 153 | } 154 | 155 | export namespace User { 156 | export interface User { 157 | id: number; 158 | userId: string; 159 | name: string; 160 | roleType: Types.RoleType; 161 | lang: Types.Language; 162 | mailAddress: string; 163 | lastLoginTime: string; 164 | } 165 | } 166 | 167 | export namespace Activity { 168 | export interface Activity { 169 | id: number; 170 | project: Project.Project; 171 | type: Types.ActivityType; 172 | content: any; // Depends on `type`. 173 | notifications: []; // Always an empty array. https://nulab.com/release-notes/backlog/backlog-will-changes-to-the-get-recent-updates-apis/ 174 | createdUser: User.User; 175 | created: string; 176 | } 177 | } 178 | 179 | export namespace DiskUsage { 180 | export interface DiskUsage { 181 | issue: number; 182 | wiki: number; 183 | file: number; 184 | subversion: number; 185 | git: number; 186 | gitLFS: number; 187 | } 188 | 189 | export interface ProjectDiskUsage extends DiskUsage { 190 | projectId: number; 191 | } 192 | 193 | export interface SpaceDiskUsage extends DiskUsage { 194 | capacity: number; 195 | details: ProjectDiskUsage[]; 196 | } 197 | } 198 | 199 | export namespace CommentNotification { 200 | export interface CommentNotification { 201 | id: number; 202 | alreadyRead: boolean; 203 | reason: number; 204 | user: User.User; 205 | resourceAlreadyRead: boolean; 206 | } 207 | } 208 | 209 | export namespace Document { 210 | export interface Document { 211 | id: string; 212 | projectId: number; 213 | title: string; 214 | plain: string; 215 | json: string; 216 | statusId: number; 217 | emoji: string | null; 218 | attachments: File.DocumentFileInfo[]; 219 | tags: Tag[]; 220 | createdUser: User.User; 221 | created: string; 222 | updatedUser: User.User; 223 | updated: string; 224 | } 225 | 226 | export interface Tag { 227 | id: number; 228 | name: string; 229 | } 230 | 231 | export interface ActiveTrashTree { 232 | id: string; 233 | children: DocumentTreeNode[]; 234 | } 235 | 236 | export interface DocumentTreeNode { 237 | id: string; 238 | name?: string; 239 | children: DocumentTreeNode[]; 240 | statusId?: number 241 | emoji?: string; 242 | emojiType?: string; 243 | updated?: string; 244 | } 245 | 246 | export interface DocumentTree { 247 | projectId: string; 248 | activeTree?: ActiveTrashTree; 249 | trashTree?: ActiveTrashTree; 250 | } 251 | } 252 | 253 | export namespace Issue { 254 | export interface IssueType { 255 | id: number; 256 | projectId: number; 257 | name: string; 258 | color: Types.IssueTypeColor; 259 | displayOrder: number; 260 | templateSummary?: string; 261 | templateDescription?: string; 262 | } 263 | 264 | export interface Priority { 265 | id: number; 266 | name: string; 267 | } 268 | 269 | export interface Resolution { 270 | id: number; 271 | name: string; 272 | } 273 | 274 | export interface Issue { 275 | id: number; 276 | projectId: number; 277 | issueKey: string; 278 | keyId: number; 279 | issueType: IssueType; 280 | summary: string; 281 | description: string; 282 | resolution?: Resolution; 283 | priority: Priority; 284 | status: Project.ProjectStatus; 285 | assignee?: User.User; 286 | category: Project.Category[]; 287 | versions: Project.Version[]; 288 | milestone: Project.Version[]; 289 | startDate?: string; 290 | dueDate?: string; 291 | estimatedHours?: number; 292 | actualHours?: number; 293 | parentIssueId?: number; 294 | createdUser: User.User; 295 | created: string; 296 | updatedUser: User.User; 297 | updated: string; 298 | customFields: Project.CustomField[]; 299 | attachments: File.IssueFileInfo[]; 300 | sharedFiles: Project.SharedFile[]; 301 | stars: Star.Star[]; 302 | } 303 | 304 | export interface RecentlyViewedIssue { 305 | issue: Issue; 306 | updated: string; 307 | } 308 | 309 | export interface IssueCount { 310 | count: number; 311 | } 312 | 313 | export interface IssueCommentCount { 314 | count: number; 315 | } 316 | 317 | export interface Comment { 318 | id: number; 319 | projectId: number; 320 | issueId: number; 321 | content: string; 322 | changeLog: ChangeLog.IssueChangeLog[]; 323 | createdUser: User.User; 324 | created: string; 325 | updated: string; 326 | stars: Star.Star[]; 327 | notifications: CommentNotification.CommentNotification[]; 328 | } 329 | } 330 | 331 | export namespace Star { 332 | export interface Star { 333 | id: number; 334 | comment?: string; 335 | url: string; 336 | title: string; 337 | presenter: User.User; 338 | created: string; 339 | } 340 | 341 | export interface StarCount { 342 | count: number; 343 | } 344 | } 345 | 346 | export namespace Wiki { 347 | export interface Tag { 348 | id: number; 349 | name: string; 350 | } 351 | 352 | export interface History { 353 | pageId: number; 354 | version: number; 355 | name: string; 356 | content: string; 357 | createdUser: User.User; 358 | created: string; 359 | } 360 | 361 | export interface WikiListItem { 362 | id: number; 363 | projectId: number; 364 | name: string; 365 | tags: Tag[]; 366 | createdUser: User.User; 367 | created: string; 368 | updatedUser: User.User; 369 | updated: string; 370 | } 371 | 372 | export interface Wiki { 373 | id: number; 374 | projectId: number; 375 | name: string; 376 | content: string; 377 | tags: Tag[]; 378 | attachments: File.WikiFileInfo[]; 379 | sharedFiles: Project.SharedFile[]; 380 | stars: Star.Star[]; 381 | createdUser: User.User; 382 | created: string; 383 | updatedUser: User.User; 384 | updated: string; 385 | } 386 | 387 | export interface RecentlyViewedWiki { 388 | page: WikiListItem; 389 | updated: string; 390 | } 391 | 392 | export interface WikiCount { 393 | count: number; 394 | } 395 | } 396 | 397 | export namespace PullRequest { 398 | export interface Status { 399 | id: number; 400 | name: string; 401 | } 402 | 403 | export interface PullRequest { 404 | id: number; 405 | projectId: number; 406 | repositoryId: number; 407 | number: number; 408 | summary: string; 409 | description: string; 410 | base: string; 411 | branch: string; 412 | status: Status; 413 | assignee?: User.User; 414 | issue: Issue.Issue; 415 | baseCommit?: string; 416 | branchCommit?: string; 417 | mergeCommit?: string; 418 | closeAt?: string; 419 | mergeAt?: string; 420 | createdUser: User.User; 421 | created: string; 422 | updatedUser: User.User; 423 | updated: string; 424 | attachments: File.PullRequestFileInfo[]; 425 | stars: Star.Star[]; 426 | } 427 | 428 | export interface Comment { 429 | id: number; 430 | content: string; 431 | changeLog: ChangeLog.PullRequestChangeLog[] 432 | createdUser: User.User; 433 | created: string; 434 | updated: string; 435 | stars: Star.Star[]; 436 | notifications: CommentNotification.CommentNotification[]; 437 | } 438 | 439 | export interface PullRequestCount { 440 | count: number; 441 | } 442 | 443 | export interface PullRequestCommentCount { 444 | count: number; 445 | } 446 | } 447 | 448 | export namespace ChangeLog { 449 | export interface ChangeLog { 450 | field: string; 451 | newValue: string; 452 | originalValue: string; 453 | } 454 | 455 | export interface AttachmentInfo { 456 | id: number; 457 | type: string; 458 | } 459 | 460 | export interface AttributeInfo { 461 | id: number; 462 | typeId: number; 463 | } 464 | 465 | export interface NotificationInfo { 466 | type: string; 467 | } 468 | 469 | export interface IssueChangeLog extends ChangeLog { 470 | attachmentInfo: AttachmentInfo; 471 | attributeInfo: AttributeInfo; 472 | notificationInfo: NotificationInfo; 473 | } 474 | 475 | export type PullRequestChangeLog = ChangeLog; 476 | } 477 | 478 | export namespace Git { 479 | export interface GitRepository { 480 | id: number; 481 | projectId: number; 482 | name: string; 483 | description: string; 484 | hookUrl?: string; 485 | httpUrl: string; 486 | sshUrl: string; 487 | displayOrder: number; 488 | pushedAt?: string; 489 | createdUser: User.User; 490 | created: string; 491 | updatedUser: User.User; 492 | updated: string; 493 | } 494 | } 495 | 496 | export namespace WatchingList { 497 | export interface WatchingListItem { 498 | id: number; 499 | resourceAlreadyRead: boolean; 500 | note: string; 501 | type: string; 502 | issue: Issue.Issue; 503 | lastContentUpdated: string; 504 | created: string; 505 | updated: string; 506 | } 507 | 508 | export interface WatchingListCount { 509 | count: number; 510 | } 511 | } 512 | 513 | export namespace Team { 514 | export interface Team { 515 | id: number; 516 | name: string; 517 | members: User.User[]; 518 | displayOrder?: number; 519 | createdUser: User.User; 520 | created: string; 521 | updatedUser: User.User; 522 | updated: string; 523 | } 524 | } 525 | 526 | export namespace Notification { 527 | export interface Notification { 528 | id: number; 529 | alreadyRead: boolean; 530 | reason: number; 531 | resourceAlreadyRead: boolean; 532 | project: Project.Project; 533 | issue?: Issue.Issue; 534 | comment?: Issue.Comment; 535 | pullRequest?: PullRequest.PullRequest; 536 | pullRequestComment?: PullRequest.Comment; 537 | sender: User.User; 538 | created: string; 539 | } 540 | 541 | export interface NotificationCount { 542 | count: number; 543 | } 544 | } 545 | 546 | export namespace Webhook { 547 | export interface Webhook { 548 | id: number; 549 | name: string; 550 | description: string; 551 | hookUrl: string; 552 | allEvent: boolean; 553 | activityTypeIds: Types.WebhookActivityId[]; 554 | createdUser: User.User; 555 | created: string; 556 | updatedUser: User.User; 557 | updated: string; 558 | } 559 | } 560 | 561 | export namespace License { 562 | export interface License { 563 | active: boolean; 564 | attachmentLimit: number; 565 | attachmentLimitPerFile: number; 566 | attachmentNumLimit: number; 567 | attribute: boolean; 568 | attributeLimit: number; 569 | burndown: boolean; 570 | commentLimit: number; 571 | componentLimit: number; 572 | fileSharing: boolean; 573 | gantt: boolean; 574 | git: boolean; 575 | issueLimit: number; 576 | licenceTypeId: number; 577 | limitDate: string; 578 | nulabAccount: boolean; 579 | parentChildIssue: boolean; 580 | postIssueByMail: boolean; 581 | projectLimit: number; 582 | pullRequestAttachmentLimitPerFile: number; 583 | pullRequestAttachmentNumLimit: number; 584 | remoteAddress: boolean; 585 | remoteAddressLimit: number; 586 | startedOn: string; 587 | storageLimit: number; 588 | subversion: boolean; 589 | subversionExternal: boolean; 590 | userLimit: number; 591 | versionLimit: number; 592 | wikiAttachment: boolean; 593 | wikiAttachmentLimitPerFile: number; 594 | wikiAttachmentNumLimit: number; 595 | } 596 | } 597 | 598 | export namespace RateLimit { 599 | export interface RateLimit { 600 | rateLimit: ApiRateLimits; 601 | } 602 | 603 | export interface ApiRateLimits { 604 | read: ApiRateLimit; 605 | update: ApiRateLimit; 606 | search: ApiRateLimit; 607 | icon: ApiRateLimit; 608 | } 609 | 610 | export interface ApiRateLimit { 611 | limit: number; 612 | remaining: number; 613 | reset: number; 614 | } 615 | } 616 | -------------------------------------------------------------------------------- /dist/types/entity.d.ts: -------------------------------------------------------------------------------- 1 | import { PassThrough } from 'stream'; 2 | import * as Types from "./types"; 3 | export declare namespace File { 4 | type FileData = NodeFileData | BrowserFileData; 5 | interface NodeFileData { 6 | body: PassThrough; 7 | url: string; 8 | filename: string; 9 | } 10 | interface BrowserFileData { 11 | body: any; 12 | url: string; 13 | blob?: () => Promise; 14 | } 15 | interface FileInfo { 16 | id: number; 17 | name: string; 18 | size: number; 19 | } 20 | interface IssueFileInfo extends FileInfo { 21 | createdUser: User.User; 22 | created: string; 23 | } 24 | interface WikiFileInfo extends FileInfo { 25 | createdUser: User.User; 26 | created: string; 27 | } 28 | interface PullRequestFileInfo extends FileInfo { 29 | createdUser: User.User; 30 | created: string; 31 | } 32 | interface DocumentFileInfo extends FileInfo { 33 | createdUser: User.User; 34 | created: string; 35 | } 36 | } 37 | export declare namespace OAuth2 { 38 | interface AccessToken { 39 | access_token: string; 40 | token_type: string; 41 | expires_in: number; 42 | refresh_token: string; 43 | } 44 | } 45 | export declare namespace Space { 46 | interface Space { 47 | spaceKey: string; 48 | name: string; 49 | ownerId: number; 50 | lang: string; 51 | timezone: string; 52 | reportSendTime: string; 53 | textFormattingRule: Types.TextFormattingRule; 54 | created: string; 55 | updated: string; 56 | } 57 | interface Notification { 58 | content: string; 59 | updated: string; 60 | } 61 | } 62 | export declare namespace Project { 63 | interface Project { 64 | id: number; 65 | projectKey: string; 66 | name: string; 67 | chartEnabled: boolean; 68 | useResolvedForChart: boolean; 69 | subtaskingEnabled: boolean; 70 | projectLeaderCanEditProjectLeader: boolean; 71 | useWiki: boolean; 72 | useFileSharing: boolean; 73 | useWikiTreeView: boolean; 74 | useOriginalImageSizeAtWiki: boolean; 75 | useSubversion: boolean; 76 | useGit: boolean; 77 | textFormattingRule: Types.TextFormattingRule; 78 | archived: boolean; 79 | displayOrder: number; 80 | useDevAttributes: boolean; 81 | } 82 | interface RecentlyViewedProject { 83 | project: Project; 84 | updated: string; 85 | } 86 | interface ProjectStatus { 87 | id: number; 88 | projectId: number; 89 | name: string; 90 | color: Types.ProjectStatusColor; 91 | displayOrder: number; 92 | } 93 | interface Category { 94 | id: number; 95 | projectId: number; 96 | name: string; 97 | displayOrder: number; 98 | } 99 | interface Version { 100 | id: number; 101 | projectId: number; 102 | name: string; 103 | description?: string; 104 | startDate?: string; 105 | releaseDueDate?: string; 106 | archived: boolean; 107 | displayOrder: number; 108 | } 109 | interface CustomField { 110 | id: number; 111 | projectId: number; 112 | typeId: Types.CustomFieldType; 113 | name: string; 114 | description: string; 115 | required: boolean; 116 | applicableIssueTypes: number[]; 117 | [key: string]: any; 118 | } 119 | interface SharedFile { 120 | id: number; 121 | projectId: number; 122 | type: string; 123 | dir: string; 124 | name: string; 125 | size: number; 126 | createdUser: User.User; 127 | created: string; 128 | updatedUser: User.User; 129 | updated: string; 130 | } 131 | } 132 | export declare namespace User { 133 | interface User { 134 | id: number; 135 | userId: string; 136 | name: string; 137 | roleType: Types.RoleType; 138 | lang: Types.Language; 139 | mailAddress: string; 140 | lastLoginTime: string; 141 | } 142 | } 143 | export declare namespace Activity { 144 | interface Activity { 145 | id: number; 146 | project: Project.Project; 147 | type: Types.ActivityType; 148 | content: any; 149 | notifications: []; 150 | createdUser: User.User; 151 | created: string; 152 | } 153 | } 154 | export declare namespace DiskUsage { 155 | interface DiskUsage { 156 | issue: number; 157 | wiki: number; 158 | file: number; 159 | subversion: number; 160 | git: number; 161 | gitLFS: number; 162 | } 163 | interface ProjectDiskUsage extends DiskUsage { 164 | projectId: number; 165 | } 166 | interface SpaceDiskUsage extends DiskUsage { 167 | capacity: number; 168 | details: ProjectDiskUsage[]; 169 | } 170 | } 171 | export declare namespace CommentNotification { 172 | interface CommentNotification { 173 | id: number; 174 | alreadyRead: boolean; 175 | reason: number; 176 | user: User.User; 177 | resourceAlreadyRead: boolean; 178 | } 179 | } 180 | export declare namespace Document { 181 | interface Document { 182 | id: string; 183 | projectId: number; 184 | title: string; 185 | plain: string; 186 | json: string; 187 | statusId: number; 188 | emoji: string | null; 189 | attachments: File.DocumentFileInfo[]; 190 | tags: Tag[]; 191 | createdUser: User.User; 192 | created: string; 193 | updatedUser: User.User; 194 | updated: string; 195 | } 196 | interface Tag { 197 | id: number; 198 | name: string; 199 | } 200 | interface ActiveTrashTree { 201 | id: string; 202 | children: DocumentTreeNode[]; 203 | } 204 | interface DocumentTreeNode { 205 | id: string; 206 | name?: string; 207 | children: DocumentTreeNode[]; 208 | statusId?: number; 209 | emoji?: string; 210 | emojiType?: string; 211 | updated?: string; 212 | } 213 | interface DocumentTree { 214 | projectId: string; 215 | activeTree?: ActiveTrashTree; 216 | trashTree?: ActiveTrashTree; 217 | } 218 | } 219 | export declare namespace Issue { 220 | interface IssueType { 221 | id: number; 222 | projectId: number; 223 | name: string; 224 | color: Types.IssueTypeColor; 225 | displayOrder: number; 226 | templateSummary?: string; 227 | templateDescription?: string; 228 | } 229 | interface Priority { 230 | id: number; 231 | name: string; 232 | } 233 | interface Resolution { 234 | id: number; 235 | name: string; 236 | } 237 | interface Issue { 238 | id: number; 239 | projectId: number; 240 | issueKey: string; 241 | keyId: number; 242 | issueType: IssueType; 243 | summary: string; 244 | description: string; 245 | resolution?: Resolution; 246 | priority: Priority; 247 | status: Project.ProjectStatus; 248 | assignee?: User.User; 249 | category: Project.Category[]; 250 | versions: Project.Version[]; 251 | milestone: Project.Version[]; 252 | startDate?: string; 253 | dueDate?: string; 254 | estimatedHours?: number; 255 | actualHours?: number; 256 | parentIssueId?: number; 257 | createdUser: User.User; 258 | created: string; 259 | updatedUser: User.User; 260 | updated: string; 261 | customFields: Project.CustomField[]; 262 | attachments: File.IssueFileInfo[]; 263 | sharedFiles: Project.SharedFile[]; 264 | stars: Star.Star[]; 265 | } 266 | interface RecentlyViewedIssue { 267 | issue: Issue; 268 | updated: string; 269 | } 270 | interface IssueCount { 271 | count: number; 272 | } 273 | interface IssueCommentCount { 274 | count: number; 275 | } 276 | interface Comment { 277 | id: number; 278 | projectId: number; 279 | issueId: number; 280 | content: string; 281 | changeLog: ChangeLog.IssueChangeLog[]; 282 | createdUser: User.User; 283 | created: string; 284 | updated: string; 285 | stars: Star.Star[]; 286 | notifications: CommentNotification.CommentNotification[]; 287 | } 288 | } 289 | export declare namespace Star { 290 | interface Star { 291 | id: number; 292 | comment?: string; 293 | url: string; 294 | title: string; 295 | presenter: User.User; 296 | created: string; 297 | } 298 | interface StarCount { 299 | count: number; 300 | } 301 | } 302 | export declare namespace Wiki { 303 | interface Tag { 304 | id: number; 305 | name: string; 306 | } 307 | interface History { 308 | pageId: number; 309 | version: number; 310 | name: string; 311 | content: string; 312 | createdUser: User.User; 313 | created: string; 314 | } 315 | interface WikiListItem { 316 | id: number; 317 | projectId: number; 318 | name: string; 319 | tags: Tag[]; 320 | createdUser: User.User; 321 | created: string; 322 | updatedUser: User.User; 323 | updated: string; 324 | } 325 | interface Wiki { 326 | id: number; 327 | projectId: number; 328 | name: string; 329 | content: string; 330 | tags: Tag[]; 331 | attachments: File.WikiFileInfo[]; 332 | sharedFiles: Project.SharedFile[]; 333 | stars: Star.Star[]; 334 | createdUser: User.User; 335 | created: string; 336 | updatedUser: User.User; 337 | updated: string; 338 | } 339 | interface RecentlyViewedWiki { 340 | page: WikiListItem; 341 | updated: string; 342 | } 343 | interface WikiCount { 344 | count: number; 345 | } 346 | } 347 | export declare namespace PullRequest { 348 | interface Status { 349 | id: number; 350 | name: string; 351 | } 352 | interface PullRequest { 353 | id: number; 354 | projectId: number; 355 | repositoryId: number; 356 | number: number; 357 | summary: string; 358 | description: string; 359 | base: string; 360 | branch: string; 361 | status: Status; 362 | assignee?: User.User; 363 | issue: Issue.Issue; 364 | baseCommit?: string; 365 | branchCommit?: string; 366 | mergeCommit?: string; 367 | closeAt?: string; 368 | mergeAt?: string; 369 | createdUser: User.User; 370 | created: string; 371 | updatedUser: User.User; 372 | updated: string; 373 | attachments: File.PullRequestFileInfo[]; 374 | stars: Star.Star[]; 375 | } 376 | interface Comment { 377 | id: number; 378 | content: string; 379 | changeLog: ChangeLog.PullRequestChangeLog[]; 380 | createdUser: User.User; 381 | created: string; 382 | updated: string; 383 | stars: Star.Star[]; 384 | notifications: CommentNotification.CommentNotification[]; 385 | } 386 | interface PullRequestCount { 387 | count: number; 388 | } 389 | interface PullRequestCommentCount { 390 | count: number; 391 | } 392 | } 393 | export declare namespace ChangeLog { 394 | interface ChangeLog { 395 | field: string; 396 | newValue: string; 397 | originalValue: string; 398 | } 399 | interface AttachmentInfo { 400 | id: number; 401 | type: string; 402 | } 403 | interface AttributeInfo { 404 | id: number; 405 | typeId: number; 406 | } 407 | interface NotificationInfo { 408 | type: string; 409 | } 410 | interface IssueChangeLog extends ChangeLog { 411 | attachmentInfo: AttachmentInfo; 412 | attributeInfo: AttributeInfo; 413 | notificationInfo: NotificationInfo; 414 | } 415 | type PullRequestChangeLog = ChangeLog; 416 | } 417 | export declare namespace Git { 418 | interface GitRepository { 419 | id: number; 420 | projectId: number; 421 | name: string; 422 | description: string; 423 | hookUrl?: string; 424 | httpUrl: string; 425 | sshUrl: string; 426 | displayOrder: number; 427 | pushedAt?: string; 428 | createdUser: User.User; 429 | created: string; 430 | updatedUser: User.User; 431 | updated: string; 432 | } 433 | } 434 | export declare namespace WatchingList { 435 | interface WatchingListItem { 436 | id: number; 437 | resourceAlreadyRead: boolean; 438 | note: string; 439 | type: string; 440 | issue: Issue.Issue; 441 | lastContentUpdated: string; 442 | created: string; 443 | updated: string; 444 | } 445 | interface WatchingListCount { 446 | count: number; 447 | } 448 | } 449 | export declare namespace Team { 450 | interface Team { 451 | id: number; 452 | name: string; 453 | members: User.User[]; 454 | displayOrder?: number; 455 | createdUser: User.User; 456 | created: string; 457 | updatedUser: User.User; 458 | updated: string; 459 | } 460 | } 461 | export declare namespace Notification { 462 | interface Notification { 463 | id: number; 464 | alreadyRead: boolean; 465 | reason: number; 466 | resourceAlreadyRead: boolean; 467 | project: Project.Project; 468 | issue?: Issue.Issue; 469 | comment?: Issue.Comment; 470 | pullRequest?: PullRequest.PullRequest; 471 | pullRequestComment?: PullRequest.Comment; 472 | sender: User.User; 473 | created: string; 474 | } 475 | interface NotificationCount { 476 | count: number; 477 | } 478 | } 479 | export declare namespace Webhook { 480 | interface Webhook { 481 | id: number; 482 | name: string; 483 | description: string; 484 | hookUrl: string; 485 | allEvent: boolean; 486 | activityTypeIds: Types.WebhookActivityId[]; 487 | createdUser: User.User; 488 | created: string; 489 | updatedUser: User.User; 490 | updated: string; 491 | } 492 | } 493 | export declare namespace License { 494 | interface License { 495 | active: boolean; 496 | attachmentLimit: number; 497 | attachmentLimitPerFile: number; 498 | attachmentNumLimit: number; 499 | attribute: boolean; 500 | attributeLimit: number; 501 | burndown: boolean; 502 | commentLimit: number; 503 | componentLimit: number; 504 | fileSharing: boolean; 505 | gantt: boolean; 506 | git: boolean; 507 | issueLimit: number; 508 | licenceTypeId: number; 509 | limitDate: string; 510 | nulabAccount: boolean; 511 | parentChildIssue: boolean; 512 | postIssueByMail: boolean; 513 | projectLimit: number; 514 | pullRequestAttachmentLimitPerFile: number; 515 | pullRequestAttachmentNumLimit: number; 516 | remoteAddress: boolean; 517 | remoteAddressLimit: number; 518 | startedOn: string; 519 | storageLimit: number; 520 | subversion: boolean; 521 | subversionExternal: boolean; 522 | userLimit: number; 523 | versionLimit: number; 524 | wikiAttachment: boolean; 525 | wikiAttachmentLimitPerFile: number; 526 | wikiAttachmentNumLimit: number; 527 | } 528 | } 529 | export declare namespace RateLimit { 530 | interface RateLimit { 531 | rateLimit: ApiRateLimits; 532 | } 533 | interface ApiRateLimits { 534 | read: ApiRateLimit; 535 | update: ApiRateLimit; 536 | search: ApiRateLimit; 537 | icon: ApiRateLimit; 538 | } 539 | interface ApiRateLimit { 540 | limit: number; 541 | remaining: number; 542 | reset: number; 543 | } 544 | } 545 | -------------------------------------------------------------------------------- /dist/types/backlog.d.ts: -------------------------------------------------------------------------------- 1 | import * as Option from './option'; 2 | import * as Entity from './entity'; 3 | import Request from './request'; 4 | export default class Backlog extends Request { 5 | constructor(configure: { 6 | host: string; 7 | apiKey?: string; 8 | accessToken?: string; 9 | timeout?: number; 10 | }); 11 | /** 12 | * https://developer.nulab.com/docs/backlog/api/2/get-space/ 13 | */ 14 | getSpace(): Promise; 15 | /** 16 | * https://developer.nulab.com/docs/backlog/api/2/get-recent-updates/ 17 | */ 18 | getSpaceActivities(params: Option.Space.GetActivitiesParams): Promise; 19 | /** 20 | * https://developer.nulab.com/docs/backlog/api/2/get-space-logo/ 21 | */ 22 | getSpaceIcon(): Promise; 23 | /** 24 | * https://developer.nulab.com/docs/backlog/api/2/get-space-notification/ 25 | */ 26 | getSpaceNotification(): Promise; 27 | /** 28 | * https://developer.nulab.com/docs/backlog/api/2/update-space-notification/ 29 | */ 30 | putSpaceNotification(params: Option.Space.PutSpaceNotificationParams): Promise; 31 | /** 32 | * https://developer.nulab.com/docs/backlog/api/2/get-space-disk-usage/ 33 | */ 34 | getSpaceDiskUsage(): Promise; 35 | /** 36 | * https://developer.nulab.com/docs/backlog/api/2/post-attachment-file/ 37 | */ 38 | postSpaceAttachment(form: FormData): Promise; 39 | /** 40 | * https://developer.nulab.com/docs/backlog/api/2/get-user-list/ 41 | */ 42 | getUsers(): Promise; 43 | /** 44 | * https://developer.nulab.com/docs/backlog/api/2/get-user/ 45 | */ 46 | getUser(userId: number): Promise; 47 | /** 48 | * https://developer.nulab.com/docs/backlog/api/2/add-user/ 49 | */ 50 | postUser(params: Option.User.PostUserParams): Promise; 51 | /** 52 | * https://developer.nulab.com/docs/backlog/api/2/update-user/ 53 | */ 54 | patchUser(userId: number, params: Option.User.PatchUserParams): Promise; 55 | /** 56 | * https://developer.nulab.com/docs/backlog/api/2/delete-user/ 57 | */ 58 | deleteUser(userId: number): Promise; 59 | /** 60 | * https://developer.nulab.com/docs/backlog/api/2/get-own-user/ 61 | */ 62 | getMyself(): Promise; 63 | /** 64 | * https://developer.nulab.com/docs/backlog/api/2/get-user-icon/ 65 | */ 66 | getUserIcon(userId: number): Promise; 67 | /** 68 | * https://developer.nulab.com/docs/backlog/api/2/get-user-recent-updates/ 69 | */ 70 | getUserActivities(userId: number, params: Option.User.GetUserActivitiesParams): Promise; 71 | /** 72 | * https://developer.nulab.com/docs/backlog/api/2/get-received-star-list/ 73 | */ 74 | getUserStars(userId: number, params: Option.User.GetUserStarsParams): Promise; 75 | /** 76 | * https://developer.nulab.com/docs/backlog/api/2/count-user-received-stars/ 77 | */ 78 | getUserStarsCount(userId: number, params: Option.User.GetUserStarsCountParams): Promise; 79 | /** 80 | * https://developer.nulab.com/docs/backlog/api/2/get-list-of-recently-viewed-issues/ 81 | */ 82 | getRecentlyViewedIssues(params: Option.User.GetRecentlyViewedParams): Promise; 83 | /** 84 | * https://developer.nulab.com/docs/backlog/api/2/get-list-of-recently-viewed-projects/ 85 | */ 86 | getRecentlyViewedProjects(params: Option.User.GetRecentlyViewedParams): Promise; 87 | /** 88 | * https://developer.nulab.com/docs/backlog/api/2/get-list-of-recently-viewed-wikis/ 89 | */ 90 | getRecentlyViewedWikis(params: Option.User.GetRecentlyViewedParams): Promise; 91 | /** 92 | * https://developer.nulab.com/docs/backlog/api/2/get-status-list-of-project/ 93 | */ 94 | getProjectStatuses(projectIdOrKey: string | number): Promise; 95 | /** 96 | * https://developer.nulab.com/docs/backlog/api/2/get-resolution-list/ 97 | */ 98 | getResolutions(): Promise; 99 | /** 100 | * https://developer.nulab.com/docs/backlog/api/2/get-priority-list/ 101 | */ 102 | getPriorities(): Promise; 103 | /** 104 | * https://developer.nulab.com/docs/backlog/api/2/get-project-list/ 105 | */ 106 | getProjects(params?: Option.Project.GetProjectsParams): Promise; 107 | /** 108 | * https://developer.nulab.com/docs/backlog/api/2/add-project/ 109 | */ 110 | postProject(params: Option.Project.PostProjectParams): Promise; 111 | /** 112 | * https://developer.nulab.com/docs/backlog/api/2/get-project/ 113 | */ 114 | getProject(projectIdOrKey: string | number): Promise; 115 | /** 116 | * https://developer.nulab.com/docs/backlog/api/2/update-project/ 117 | */ 118 | patchProject(projectIdOrKey: string | number, params: Option.Project.PatchProjectParams): Promise; 119 | /** 120 | * https://developer.nulab.com/docs/backlog/api/2/delete-project/ 121 | */ 122 | deleteProject(projectIdOrKey: string | number): Promise; 123 | /** 124 | * https://developer.nulab.com/docs/backlog/api/2/get-project-icon/ 125 | */ 126 | getProjectIcon(projectIdOrKey: string | number): Promise; 127 | /** 128 | * https://developer.nulab.com/docs/backlog/api/2/get-project-recent-updates/ 129 | */ 130 | getProjectActivities(projectIdOrKey: string | number, params: Option.Space.GetActivitiesParams): Promise; 131 | /** 132 | * https://developer.nulab.com/docs/backlog/api/2/add-project-user/ 133 | */ 134 | postProjectUser(projectIdOrKey: string | number, userId: string): Promise; 135 | /** 136 | * https://developer.nulab.com/docs/backlog/api/2/get-project-user-list/ 137 | */ 138 | getProjectUsers(projectIdOrKey: string | number): Promise; 139 | /** 140 | * https://developer.nulab.com/docs/backlog/api/2/delete-project-user/ 141 | */ 142 | deleteProjectUsers(projectIdOrKey: string | number, params: Option.Project.DeleteProjectUsersParams): Promise; 143 | /** 144 | * https://developer.nulab.com/docs/backlog/api/2/add-project-administrator/ 145 | */ 146 | postProjectAdministrators(projectIdOrKey: string | number, params: Option.Project.PostProjectAdministrators): Promise; 147 | /** 148 | * https://developer.nulab.com/docs/backlog/api/2/get-list-of-project-administrators/ 149 | */ 150 | getProjectAdministrators(projectIdOrKey: string | number): Promise; 151 | /** 152 | * https://developer.nulab.com/docs/backlog/api/2/delete-project-administrator/ 153 | */ 154 | deleteProjectAdministrators(projectIdOrKey: string | number, params: Option.Project.DeleteProjectAdministrators): Promise; 155 | /** 156 | * https://developer.nulab.com/docs/backlog/api/2/add-status/ 157 | */ 158 | postProjectStatus(projectIdOrKey: string | number, params: Option.Project.PostStatusParams): Promise; 159 | /** 160 | * https://developer.nulab.com/docs/backlog/api/2/update-status/ 161 | */ 162 | patchProjectStatus(projectIdOrKey: string | number, id: number, params: Option.Project.PatchStatusParams): Promise; 163 | /** 164 | * https://developer.nulab.com/docs/backlog/api/2/delete-status/ 165 | */ 166 | deleteProjectStatus(projectIdOrKey: string | number, id: number, substituteStatusId: number): Promise; 167 | /** 168 | * https://developer.nulab.com/docs/backlog/api/2/update-order-of-status/ 169 | */ 170 | patchProjectStatusOrder(projectIdOrKey: string | number, statusId: number[]): Promise; 171 | /** 172 | * https://developer.nulab.com/docs/backlog/api/2/get-issue-type-list/ 173 | */ 174 | getIssueTypes(projectIdOrKey: string | number): Promise; 175 | /** 176 | * https://developer.nulab.com/docs/backlog/api/2/add-issue-type/ 177 | */ 178 | postIssueType(projectIdOrKey: string | number, params: Option.Project.PostIssueTypeParams): Promise; 179 | /** 180 | * https://developer.nulab.com/docs/backlog/api/2/update-issue-type/ 181 | */ 182 | patchIssueType(projectIdOrKey: string | number, id: number, params: Option.Project.PatchIssueTypeParams): Promise; 183 | /** 184 | * https://developer.nulab.com/docs/backlog/api/2/delete-issue-type/ 185 | */ 186 | deleteIssueType(projectIdOrKey: string | number, id: number, params: Option.Project.DeleteIssueTypeParams): Promise; 187 | /** 188 | * https://developer.nulab.com/docs/backlog/api/2/get-category-list/ 189 | */ 190 | getCategories(projectIdOrKey: string | number): Promise; 191 | /** 192 | * https://developer.nulab.com/docs/backlog/api/2/add-category/ 193 | */ 194 | postCategories(projectIdOrKey: string | number, params: Option.Project.PostCategoriesParams): Promise; 195 | /** 196 | * https://developer.nulab.com/docs/backlog/api/2/update-category/ 197 | */ 198 | patchCategories(projectIdOrKey: string | number, id: number, params: Option.Project.PatchCategoriesParams): Promise; 199 | /** 200 | * https://developer.nulab.com/docs/backlog/api/2/delete-category/ 201 | */ 202 | deleteCategories(projectIdOrKey: string | number, id: number): Promise; 203 | /** 204 | * https://developer.nulab.com/docs/backlog/api/2/get-version-milestone-list/ 205 | */ 206 | getVersions(projectIdOrKey: string | number): Promise; 207 | /** 208 | * https://developer.nulab.com/docs/backlog/api/2/add-version-milestone/ 209 | */ 210 | postVersions(projectIdOrKey: string | number, params: Option.Project.PostVersionsParams): Promise; 211 | /** 212 | * https://developer.nulab.com/docs/backlog/api/2/update-version-milestone/ 213 | */ 214 | patchVersions(projectIdOrKey: string | number, id: number, params: Option.Project.PatchVersionsParams): Promise; 215 | /** 216 | * https://developer.nulab.com/docs/backlog/api/2/delete-version/ 217 | */ 218 | deleteVersions(projectIdOrKey: string | number, id: number): Promise; 219 | /** 220 | * https://developer.nulab.com/docs/backlog/api/2/get-custom-field-list/ 221 | */ 222 | getCustomFields(projectIdOrKey: string | number): Promise; 223 | /** 224 | * https://developer.nulab.com/docs/backlog/api/2/add-custom-field/ 225 | */ 226 | postCustomField(projectIdOrKey: string | number, params: Option.Project.PostCustomFieldParams | Option.Project.PostCustomFieldWithNumericParams | Option.Project.PostCustomFieldWithDateParams | Option.Project.PostCustomFieldWithListParams): Promise; 227 | /** 228 | * https://developer.nulab.com/docs/backlog/api/2/update-custom-field/ 229 | */ 230 | patchCustomField(projectIdOrKey: string | number, id: number, params: Option.Project.PatchCustomFieldParams | Option.Project.PatchCustomFieldWithNumericParams | Option.Project.PatchCustomFieldWithDateParams | Option.Project.PatchCustomFieldWithListParams): Promise; 231 | /** 232 | * https://developer.nulab.com/docs/backlog/api/2/delete-custom-field/ 233 | */ 234 | deleteCustomField(projectIdOrKey: string | number, id: number): Promise; 235 | /** 236 | * https://developer.nulab.com/docs/backlog/api/2/add-list-item-for-list-type-custom-field/ 237 | */ 238 | postCustomFieldItem(projectIdOrKey: string | number, id: number, params: Option.Project.PostCustomFieldItemParams): Promise; 239 | /** 240 | * https://developer.nulab.com/docs/backlog/api/2/update-list-item-for-list-type-custom-field/ 241 | */ 242 | patchCustomFieldItem(projectIdOrKey: string | number, id: number, itemId: number, params: Option.Project.PatchCustomFieldItemParams): Promise; 243 | /** 244 | * https://developer.nulab.com/docs/backlog/api/2/delete-list-item-for-list-type-custom-field/ 245 | */ 246 | deleteCustomFieldItem(projectIdOrKey: string | number, id: number, itemId: number): Promise; 247 | /** 248 | * https://developer.nulab.com/docs/backlog/api/2/get-list-of-shared-files/ 249 | */ 250 | getSharedFiles(projectIdOrKey: string | number, path: string, params: Option.Project.GetSharedFilesParams): Promise; 251 | /** 252 | * https://developer.nulab.com/docs/backlog/api/2/get-file/ 253 | */ 254 | getSharedFile(projectIdOrKey: string | number, sharedFileId: number): Promise; 255 | /** 256 | * https://developer.nulab.com/docs/backlog/api/2/get-project-disk-usage/ 257 | */ 258 | getProjectsDiskUsage(projectIdOrKey: string | number): Promise; 259 | /** 260 | * https://developer.nulab.com/docs/backlog/api/2/get-list-of-webhooks/ 261 | */ 262 | getWebhooks(projectIdOrKey: string | number): Promise; 263 | /** 264 | * https://developer.nulab.com/docs/backlog/api/2/add-webhook/ 265 | */ 266 | postWebhook(projectIdOrKey: string | number, params: Option.Project.PostWebhookParams): Promise; 267 | /** 268 | * https://developer.nulab.com/docs/backlog/api/2/get-webhook/ 269 | */ 270 | getWebhook(projectIdOrKey: string | number, webhookId: string): Promise; 271 | /** 272 | * https://developer.nulab.com/docs/backlog/api/2/update-webhook/ 273 | */ 274 | patchWebhook(projectIdOrKey: string | number, webhookId: string, params: Option.Project.PatchWebhookParams): Promise; 275 | /** 276 | * https://developer.nulab.com/docs/backlog/api/2/delete-webhook/ 277 | */ 278 | deleteWebhook(projectIdOrKey: string | number, webhookId: string): Promise; 279 | /** 280 | * https://developer.nulab.com/docs/backlog/api/2/get-issue-list/ 281 | */ 282 | getIssues(params?: Option.Issue.GetIssuesParams): Promise; 283 | /** 284 | * https://developer.nulab.com/docs/backlog/api/2/count-issue/ 285 | */ 286 | getIssuesCount(params?: Option.Issue.GetIssuesParams): Promise; 287 | /** 288 | * https://developer.nulab.com/docs/backlog/api/2/add-issue/ 289 | */ 290 | postIssue(params: Option.Issue.PostIssueParams): Promise; 291 | /** 292 | * https://developer.nulab.com/docs/backlog/api/2/update-issue/ 293 | */ 294 | patchIssue(issueIdOrKey: string | number, params: Option.Issue.PatchIssueParams): Promise; 295 | /** 296 | * https://developer.nulab.com/docs/backlog/api/2/get-issue/ 297 | */ 298 | getIssue(issueIdOrKey: string | number): Promise; 299 | /** 300 | * https://developer.nulab.com/docs/backlog/api/2/delete-issue/ 301 | */ 302 | deleteIssue(issueIdOrKey: string | number): Promise; 303 | /** 304 | * https://developer.nulab.com/docs/backlog/api/2/get-comment-list/ 305 | */ 306 | getIssueComments(issueIdOrKey: string | number, params: Option.Issue.GetIssueCommentsParams): Promise; 307 | /** 308 | * https://developer.nulab.com/docs/backlog/api/2/add-comment/ 309 | */ 310 | postIssueComments(issueIdOrKey: string | number, params: Option.Issue.PostIssueCommentsParams): Promise; 311 | /** 312 | * https://developer.nulab.com/docs/backlog/api/2/count-comment/ 313 | */ 314 | getIssueCommentsCount(issueIdOrKey: string | number): Promise; 315 | /** 316 | * https://developer.nulab.com/docs/backlog/api/2/get-comment/ 317 | */ 318 | getIssueComment(issueIdOrKey: string | number, commentId: number): Promise; 319 | /** 320 | * https://developer.nulab.com/docs/backlog/api/2/delete-comment/ 321 | */ 322 | deleteIssueComment(issueIdOrKey: string | number, commentId: number): Promise; 323 | /** 324 | * https://developer.nulab.com/docs/backlog/api/2/update-comment/ 325 | */ 326 | patchIssueComment(issueIdOrKey: string | number, commentId: number, params: Option.Issue.PatchIssueCommentParams): Promise; 327 | /** 328 | * https://developer.nulab.com/docs/backlog/api/2/get-list-of-comment-notifications/ 329 | */ 330 | getIssueCommentNotifications(issueIdOrKey: string | number, commentId: number): Promise; 331 | /** 332 | * https://developer.nulab.com/docs/backlog/api/2/add-comment-notification/ 333 | */ 334 | postIssueCommentNotifications(issueIdOrKey: string | number, commentId: number, prams: Option.Issue.IssueCommentNotifications): Promise; 335 | /** 336 | * https://developer.nulab.com/docs/backlog/api/2/get-list-of-issue-attachments/ 337 | */ 338 | getIssueAttachments(issueIdOrKey: string | number): Promise; 339 | /** 340 | * https://developer.nulab.com/docs/backlog/api/2/get-issue-attachment/ 341 | */ 342 | getIssueAttachment(issueIdOrKey: string | number, attachmentId: number): Promise; 343 | /** 344 | * https://developer.nulab.com/docs/backlog/api/2/delete-issue-attachment/ 345 | */ 346 | deleteIssueAttachment(issueIdOrKey: string | number, attachmentId: string): Promise; 347 | /** 348 | * https://developer.nulab.com/docs/backlog/api/2/get-issue-participant-list/ 349 | */ 350 | getIssueParticipants(issueIdOrKey: string | number): Promise; 351 | /** 352 | * https://developer.nulab.com/docs/backlog/api/2/get-list-of-linked-shared-files/ 353 | */ 354 | getIssueSharedFiles(issueIdOrKey: string | number): Promise; 355 | /** 356 | * https://developer.nulab.com/docs/backlog/api/2/link-shared-files-to-issue/ 357 | */ 358 | linkIssueSharedFiles(issueIdOrKey: string | number, params: Option.Issue.LinkIssueSharedFilesParams): Promise; 359 | /** 360 | * https://developer.nulab.com/docs/backlog/api/2/remove-link-to-shared-file-from-issue/ 361 | */ 362 | unlinkIssueSharedFile(issueIdOrKey: string | number, id: number): Promise; 363 | /** 364 | * https://developer.nulab.com/docs/backlog/api/2/get-wiki-page-list/ 365 | */ 366 | getWikis(params: Option.Wiki.GetWikiParams): Promise; 367 | /** 368 | * https://developer.nulab.com/docs/backlog/api/2/count-wiki-page/ 369 | */ 370 | getWikisCount(projectIdOrKey: string | number): Promise; 371 | /** 372 | * https://developer.nulab.com/docs/backlog/api/2/get-wiki-page-tag-list/ 373 | */ 374 | getWikisTags(projectIdOrKey: string | number): Promise; 375 | /** 376 | * https://developer.nulab.com/docs/backlog/api/2/add-wiki-page/ 377 | */ 378 | postWiki(params: Option.Wiki.PostWikiParams): Promise; 379 | /** 380 | * https://developer.nulab.com/docs/backlog/api/2/get-wiki-page/ 381 | */ 382 | getWiki(wikiId: number): Promise; 383 | /** 384 | * https://developer.nulab.com/docs/backlog/api/2/update-wiki-page/ 385 | */ 386 | patchWiki(wikiId: number, params: Option.Wiki.PatchWikiParams): Promise; 387 | /** 388 | * https://developer.nulab.com/docs/backlog/api/2/delete-wiki-page/ 389 | */ 390 | deleteWiki(wikiId: number, mailNotify: boolean): Promise; 391 | /** 392 | * https://developer.nulab.com/docs/backlog/api/2/get-list-of-wiki-attachments/ 393 | */ 394 | getWikisAttachments(wikiId: number): Promise; 395 | /** 396 | * https://developer.nulab.com/docs/backlog/api/2/attach-file-to-wiki/ 397 | */ 398 | postWikisAttachments(wikiId: number, attachmentId: number[]): Promise; 399 | /** 400 | * https://developer.nulab.com/docs/backlog/api/2/get-wiki-page-attachment/ 401 | */ 402 | getWikiAttachment(wikiId: number, attachmentId: number): Promise; 403 | /** 404 | * https://developer.nulab.com/docs/backlog/api/2/remove-wiki-attachment/ 405 | */ 406 | deleteWikisAttachments(wikiId: number, attachmentId: number): Promise; 407 | /** 408 | * https://developer.nulab.com/docs/backlog/api/2/get-list-of-shared-files-on-wiki/ 409 | */ 410 | getWikisSharedFiles(wikiId: number): Promise; 411 | /** 412 | * https://developer.nulab.com/docs/backlog/api/2/link-shared-files-to-wiki/ 413 | */ 414 | linkWikisSharedFiles(wikiId: number, fileId: number[]): Promise; 415 | /** 416 | * https://developer.nulab.com/docs/backlog/api/2/remove-link-to-shared-file-from-wiki/ 417 | */ 418 | unlinkWikisSharedFiles(wikiId: number, id: number): Promise; 419 | /** 420 | * https://developer.nulab.com/docs/backlog/api/get-document-list/ 421 | */ 422 | getDocuments(params: Option.Document.GetDocumentsParams): Promise; 423 | /** 424 | * https://developer.nulab.com/docs/backlog/api/get-document-tree/ 425 | */ 426 | getDocumentTree(projectIdOrKey: string | number): Promise; 427 | /** 428 | * https://developer.nulab.com/docs/backlog/api/get-document/ 429 | */ 430 | getDocument(documentId: string): Promise; 431 | /** 432 | * https://developer.nulab.com/docs/backlog/api/get-document-attachments/ 433 | */ 434 | downloadDocumentAttachment(documentId: string, attachmentId: number): Promise; 435 | /** 436 | * https://developer.nulab.com/docs/backlog/api/2/get-wiki-page-history/ 437 | */ 438 | getWikisHistory(wikiId: number, params: Option.Wiki.GetWikisHistoryParams): Promise; 439 | /** 440 | * https://developer.nulab.com/docs/backlog/api/2/get-wiki-page-star/ 441 | */ 442 | getWikisStars(wikiId: number): Promise; 443 | /** 444 | * https://developer.nulab.com/docs/backlog/api/2/add-star/ 445 | */ 446 | postStar(params: Option.Project.PostStarParams): Promise; 447 | /** 448 | * https://developer.nulab.com/docs/backlog/api/2/remove-star/ 449 | */ 450 | removeStar(starId: number): Promise; 451 | /** 452 | * https://developer.nulab.com/docs/backlog/api/2/get-notification/ 453 | */ 454 | getNotifications(params: Option.Notification.GetNotificationsParams): Promise; 455 | /** 456 | * https://developer.nulab.com/docs/backlog/api/2/count-notification/ 457 | */ 458 | getNotificationsCount(params: Option.Notification.GetNotificationsCountParams): Promise; 459 | /** 460 | * https://developer.nulab.com/docs/backlog/api/2/reset-unread-notification-count/ 461 | */ 462 | resetNotificationsMarkAsRead(): Promise; 463 | /** 464 | * https://developer.nulab.com/docs/backlog/api/2/read-notification/ 465 | */ 466 | markAsReadNotification(id: number): Promise; 467 | /** 468 | * https://developer.nulab.com/docs/backlog/api/2/get-list-of-git-repositories/ 469 | */ 470 | getGitRepositories(projectIdOrKey: string | number): Promise; 471 | /** 472 | * https://developer.nulab.com/docs/backlog/api/2/get-git-repository/ 473 | */ 474 | getGitRepository(projectIdOrKey: string | number, repoIdOrName: string): Promise; 475 | /** 476 | * https://developer.nulab.com/docs/backlog/api/2/get-pull-request-list/ 477 | */ 478 | getPullRequests(projectIdOrKey: string | number, repoIdOrName: string, params: Option.PullRequest.GetPullRequestsParams): Promise; 479 | /** 480 | * https://developer.nulab.com/docs/backlog/api/2/get-number-of-pull-requests/ 481 | */ 482 | getPullRequestsCount(projectIdOrKey: string | number, repoIdOrName: string, params: Option.PullRequest.GetPullRequestsParams): Promise; 483 | /** 484 | * https://developer.nulab.com/docs/backlog/api/2/add-pull-request/ 485 | */ 486 | postPullRequest(projectIdOrKey: string | number, repoIdOrName: string, params: Option.PullRequest.PostPullRequestParams): Promise; 487 | /** 488 | * https://developer.nulab.com/docs/backlog/api/2/get-pull-request/ 489 | */ 490 | getPullRequest(projectIdOrKey: string | number, repoIdOrName: string, number: number): Promise; 491 | /** 492 | * https://developer.nulab.com/docs/backlog/api/2/update-pull-request/ 493 | */ 494 | patchPullRequest(projectIdOrKey: string | number, repoIdOrName: string, number: number, params: Option.PullRequest.PatchPullRequestParams): Promise; 495 | /** 496 | * https://developer.nulab.com/docs/backlog/api/2/get-pull-request-comment/ 497 | */ 498 | getPullRequestComments(projectIdOrKey: string | number, repoIdOrName: string, number: number, params: Option.PullRequest.GetPullRequestCommentsParams): Promise; 499 | /** 500 | * https://developer.nulab.com/docs/backlog/api/2/add-pull-request-comment/ 501 | */ 502 | postPullRequestComments(projectIdOrKey: string | number, repoIdOrName: string, number: number, params: Option.PullRequest.PostPullRequestCommentsParams): Promise; 503 | /** 504 | * https://developer.nulab.com/docs/backlog/api/2/get-number-of-pull-request-comments/ 505 | */ 506 | getPullRequestCommentsCount(projectIdOrKey: string | number, repoIdOrName: string, number: number): Promise; 507 | /** 508 | * https://developer.nulab.com/docs/backlog/api/2/update-pull-request-comment-information/ 509 | */ 510 | patchPullRequestComments(projectIdOrKey: string | number, repoIdOrName: string, number: number, commentId: number, params: Option.PullRequest.PatchPullRequestCommentsParams): Promise; 511 | /** 512 | * https://developer.nulab.com/docs/backlog/api/2/get-list-of-pull-request-attachment/ 513 | */ 514 | getPullRequestAttachments(projectIdOrKey: string | number, repoIdOrName: string, number: number): Promise; 515 | /** 516 | * https://developer.nulab.com/docs/backlog/api/2/download-pull-request-attachment/ 517 | */ 518 | getPullRequestAttachment(projectIdOrKey: string | number, repoIdOrName: string, number: number, attachmentId: number): Promise; 519 | /** 520 | * https://developer.nulab.com/docs/backlog/api/2/delete-pull-request-attachments/ 521 | */ 522 | deletePullRequestAttachment(projectIdOrKey: string | number, repoIdOrName: string, number: number, attachmentId: number): Promise; 523 | /** 524 | * https://developer.nulab.com/docs/backlog/api/2/get-watching-list 525 | */ 526 | getWatchingListItems(userId: number, params?: Option.WatchingList.GetWatchingListParams): Promise; 527 | /** 528 | * https://developer.nulab.com/docs/backlog/api/2/count-watching 529 | */ 530 | getWatchingListCount(userId: number, params?: Option.WatchingList.GetWatchingListCountParams): Promise; 531 | /** 532 | * https://developer.nulab.com/docs/backlog/api/2/get-watching 533 | */ 534 | getWatchingListItem(watchId: number): Promise; 535 | /** 536 | * https://developer.nulab.com/docs/backlog/api/2/add-watching 537 | */ 538 | postWatchingListItem(params: Option.WatchingList.PostWatchingListItemParams): Promise; 539 | /** 540 | * https://developer.nulab.com/docs/backlog/api/2/update-watching 541 | */ 542 | patchWatchingListItem(watchId: number, note: string): Promise; 543 | /** 544 | * https://developer.nulab.com/docs/backlog/api/2/delete-watching 545 | */ 546 | deletehWatchingListItem(watchId: number): Promise; 547 | /** 548 | * https://developer.nulab.com/docs/backlog/api/2/mark-watching-as-read 549 | */ 550 | resetWatchingListItemAsRead(watchId: number): Promise; 551 | /** 552 | * https://developer.nulab.com/docs/backlog/api/2/get-licence 553 | */ 554 | getLicence(): Promise; 555 | /** 556 | * https://developer.nulab.com/docs/backlog/api/2/get-list-of-teams/ 557 | */ 558 | getTeams(params?: Option.Team.GetTeamsParams): Promise; 559 | /** 560 | * https://developer.nulab.com/docs/backlog/api/2/add-team/ 561 | */ 562 | postTeam(params: Option.Team.PostTeamParams): Promise; 563 | /** 564 | * https://developer.nulab.com/docs/backlog/api/2/get-team/ 565 | */ 566 | getTeam(teamId: number): Promise; 567 | /** 568 | * https://developer.nulab.com/docs/backlog/api/2/update-team/ 569 | */ 570 | patchTeam(teamId: number, params: Option.Team.PatchTeamParams): Promise; 571 | /** 572 | * https://developer.nulab.com/docs/backlog/api/2/delete-team/ 573 | */ 574 | deleteTeam(teamId: number): Promise; 575 | /** 576 | * https://developer.nulab.com/docs/backlog/api/2/get-team-icon/ 577 | */ 578 | getTeamIcon(teamId: number): Promise; 579 | /** 580 | * https://developer.nulab.com/docs/backlog/api/2/get-project-team-list/ 581 | */ 582 | getProjectTeams(projectIdOrKey: string | number): Promise; 583 | /** 584 | * https://developer.nulab.com/docs/backlog/api/2/add-project-team/ 585 | */ 586 | postProjectTeam(projectIdOrKey: string | number, teamId: number): Promise; 587 | /** 588 | * https://developer.nulab.com/docs/backlog/api/2/delete-project-team/ 589 | */ 590 | deleteProjectTeam(projectIdOrKey: string | number, teamId: number): Promise; 591 | /** 592 | * https://developer.nulab.com/docs/backlog/api/2/get-rate-limit/ 593 | */ 594 | getRateLimit(): Promise; 595 | private download; 596 | private upload; 597 | private parseFileData; 598 | } 599 | -------------------------------------------------------------------------------- /src/backlog.ts: -------------------------------------------------------------------------------- 1 | import * as Option from './option'; 2 | import * as Entity from './entity'; 3 | import Request from './request'; 4 | 5 | export default class Backlog extends Request { 6 | 7 | constructor(configure: { 8 | host: string, apiKey?: string, accessToken?: string, timeout?: number 9 | }) { 10 | super(configure); 11 | } 12 | 13 | /** 14 | * https://developer.nulab.com/docs/backlog/api/2/get-space/ 15 | */ 16 | public getSpace(): Promise { 17 | return this.get('space'); 18 | } 19 | 20 | /** 21 | * https://developer.nulab.com/docs/backlog/api/2/get-recent-updates/ 22 | */ 23 | public getSpaceActivities( 24 | params: Option.Space.GetActivitiesParams 25 | ): Promise { 26 | return this.get('space/activities', params); 27 | } 28 | 29 | /** 30 | * https://developer.nulab.com/docs/backlog/api/2/get-space-logo/ 31 | */ 32 | public getSpaceIcon(): Promise { 33 | return this.download('space/image'); 34 | } 35 | 36 | /** 37 | * https://developer.nulab.com/docs/backlog/api/2/get-space-notification/ 38 | */ 39 | public getSpaceNotification(): Promise { 40 | return this.get('space/notification'); 41 | } 42 | 43 | /** 44 | * https://developer.nulab.com/docs/backlog/api/2/update-space-notification/ 45 | */ 46 | public putSpaceNotification( 47 | params: Option.Space.PutSpaceNotificationParams 48 | ): Promise { 49 | return this.put('space/notification', params); 50 | } 51 | 52 | /** 53 | * https://developer.nulab.com/docs/backlog/api/2/get-space-disk-usage/ 54 | */ 55 | public getSpaceDiskUsage(): Promise { 56 | return this.get('space/diskUsage'); 57 | } 58 | 59 | /** 60 | * https://developer.nulab.com/docs/backlog/api/2/post-attachment-file/ 61 | */ 62 | public postSpaceAttachment(form: FormData): Promise { 63 | return this.upload("space/attachment", form); 64 | } 65 | 66 | /** 67 | * https://developer.nulab.com/docs/backlog/api/2/get-user-list/ 68 | */ 69 | public getUsers(): Promise { 70 | return this.get(`users`); 71 | } 72 | 73 | /** 74 | * https://developer.nulab.com/docs/backlog/api/2/get-user/ 75 | */ 76 | public getUser(userId: number): Promise { 77 | return this.get(`users/${userId}`); 78 | } 79 | 80 | /** 81 | * https://developer.nulab.com/docs/backlog/api/2/add-user/ 82 | */ 83 | public postUser(params: Option.User.PostUserParams): Promise { 84 | return this.post(`users`, params); 85 | } 86 | 87 | /** 88 | * https://developer.nulab.com/docs/backlog/api/2/update-user/ 89 | */ 90 | public patchUser( 91 | userId: number, params: Option.User.PatchUserParams 92 | ): Promise { 93 | return this.patch(`users/${userId}`, params); 94 | } 95 | 96 | /** 97 | * https://developer.nulab.com/docs/backlog/api/2/delete-user/ 98 | */ 99 | public deleteUser(userId: number): Promise { 100 | return this.delete(`users/${userId}`); 101 | } 102 | 103 | /** 104 | * https://developer.nulab.com/docs/backlog/api/2/get-own-user/ 105 | */ 106 | public getMyself(): Promise { 107 | return this.get('users/myself'); 108 | } 109 | 110 | /** 111 | * https://developer.nulab.com/docs/backlog/api/2/get-user-icon/ 112 | */ 113 | public getUserIcon(userId: number): Promise { 114 | return this.download(`users/${userId}/icon`); 115 | } 116 | 117 | /** 118 | * https://developer.nulab.com/docs/backlog/api/2/get-user-recent-updates/ 119 | */ 120 | public getUserActivities( 121 | userId: number, params: Option.User.GetUserActivitiesParams 122 | ): Promise { 123 | return this.get(`users/${userId}/activities`, params); 124 | } 125 | 126 | /** 127 | * https://developer.nulab.com/docs/backlog/api/2/get-received-star-list/ 128 | */ 129 | public getUserStars( 130 | userId: number, params: Option.User.GetUserStarsParams 131 | ): Promise { 132 | return this.get(`users/${userId}/stars`, params); 133 | } 134 | 135 | /** 136 | * https://developer.nulab.com/docs/backlog/api/2/count-user-received-stars/ 137 | */ 138 | public getUserStarsCount( 139 | userId: number, params: Option.User.GetUserStarsCountParams 140 | ): Promise { 141 | return this.get(`users/${userId}/stars/count`, params); 142 | } 143 | 144 | /** 145 | * https://developer.nulab.com/docs/backlog/api/2/get-list-of-recently-viewed-issues/ 146 | */ 147 | public getRecentlyViewedIssues( 148 | params: Option.User.GetRecentlyViewedParams 149 | ): Promise { 150 | return this.get('users/myself/recentlyViewedIssues', params); 151 | } 152 | 153 | /** 154 | * https://developer.nulab.com/docs/backlog/api/2/get-list-of-recently-viewed-projects/ 155 | */ 156 | public getRecentlyViewedProjects( 157 | params: Option.User.GetRecentlyViewedParams 158 | ): Promise { 159 | return this.get('users/myself/recentlyViewedProjects', params); 160 | } 161 | 162 | /** 163 | * https://developer.nulab.com/docs/backlog/api/2/get-list-of-recently-viewed-wikis/ 164 | */ 165 | public getRecentlyViewedWikis( 166 | params: Option.User.GetRecentlyViewedParams 167 | ): Promise { 168 | return this.get('users/myself/recentlyViewedWikis', params); 169 | } 170 | 171 | /** 172 | * https://developer.nulab.com/docs/backlog/api/2/get-status-list-of-project/ 173 | */ 174 | public getProjectStatuses(projectIdOrKey: string | number): Promise { 175 | return this.get(`projects/${projectIdOrKey}/statuses`); 176 | } 177 | 178 | /** 179 | * https://developer.nulab.com/docs/backlog/api/2/get-resolution-list/ 180 | */ 181 | public getResolutions(): Promise { 182 | return this.get('resolutions'); 183 | } 184 | 185 | /** 186 | * https://developer.nulab.com/docs/backlog/api/2/get-priority-list/ 187 | */ 188 | public getPriorities(): Promise { 189 | return this.get('priorities'); 190 | } 191 | 192 | /** 193 | * https://developer.nulab.com/docs/backlog/api/2/get-project-list/ 194 | */ 195 | public getProjects(params?: Option.Project.GetProjectsParams): Promise { 196 | return this.get('projects', params); 197 | } 198 | 199 | /** 200 | * https://developer.nulab.com/docs/backlog/api/2/add-project/ 201 | */ 202 | public postProject(params: Option.Project.PostProjectParams): Promise { 203 | return this.post('projects', params); 204 | } 205 | 206 | /** 207 | * https://developer.nulab.com/docs/backlog/api/2/get-project/ 208 | */ 209 | public getProject(projectIdOrKey: string | number): Promise { 210 | return this.get(`projects/${projectIdOrKey}`); 211 | } 212 | 213 | /** 214 | * https://developer.nulab.com/docs/backlog/api/2/update-project/ 215 | */ 216 | public patchProject( 217 | projectIdOrKey: string | number, params: Option.Project.PatchProjectParams 218 | ): Promise { 219 | return this.patch(`projects/${projectIdOrKey}`, params); 220 | } 221 | 222 | /** 223 | * https://developer.nulab.com/docs/backlog/api/2/delete-project/ 224 | */ 225 | public deleteProject(projectIdOrKey: string | number): Promise { 226 | return this.delete(`projects/${projectIdOrKey}`); 227 | } 228 | /** 229 | * https://developer.nulab.com/docs/backlog/api/2/get-project-icon/ 230 | */ 231 | public getProjectIcon(projectIdOrKey: string | number): Promise { 232 | return this.download(`projects/${projectIdOrKey}/image`); 233 | } 234 | 235 | /** 236 | * https://developer.nulab.com/docs/backlog/api/2/get-project-recent-updates/ 237 | */ 238 | public getProjectActivities( 239 | projectIdOrKey: string | number, params: Option.Space.GetActivitiesParams 240 | ): Promise { 241 | return this.get(`projects/${projectIdOrKey}/activities`, params); 242 | } 243 | 244 | /** 245 | * https://developer.nulab.com/docs/backlog/api/2/add-project-user/ 246 | */ 247 | public postProjectUser(projectIdOrKey: string | number, userId: string): Promise { 248 | return this.post(`projects/${projectIdOrKey}/users`, { userId }); 249 | } 250 | 251 | /** 252 | * https://developer.nulab.com/docs/backlog/api/2/get-project-user-list/ 253 | */ 254 | public getProjectUsers(projectIdOrKey: string | number): Promise { 255 | return this.get(`projects/${projectIdOrKey}/users`); 256 | } 257 | 258 | /** 259 | * https://developer.nulab.com/docs/backlog/api/2/delete-project-user/ 260 | */ 261 | public deleteProjectUsers( 262 | projectIdOrKey: string | number, params: Option.Project.DeleteProjectUsersParams 263 | ): Promise { 264 | return this.delete(`projects/${projectIdOrKey}/users`, params); 265 | } 266 | 267 | /** 268 | * https://developer.nulab.com/docs/backlog/api/2/add-project-administrator/ 269 | */ 270 | public postProjectAdministrators( 271 | projectIdOrKey: string | number, params: Option.Project.PostProjectAdministrators 272 | ): Promise { 273 | return this.post(`projects/${projectIdOrKey}/administrators`, params); 274 | } 275 | 276 | /** 277 | * https://developer.nulab.com/docs/backlog/api/2/get-list-of-project-administrators/ 278 | */ 279 | public getProjectAdministrators(projectIdOrKey: string | number): Promise { 280 | return this.get(`projects/${projectIdOrKey}/administrators`); 281 | } 282 | 283 | /** 284 | * https://developer.nulab.com/docs/backlog/api/2/delete-project-administrator/ 285 | */ 286 | public deleteProjectAdministrators( 287 | projectIdOrKey: string | number, params: Option.Project.DeleteProjectAdministrators 288 | ): Promise { 289 | return this.delete(`projects/${projectIdOrKey}/administrators`, params); 290 | } 291 | 292 | /** 293 | * https://developer.nulab.com/docs/backlog/api/2/add-status/ 294 | */ 295 | public postProjectStatus( 296 | projectIdOrKey: string | number, params: Option.Project.PostStatusParams, 297 | ): Promise { 298 | return this.post(`projects/${projectIdOrKey}/statuses`, params); 299 | } 300 | 301 | /** 302 | * https://developer.nulab.com/docs/backlog/api/2/update-status/ 303 | */ 304 | public patchProjectStatus( 305 | projectIdOrKey: string | number, id: number, params: Option.Project.PatchStatusParams 306 | ): Promise { 307 | return this.patch(`projects/${projectIdOrKey}/statuses/${id}`, params); 308 | } 309 | 310 | /** 311 | * https://developer.nulab.com/docs/backlog/api/2/delete-status/ 312 | */ 313 | public deleteProjectStatus( 314 | projectIdOrKey: string | number, id: number, substituteStatusId: number 315 | ): Promise { 316 | return this.delete(`projects/${projectIdOrKey}/statuses/${id}`, { substituteStatusId }); 317 | } 318 | 319 | /** 320 | * https://developer.nulab.com/docs/backlog/api/2/update-order-of-status/ 321 | */ 322 | public patchProjectStatusOrder( 323 | projectIdOrKey: string | number, statusId: number[] 324 | ): Promise { 325 | return this.patch(`projects/${projectIdOrKey}/statuses/updateDisplayOrder`, { statusId }); 326 | } 327 | 328 | /** 329 | * https://developer.nulab.com/docs/backlog/api/2/get-issue-type-list/ 330 | */ 331 | public getIssueTypes(projectIdOrKey: string | number): Promise { 332 | return this.get(`projects/${projectIdOrKey}/issueTypes`); 333 | } 334 | 335 | /** 336 | * https://developer.nulab.com/docs/backlog/api/2/add-issue-type/ 337 | */ 338 | public postIssueType( 339 | projectIdOrKey: string | number, params: Option.Project.PostIssueTypeParams 340 | ): Promise { 341 | return this.post(`projects/${projectIdOrKey}/issueTypes`, params); 342 | } 343 | 344 | /** 345 | * https://developer.nulab.com/docs/backlog/api/2/update-issue-type/ 346 | */ 347 | public patchIssueType( 348 | projectIdOrKey: string | number, id: number, params: Option.Project.PatchIssueTypeParams 349 | ): Promise { 350 | return this.patch(`projects/${projectIdOrKey}/issueTypes/${id}`, params); 351 | } 352 | 353 | /** 354 | * https://developer.nulab.com/docs/backlog/api/2/delete-issue-type/ 355 | */ 356 | public deleteIssueType( 357 | projectIdOrKey: string | number, id: number, params: Option.Project.DeleteIssueTypeParams 358 | ): Promise { 359 | return this.delete(`projects/${projectIdOrKey}/issueTypes/${id}`, params); 360 | } 361 | 362 | /** 363 | * https://developer.nulab.com/docs/backlog/api/2/get-category-list/ 364 | */ 365 | public getCategories(projectIdOrKey: string | number): Promise { 366 | return this.get(`projects/${projectIdOrKey}/categories`); 367 | } 368 | 369 | /** 370 | * https://developer.nulab.com/docs/backlog/api/2/add-category/ 371 | */ 372 | public postCategories( 373 | projectIdOrKey: string | number, params: Option.Project.PostCategoriesParams 374 | ): Promise { 375 | return this.post(`projects/${projectIdOrKey}/categories`, params); 376 | } 377 | 378 | /** 379 | * https://developer.nulab.com/docs/backlog/api/2/update-category/ 380 | */ 381 | public patchCategories( 382 | projectIdOrKey: string | number, id: number, params: Option.Project.PatchCategoriesParams 383 | ): Promise { 384 | return this.patch(`projects/${projectIdOrKey}/categories/${id}`, params); 385 | } 386 | 387 | /** 388 | * https://developer.nulab.com/docs/backlog/api/2/delete-category/ 389 | */ 390 | public deleteCategories(projectIdOrKey: string | number, id: number): Promise { 391 | return this.delete(`projects/${projectIdOrKey}/categories/${id}`); 392 | } 393 | 394 | /** 395 | * https://developer.nulab.com/docs/backlog/api/2/get-version-milestone-list/ 396 | */ 397 | public getVersions(projectIdOrKey: string | number): Promise { 398 | return this.get(`projects/${projectIdOrKey}/versions`); 399 | } 400 | 401 | /** 402 | * https://developer.nulab.com/docs/backlog/api/2/add-version-milestone/ 403 | */ 404 | public postVersions( 405 | projectIdOrKey: string | number, params: Option.Project.PostVersionsParams 406 | ): Promise { 407 | return this.post(`projects/${projectIdOrKey}/versions`, params); 408 | } 409 | 410 | /** 411 | * https://developer.nulab.com/docs/backlog/api/2/update-version-milestone/ 412 | */ 413 | public patchVersions( 414 | projectIdOrKey: string | number, id: number, params: Option.Project.PatchVersionsParams 415 | ): Promise { 416 | return this.patch(`projects/${projectIdOrKey}/versions/${id}`, params); 417 | } 418 | 419 | /** 420 | * https://developer.nulab.com/docs/backlog/api/2/delete-version/ 421 | */ 422 | public deleteVersions(projectIdOrKey: string | number, id: number): Promise { 423 | return this.delete(`projects/${projectIdOrKey}/versions/${id}`); 424 | } 425 | 426 | /** 427 | * https://developer.nulab.com/docs/backlog/api/2/get-custom-field-list/ 428 | */ 429 | public getCustomFields(projectIdOrKey: string | number): Promise { 430 | return this.get(`projects/${projectIdOrKey}/customFields`); 431 | } 432 | 433 | /** 434 | * https://developer.nulab.com/docs/backlog/api/2/add-custom-field/ 435 | */ 436 | public postCustomField( 437 | projectIdOrKey: string | number, 438 | params: Option.Project.PostCustomFieldParams 439 | | Option.Project.PostCustomFieldWithNumericParams 440 | | Option.Project.PostCustomFieldWithDateParams 441 | | Option.Project.PostCustomFieldWithListParams 442 | ): Promise { 443 | return this.post(`projects/${projectIdOrKey}/customFields`, params); 444 | } 445 | 446 | /** 447 | * https://developer.nulab.com/docs/backlog/api/2/update-custom-field/ 448 | */ 449 | public patchCustomField( 450 | projectIdOrKey: string | number, 451 | id: number, 452 | params: Option.Project.PatchCustomFieldParams 453 | | Option.Project.PatchCustomFieldWithNumericParams 454 | | Option.Project.PatchCustomFieldWithDateParams 455 | | Option.Project.PatchCustomFieldWithListParams 456 | ): Promise { 457 | return this.patch(`projects/${projectIdOrKey}/customFields/${id}`, params); 458 | } 459 | 460 | /** 461 | * https://developer.nulab.com/docs/backlog/api/2/delete-custom-field/ 462 | */ 463 | public deleteCustomField(projectIdOrKey: string | number, id: number): Promise { 464 | return this.delete(`projects/${projectIdOrKey}/customFields/${id}`); 465 | } 466 | 467 | /** 468 | * https://developer.nulab.com/docs/backlog/api/2/add-list-item-for-list-type-custom-field/ 469 | */ 470 | public postCustomFieldItem( 471 | projectIdOrKey: string | number, id: number, params: Option.Project.PostCustomFieldItemParams 472 | ): Promise { 473 | return this.post(`projects/${projectIdOrKey}/customFields/${id}/items`, params); 474 | } 475 | 476 | /** 477 | * https://developer.nulab.com/docs/backlog/api/2/update-list-item-for-list-type-custom-field/ 478 | */ 479 | public patchCustomFieldItem( 480 | projectIdOrKey: string | number, id: number, itemId: number, params: Option.Project.PatchCustomFieldItemParams 481 | ): Promise { 482 | return this.patch(`projects/${projectIdOrKey}/customFields/${id}/items/${itemId}`, params); 483 | } 484 | 485 | /** 486 | * https://developer.nulab.com/docs/backlog/api/2/delete-list-item-for-list-type-custom-field/ 487 | */ 488 | public deleteCustomFieldItem( 489 | projectIdOrKey: string | number, id: number, itemId: number 490 | ): Promise { 491 | return this.delete(`projects/${projectIdOrKey}/customFields/${id}/items/${itemId}`); 492 | } 493 | 494 | /** 495 | * https://developer.nulab.com/docs/backlog/api/2/get-list-of-shared-files/ 496 | */ 497 | public getSharedFiles( 498 | projectIdOrKey: string | number, path: string, params: Option.Project.GetSharedFilesParams 499 | ): Promise { 500 | return this.get(`projects/${projectIdOrKey}/files/metadata/${path}`, params); 501 | } 502 | 503 | /** 504 | * https://developer.nulab.com/docs/backlog/api/2/get-file/ 505 | */ 506 | public getSharedFile(projectIdOrKey: string | number, sharedFileId: number): Promise { 507 | return this.download(`projects/${projectIdOrKey}/files/${sharedFileId}`); 508 | } 509 | 510 | /** 511 | * https://developer.nulab.com/docs/backlog/api/2/get-project-disk-usage/ 512 | */ 513 | public getProjectsDiskUsage( 514 | projectIdOrKey: string | number 515 | ): Promise { 516 | return this.get(`projects/${projectIdOrKey}/diskUsage`); 517 | } 518 | 519 | /** 520 | * https://developer.nulab.com/docs/backlog/api/2/get-list-of-webhooks/ 521 | */ 522 | public getWebhooks( 523 | projectIdOrKey: string | number 524 | ): Promise { 525 | return this.get(`projects/${projectIdOrKey}/webhooks`); 526 | } 527 | 528 | /** 529 | * https://developer.nulab.com/docs/backlog/api/2/add-webhook/ 530 | */ 531 | public postWebhook( 532 | projectIdOrKey: string | number, params: Option.Project.PostWebhookParams 533 | ): Promise { 534 | return this.post(`projects/${projectIdOrKey}/webhooks`, params); 535 | } 536 | 537 | /** 538 | * https://developer.nulab.com/docs/backlog/api/2/get-webhook/ 539 | */ 540 | public getWebhook( 541 | projectIdOrKey: string | number, webhookId: string 542 | ): Promise { 543 | return this.get(`projects/${projectIdOrKey}/webhooks/${webhookId}`); 544 | } 545 | 546 | /** 547 | * https://developer.nulab.com/docs/backlog/api/2/update-webhook/ 548 | */ 549 | public patchWebhook( 550 | projectIdOrKey: string | number, webhookId: string, params: Option.Project.PatchWebhookParams 551 | ): Promise { 552 | return this.patch(`projects/${projectIdOrKey}/webhooks/${webhookId}`, params); 553 | } 554 | 555 | /** 556 | * https://developer.nulab.com/docs/backlog/api/2/delete-webhook/ 557 | */ 558 | public deleteWebhook( 559 | projectIdOrKey: string | number, webhookId: string 560 | ): Promise { 561 | return this.delete(`projects/${projectIdOrKey}/webhooks/${webhookId}`); 562 | } 563 | 564 | /** 565 | * https://developer.nulab.com/docs/backlog/api/2/get-issue-list/ 566 | */ 567 | public getIssues(params?: Option.Issue.GetIssuesParams): Promise { 568 | return this.get('issues', params); 569 | } 570 | 571 | /** 572 | * https://developer.nulab.com/docs/backlog/api/2/count-issue/ 573 | */ 574 | public getIssuesCount(params?: Option.Issue.GetIssuesParams): Promise { 575 | return this.get('issues/count', params); 576 | } 577 | 578 | /** 579 | * https://developer.nulab.com/docs/backlog/api/2/add-issue/ 580 | */ 581 | public postIssue(params: Option.Issue.PostIssueParams): Promise { 582 | return this.post('issues', params); 583 | } 584 | 585 | /** 586 | * https://developer.nulab.com/docs/backlog/api/2/update-issue/ 587 | */ 588 | public patchIssue( 589 | issueIdOrKey: string | number, params: Option.Issue.PatchIssueParams 590 | ): Promise { 591 | return this.patch(`issues/${issueIdOrKey}`, params); 592 | } 593 | 594 | /** 595 | * https://developer.nulab.com/docs/backlog/api/2/get-issue/ 596 | */ 597 | public getIssue(issueIdOrKey: string | number): Promise { 598 | return this.get(`issues/${issueIdOrKey}`); 599 | } 600 | 601 | 602 | /** 603 | * https://developer.nulab.com/docs/backlog/api/2/delete-issue/ 604 | */ 605 | public deleteIssue(issueIdOrKey: string | number): Promise { 606 | return this.delete(`issues/${issueIdOrKey}`); 607 | } 608 | 609 | /** 610 | * https://developer.nulab.com/docs/backlog/api/2/get-comment-list/ 611 | */ 612 | public getIssueComments( 613 | issueIdOrKey: string | number, params: Option.Issue.GetIssueCommentsParams 614 | ): Promise { 615 | return this.get(`issues/${issueIdOrKey}/comments`, params); 616 | } 617 | 618 | /** 619 | * https://developer.nulab.com/docs/backlog/api/2/add-comment/ 620 | */ 621 | public postIssueComments( 622 | issueIdOrKey: string | number, params: Option.Issue.PostIssueCommentsParams 623 | ): Promise { 624 | return this.post(`issues/${issueIdOrKey}/comments`, params); 625 | } 626 | 627 | /** 628 | * https://developer.nulab.com/docs/backlog/api/2/count-comment/ 629 | */ 630 | public getIssueCommentsCount(issueIdOrKey: string | number): Promise { 631 | return this.get(`issues/${issueIdOrKey}/comments/count`); 632 | } 633 | 634 | /** 635 | * https://developer.nulab.com/docs/backlog/api/2/get-comment/ 636 | */ 637 | public getIssueComment(issueIdOrKey: string | number, commentId: number): Promise { 638 | return this.get(`issues/${issueIdOrKey}/comments/${commentId}`); 639 | } 640 | 641 | /** 642 | * https://developer.nulab.com/docs/backlog/api/2/delete-comment/ 643 | */ 644 | public deleteIssueComment(issueIdOrKey: string | number, commentId: number): Promise { 645 | return this.delete(`issues/${issueIdOrKey}/comments/${commentId}`); 646 | } 647 | 648 | /** 649 | * https://developer.nulab.com/docs/backlog/api/2/update-comment/ 650 | */ 651 | public patchIssueComment( 652 | issueIdOrKey: string | number, commentId: number, params: Option.Issue.PatchIssueCommentParams 653 | ): Promise { 654 | return this.patch(`issues/${issueIdOrKey}/comments/${commentId}`, params); 655 | } 656 | 657 | /** 658 | * https://developer.nulab.com/docs/backlog/api/2/get-list-of-comment-notifications/ 659 | */ 660 | public getIssueCommentNotifications( 661 | issueIdOrKey: string | number, commentId: number 662 | ): Promise { 663 | return this.get(`issues/${issueIdOrKey}/comments/${commentId}/notifications`); 664 | } 665 | 666 | /** 667 | * https://developer.nulab.com/docs/backlog/api/2/add-comment-notification/ 668 | */ 669 | public postIssueCommentNotifications( 670 | issueIdOrKey: string | number, commentId: number, prams: Option.Issue.IssueCommentNotifications 671 | ): Promise { 672 | return this.post(`issues/${issueIdOrKey}/comments/${commentId}/notifications`, prams); 673 | } 674 | 675 | /** 676 | * https://developer.nulab.com/docs/backlog/api/2/get-list-of-issue-attachments/ 677 | */ 678 | public getIssueAttachments(issueIdOrKey: string | number): Promise { 679 | return this.get(`issues/${issueIdOrKey}/attachments`); 680 | } 681 | 682 | /** 683 | * https://developer.nulab.com/docs/backlog/api/2/get-issue-attachment/ 684 | */ 685 | public getIssueAttachment(issueIdOrKey: string | number, attachmentId: number): Promise { 686 | return this.download(`issues/${issueIdOrKey}/attachments/${attachmentId}`); 687 | } 688 | 689 | /** 690 | * https://developer.nulab.com/docs/backlog/api/2/delete-issue-attachment/ 691 | */ 692 | public deleteIssueAttachment(issueIdOrKey: string | number, attachmentId: string): Promise { 693 | return this.delete(`issues/${issueIdOrKey}/attachments/${attachmentId}`); 694 | } 695 | 696 | /** 697 | * https://developer.nulab.com/docs/backlog/api/2/get-issue-participant-list/ 698 | */ 699 | public getIssueParticipants(issueIdOrKey: string | number): Promise { 700 | return this.get(`issues/${issueIdOrKey}/participants`); 701 | } 702 | 703 | /** 704 | * https://developer.nulab.com/docs/backlog/api/2/get-list-of-linked-shared-files/ 705 | */ 706 | public getIssueSharedFiles(issueIdOrKey: string | number): Promise { 707 | return this.get(`issues/${issueIdOrKey}/sharedFiles`); 708 | } 709 | 710 | /** 711 | * https://developer.nulab.com/docs/backlog/api/2/link-shared-files-to-issue/ 712 | */ 713 | public linkIssueSharedFiles( 714 | issueIdOrKey: string | number, params: Option.Issue.LinkIssueSharedFilesParams 715 | ): Promise { 716 | return this.post(`issues/${issueIdOrKey}/sharedFiles`, params); 717 | } 718 | 719 | /** 720 | * https://developer.nulab.com/docs/backlog/api/2/remove-link-to-shared-file-from-issue/ 721 | */ 722 | public unlinkIssueSharedFile(issueIdOrKey: string | number, id: number): Promise { 723 | return this.delete(`issues/${issueIdOrKey}/sharedFiles/${id}`); 724 | } 725 | 726 | /** 727 | * https://developer.nulab.com/docs/backlog/api/2/get-wiki-page-list/ 728 | */ 729 | public getWikis(params: Option.Wiki.GetWikiParams): Promise { 730 | return this.get(`wikis`, params); 731 | } 732 | 733 | /** 734 | * https://developer.nulab.com/docs/backlog/api/2/count-wiki-page/ 735 | */ 736 | public getWikisCount(projectIdOrKey: string | number): Promise { 737 | return this.get(`wikis/count`, { projectIdOrKey }); 738 | } 739 | 740 | /** 741 | * https://developer.nulab.com/docs/backlog/api/2/get-wiki-page-tag-list/ 742 | */ 743 | public getWikisTags(projectIdOrKey: string | number): Promise { 744 | return this.get(`wikis/tags`, { projectIdOrKey }); 745 | } 746 | 747 | /** 748 | * https://developer.nulab.com/docs/backlog/api/2/add-wiki-page/ 749 | */ 750 | public postWiki(params: Option.Wiki.PostWikiParams): Promise { 751 | return this.post(`wikis`, params); 752 | } 753 | 754 | /** 755 | * https://developer.nulab.com/docs/backlog/api/2/get-wiki-page/ 756 | */ 757 | public getWiki(wikiId: number): Promise { 758 | return this.get(`wikis/${wikiId}`); 759 | } 760 | 761 | /** 762 | * https://developer.nulab.com/docs/backlog/api/2/update-wiki-page/ 763 | */ 764 | public patchWiki( 765 | wikiId: number, params: Option.Wiki.PatchWikiParams 766 | ): Promise { 767 | return this.patch(`wikis/${wikiId}`, params); 768 | } 769 | 770 | /** 771 | * https://developer.nulab.com/docs/backlog/api/2/delete-wiki-page/ 772 | */ 773 | public deleteWiki(wikiId: number, mailNotify: boolean): Promise { 774 | return this.delete(`wikis/${wikiId}`, { mailNotify }); 775 | } 776 | 777 | /** 778 | * https://developer.nulab.com/docs/backlog/api/2/get-list-of-wiki-attachments/ 779 | */ 780 | public getWikisAttachments(wikiId: number): Promise { 781 | return this.get(`wikis/${wikiId}/attachments`); 782 | } 783 | 784 | /** 785 | * https://developer.nulab.com/docs/backlog/api/2/attach-file-to-wiki/ 786 | */ 787 | public postWikisAttachments(wikiId: number, attachmentId: number[]): Promise { 788 | return this.post(`wikis/${wikiId}/attachments`, { attachmentId }); 789 | } 790 | 791 | /** 792 | * https://developer.nulab.com/docs/backlog/api/2/get-wiki-page-attachment/ 793 | */ 794 | public getWikiAttachment(wikiId: number, attachmentId: number): Promise { 795 | return this.download(`wikis/${wikiId}/attachments/${attachmentId}`); 796 | } 797 | 798 | /** 799 | * https://developer.nulab.com/docs/backlog/api/2/remove-wiki-attachment/ 800 | */ 801 | public deleteWikisAttachments(wikiId: number, attachmentId: number): Promise { 802 | return this.delete(`wikis/${wikiId}/attachments/${attachmentId}`); 803 | } 804 | 805 | /** 806 | * https://developer.nulab.com/docs/backlog/api/2/get-list-of-shared-files-on-wiki/ 807 | */ 808 | public getWikisSharedFiles(wikiId: number): Promise { 809 | return this.get(`wikis/${wikiId}/sharedFiles`); 810 | } 811 | 812 | /** 813 | * https://developer.nulab.com/docs/backlog/api/2/link-shared-files-to-wiki/ 814 | */ 815 | public linkWikisSharedFiles(wikiId: number, fileId: number[]): Promise { 816 | return this.post(`wikis/${wikiId}/sharedFiles`, { fileId }); 817 | } 818 | 819 | /** 820 | * https://developer.nulab.com/docs/backlog/api/2/remove-link-to-shared-file-from-wiki/ 821 | */ 822 | public unlinkWikisSharedFiles(wikiId: number, id: number): Promise { 823 | return this.delete(`wikis/${wikiId}/sharedFiles/${id}`); 824 | } 825 | 826 | /** 827 | * https://developer.nulab.com/docs/backlog/api/get-document-list/ 828 | */ 829 | public getDocuments(params: Option.Document.GetDocumentsParams): Promise { 830 | return this.get('documents', params); 831 | } 832 | 833 | /** 834 | * https://developer.nulab.com/docs/backlog/api/get-document-tree/ 835 | */ 836 | public getDocumentTree(projectIdOrKey: string | number): Promise { 837 | return this.get(`documents/tree`, { projectIdOrKey }); 838 | } 839 | 840 | /** 841 | * https://developer.nulab.com/docs/backlog/api/get-document/ 842 | */ 843 | public getDocument(documentId: string): Promise { 844 | return this.get(`documents/${documentId}`); 845 | } 846 | 847 | /** 848 | * https://developer.nulab.com/docs/backlog/api/get-document-attachments/ 849 | */ 850 | public downloadDocumentAttachment(documentId: string, attachmentId: number): Promise { 851 | return this.download(`documents/${documentId}/attachments/${attachmentId}`); 852 | } 853 | 854 | /** 855 | * https://developer.nulab.com/docs/backlog/api/2/get-wiki-page-history/ 856 | */ 857 | public getWikisHistory( 858 | wikiId: number, params: Option.Wiki.GetWikisHistoryParams 859 | ): Promise { 860 | return this.get(`wikis/${wikiId}/history`, params); 861 | } 862 | 863 | /** 864 | * https://developer.nulab.com/docs/backlog/api/2/get-wiki-page-star/ 865 | */ 866 | public getWikisStars(wikiId: number): Promise { 867 | return this.get(`wikis/${wikiId}/stars`); 868 | } 869 | 870 | /** 871 | * https://developer.nulab.com/docs/backlog/api/2/add-star/ 872 | */ 873 | public postStar(params: Option.Project.PostStarParams): Promise { 874 | return this.post('stars', params); 875 | } 876 | 877 | /** 878 | * https://developer.nulab.com/docs/backlog/api/2/remove-star/ 879 | */ 880 | public removeStar(starId: number): Promise { 881 | const endpoint = `stars/${starId}`; 882 | return this.delete(endpoint); 883 | } 884 | 885 | /** 886 | * https://developer.nulab.com/docs/backlog/api/2/get-notification/ 887 | */ 888 | public getNotifications( 889 | params: Option.Notification.GetNotificationsParams 890 | ): Promise { 891 | return this.get('notifications', params); 892 | } 893 | 894 | /** 895 | * https://developer.nulab.com/docs/backlog/api/2/count-notification/ 896 | */ 897 | public getNotificationsCount( 898 | params: Option.Notification.GetNotificationsCountParams 899 | ): Promise { 900 | return this.get('notifications/count', params); 901 | } 902 | 903 | /** 904 | * https://developer.nulab.com/docs/backlog/api/2/reset-unread-notification-count/ 905 | */ 906 | public resetNotificationsMarkAsRead(): Promise { 907 | return this.post('notifications/markAsRead'); 908 | } 909 | 910 | /** 911 | * https://developer.nulab.com/docs/backlog/api/2/read-notification/ 912 | */ 913 | public markAsReadNotification(id: number): Promise { 914 | return this.post(`notifications/${id}/markAsRead`); 915 | } 916 | 917 | /** 918 | * https://developer.nulab.com/docs/backlog/api/2/get-list-of-git-repositories/ 919 | */ 920 | public getGitRepositories(projectIdOrKey: string | number): Promise { 921 | return this.get(`projects/${projectIdOrKey}/git/repositories`); 922 | } 923 | 924 | /** 925 | * https://developer.nulab.com/docs/backlog/api/2/get-git-repository/ 926 | */ 927 | public getGitRepository( 928 | projectIdOrKey: string | number, repoIdOrName: string 929 | ): Promise { 930 | return this.get(`projects/${projectIdOrKey}/git/repositories/${repoIdOrName}`); 931 | } 932 | 933 | /** 934 | * https://developer.nulab.com/docs/backlog/api/2/get-pull-request-list/ 935 | */ 936 | public getPullRequests( 937 | projectIdOrKey: string | number, 938 | repoIdOrName: string, 939 | params: Option.PullRequest.GetPullRequestsParams 940 | ): Promise { 941 | return this.get(`projects/${projectIdOrKey}/git/repositories/${repoIdOrName}/pullRequests`, params); 942 | } 943 | 944 | /** 945 | * https://developer.nulab.com/docs/backlog/api/2/get-number-of-pull-requests/ 946 | */ 947 | public getPullRequestsCount( 948 | projectIdOrKey: string | number, 949 | repoIdOrName: string, 950 | params: Option.PullRequest.GetPullRequestsParams 951 | ): Promise { 952 | return this.get(`projects/${projectIdOrKey}/git/repositories/${repoIdOrName}/pullRequests/count`, params); 953 | } 954 | 955 | /** 956 | * https://developer.nulab.com/docs/backlog/api/2/add-pull-request/ 957 | */ 958 | public postPullRequest( 959 | projectIdOrKey: string | number, 960 | repoIdOrName: string, 961 | params: Option.PullRequest.PostPullRequestParams 962 | ): Promise { 963 | return this.post(`projects/${projectIdOrKey}/git/repositories/${repoIdOrName}/pullRequests`, params); 964 | } 965 | 966 | /** 967 | * https://developer.nulab.com/docs/backlog/api/2/get-pull-request/ 968 | */ 969 | public getPullRequest( 970 | projectIdOrKey: string | number, repoIdOrName: string, number: number 971 | ): Promise { 972 | return this.get(`projects/${projectIdOrKey}/git/repositories/${repoIdOrName}/pullRequests/${number}`); 973 | } 974 | 975 | /** 976 | * https://developer.nulab.com/docs/backlog/api/2/update-pull-request/ 977 | */ 978 | public patchPullRequest( 979 | projectIdOrKey: string | number, 980 | repoIdOrName: string, 981 | number: number, 982 | params: Option.PullRequest.PatchPullRequestParams 983 | ): Promise { 984 | return this.patch(`projects/${projectIdOrKey}/git/repositories/${repoIdOrName}/pullRequests/${number}`, params); 985 | } 986 | 987 | /** 988 | * https://developer.nulab.com/docs/backlog/api/2/get-pull-request-comment/ 989 | */ 990 | public getPullRequestComments( 991 | projectIdOrKey: string | number, 992 | repoIdOrName: string, 993 | number: number, 994 | params: Option.PullRequest.GetPullRequestCommentsParams 995 | ): Promise { 996 | return this.get(`projects/${projectIdOrKey}/git/repositories/${repoIdOrName}/pullRequests/${number}/comments`, params); 997 | } 998 | 999 | /** 1000 | * https://developer.nulab.com/docs/backlog/api/2/add-pull-request-comment/ 1001 | */ 1002 | public postPullRequestComments( 1003 | projectIdOrKey: string | number, 1004 | repoIdOrName: string, 1005 | number: number, 1006 | params: Option.PullRequest.PostPullRequestCommentsParams 1007 | ): Promise { 1008 | return this.post(`projects/${projectIdOrKey}/git/repositories/${repoIdOrName}/pullRequests/${number}/comments`, params); 1009 | } 1010 | 1011 | /** 1012 | * https://developer.nulab.com/docs/backlog/api/2/get-number-of-pull-request-comments/ 1013 | */ 1014 | public getPullRequestCommentsCount( 1015 | projectIdOrKey: string | number, repoIdOrName: string, number: number 1016 | ): Promise { 1017 | return this.get(`projects/${projectIdOrKey}/git/repositories/${repoIdOrName}/pullRequests/${number}/comments/count`); 1018 | } 1019 | 1020 | /** 1021 | * https://developer.nulab.com/docs/backlog/api/2/update-pull-request-comment-information/ 1022 | */ 1023 | public patchPullRequestComments( 1024 | projectIdOrKey: string | number, 1025 | repoIdOrName: string, 1026 | number: number, 1027 | commentId: number, 1028 | params: Option.PullRequest.PatchPullRequestCommentsParams 1029 | ): Promise { 1030 | return this.patch(`projects/${projectIdOrKey}/git/repositories/${repoIdOrName}/pullRequests/${number}/comments/${commentId}`, params); 1031 | } 1032 | 1033 | /** 1034 | * https://developer.nulab.com/docs/backlog/api/2/get-list-of-pull-request-attachment/ 1035 | */ 1036 | public getPullRequestAttachments( 1037 | projectIdOrKey: string | number, repoIdOrName: string, number: number 1038 | ): Promise { 1039 | return this.get(`projects/${projectIdOrKey}/git/repositories/${repoIdOrName}/pullRequests/${number}/attachments`); 1040 | } 1041 | 1042 | /** 1043 | * https://developer.nulab.com/docs/backlog/api/2/download-pull-request-attachment/ 1044 | */ 1045 | public getPullRequestAttachment( 1046 | projectIdOrKey: string | number, repoIdOrName: string, number: number, attachmentId: number 1047 | ): Promise { 1048 | return this.download(`projects/${projectIdOrKey}/git/repositories/${repoIdOrName}/pullRequests/${number}/attachments/${attachmentId}`); 1049 | } 1050 | 1051 | /** 1052 | * https://developer.nulab.com/docs/backlog/api/2/delete-pull-request-attachments/ 1053 | */ 1054 | public deletePullRequestAttachment( 1055 | projectIdOrKey: string | number, repoIdOrName: string, number: number, attachmentId: number 1056 | ): Promise { 1057 | return this.get(`projects/${projectIdOrKey}/git/repositories/${repoIdOrName}/pullRequests/${number}/attachments/${attachmentId}`); 1058 | } 1059 | 1060 | /** 1061 | * https://developer.nulab.com/docs/backlog/api/2/get-watching-list 1062 | */ 1063 | public getWatchingListItems(userId: number, params?: Option.WatchingList.GetWatchingListParams): Promise { 1064 | return this.get(`users/${userId}/watchings`, params); 1065 | } 1066 | 1067 | /** 1068 | * https://developer.nulab.com/docs/backlog/api/2/count-watching 1069 | */ 1070 | public getWatchingListCount(userId: number, params?: Option.WatchingList.GetWatchingListCountParams): Promise { 1071 | return this.get(`users/${userId}/watchings/count`, params); 1072 | } 1073 | 1074 | /** 1075 | * https://developer.nulab.com/docs/backlog/api/2/get-watching 1076 | */ 1077 | public getWatchingListItem(watchId: number): Promise { 1078 | return this.get(`watchings/${watchId}`); 1079 | } 1080 | 1081 | /** 1082 | * https://developer.nulab.com/docs/backlog/api/2/add-watching 1083 | */ 1084 | public postWatchingListItem( 1085 | params: Option.WatchingList.PostWatchingListItemParams, 1086 | ): Promise { 1087 | return this.post(`watchings`, params); 1088 | } 1089 | 1090 | /** 1091 | * https://developer.nulab.com/docs/backlog/api/2/update-watching 1092 | */ 1093 | public patchWatchingListItem(watchId: number, note: string): Promise { 1094 | return this.patch(`watchings/${watchId}`, { note }); 1095 | } 1096 | 1097 | /** 1098 | * https://developer.nulab.com/docs/backlog/api/2/delete-watching 1099 | */ 1100 | public deletehWatchingListItem(watchId: number): Promise { 1101 | return this.delete(`watchings/${watchId}`); 1102 | } 1103 | 1104 | /** 1105 | * https://developer.nulab.com/docs/backlog/api/2/mark-watching-as-read 1106 | */ 1107 | public resetWatchingListItemAsRead(watchId: number): Promise { 1108 | return this.post(`watchings/${watchId}/markAsRead`); 1109 | } 1110 | 1111 | /** 1112 | * https://developer.nulab.com/docs/backlog/api/2/get-licence 1113 | */ 1114 | public getLicence(): Promise { 1115 | return this.get(`space/licence`); 1116 | } 1117 | 1118 | /** 1119 | * https://developer.nulab.com/docs/backlog/api/2/get-list-of-teams/ 1120 | */ 1121 | public getTeams(params?: Option.Team.GetTeamsParams): Promise { 1122 | return this.get(`teams`, params); 1123 | } 1124 | 1125 | /** 1126 | * https://developer.nulab.com/docs/backlog/api/2/add-team/ 1127 | */ 1128 | public postTeam(params: Option.Team.PostTeamParams): Promise { 1129 | return this.post(`teams`, params); 1130 | } 1131 | 1132 | /** 1133 | * https://developer.nulab.com/docs/backlog/api/2/get-team/ 1134 | */ 1135 | public getTeam(teamId: number): Promise { 1136 | return this.get(`teams/${teamId}`); 1137 | } 1138 | 1139 | /** 1140 | * https://developer.nulab.com/docs/backlog/api/2/update-team/ 1141 | */ 1142 | public patchTeam(teamId: number, params: Option.Team.PatchTeamParams): Promise { 1143 | return this.patch(`teams/${teamId}`, params); 1144 | } 1145 | 1146 | /** 1147 | * https://developer.nulab.com/docs/backlog/api/2/delete-team/ 1148 | */ 1149 | public deleteTeam(teamId: number): Promise { 1150 | return this.delete(`teams/${teamId}`); 1151 | } 1152 | 1153 | /** 1154 | * https://developer.nulab.com/docs/backlog/api/2/get-team-icon/ 1155 | */ 1156 | public getTeamIcon(teamId: number): Promise { 1157 | return this.download(`teams/${teamId}/icon`); 1158 | } 1159 | 1160 | /** 1161 | * https://developer.nulab.com/docs/backlog/api/2/get-project-team-list/ 1162 | */ 1163 | public getProjectTeams(projectIdOrKey: string | number): Promise { 1164 | return this.get(`projects/${projectIdOrKey}/teams`); 1165 | } 1166 | 1167 | /** 1168 | * https://developer.nulab.com/docs/backlog/api/2/add-project-team/ 1169 | */ 1170 | public postProjectTeam(projectIdOrKey: string | number, teamId: number): Promise { 1171 | return this.post(`projects/${projectIdOrKey}/teams`, { teamId }); 1172 | } 1173 | 1174 | /** 1175 | * https://developer.nulab.com/docs/backlog/api/2/delete-project-team/ 1176 | */ 1177 | public deleteProjectTeam(projectIdOrKey: string | number, teamId: number): Promise { 1178 | return this.delete(`projects/${projectIdOrKey}/teams`, { teamId }); 1179 | } 1180 | 1181 | /** 1182 | * https://developer.nulab.com/docs/backlog/api/2/get-rate-limit/ 1183 | */ 1184 | public getRateLimit(): Promise { 1185 | return this.get("rateLimit"); 1186 | } 1187 | 1188 | private download(path: string): Promise { 1189 | return this.request({ method: 'GET', path }).then(this.parseFileData); 1190 | } 1191 | 1192 | private upload(path: string, params: FormData): Promise { 1193 | return this.request({ method: 'POST', path, params }).then(this.parseJSON); 1194 | } 1195 | 1196 | private parseFileData(response: Response): Promise { 1197 | return new Promise((resolve, reject) => { 1198 | if (typeof window !== 'undefined') { 1199 | resolve({ 1200 | body: (response).body, 1201 | url: response.url, 1202 | blob: () => response.blob(), 1203 | }); 1204 | } else { 1205 | const disposition = response.headers.get("Content-Disposition"); 1206 | const filename = disposition 1207 | ? disposition.substring(disposition.indexOf("''") + 2) : ""; 1208 | resolve({ 1209 | body: (response).body, 1210 | url: response.url, 1211 | filename: filename 1212 | }); 1213 | } 1214 | }); 1215 | } 1216 | 1217 | } 1218 | --------------------------------------------------------------------------------