Skip to content

Commit e0dd32e

Browse files
* v2.15.10 * eslint fix
1 parent d963266 commit e0dd32e

Some content is hidden

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

56 files changed

+1093
-283
lines changed

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ tests
44
coverage
55
.github
66
.idea
7+
example
78

89
.eslintrc
910
.editorconfig

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Jira.js changelog
22

3+
### 2.15.10
4+
5+
- `newErrorHandling` console message removed.
6+
- [`example`](https://github.com/MrRefactoring/jira.js/tree/master/example) added.
7+
- Improved example in the `README`.
8+
- Throwing error if `host` has incorrect URL format. Thanks to [Isuru Uthpala Priyaranjana](https://github.com/IsuruUthpala) for [reporting the enhancement](https://github.com/MrRefactoring/jira.js/issues/235).
9+
- Types improvements.
10+
311
### 2.15.9
412

513
- JSDoc improvements

README.md

Lines changed: 60 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Usability, consistency, and performance are key focuses of jira.js, and it also
2727
- [OAuth 2.0](#oauth-20)
2828
- [JWT](#jwt)
2929
- [Personal access token](#personal-access-token)
30-
- [Your first request and using algorithm](#your-first-request-and-using-algorithm)
30+
- [Example and using algorithm](#example-and-using-algorithm)
3131
- [Decreasing Webpack bundle size](#decreasing-webpack-bundle-size)
3232
- [Take a look at our other products](#take-a-look-at-our-other-products)
3333
- [License](#license)
@@ -113,9 +113,9 @@ Basic authentication allows you to log in with credentials. You can use username
113113
Username and password example:
114114
115115
```typescript
116-
import { Version2Client } from 'jira.js';
116+
import { Version3Client } from 'jira.js';
117117
118-
const client = new Version2Client({
118+
const client = new Version3Client({
119119
host: 'https://your-domain.atlassian.net',
120120
authentication: {
121121
basic: {
@@ -129,9 +129,9 @@ const client = new Version2Client({
129129
Email and API Token example:
130130

131131
```typescript
132-
import { Version2Client } from 'jira.js';
132+
import { Version3Client } from 'jira.js';
133133

134-
const client = new Version2Client({
134+
const client = new Version3Client({
135135
host: 'https://your-domain.atlassian.net',
136136
authentication: {
137137
basic: {
@@ -145,9 +145,9 @@ const client = new Version2Client({
145145
##### [OAuth](https://developer.atlassian.com/cloud/jira/platform/jira-rest-api-oauth-authentication/)
146146

147147
```typescript
148-
import { Version2Client } from 'jira.js';
148+
import { Version3Client } from 'jira.js';
149149

150-
const client = new Version2Client({
150+
const client = new Version3Client({
151151
host: 'https://your-domain.atlassian.net',
152152
authentication: {
153153
oauth: {
@@ -167,9 +167,9 @@ Only the authorization token is currently supported. To release it, you need to
167167
Example of usage
168168

169169
```typescript
170-
import { Version2Client } from 'jira.js';
170+
import { Version3Client } from 'jira.js';
171171

172-
const client = new Version2Client({
172+
const client = new Version3Client({
173173
host: 'https://your-domain.atlassian.net',
174174
authentication: {
175175
oauth2: {
@@ -182,9 +182,9 @@ const client = new Version2Client({
182182
##### [JWT](https://developer.atlassian.com/cloud/jira/platform/understanding-jwt-for-connect-apps/)
183183

184184
```typescript
185-
import { Version2Client } from 'jira.js';
185+
import { Version3Client } from 'jira.js';
186186

187-
const client = new Version2Client({
187+
const client = new Version3Client({
188188
host: 'https://your-domain.atlassian.net',
189189
authentication: {
190190
jwt: {
@@ -199,65 +199,80 @@ const client = new Version2Client({
199199
##### [Personal access token](https://confluence.atlassian.com/enterprise/using-personal-access-tokens-1026032365.html)
200200

201201
```typescript
202-
import { Version2Client } from 'jira.js';
202+
import { Version3Client } from 'jira.js';
203203

204-
const client = new Version2Client({
204+
const client = new Version3Client({
205205
host: 'https://your-domain.atlassian.net',
206206
authentication: {
207207
personalAccessToken: 'secrectPAT',
208208
},
209209
});
210210
```
211211

212-
#### Your first request and using algorithm
212+
#### Example and using algorithm
213+
214+
1. Example
215+
216+
You can find out [example project here](https://github.com/MrRefactoring/jira.js/tree/master/example) or perform the following actions:
217+
218+
- Change the `host`, `email` and `apiToken` to your data
219+
- Run script
213220

214221
```typescript
215-
import { Version2Client } from 'jira.js';
222+
import { Version3Client } from 'jira.js';
216223

217-
const client = new Version2Client({
218-
host: 'https://your-domain.atlassian.net',
224+
const client = new Version3Client({
225+
host,
219226
authentication: {
220227
basic: {
221-
email: 'YOUR_EMAIL',
222-
apiToken: 'YOUR_API_TOKEN',
228+
email,
229+
apiToken,
223230
},
224231
},
232+
newErrorHandling: true,
225233
});
226234

227235
async function main() {
228236
const projects = await client.projects.getAllProjects();
229237

230-
console.log(projects);
238+
if (projects.length) {
239+
const project = projects[0];
240+
241+
const { id } = await client.issues.createIssue({
242+
fields: {
243+
summary: 'My first issue',
244+
issuetype: {
245+
name: 'Task'
246+
},
247+
project: {
248+
key: project.key,
249+
},
250+
}
251+
});
252+
253+
const issue = await client.issues.getIssue({ issueIdOrKey: id });
254+
255+
console.log(`Issue '${issue.fields.summary}' was successfully added to '${project.name}' project.`);
256+
} else {
257+
const myself = await client.myself.getCurrentUser();
258+
259+
const { id } = await client.projects.createProject({
260+
key: 'PROJECT',
261+
name: "My Project",
262+
leadAccountId: myself.accountId,
263+
projectTypeKey: 'software',
264+
});
265+
266+
const project = await client.projects.getProject({ projectIdOrKey: id.toString() });
267+
268+
console.log(`Project '${project.name}' was successfully created.`);
269+
}
231270
}
232271

233272
main();
234-
235-
// Expected output:
236-
// [
237-
// {
238-
// expand: 'description,lead,issueTypes,url,projectKeys,permissions,insight',
239-
// self: 'https://your-domain.atlassian.net/rest/api/2/project/10000',
240-
// id: '10000',
241-
// key: 'TEST',
242-
// name: 'test',
243-
// avatarUrls: {
244-
// '48x48': 'https://your-domain.atlassian.net/secure/projectavatar?pid=10000&avatarId=10425',
245-
// '24x24': 'https://your-domain.atlassian.net/secure/projectavatar?size=small&s=small&pid=10000&avatarId=10425',
246-
// '16x16': 'https://your-domain.atlassian.net/secure/projectavatar?size=xsmall&s=xsmall&pid=10000&avatarId=10425',
247-
// '32x32': 'https://your-domain.atlassian.net/secure/projectavatar?size=medium&s=medium&pid=10000&avatarId=10425'
248-
// },
249-
// projectTypeKey: 'software',
250-
// simplified: true,
251-
// style: 'next-gen',
252-
// isPrivate: false,
253-
// properties: {},
254-
// entityId: 'e0a412bd-1510-4841-bdbc-84180db3ee3b',
255-
// uuid: 'e0a412bd-1510-4841-bdbc-84180db3ee3b'
256-
// }
257-
// ]
258273
```
259274

260-
The algorithm for using the library:
275+
2. The algorithm for using the library:
261276

262277
```typescript
263278
client.<group>.<methodName>(parametersObject);

example/.editorconfig

Lines changed: 11 additions & 0 deletions
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

example/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.idea/
2+
node_modules/
3+
4+
.DS_Store

example/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Jira.js usage example
2+
3+
### How to run
4+
5+
1. Install dependencies
6+
7+
```shell
8+
npm i
9+
```
10+
11+
2. Specify `host`, `email` and `apiToken` variables in top of `src/index.ts` file
12+
13+
```ts
14+
const host = 'https://your-domain.atlassian.net';
15+
const email = 'YOUR_EMAIL';
16+
const apiToken = 'YOUR_API_TOKEN';
17+
```
18+
19+
3. Run `start` script
20+
21+
```shell
22+
npm run start
23+
```

0 commit comments

Comments
 (0)