type for node-redmine package (#37495)

* first commit

* test 1

* test 1

* test 2

* test 2
This commit is contained in:
grptx
2019-08-09 08:28:27 -07:00
committed by Nathan Shively-Sanders
parent b56ebdbf4e
commit 4cd01a0797
4 changed files with 144 additions and 0 deletions
+102
View File
@@ -0,0 +1,102 @@
// Type definitions for node-redmine 0.2
// Project: https://github.com/zanran/node-redmine#readme
// Definitions by: Roberto Rossetti <https://github.com/grptx>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
export interface IssueRecord {
id: number;
project: IssueRecordField;
tracker: IssueRecordField;
status: IssueRecordField;
priority: IssueRecordField;
author: IssueRecordField;
assigned_to: IssueRecordField;
parent?: IssueRecordField;
subject: string;
description: string;
start_date: string | null;
due_date: string | null;
done_ratio: number;
is_private: boolean;
total_estimated_hours: number | null;
created_at: string;
updated_at: string | null;
closed_on: string | null;
}
export interface IssueRecordField {
id: number;
name?: string;
}
export interface IssueParams {
project_id?: number;
tracker_id?: number;
priority_id?: number;
category_id?: number;
status_id?: number;
assigned_to_id?: number;
subject?: string;
description?: string;
parent_issue_id?: number;
notes?: string;
uploads?: UploadRecord[];
}
export interface UploadResult {
upload: UploadRecord;
}
export interface UploadRecord {
token: string;
content_type?: string;
filename: string;
}
export interface IssueData {
issue: IssueParams;
}
export interface Issue {
issue: IssueRecord;
}
export interface Issues {
issues: IssueRecord[];
}
export class Redmine {
constructor(host: string, config: any, port: number);
/////////////////////////////////////// REST API for issues(Stable) ///////////////////////////////////////
issues(params: any, callback: (err: any, data: any) => void): Issues;
get_issue_by_id(id: number, params: any, callback: (err: any, data: any) => void): Issue;
create_issue(issue: IssueData, callback: (err: any, data: any) => void): Issue;
update_issue(id: number, issue: IssueData, callback: (err: any, data: any) => void): Issue;
delete_issue(id: number, callback: (err: any, data: any) => void): void;
add_watcher(id: number, params: any, callback: (err: any, data: any) => void): void;
remove_watcher(id: number, params: any, callback: (err: any, data: any) => void): void;
/////////////////////////////////////// REST API for Issue Relations(Alpha) ///////////////////////////////////////
issue_relation_by_issue_id(id: number, callback: (err: any, data: any) => void): void;
create_issue_relation(id: number, params: any, callback: (err: any, data: any) => void): void;
issue_relation_by_id(id: number, callback: (err: any, data: any) => void): void;
delete_issue_relation(id: number, callback: (err: any, data: any) => void): void;
/////////////////////////////////////// REST API for Common(Alpha) ///////////////////////////////////////
upload(content: any, callback: (err: any, data: any) => void): UploadResult;
}
+18
View File
@@ -0,0 +1,18 @@
import { Issue, Redmine } from 'node-redmine';
const redmine = new Redmine('http://localhost', { apiKey: 'QWERTYUIOP' }, 8080);
const dump_issue = (issue: Issue) => {
console.log('Dumping issue:');
for (const item in issue) {
console.log(`${JSON.stringify(issue)}: `);
}
};
redmine.issues({ limit: 2 }, (err, data) => {
if (err) throw err;
for (const issue of data.issues) {
dump_issue(issue);
}
console.log(`total count: ${data.total_count}`);
});
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"node-redmine-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }