Skip to content

Commit 1dcc8fb

Browse files
New experimental endpoints (#12)
* expand expanded :) * New experimental endpoints
1 parent 608fcca commit 1dcc8fb

22 files changed

+403
-262
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
### 1.2.2
4+
5+
- JSDOC improvements
6+
- New experimental endpoints
7+
- Small improvements
8+
39
### 1.2.1
410

511
- Vulnerabilities fixes.

package-lock.json

Lines changed: 119 additions & 214 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "confluence.js",
3-
"version": "1.2.1",
3+
"version": "1.2.2",
44
"description": "confluence.js is a powerful Node.JS/Browser module that allows you to interact with the Confluence API very easily",
55
"author": "Vladislav Tupikin <[email protected]>",
66
"license": "MIT",
@@ -34,25 +34,25 @@
3434
],
3535
"devDependencies": {
3636
"@types/express": "^4.17.13",
37-
"@types/jest": "^27.0.2",
37+
"@types/jest": "^27.0.3",
3838
"@types/oauth": "^0.9.1",
3939
"@types/sinon": "^10.0.6",
40-
"@typescript-eslint/eslint-plugin": "^5.2.0",
41-
"@typescript-eslint/parser": "^5.2.0",
40+
"@typescript-eslint/eslint-plugin": "^5.4.0",
41+
"@typescript-eslint/parser": "^5.4.0",
4242
"dotenv": "^10.0.0",
43-
"eslint": "^8.1.0",
44-
"eslint-config-airbnb": "^18.2.1",
45-
"eslint-config-airbnb-typescript": "^14.0.1",
43+
"eslint": "^8.2.0",
44+
"eslint-config-airbnb": "^19.0.0",
45+
"eslint-config-airbnb-typescript": "^16.0.0",
4646
"eslint-import-resolver-typescript": "^2.5.0",
47-
"eslint-plugin-import": "^2.25.2",
47+
"eslint-plugin-import": "^2.25.3",
4848
"jest": "^27.3.1",
4949
"prettier": "^2.4.1",
50-
"prettier-plugin-jsdoc": "^0.3.24",
51-
"sinon": "^11.1.2",
50+
"prettier-plugin-jsdoc": "^0.3.30",
51+
"sinon": "^12.0.1",
5252
"ts-jest": "^27.0.7",
53-
"typedoc": "^0.22.7",
53+
"typedoc": "^0.22.9",
5454
"typedoc-plugin-extras": "^2.2.1",
55-
"typescript": "^4.4.4"
55+
"typescript": "^4.5.2"
5656
},
5757
"dependencies": {
5858
"atlassian-jwt": "^2.0.2",

src/api/contentProperties.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ export class ContentProperties {
126126
method: 'GET',
127127
params: {
128128
expand: parameters.expand,
129+
status: parameters.status,
129130
},
130131
};
131132

src/api/experimental.ts

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,99 @@ import { RequestConfig } from '../requestConfig';
77
export class Experimental {
88
constructor(private client: Client) {}
99

10+
/**
11+
* Returns a list of labels associated with a space. Can provide a prefix as well as other filters to select different
12+
* types of labels.
13+
*/
14+
async getLabelsForSpace<T = Models.LabelArray>(
15+
parameters: Parameters.GetLabelsForSpace,
16+
callback: Callback<T>
17+
): Promise<void>;
18+
/**
19+
* Returns a list of labels associated with a space. Can provide a prefix as well as other filters to select different
20+
* types of labels.
21+
*/
22+
async getLabelsForSpace<T = Models.LabelArray>(
23+
parameters: Parameters.GetLabelsForSpace,
24+
callback?: never
25+
): Promise<T>;
26+
async getLabelsForSpace<T = Models.LabelArray>(
27+
parameters: Parameters.GetLabelsForSpace,
28+
callback?: Callback<T>,
29+
): Promise<void | T> {
30+
const config: RequestConfig = {
31+
url: `/api/space/${parameters.spaceKey}/label`,
32+
method: 'GET',
33+
params: {
34+
prefix: parameters.prefix,
35+
start: parameters.start,
36+
limit: parameters.limit,
37+
},
38+
};
39+
40+
return this.client.sendRequest(config, callback, { methodName: 'getLabelsForSpace' });
41+
}
42+
43+
/**
44+
* Adds labels to a piece of content. Does not modify the existing labels.
45+
*
46+
* Notes:
47+
*
48+
* - Labels can also be added when creating content ([Create content](#api-content-post)).
49+
* - Labels can be updated when updating content ([Update content](#api-content-id-put)). This will delete the existing
50+
* labels and replace them with the labels in the request.
51+
*
52+
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to update the content.
53+
*/
54+
async addLabelsToSpace<T = Models.LabelArray>(
55+
parameters: Parameters.AddLabelsToSpace,
56+
callback: Callback<T>
57+
): Promise<void>;
58+
/**
59+
* Adds labels to a piece of content. Does not modify the existing labels.
60+
*
61+
* Notes:
62+
*
63+
* - Labels can also be added when creating content ([Create content](#api-content-post)).
64+
* - Labels can be updated when updating content ([Update content](#api-content-id-put)). This will delete the existing
65+
* labels and replace them with the labels in the request.
66+
*
67+
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to update the content.
68+
*/
69+
async addLabelsToSpace<T = Models.LabelArray>(parameters: Parameters.AddLabelsToSpace, callback?: never): Promise<T>;
70+
async addLabelsToSpace<T = Models.LabelArray>(
71+
parameters: Parameters.AddLabelsToSpace,
72+
callback?: Callback<T>,
73+
): Promise<void | T> {
74+
const config: RequestConfig = {
75+
url: `/api/space/${parameters.spaceKey}/label`,
76+
method: 'POST',
77+
};
78+
79+
return this.client.sendRequest(config, callback, { methodName: 'addLabelsToSpace' });
80+
}
81+
82+
async deleteLabelFromSpace<T = void>(
83+
parameters: Parameters.DeleteLabelFromSpace,
84+
callback: Callback<T>
85+
): Promise<void>;
86+
async deleteLabelFromSpace<T = void>(parameters: Parameters.DeleteLabelFromSpace, callback?: never): Promise<T>;
87+
async deleteLabelFromSpace<T = void>(
88+
parameters: Parameters.DeleteLabelFromSpace,
89+
callback?: Callback<T>,
90+
): Promise<void | T> {
91+
const config: RequestConfig = {
92+
url: `/api/space/${parameters.spaceKey}/label`,
93+
method: 'DELETE',
94+
params: {
95+
name: parameters.name,
96+
prefix: parameters.prefix,
97+
},
98+
};
99+
100+
return this.client.sendRequest(config, callback, { methodName: 'deleteLabelFromSpace' });
101+
}
102+
10103
/** Get the total number of views a piece of content has. */
11104
async getViews<T = Models.GetViews>(parameters: Parameters.GetViews, callback: Callback<T>): Promise<void>;
12105
/** Get the total number of views a piece of content has. */
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export interface AddLabelsToSpace {
2+
/** The key of the space to add labels to. */
3+
spaceKey: string;
4+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export interface DeleteLabelFromSpace {
2+
/** The key of the space to remove a labels from. */
3+
spaceKey: string;
4+
/** The name of the label to remove */
5+
name: string;
6+
/** The prefix of the label to remove. If not provided defaults to global. */
7+
prefix?: string;
8+
}

src/api/parameters/getBulkUserLookup.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@ export interface GetBulkUserLookup {
55
* A multi-value parameter indicating which properties of the user to expand.
66
*
77
* - `operations` returns the operations that the user is allowed to do.
8-
* - `details.personal` returns the 'Personal' details in the user's profile, like the 'Email' and 'Phone'. Note that
9-
* these fields have been deprecated due to privacy changes. See the [migration
10-
* guide](https://developer.atlassian.com/cloud/confluence/deprecation-notice-user-privacy-api-migration-guide/) for details.
11-
* - `details.business` returns the 'Company' details in the user's profile, like the 'Position' and 'Department'. Note
12-
* that these fields have been deprecated due to privacy changes. See the [migration
13-
* guide](https://developer.atlassian.com/cloud/confluence/deprecation-notice-user-privacy-api-migration-guide/) for details.
148
* - PersonalSpace returns the user's personal space, if it exists.
159
*/
1610
expand?: string[];

src/api/parameters/getContentById.ts

Lines changed: 86 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,95 @@ export interface GetContentById {
1919
*/
2020
embeddedContentRender?: string;
2121
/** A multi-value parameter indicating which properties of the content to expand. */
22-
expand?: string[];
22+
expand?: string | string[] | GetContentById.Expand | GetContentById.Expand[];
2323
/**
2424
* If set to `viewed`, the request will trigger a 'viewed' event for the content. When this event is triggered, the
2525
* page/blogpost will appear on the 'Recently visited' tab of the user's Confluence dashboard.
2626
*/
2727
trigger?: string;
2828
}
29+
30+
export namespace GetContentById {
31+
export enum Expand {
32+
/**
33+
* Returns whether the content has attachments, comments, or child pages. Use this if you only need to check whether
34+
* the content has children of a particular type.
35+
*/
36+
AllChildTypes = 'childTypes.all',
37+
/** Returns whether the content has attachments. */
38+
AttachmentChildType = 'childTypes.attachment',
39+
/** Returns whether the content has comments. */
40+
CommentChildType = 'childTypes.comment',
41+
/** Returns whether the content has child pages. */
42+
PageChildType = 'childTypes.page',
43+
/**
44+
* Returns the space that the content is in. This is the same as the information returned by [Get
45+
* space](https://developer.atlassian.com/cloud/confluence/rest/api-group-content---attachments/).
46+
*/
47+
Container = 'container',
48+
/**
49+
* Returns information about the current user in relation to the content, including when they last viewed it,
50+
* modified it, contributed to it, or added it as a favorite.
51+
*/
52+
CurrentUserMetadata = 'metadata.currentuser',
53+
/** Returns content properties that have been set via the Confluence REST API. */
54+
PropertiesMetadata = 'metadata.properties',
55+
/** Returns the labels that have been added to the content. */
56+
LabelsMetadata = 'metadata.labels',
57+
/** This property is only used by Atlassian. */
58+
FrontendMetadata = 'metadata.frontend',
59+
/** Returns the operations for the content, which are used when setting permissions. */
60+
Operations = 'operations',
61+
/** Returns pages that are descendants at the level immediately below the content. */
62+
PageChildren = 'children.page',
63+
/** Returns all attachments for the content. */
64+
AttachmentChildren = 'children.attachment',
65+
/** Returns all comments on the content. */
66+
CommentChildren = 'children.comment',
67+
/** Returns the users that have permission to read the content. */
68+
ReadUserRestriction = 'restrictions.read.restrictions.user',
69+
/**
70+
* Returns the groups that have permission to read the content. Note that this may return deleted groups, because
71+
* deleting a group doesn't remove associated restrictions.
72+
*/
73+
ReadGroupRestriction = 'restrictions.read.restrictions.group',
74+
/** Returns the users that have permission to update the content. */
75+
UpdateUserRestriction = 'restrictions.update.restrictions.user',
76+
/**
77+
* Returns the groups that have permission to update the content. Note that this may return deleted groups because
78+
* deleting a group doesn't remove associated restrictions.
79+
*/
80+
UpdateGroupRestriction = 'restrictions.update.restrictions.group',
81+
/** Returns the history of the content, including the date it was created. */
82+
History = 'history',
83+
/** Returns information about the most recent update of the content, including who updated it and when it was updated. */
84+
LastUpdated = 'history.lastUpdated',
85+
/** Returns information about the update prior to the current content update. */
86+
PreviousVersion = 'history.previousVersion',
87+
/** Returns all of the users who have contributed to the content. */
88+
Contributors = 'history.contributors',
89+
/** Returns information about the update after to the current content update. */
90+
NextVersion = 'history.nextVersion',
91+
/** Returns the parent page, if the content is a page. */
92+
Ancestors = 'ancestors',
93+
/** Returns the body of the content in different formats, including the editor format, view format, and export format. */
94+
Body = 'body',
95+
/** Returns information about the most recent update of the content, including who updated it and when it was updated. */
96+
Version = 'version',
97+
/** Returns pages that are descendants at any level below the content. */
98+
PageDescendant = 'descendants.page',
99+
/** Returns all attachments for the content, same as `children.attachment`. */
100+
AttachmentDescendant = 'descendants.attachment',
101+
/** Returns all comments on the content, same as `children.comment`. */
102+
CommentDescendant = 'descendants.comment',
103+
/**
104+
* Returns the space that the content is in. This is the same as the information returned by [Get
105+
* space](https://developer.atlassian.com/cloud/confluence/rest/api-group-content---attachments/).
106+
*/
107+
Space = 'space',
108+
/** Returns inline comment-specific properties. */
109+
InlineProperties = 'extensions.inlineProperties',
110+
/** Returns the resolution status of each comment. */
111+
Resolution = 'extensions.resolution',
112+
}
113+
}

src/api/parameters/getContentChildren.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export interface GetContentChildren {
77
* - `attachment` returns all attachments for the content.
88
* - `comments` returns all comments for the content.
99
* - `page` returns all child pages of the content.
10+
* - Custom content types that are provided by apps are also supported.
1011
*/
1112
expand?: string[];
1213
/** The version of the parent content to retrieve children for. Currently, this only works for the latest version. */

0 commit comments

Comments
 (0)