Skip to content

Commit a0a29aa

Browse files
Cloud API updates (#32)
* Cloud API updates * e2e tests fixes * prettier
1 parent ac097f5 commit a0a29aa

37 files changed

+961
-86
lines changed

CHANGELOG.md

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

3+
### 1.6.0
4+
5+
Cloud API:
6+
- `asyncConvertContentBodyRequest` method added to `ContentBody` API.
7+
- `asyncConvertContentBodyResponse` method added to `ContentBody` API.
8+
- [`ContentContentState`](https://github.com/MrRefactoring/confluence.js/blob/master/src/api/contentContentState.ts) API are deprecated. Use [`ContentStates`](https://github.com/MrRefactoring/confluence.js/blob/master/src/api/contentStates.ts) instead.
9+
- `getAndConvertMacroBodyByMacroId` method added to `ContentMacroBody` API.
10+
- `getAndAsyncConvertMacroBodyByMacroId` method added to `ContentMacroBody` API.
11+
- `registerModules` method fixed via adding body to the request. `DynamicModules` API.
12+
- Other fixes and improvements. (like `expand` property adding).
13+
314
### 1.5.3
415

516
`expand` property added to `convertContentBody` method to `ContentBody` API. Thanks to [Federico Gonzalez](https://github.com/FedeG) for report.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ Available groups:
247247
- [contentPermissions](https://developer.atlassian.com/cloud/confluence/rest/api-group-content-permissions/#api-group-content-permissions)
248248
- [contentProperties](https://developer.atlassian.com/cloud/confluence/rest/api-group-content-properties/#api-group-content-properties)
249249
- [contentRestrictions](https://developer.atlassian.com/cloud/confluence/rest/api-group-content-restrictions/#api-group-content-restrictions)
250+
- [contentStates](https://developer.atlassian.com/cloud/confluence/rest/api-group-content-states/#api-group-content-states)
250251
- [contentVersions](https://developer.atlassian.com/cloud/confluence/rest/api-group-content-versions/#api-group-content-versions)
251252
- [contentWatches](https://developer.atlassian.com/cloud/confluence/rest/api-group-content-watches/#api-group-content-watches)
252253
- [dynamicModules](https://developer.atlassian.com/cloud/confluence/rest/api-group-dynamic-modules/#api-group-dynamic-modules)

package-lock.json

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

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "confluence.js",
3-
"version": "1.5.3",
3+
"version": "1.6.0",
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",
@@ -60,7 +60,7 @@
6060
"sinon": "^14.0.0",
6161
"typedoc": "^0.23.14",
6262
"typedoc-plugin-extras": "^2.3.0",
63-
"typescript": "^4.8.2"
63+
"typescript": "^4.8.3"
6464
},
6565
"dependencies": {
6666
"atlassian-jwt": "^2.0.2",

src/api/contentBody.ts

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,104 @@ export class ContentBody {
6565

6666
return this.client.sendRequest(config, callback);
6767
}
68+
69+
/**
70+
* Converts a content body from one format to another format asynchronously. Returns the asyncId for the asynchronous
71+
* task.
72+
*
73+
* Supported conversions:
74+
*
75+
* - Storage: export_view
76+
*
77+
* No other conversions are supported at the moment. Once a conversion is completed, it will be available for 5
78+
* minutes at the result endpoint.
79+
*
80+
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: If request specifies 'contentIdContext',
81+
* 'View' permission for the space, and permission to view the content.
82+
*/
83+
async asyncConvertContentBodyRequest<T = Models.AsyncId>(
84+
parameters: Parameters.AsyncConvertContentBodyRequest,
85+
callback: Callback<T>
86+
): Promise<void>;
87+
/**
88+
* Converts a content body from one format to another format asynchronously. Returns the asyncId for the asynchronous
89+
* task.
90+
*
91+
* Supported conversions:
92+
*
93+
* - Storage: export_view
94+
*
95+
* No other conversions are supported at the moment. Once a conversion is completed, it will be available for 5
96+
* minutes at the result endpoint.
97+
*
98+
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: If request specifies 'contentIdContext',
99+
* 'View' permission for the space, and permission to view the content.
100+
*/
101+
async asyncConvertContentBodyRequest<T = Models.AsyncId>(
102+
parameters: Parameters.AsyncConvertContentBodyRequest,
103+
callback?: never
104+
): Promise<T>;
105+
async asyncConvertContentBodyRequest<T = Models.AsyncId>(
106+
parameters: Parameters.AsyncConvertContentBodyRequest,
107+
callback?: Callback<T>,
108+
): Promise<void | T> {
109+
const config: RequestConfig = {
110+
url: `/api/contentbody/convert/async/${parameters.to}`,
111+
method: 'POST',
112+
params: {
113+
spaceKeyContext: parameters.spaceKeyContext,
114+
contentIdContext: parameters.contentIdContext,
115+
allowCache: parameters.allowCache,
116+
embeddedContentRender: parameters.embeddedContentRender,
117+
expand: parameters.expand,
118+
},
119+
data: {
120+
value: parameters.value,
121+
representation: parameters.representation,
122+
...parameters.additionalProperties,
123+
},
124+
};
125+
126+
return this.client.sendRequest(config, callback);
127+
}
128+
129+
/**
130+
* Returns the Asynchronous Content Body for the corresponding asyncId if the task is complete or returns the status
131+
* of the task.
132+
*
133+
* After the task is completed, the result can be obtained for 5 minutes, or until an identical conversion request is
134+
* made again, with allowCache query param set to false.
135+
*
136+
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: If request specifies 'contentIdContext',
137+
* 'View' permission for the space, and permission to view the content.
138+
*/
139+
async asyncConvertContentBodyResponse<T = Models.AsyncContentBody>(
140+
parameters: Parameters.AsyncConvertContentBodyResponse,
141+
callback: Callback<T>
142+
): Promise<void>;
143+
/**
144+
* Returns the Asynchronous Content Body for the corresponding asyncId if the task is complete or returns the status
145+
* of the task.
146+
*
147+
* After the task is completed, the result can be obtained for 5 minutes, or until an identical conversion request is
148+
* made again, with allowCache query param set to false.
149+
*
150+
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: If request specifies 'contentIdContext',
151+
* 'View' permission for the space, and permission to view the content.
152+
*/
153+
async asyncConvertContentBodyResponse<T = Models.AsyncContentBody>(
154+
parameters: Parameters.AsyncConvertContentBodyResponse,
155+
callback?: never
156+
): Promise<T>;
157+
async asyncConvertContentBodyResponse<T = Models.AsyncContentBody>(
158+
parameters: Parameters.AsyncConvertContentBodyResponse,
159+
callback?: Callback<T>,
160+
): Promise<void | T> {
161+
const config: RequestConfig = {
162+
url: `/api/contentbody/convert/async/${parameters.id}`,
163+
method: 'GET',
164+
};
165+
166+
return this.client.sendRequest(config, callback);
167+
}
68168
}

src/api/contentChildrenAndDescendants.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,10 @@ export class ContentChildrenAndDescendants {
9292
*/
9393
async movePage<T = Models.MovePage>(parameters: Parameters.MovePage, callback?: never): Promise<T>;
9494
async movePage<T = Models.MovePage>(parameters: Parameters.MovePage, callback?: Callback<T>): Promise<void | T> {
95+
const pageId = parameters.pageId || parameters.id;
96+
9597
const config: RequestConfig = {
96-
url: `/api/content/${parameters.id}/move/${parameters.position}/${parameters.targetId}`,
98+
url: `/api/content/${pageId}/move/${parameters.position}/${parameters.targetId}`,
9799
method: 'PUT',
98100
};
99101

src/api/contentContentState.ts

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,22 @@ import { Callback } from '../callback';
44
import { Client } from '../clients';
55
import { RequestConfig } from '../requestConfig';
66

7+
/** @deprecated Use {@link ContentStates} instead. */
78
export class ContentContentState {
9+
/** @deprecated */
810
constructor(private client: Client) {}
911

1012
/**
11-
* Gets the current page status of the draft or published version of content. To specify the draft version, set the
12-
* parameter status to PUBLISHED, otherwise DRAFT.
13+
* @deprecated Gets the current page status of the draft or published version of content. To specify the draft
14+
* version, set the parameter status to PUBLISHED, otherwise DRAFT.
1315
*/
1416
async getContentState<T = Models.ContentStateContainer>(
1517
parameters: Parameters.GetContentState,
1618
callback: Callback<T>
1719
): Promise<void>;
1820
/**
19-
* Gets the current page status of the draft or published version of content. To specify the draft version, set the
20-
* parameter status to PUBLISHED, otherwise DRAFT.
21+
* @deprecated Gets the current page status of the draft or published version of content. To specify the draft
22+
* version, set the parameter status to PUBLISHED, otherwise DRAFT.
2123
*/
2224
async getContentState<T = Models.ContentStateContainer>(
2325
parameters: Parameters.GetContentState,
@@ -39,28 +41,28 @@ export class ContentContentState {
3941
}
4042

4143
/**
42-
* Sets the content state of the content specified and creates a new version (publishes the content without changing
43-
* the body) of the content with the new status. The desired type of status must be allowed. There are space suggested
44-
* statuses and custom statuses. To specify the desired new status, one can use the id of the status or the name and
45-
* color of the status. If contentStateId is defined, then name and color are ignored. If contentStateId is not
46-
* defined, name and color will be used if provided. Firstly, we will determine if a status of this name and color
47-
* exists, and if it does, that this status is used. If it does not exist, and custom statuses are allowed, a custom
48-
* status with this name and color will be created. Color can be specified in traditional english colors (teal,
49-
* magenta, lavender, etc.) or as a hex string ex: #0ff0Fd.
44+
* @deprecated Sets the content state of the content specified and creates a new version (publishes the content
45+
* without changing the body) of the content with the new status. The desired type of status must be allowed. There
46+
* are space suggested statuses and custom statuses. To specify the desired new status, one can use the id of the
47+
* status or the name and color of the status. If contentStateId is defined, then name and color are ignored. If
48+
* contentStateId is not defined, name and color will be used if provided. Firstly, we will determine if a status of
49+
* this name and color exists, and if it does, that this status is used. If it does not exist, and custom statuses
50+
* are allowed, a custom status with this name and color will be created. Color can be specified in traditional
51+
* english colors (teal, magenta, lavender, etc.) or as a hex string ex: #0ff0Fd.
5052
*/
5153
async setContentState<T = Models.ContentStateContainer>(
5254
parameters: Parameters.SetContentState,
5355
callback: Callback<T>
5456
): Promise<void>;
5557
/**
56-
* Sets the content state of the content specified and creates a new version (publishes the content without changing
57-
* the body) of the content with the new status. The desired type of status must be allowed. There are space suggested
58-
* statuses and custom statuses. To specify the desired new status, one can use the id of the status or the name and
59-
* color of the status. If contentStateId is defined, then name and color are ignored. If contentStateId is not
60-
* defined, name and color will be used if provided. Firstly, we will determine if a status of this name and color
61-
* exists, and if it does, that this status is used. If it does not exist, and custom statuses are allowed, a custom
62-
* status with this name and color will be created. Color can be specified in traditional english colors (teal,
63-
* magenta, lavender, etc.) or as a hex string ex: #0ff0Fd.
58+
* @deprecated Sets the content state of the content specified and creates a new version (publishes the content
59+
* without changing the body) of the content with the new status. The desired type of status must be allowed. There
60+
* are space suggested statuses and custom statuses. To specify the desired new status, one can use the id of the
61+
* status or the name and color of the status. If contentStateId is defined, then name and color are ignored. If
62+
* contentStateId is not defined, name and color will be used if provided. Firstly, we will determine if a status of
63+
* this name and color exists, and if it does, that this status is used. If it does not exist, and custom statuses
64+
* are allowed, a custom status with this name and color will be created. Color can be specified in traditional
65+
* english colors (teal, magenta, lavender, etc.) or as a hex string ex: #0ff0Fd.
6466
*/
6567
async setContentState<T = Models.ContentStateContainer>(
6668
parameters: Parameters.SetContentState,
@@ -84,16 +86,16 @@ export class ContentContentState {
8486
}
8587

8688
/**
87-
* Removes the content state of the content specified and creates a new version (publishes the content without
88-
* changing the body) of the content with the new status.
89+
* @deprecated Removes the content state of the content specified and creates a new version (publishes the content
90+
* without changing the body) of the content with the new status.
8991
*/
9092
async removeContentState<T = Models.ContentStateContainer>(
9193
parameters: Parameters.RemoveContentState,
9294
callback: Callback<T>
9395
): Promise<void>;
9496
/**
95-
* Removes the content state of the content specified and creates a new version (publishes the content without
96-
* changing the body) of the content with the new status.
97+
* @deprecated Removes the content state of the content specified and creates a new version (publishes the content
98+
* without changing the body) of the content with the new status.
9799
*/
98100
async removeContentState<T = Models.ContentStateContainer>(
99101
parameters: Parameters.RemoveContentState,
@@ -111,12 +113,12 @@ export class ContentContentState {
111113
return this.client.sendRequest(config, callback);
112114
}
113115

114-
/** Gets a Global Timestamp of the last time the content state was updated */
116+
/** @deprecated Gets a Global Timestamp of the last time the content state was updated */
115117
async getContentStateLastUpdated<T = unknown>(
116118
parameters: Parameters.GetContentStateLastUpdated,
117119
callback: Callback<T>
118120
): Promise<void>;
119-
/** Gets a Global Timestamp of the last time the content state was updated */
121+
/** @deprecated Gets a Global Timestamp of the last time the content state was updated */
120122
async getContentStateLastUpdated<T = unknown>(
121123
parameters: Parameters.GetContentStateLastUpdated,
122124
callback?: never
@@ -133,12 +135,12 @@ export class ContentContentState {
133135
return this.client.sendRequest(config, callback);
134136
}
135137

136-
/** Gets content states that are available for the content to be set as. */
138+
/** @deprecated Gets content states that are available for the content to be set as. */
137139
async getAvailableContentStates<T = Models.AvailableContentStates>(
138140
parameters: Parameters.GetAvailableContentStates,
139141
callback: Callback<T>
140142
): Promise<void>;
141-
/** Gets content states that are available for the content to be set as. */
143+
/** @deprecated Gets content states that are available for the content to be set as. */
142144
async getAvailableContentStates<T = Models.AvailableContentStates>(
143145
parameters: Parameters.GetAvailableContentStates,
144146
callback?: never

0 commit comments

Comments
 (0)