Skip to content

Commit 8c0f3af

Browse files
committed
1.0.0
0 parents  commit 8c0f3af

File tree

92 files changed

+10262
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+10262
-0
lines changed

.editorconfig

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
tab_width = 2
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
max_line_length = 120

.eslintrc

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"parser": "@typescript-eslint/parser",
3+
"extends": [
4+
"plugin:@typescript-eslint/recommended",
5+
"plugin:import/errors",
6+
"plugin:import/typescript"
7+
],
8+
"parserOptions": {
9+
"ecmaVersion": 2018,
10+
"sourceType": "module"
11+
},
12+
"plugins": [
13+
"import"
14+
],
15+
"rules": {
16+
"import/no-unresolved": "error",
17+
"@typescript-eslint/no-explicit-any": "off",
18+
"@typescript-eslint/camelcase": "error",
19+
"@typescript-eslint/class-name-casing": "error",
20+
"semi": "error",
21+
"eqeqeq": "error",
22+
"eol-last": "error",
23+
"lines-between-class-members": "error",
24+
"no-trailing-spaces": "error",
25+
"indent": [
26+
"error",
27+
2,
28+
{
29+
"SwitchCase": 1
30+
}
31+
],
32+
"quotes": [
33+
"error",
34+
"single"
35+
],
36+
"prefer-const": "error",
37+
"no-var": "error",
38+
"no-undef": "error"
39+
},
40+
"settings": {
41+
"import/parsers": {
42+
"@typescript-eslint/parser": [
43+
".ts",
44+
".tsx"
45+
]
46+
}
47+
}
48+
}

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
out
3+
docs

.npmignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
src
3+
docs
4+
.eslintrc
5+
.editorconfig

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Vladislav Tupikin
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# JavaScript JIRA API Client
2+
3+
[![npm](https://img.shields.io/npm/v/jira.js.svg)](https://www.npmjs.com/package/jira.js)
4+
[![Downloads](https://img.shields.io/npm/dm/jira.js.svg)](https://npmjs.com/jira.js)
5+
[![Install Size](https://badgen.net/packagephobia/publish/jira.js)](https://packagephobia.now.sh/result?p=jira.js)
6+
[![dependencies Status](https://david-dm.org/mrrefactoring/jira.js/status.svg)](https://david-dm.org/mrrefactoring/jira.js)
7+
[![devDependencies Status](https://david-dm.org/mrrefactoring/jira.js/dev-status.svg)](https://david-dm.org/mrrefactoring/jira.js?type=dev)
8+
9+
## Installation
10+
11+
Install with the npm:
12+
13+
```shell
14+
$ npm install jira.js
15+
```
16+
17+
Install with the yarn:
18+
19+
```shell
20+
$ yarn add jira.js
21+
```
22+
23+
## Examples
24+
25+
### Create the JIRA client
26+
27+
```js
28+
// ES5
29+
var { Client } = require("jira.js");
30+
31+
// ES6
32+
import { Client } from "jira.js";
33+
34+
// Initialize
35+
var client = new Client({
36+
host: "https://jira.somehost.com"
37+
});
38+
```
39+
40+
### Get all projects
41+
42+
```js
43+
// ES5/ES6
44+
client.projects
45+
.getAllProjects({})
46+
.then(projects => console.log(projects))
47+
.catch(error => console.log(error));
48+
49+
// ES7
50+
async function getProjects() {
51+
const projects = await client.projects.getAllProjects({});
52+
53+
console.log(projects);
54+
55+
return projects;
56+
}
57+
```
58+
59+
## Documentation
60+
61+
Can't find what you need in the readme? Check out our documentation here: https://jira.js.github.io/

package.json

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "jira.js",
3+
"version": "1.0.0",
4+
"main": "out/index.js",
5+
"types": "out/index.d.ts",
6+
"repository": "https://github.com/MrRefactoring/jira.js.git",
7+
"author": "Vladislav Tupikin <[email protected]>",
8+
"license": "MIT",
9+
"scripts": {
10+
"compile": "tsc",
11+
"prepublishOnly": "npm run lint && npm run compile",
12+
"lint": "eslint ./src --ext .js,.ts",
13+
"lint:fix": "npm run lint -- --fix",
14+
"doc": "typedoc --out docs --mode file --ignoreCompilerErrors ./src"
15+
},
16+
"devDependencies": {
17+
"@types/express": "^4.17.2",
18+
"@types/node": "^13.1.2",
19+
"@typescript-eslint/eslint-plugin": "^2.14.0",
20+
"@typescript-eslint/parser": "^2.14.0",
21+
"eslint": "^6.8.0",
22+
"eslint-import-resolver-typescript": "^2.0.0",
23+
"eslint-plugin-import": "^2.19.1",
24+
"typedoc": "^0.15.6",
25+
"typescript": "^3.7.4"
26+
},
27+
"dependencies": {
28+
"atlassian-jwt": "^1.0.2",
29+
"axios": "^0.19.0"
30+
}
31+
}

src/api/appProperties.ts

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import { AxiosRequestConfig } from 'axios';
2+
import { Sender } from '../sender';
3+
import { Callback } from '../callback';
4+
export class AppProperties {
5+
constructor(private readonly client: Sender) {}
6+
7+
public async getAppProperties(
8+
params: {
9+
addonKey: string;
10+
},
11+
callback?: Callback
12+
): Promise<any> {
13+
const request: AxiosRequestConfig = {
14+
url: `/rest/atlassian-connect/1/addons/${params.addonKey}/properties`,
15+
method: 'GET'
16+
};
17+
return this.client.sendRequest(request, callback);
18+
}
19+
20+
public async getAppProperty(
21+
params: {
22+
addonKey: string;
23+
propertyKey: string;
24+
},
25+
callback?: Callback
26+
): Promise<any> {
27+
const request: AxiosRequestConfig = {
28+
url: `/rest/atlassian-connect/1/addons/${params.addonKey}/properties/${params.propertyKey}`,
29+
method: 'GET'
30+
};
31+
return this.client.sendRequest(request, callback);
32+
}
33+
34+
public async setAppProperty(
35+
params: {
36+
addonKey: string;
37+
propertyKey: string;
38+
[key: string]: any;
39+
},
40+
callback?: Callback
41+
): Promise<any> {
42+
const request: AxiosRequestConfig = {
43+
url: `/rest/atlassian-connect/1/addons/${params.addonKey}/properties/${params.propertyKey}`,
44+
method: 'PUT',
45+
data: { ...params, addonKey: undefined, propertyKey: undefined }
46+
};
47+
return this.client.sendRequest(request, callback);
48+
}
49+
50+
public async deleteAppProperty(
51+
params: {
52+
addonKey: string;
53+
propertyKey: string;
54+
},
55+
callback?: Callback
56+
): Promise<any> {
57+
const request: AxiosRequestConfig = {
58+
url: `/rest/atlassian-connect/1/addons/${params.addonKey}/properties/${params.propertyKey}`,
59+
method: 'DELETE'
60+
};
61+
return this.client.sendRequest(request, callback);
62+
}
63+
}

src/api/applicationRoles.ts

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { AxiosRequestConfig } from 'axios';
2+
import { Sender } from '../sender';
3+
import { Callback } from '../callback';
4+
export class ApplicationRoles {
5+
constructor(private readonly client: Sender) {}
6+
7+
public async getAllApplicationRoles(callback?: Callback): Promise<any> {
8+
const request: AxiosRequestConfig = {
9+
url: '/rest/api/2/applicationrole',
10+
method: 'GET'
11+
};
12+
return this.client.sendRequest(request, callback);
13+
}
14+
15+
public async getApplicationRole(
16+
params: {
17+
key: string;
18+
},
19+
callback?: Callback
20+
): Promise<any> {
21+
const request: AxiosRequestConfig = {
22+
url: `/rest/api/2/applicationrole/${params.key}`,
23+
method: 'GET'
24+
};
25+
return this.client.sendRequest(request, callback);
26+
}
27+
}

src/api/auditRecords.ts

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { AxiosRequestConfig } from 'axios';
2+
import { Sender } from '../sender';
3+
import { Callback } from '../callback';
4+
export class AuditRecords {
5+
constructor(private readonly client: Sender) {}
6+
7+
public async getAuditRecords(
8+
params: {
9+
offset?: number;
10+
limit?: number;
11+
filter?: string;
12+
from?: string;
13+
to?: string;
14+
},
15+
callback?: Callback
16+
): Promise<any> {
17+
const request: AxiosRequestConfig = {
18+
url: '/rest/api/2/auditing/record',
19+
method: 'GET',
20+
params: {
21+
offset: params.offset,
22+
limit: params.limit,
23+
filter: params.filter,
24+
from: params.from,
25+
to: params.to
26+
}
27+
};
28+
return this.client.sendRequest(request, callback);
29+
}
30+
}

src/api/avatars.ts

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import { AxiosRequestConfig } from 'axios';
2+
import { Sender } from '../sender';
3+
import { Callback } from '../callback';
4+
export class Avatars {
5+
constructor(private readonly client: Sender) {}
6+
7+
public async getSystemAvatarsByType(
8+
params: {
9+
type: string;
10+
},
11+
callback?: Callback
12+
): Promise<any> {
13+
const request: AxiosRequestConfig = {
14+
url: `/rest/api/2/avatar/${params.type}/system`,
15+
method: 'GET'
16+
};
17+
return this.client.sendRequest(request, callback);
18+
}
19+
20+
public async getAvatars(
21+
params: {
22+
type: string;
23+
entityId: string;
24+
},
25+
callback?: Callback
26+
): Promise<any> {
27+
const request: AxiosRequestConfig = {
28+
url: `/rest/api/2/universal_avatar/type/${params.type}/owner/${params.entityId}`,
29+
method: 'GET'
30+
};
31+
return this.client.sendRequest(request, callback);
32+
}
33+
34+
public async loadAvatar(
35+
params: {
36+
type: string;
37+
entityId: string;
38+
x?: number;
39+
y?: number;
40+
size: number;
41+
[key: string]: any;
42+
},
43+
callback?: Callback
44+
): Promise<any> {
45+
const request: AxiosRequestConfig = {
46+
url: `/rest/api/2/universal_avatar/type/${params.type}/owner/${params.entityId}`,
47+
method: 'POST',
48+
params: {
49+
x: params.x,
50+
y: params.y,
51+
size: params.size
52+
},
53+
data: {
54+
...params,
55+
type: undefined,
56+
entityId: undefined,
57+
x: undefined,
58+
y: undefined,
59+
size: undefined
60+
}
61+
};
62+
return this.client.sendRequest(request, callback);
63+
}
64+
65+
public async deleteAvatar(
66+
params: {
67+
type: string;
68+
owningObjectId: string;
69+
id: number;
70+
},
71+
callback?: Callback
72+
): Promise<any> {
73+
const request: AxiosRequestConfig = {
74+
url: `/rest/api/2/universal_avatar/type/${params.type}/owner/${params.owningObjectId}/avatar/${params.id}`,
75+
method: 'DELETE'
76+
};
77+
return this.client.sendRequest(request, callback);
78+
}
79+
}

0 commit comments

Comments
 (0)