diff --git a/CHANGELOG.md b/CHANGELOG.md index fcfb4a6b..029dbdc3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # Changelog +### 1.6.0 + +Cloud API: + - `asyncConvertContentBodyRequest` method added to `ContentBody` API. + - `asyncConvertContentBodyResponse` method added to `ContentBody` API. + - [`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. + - `getAndConvertMacroBodyByMacroId` method added to `ContentMacroBody` API. + - `getAndAsyncConvertMacroBodyByMacroId` method added to `ContentMacroBody` API. + - `registerModules` method fixed via adding body to the request. `DynamicModules` API. + - Other fixes and improvements. (like `expand` property adding). + ### 1.5.3 `expand` property added to `convertContentBody` method to `ContentBody` API. Thanks to [Federico Gonzalez](https://github.com/FedeG) for report. diff --git a/README.md b/README.md index c583d798..2ba2b625 100644 --- a/README.md +++ b/README.md @@ -247,6 +247,7 @@ Available groups: - [contentPermissions](https://developer.atlassian.com/cloud/confluence/rest/api-group-content-permissions/#api-group-content-permissions) - [contentProperties](https://developer.atlassian.com/cloud/confluence/rest/api-group-content-properties/#api-group-content-properties) - [contentRestrictions](https://developer.atlassian.com/cloud/confluence/rest/api-group-content-restrictions/#api-group-content-restrictions) +- [contentStates](https://developer.atlassian.com/cloud/confluence/rest/api-group-content-states/#api-group-content-states) - [contentVersions](https://developer.atlassian.com/cloud/confluence/rest/api-group-content-versions/#api-group-content-versions) - [contentWatches](https://developer.atlassian.com/cloud/confluence/rest/api-group-content-watches/#api-group-content-watches) - [dynamicModules](https://developer.atlassian.com/cloud/confluence/rest/api-group-dynamic-modules/#api-group-dynamic-modules) diff --git a/package-lock.json b/package-lock.json index 3db5ce01..4d2f211d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "confluence.js", - "version": "1.5.3", + "version": "1.6.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "confluence.js", - "version": "1.5.3", + "version": "1.6.0", "license": "MIT", "dependencies": { "atlassian-jwt": "^2.0.2", @@ -34,7 +34,7 @@ "sinon": "^14.0.0", "typedoc": "^0.23.14", "typedoc-plugin-extras": "^2.3.0", - "typescript": "^4.8.2" + "typescript": "^4.8.3" } }, "node_modules/@babel/runtime": { @@ -5586,9 +5586,9 @@ } }, "node_modules/typescript": { - "version": "4.8.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.2.tgz", - "integrity": "sha512-C0I1UsrrDHo2fYI5oaCGbSejwX4ch+9Y5jTQELvovfmFkK3HHSZJB8MSJcWLmCUBzQBchCrZ9rMRV6GuNrvGtw==", + "version": "4.8.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.3.tgz", + "integrity": "sha512-goMHfm00nWPa8UvR/CPSvykqf6dVV8x/dp0c5mFTMTIu0u0FlGWRioyy7Nn0PGAdHxpJZnuO/ut+PpQ8UiHAig==", "dev": true, "bin": { "tsc": "bin/tsc", @@ -9819,9 +9819,9 @@ "requires": {} }, "typescript": { - "version": "4.8.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.2.tgz", - "integrity": "sha512-C0I1UsrrDHo2fYI5oaCGbSejwX4ch+9Y5jTQELvovfmFkK3HHSZJB8MSJcWLmCUBzQBchCrZ9rMRV6GuNrvGtw==", + "version": "4.8.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.3.tgz", + "integrity": "sha512-goMHfm00nWPa8UvR/CPSvykqf6dVV8x/dp0c5mFTMTIu0u0FlGWRioyy7Nn0PGAdHxpJZnuO/ut+PpQ8UiHAig==", "dev": true }, "unbox-primitive": { diff --git a/package.json b/package.json index 0abdd157..718d87ef 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "confluence.js", - "version": "1.5.3", + "version": "1.6.0", "description": "confluence.js is a powerful Node.JS/Browser module that allows you to interact with the Confluence API very easily", "author": "Vladislav Tupikin ", "license": "MIT", @@ -60,7 +60,7 @@ "sinon": "^14.0.0", "typedoc": "^0.23.14", "typedoc-plugin-extras": "^2.3.0", - "typescript": "^4.8.2" + "typescript": "^4.8.3" }, "dependencies": { "atlassian-jwt": "^2.0.2", diff --git a/src/api/contentBody.ts b/src/api/contentBody.ts index 3f27bb5f..670b86e7 100644 --- a/src/api/contentBody.ts +++ b/src/api/contentBody.ts @@ -65,4 +65,104 @@ export class ContentBody { return this.client.sendRequest(config, callback); } + + /** + * Converts a content body from one format to another format asynchronously. Returns the asyncId for the asynchronous + * task. + * + * Supported conversions: + * + * - Storage: export_view + * + * No other conversions are supported at the moment. Once a conversion is completed, it will be available for 5 + * minutes at the result endpoint. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: If request specifies 'contentIdContext', + * 'View' permission for the space, and permission to view the content. + */ + async asyncConvertContentBodyRequest( + parameters: Parameters.AsyncConvertContentBodyRequest, + callback: Callback + ): Promise; + /** + * Converts a content body from one format to another format asynchronously. Returns the asyncId for the asynchronous + * task. + * + * Supported conversions: + * + * - Storage: export_view + * + * No other conversions are supported at the moment. Once a conversion is completed, it will be available for 5 + * minutes at the result endpoint. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: If request specifies 'contentIdContext', + * 'View' permission for the space, and permission to view the content. + */ + async asyncConvertContentBodyRequest( + parameters: Parameters.AsyncConvertContentBodyRequest, + callback?: never + ): Promise; + async asyncConvertContentBodyRequest( + parameters: Parameters.AsyncConvertContentBodyRequest, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/api/contentbody/convert/async/${parameters.to}`, + method: 'POST', + params: { + spaceKeyContext: parameters.spaceKeyContext, + contentIdContext: parameters.contentIdContext, + allowCache: parameters.allowCache, + embeddedContentRender: parameters.embeddedContentRender, + expand: parameters.expand, + }, + data: { + value: parameters.value, + representation: parameters.representation, + ...parameters.additionalProperties, + }, + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Returns the Asynchronous Content Body for the corresponding asyncId if the task is complete or returns the status + * of the task. + * + * After the task is completed, the result can be obtained for 5 minutes, or until an identical conversion request is + * made again, with allowCache query param set to false. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: If request specifies 'contentIdContext', + * 'View' permission for the space, and permission to view the content. + */ + async asyncConvertContentBodyResponse( + parameters: Parameters.AsyncConvertContentBodyResponse, + callback: Callback + ): Promise; + /** + * Returns the Asynchronous Content Body for the corresponding asyncId if the task is complete or returns the status + * of the task. + * + * After the task is completed, the result can be obtained for 5 minutes, or until an identical conversion request is + * made again, with allowCache query param set to false. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: If request specifies 'contentIdContext', + * 'View' permission for the space, and permission to view the content. + */ + async asyncConvertContentBodyResponse( + parameters: Parameters.AsyncConvertContentBodyResponse, + callback?: never + ): Promise; + async asyncConvertContentBodyResponse( + parameters: Parameters.AsyncConvertContentBodyResponse, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/api/contentbody/convert/async/${parameters.id}`, + method: 'GET', + }; + + return this.client.sendRequest(config, callback); + } } diff --git a/src/api/contentChildrenAndDescendants.ts b/src/api/contentChildrenAndDescendants.ts index f579b3c5..4aed5c2f 100644 --- a/src/api/contentChildrenAndDescendants.ts +++ b/src/api/contentChildrenAndDescendants.ts @@ -92,8 +92,10 @@ export class ContentChildrenAndDescendants { */ async movePage(parameters: Parameters.MovePage, callback?: never): Promise; async movePage(parameters: Parameters.MovePage, callback?: Callback): Promise { + const pageId = parameters.pageId || parameters.id; + const config: RequestConfig = { - url: `/api/content/${parameters.id}/move/${parameters.position}/${parameters.targetId}`, + url: `/api/content/${pageId}/move/${parameters.position}/${parameters.targetId}`, method: 'PUT', }; diff --git a/src/api/contentContentState.ts b/src/api/contentContentState.ts index ec4ac552..62079a41 100644 --- a/src/api/contentContentState.ts +++ b/src/api/contentContentState.ts @@ -4,20 +4,22 @@ import { Callback } from '../callback'; import { Client } from '../clients'; import { RequestConfig } from '../requestConfig'; +/** @deprecated Use {@link ContentStates} instead. */ export class ContentContentState { + /** @deprecated */ constructor(private client: Client) {} /** - * Gets the current page status of the draft or published version of content. To specify the draft version, set the - * parameter status to PUBLISHED, otherwise DRAFT. + * @deprecated Gets the current page status of the draft or published version of content. To specify the draft + * version, set the parameter status to PUBLISHED, otherwise DRAFT. */ async getContentState( parameters: Parameters.GetContentState, callback: Callback ): Promise; /** - * Gets the current page status of the draft or published version of content. To specify the draft version, set the - * parameter status to PUBLISHED, otherwise DRAFT. + * @deprecated Gets the current page status of the draft or published version of content. To specify the draft + * version, set the parameter status to PUBLISHED, otherwise DRAFT. */ async getContentState( parameters: Parameters.GetContentState, @@ -39,28 +41,28 @@ export class ContentContentState { } /** - * Sets the content state of the content specified and creates a new version (publishes the content without changing - * the body) of the content with the new status. The desired type of status must be allowed. There are space suggested - * statuses and custom statuses. To specify the desired new status, one can use the id of the status or the name and - * color of the status. If contentStateId is defined, then name and color are ignored. If contentStateId is not - * defined, name and color will be used if provided. Firstly, we will determine if a status of this name and color - * exists, and if it does, that this status is used. If it does not exist, and custom statuses are allowed, a custom - * status with this name and color will be created. Color can be specified in traditional english colors (teal, - * magenta, lavender, etc.) or as a hex string ex: #0ff0Fd. + * @deprecated Sets the content state of the content specified and creates a new version (publishes the content + * without changing the body) of the content with the new status. The desired type of status must be allowed. There + * are space suggested statuses and custom statuses. To specify the desired new status, one can use the id of the + * status or the name and color of the status. If contentStateId is defined, then name and color are ignored. If + * contentStateId is not defined, name and color will be used if provided. Firstly, we will determine if a status of + * this name and color exists, and if it does, that this status is used. If it does not exist, and custom statuses + * are allowed, a custom status with this name and color will be created. Color can be specified in traditional + * english colors (teal, magenta, lavender, etc.) or as a hex string ex: #0ff0Fd. */ async setContentState( parameters: Parameters.SetContentState, callback: Callback ): Promise; /** - * Sets the content state of the content specified and creates a new version (publishes the content without changing - * the body) of the content with the new status. The desired type of status must be allowed. There are space suggested - * statuses and custom statuses. To specify the desired new status, one can use the id of the status or the name and - * color of the status. If contentStateId is defined, then name and color are ignored. If contentStateId is not - * defined, name and color will be used if provided. Firstly, we will determine if a status of this name and color - * exists, and if it does, that this status is used. If it does not exist, and custom statuses are allowed, a custom - * status with this name and color will be created. Color can be specified in traditional english colors (teal, - * magenta, lavender, etc.) or as a hex string ex: #0ff0Fd. + * @deprecated Sets the content state of the content specified and creates a new version (publishes the content + * without changing the body) of the content with the new status. The desired type of status must be allowed. There + * are space suggested statuses and custom statuses. To specify the desired new status, one can use the id of the + * status or the name and color of the status. If contentStateId is defined, then name and color are ignored. If + * contentStateId is not defined, name and color will be used if provided. Firstly, we will determine if a status of + * this name and color exists, and if it does, that this status is used. If it does not exist, and custom statuses + * are allowed, a custom status with this name and color will be created. Color can be specified in traditional + * english colors (teal, magenta, lavender, etc.) or as a hex string ex: #0ff0Fd. */ async setContentState( parameters: Parameters.SetContentState, @@ -84,16 +86,16 @@ export class ContentContentState { } /** - * Removes the content state of the content specified and creates a new version (publishes the content without - * changing the body) of the content with the new status. + * @deprecated Removes the content state of the content specified and creates a new version (publishes the content + * without changing the body) of the content with the new status. */ async removeContentState( parameters: Parameters.RemoveContentState, callback: Callback ): Promise; /** - * Removes the content state of the content specified and creates a new version (publishes the content without - * changing the body) of the content with the new status. + * @deprecated Removes the content state of the content specified and creates a new version (publishes the content + * without changing the body) of the content with the new status. */ async removeContentState( parameters: Parameters.RemoveContentState, @@ -111,12 +113,12 @@ export class ContentContentState { return this.client.sendRequest(config, callback); } - /** Gets a Global Timestamp of the last time the content state was updated */ + /** @deprecated Gets a Global Timestamp of the last time the content state was updated */ async getContentStateLastUpdated( parameters: Parameters.GetContentStateLastUpdated, callback: Callback ): Promise; - /** Gets a Global Timestamp of the last time the content state was updated */ + /** @deprecated Gets a Global Timestamp of the last time the content state was updated */ async getContentStateLastUpdated( parameters: Parameters.GetContentStateLastUpdated, callback?: never @@ -133,12 +135,12 @@ export class ContentContentState { return this.client.sendRequest(config, callback); } - /** Gets content states that are available for the content to be set as. */ + /** @deprecated Gets content states that are available for the content to be set as. */ async getAvailableContentStates( parameters: Parameters.GetAvailableContentStates, callback: Callback ): Promise; - /** Gets content states that are available for the content to be set as. */ + /** @deprecated Gets content states that are available for the content to be set as. */ async getAvailableContentStates( parameters: Parameters.GetAvailableContentStates, callback?: never diff --git a/src/api/contentMacroBody.ts b/src/api/contentMacroBody.ts index 00eb0edf..4da3df32 100644 --- a/src/api/contentMacroBody.ts +++ b/src/api/contentMacroBody.ts @@ -58,4 +58,119 @@ export class ContentMacroBody { return this.client.sendRequest(config, callback); } + + /** + * Returns the body of a macro in format specified in path, for the given macro ID. This includes information like the + * name of the macro, the body of the macro, and any macro parameters. + * + * About the macro ID: When a macro is created in a new version of content, Confluence will generate a random ID for + * it, unless an ID is specified (by an app). The macro ID will look similar to this: + * '50884bd9-0cb8-41d5-98be-f80943c14f96'. The ID is then persisted as new versions of content are created, and is + * only modified by Confluence if there are conflicting IDs. + * + * Note, to preserve backwards compatibility this resource will also match on the hash of the macro body, even if a + * macro ID is found. This check will eventually become redundant, as macro IDs are generated for pages and + * transparently propagate out to all instances. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content that the + * macro is in. + */ + async getAndConvertMacroBodyByMacroId( + parameters: Parameters.GetAndConvertMacroBodyByMacroId, + callback: Callback + ): Promise; + /** + * Returns the body of a macro in format specified in path, for the given macro ID. This includes information like the + * name of the macro, the body of the macro, and any macro parameters. + * + * About the macro ID: When a macro is created in a new version of content, Confluence will generate a random ID for + * it, unless an ID is specified (by an app). The macro ID will look similar to this: + * '50884bd9-0cb8-41d5-98be-f80943c14f96'. The ID is then persisted as new versions of content are created, and is + * only modified by Confluence if there are conflicting IDs. + * + * Note, to preserve backwards compatibility this resource will also match on the hash of the macro body, even if a + * macro ID is found. This check will eventually become redundant, as macro IDs are generated for pages and + * transparently propagate out to all instances. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content that the + * macro is in. + */ + async getAndConvertMacroBodyByMacroId( + parameters: Parameters.GetAndConvertMacroBodyByMacroId, + callback?: never + ): Promise; + async getAndConvertMacroBodyByMacroId( + parameters: Parameters.GetAndConvertMacroBodyByMacroId, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/api/content/${parameters.id}/history/${parameters.version}/macro/id/${parameters.macroId}/convert/${parameters.to}`, + method: 'GET', + params: { + spaceKeyContext: parameters.spaceKeyContext, + embeddedContentRender: parameters.embeddedContentRender, + expand: parameters.expand, + }, + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Returns Async Id of the conversion task which will convert the macro into a content body of the desired format. The + * result will be available for 5 minutes after completion of the conversion. + * + * About the macro ID: When a macro is created in a new version of content, Confluence will generate a random ID for + * it, unless an ID is specified (by an app). The macro ID will look similar to this: + * '884bd9-0cb8-41d5-98be-f80943c14f96'. The ID is then persisted as new versions of content are created, and is only + * modified by Confluence if there are conflicting IDs. + * + * Note, to preserve backwards compatibility this resource will also match on the hash of the macro body, even if a + * macro ID is found. This check will eventually become redundant, as macro IDs are generated for pages and + * transparently propagate out to all instances. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content that the + * macro is in. + */ + async getAndAsyncConvertMacroBodyByMacroId( + parameters: Parameters.GetAndAsyncConvertMacroBodyByMacroId, + callback: Callback + ): Promise; + /** + * Returns Async Id of the conversion task which will convert the macro into a content body of the desired format. The + * result will be available for 5 minutes after completion of the conversion. + * + * About the macro ID: When a macro is created in a new version of content, Confluence will generate a random ID for + * it, unless an ID is specified (by an app). The macro ID will look similar to this: + * '884bd9-0cb8-41d5-98be-f80943c14f96'. The ID is then persisted as new versions of content are created, and is only + * modified by Confluence if there are conflicting IDs. + * + * Note, to preserve backwards compatibility this resource will also match on the hash of the macro body, even if a + * macro ID is found. This check will eventually become redundant, as macro IDs are generated for pages and + * transparently propagate out to all instances. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content that the + * macro is in. + */ + async getAndAsyncConvertMacroBodyByMacroId( + parameters: Parameters.GetAndAsyncConvertMacroBodyByMacroId, + callback?: never + ): Promise; + async getAndAsyncConvertMacroBodyByMacroId( + parameters: Parameters.GetAndAsyncConvertMacroBodyByMacroId, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/api/content/${parameters.id}/history/${parameters.version}/macro/id/${parameters.macroId}/convert/async/${parameters.to}`, + method: 'GET', + params: { + allowCache: parameters.allowCache, + spaceKeyContext: parameters.spaceKeyContext, + embeddedContentRender: parameters.embeddedContentRender, + expand: parameters.expand, + }, + }; + + return this.client.sendRequest(config, callback); + } } diff --git a/src/api/contentStates.ts b/src/api/contentStates.ts new file mode 100644 index 00000000..1c718758 --- /dev/null +++ b/src/api/contentStates.ts @@ -0,0 +1,252 @@ +import * as Models from './models'; +import * as Parameters from './parameters'; +import { Callback } from '../callback'; +import { Client } from '../clients'; +import { RequestConfig } from '../requestConfig'; + +export class ContentStates { + constructor(private client: Client) {} + + /** + * Gets the current content state of the draft or current version of content. To specify the draft version, set the + * parameter status to draft, otherwise archived or current will get the relevant published state. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content. + */ + async getContentState( + parameters: Parameters.GetContentState, + callback: Callback + ): Promise; + /** + * Gets the current content state of the draft or current version of content. To specify the draft version, set the + * parameter status to draft, otherwise archived or current will get the relevant published state. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content. + */ + async getContentState( + parameters: Parameters.GetContentState, + callback?: never + ): Promise; + async getContentState( + parameters: Parameters.GetContentState, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/api/content/${parameters.id}/state`, + method: 'GET', + params: { + status: parameters.status, + }, + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Sets the content state of the content specified and creates a new version (publishes the content without changing + * the body) of the content with the new state. + * + * You may pass in either an id of a state, or the name and color of a desired new state. If all 3 are passed in, id + * will be used. If the name and color passed in already exist under the current user's existing custom states, the + * existing state will be reused. If custom states are disabled in the space of the content (which can be determined + * by getting the content state space settings of the content's space) then this set will fail. + * + * You may not remove a content state via this PUT request. You must use the DELETE method. A specified state is + * required in the body of this request. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to edit the content. + */ + async setContentState( + parameters: Parameters.SetContentState, + callback: Callback + ): Promise; + /** + * Sets the content state of the content specified and creates a new version (publishes the content without changing + * the body) of the content with the new state. + * + * You may pass in either an id of a state, or the name and color of a desired new state. If all 3 are passed in, id + * will be used. If the name and color passed in already exist under the current user's existing custom states, the + * existing state will be reused. If custom states are disabled in the space of the content (which can be determined + * by getting the content state space settings of the content's space) then this set will fail. + * + * You may not remove a content state via this PUT request. You must use the DELETE method. A specified state is + * required in the body of this request. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to edit the content. + */ + async setContentState( + parameters: Parameters.SetContentState, + callback?: never + ): Promise; + async setContentState( + parameters: Parameters.SetContentState, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/api/content/${parameters.id}/state`, + method: 'PUT', + params: { + status: parameters.status, + }, + data: { + name: parameters.name, + color: parameters.color, + id: parameters.stateId, + }, + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Removes the content state of the content specified and creates a new version (publishes the content without + * changing the body) of the content with the new status. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to edit the content. + */ + async removeContentState( + parameters: Parameters.RemoveContentState, + callback: Callback + ): Promise; + /** + * Removes the content state of the content specified and creates a new version (publishes the content without + * changing the body) of the content with the new status. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to edit the content. + */ + async removeContentState( + parameters: Parameters.RemoveContentState, + callback?: never + ): Promise; + async removeContentState( + parameters: Parameters.RemoveContentState, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/api/content/${parameters.id}/state`, + method: 'DELETE', + params: { + status: parameters.status, + }, + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Gets content states that are available for the content to be set as. Will return all enabled Space Content States. + * Will only return most the 3 most recently published custom content states to match UI editor list. To get all + * custom content states, use the /content-states endpoint. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to edit the content. + */ + async getAvailableContentStates( + parameters: Parameters.GetAvailableContentStates, + callback: Callback + ): Promise; + /** + * Gets content states that are available for the content to be set as. Will return all enabled Space Content States. + * Will only return most the 3 most recently published custom content states to match UI editor list. To get all + * custom content states, use the /content-states endpoint. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to edit the content. + */ + async getAvailableContentStates( + parameters: Parameters.GetAvailableContentStates, + callback?: never + ): Promise; + async getAvailableContentStates( + parameters: Parameters.GetAvailableContentStates, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/api/content/${parameters.id}/state/available`, + method: 'GET', + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Get custom content states that authenticated user has created. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required** Must have user authentication. + */ + async getCustomContentStates(callback: Callback): Promise; + /** + * Get custom content states that authenticated user has created. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required** Must have user authentication. + */ + async getCustomContentStates(callback?: never): Promise; + async getCustomContentStates(callback?: Callback): Promise { + const config: RequestConfig = { + url: '/api/content-states', + method: 'GET', + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Get content states that are suggested in the space. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Space view permission + */ + async getSpaceContentStates( + parameters: Parameters.GetSpaceContentStates, + callback: Callback + ): Promise; + /** + * Get content states that are suggested in the space. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Space view permission + */ + async getSpaceContentStates( + parameters: Parameters.GetSpaceContentStates, + callback?: never + ): Promise; + async getSpaceContentStates( + parameters: Parameters.GetSpaceContentStates, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/api/space/${parameters.spaceKey}/state`, + method: 'GET', + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Get object describing whether content states are allowed at all, if custom content states or space content states + * are restricted, and a list of space content states allowed for the space if they are not restricted. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Space admin permission + */ + async getContentStateSettings( + parameters: Parameters.GetContentStateSettings, + callback: Callback + ): Promise; + /** + * Get object describing whether content states are allowed at all, if custom content states or space content states + * are restricted, and a list of space content states allowed for the space if they are not restricted. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Space admin permission + */ + async getContentStateSettings( + parameters: Parameters.GetContentStateSettings, + callback?: never + ): Promise; + async getContentStateSettings( + parameters: Parameters.GetContentStateSettings, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/api/space/${parameters.spaceKey}/state/settings`, + method: 'GET', + }; + + return this.client.sendRequest(config, callback); + } +} diff --git a/src/api/dynamicModules.ts b/src/api/dynamicModules.ts index 983e30a3..d8262fb8 100644 --- a/src/api/dynamicModules.ts +++ b/src/api/dynamicModules.ts @@ -51,6 +51,7 @@ export class DynamicModules { const config: RequestConfig = { url: '/atlassian-connect/1/app/module/dynamic', method: 'POST', + data: parameters, }; return this.client.sendRequest(config, callback); diff --git a/src/api/experimental.ts b/src/api/experimental.ts index d37bfb3a..7bdde218 100644 --- a/src/api/experimental.ts +++ b/src/api/experimental.ts @@ -319,9 +319,9 @@ export class Experimental { return this.client.sendRequest(config, callback); } - /** Get the total number of distinct viewers a piece of content has. */ + /** @deprecated Get the total number of distinct viewers a piece of content has. */ async getViewers(parameters: Parameters.GetViewers, callback: Callback): Promise; - /** Get the total number of distinct viewers a piece of content has. */ + /** @deprecated Get the total number of distinct viewers a piece of content has. */ async getViewers(parameters: Parameters.GetViewers, callback?: never): Promise; async getViewers( parameters: Parameters.GetViewers, diff --git a/src/api/index.ts b/src/api/index.ts index 1d40496d..ce0ced36 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -11,6 +11,7 @@ export * from './contentMacroBody'; export * from './contentPermissions'; export * from './contentProperties'; export * from './contentRestrictions'; +export * from './contentStates'; export * from './contentVersions'; export * from './contentWatches'; export * from './dynamicModules'; diff --git a/src/api/models/asyncContentBody.ts b/src/api/models/asyncContentBody.ts new file mode 100644 index 00000000..80b26cd5 --- /dev/null +++ b/src/api/models/asyncContentBody.ts @@ -0,0 +1,31 @@ +import { EmbeddedContent } from './embeddedContent'; +import { GenericLinks } from './genericLinks'; +import { WebResourceDependencies } from './webResourceDependencies'; + +export interface AsyncContentBody { + value?: string; + representation?: string; + renderTaskId?: string; + error?: string; + /** + * Rerunning is reserved for when the job is working, but there is a previous run's value in the cache. You may + * choose to continue polling, or use the cached value. + */ + status?: string; + embeddedContent?: EmbeddedContent[]; + webresource?: WebResourceDependencies; + mediaToken?: { + collectionIds?: string[]; + contentId?: string; + expiryDateTime?: string; + fileIds?: string[]; + token?: string; + }; + Expandable?: { + content?: string; + embeddedContent?: string; + webresource?: string; + mediaToken?: string; + }; + Links?: GenericLinks; +} diff --git a/src/api/models/asyncId.ts b/src/api/models/asyncId.ts new file mode 100644 index 00000000..60614e4e --- /dev/null +++ b/src/api/models/asyncId.ts @@ -0,0 +1,3 @@ +export interface AsyncId { + asyncId: string; +} diff --git a/src/api/models/contentBodyCreate.ts b/src/api/models/contentBodyCreate.ts index b0547baf..d8ee0a7d 100644 --- a/src/api/models/contentBodyCreate.ts +++ b/src/api/models/contentBodyCreate.ts @@ -4,4 +4,5 @@ export interface ContentBodyCreate { value: string; /** The content format type. Set the value of this property to the name of the format being used, e.g. 'storage'. */ representation: string; + additionalProperties?: any; } diff --git a/src/api/models/contentStateResponse.ts b/src/api/models/contentStateResponse.ts new file mode 100644 index 00000000..a4e3dff4 --- /dev/null +++ b/src/api/models/contentStateResponse.ts @@ -0,0 +1,8 @@ +import { ContentState } from './contentState'; + +export interface ContentStateResponse { + /** Null or content state */ + contentState?: ContentState; + /** Timestamp of last publish event where content state changed */ + lastUpdated?: string; +} diff --git a/src/api/models/contentStateRestInput.ts b/src/api/models/contentStateRestInput.ts new file mode 100644 index 00000000..d7570324 --- /dev/null +++ b/src/api/models/contentStateRestInput.ts @@ -0,0 +1,11 @@ +export interface ContentStateRestInput { + /** Name of content state. Maximum 20 characters. */ + name?: string; + /** + * Color of state. Must be in 6 digit hex form (#FFFFFF). The default colors offered in the UI are: #ff7452 (red), + * #2684ff (blue), #ffc400 (yellow), #57d9a3 (green), and #8777d9 (purple) + */ + color?: string; + /** Id of state. This can be 0,1, or 2 if you wish to specify a default space state. */ + stateId?: string; +} diff --git a/src/api/models/index.ts b/src/api/models/index.ts index 87805bde..12dd60b5 100644 --- a/src/api/models/index.ts +++ b/src/api/models/index.ts @@ -4,14 +4,17 @@ export * from './accountIdEmailRecordArray'; export * from './addContentRestriction'; export * from './addContentRestrictionUpdateArray'; export * from './affectedObject'; +export * from './appDescriptor'; +export * from './asyncContentBody'; +export * from './asyncId'; +export * from './attachment'; export * from './attachmentContainer'; +export * from './attachmentMetadata'; export * from './attachmentUpdate'; export * from './auditRecord'; export * from './auditRecordArray'; export * from './auditRecordCreate'; -export * from './appDescriptor'; -export * from './attachment'; -export * from './attachmentMetadata'; +export * from './availableContentStates'; export * from './blueprintTemplate'; export * from './blueprintTemplateArray'; export * from './breadcrumb'; @@ -51,6 +54,11 @@ export * from './contentRestriction'; export * from './contentRestrictionArray'; export * from './contentRestrictionUpdate'; export * from './contentRestrictionUpdateArray'; +export * from './contentState'; +export * from './contentStateContainer'; +export * from './contentStateResponse'; +export * from './contentStateRestInput'; +export * from './contentStateSettings'; export * from './contentTemplate'; export * from './contentTemplateArray'; export * from './contentTemplateBodyCreate'; @@ -87,16 +95,9 @@ export * from './labelCreateArray'; export * from './labelDetails'; export * from './labeledContent'; export * from './labeledContentPageResponse'; -export * from './contentStateSettings'; export * from './labeledContentType'; +export * from './lifecycle'; export * from './longTask'; -export * from './contentState'; -export * from './userPropertyCreate'; -export * from './userPropertyUpdate'; -export * from './contentStateContainer'; -export * from './availableContentStates'; -export * from './userPropertyKeyArray'; -export * from './userProperty'; export * from './longTaskStatus'; export * from './longTaskStatusArray'; export * from './longTaskStatusWithLinks'; @@ -106,7 +107,6 @@ export * from './lookAndFeelSettings'; export * from './lookAndFeelUpdated'; export * from './macroInstance'; export * from './menusLookAndFeel'; -export * from './lifecycle'; export * from './message'; export * from './migratedUser'; export * from './migratedUserArray'; @@ -162,6 +162,10 @@ export * from './userAnonymous'; export * from './userArray'; export * from './userArrayWithLinks'; export * from './userDetails'; +export * from './userProperty'; +export * from './userPropertyCreate'; +export * from './userPropertyKeyArray'; +export * from './userPropertyUpdate'; export * from './usersUserKeys'; export * from './userWatch'; export * from './version'; diff --git a/src/api/parameters/asyncConvertContentBodyRequest.ts b/src/api/parameters/asyncConvertContentBodyRequest.ts new file mode 100644 index 00000000..9ed7757b --- /dev/null +++ b/src/api/parameters/asyncConvertContentBodyRequest.ts @@ -0,0 +1,81 @@ +import { ContentBodyCreate } from '../models'; + +export interface AsyncConvertContentBodyRequest extends ContentBodyCreate { + /** The name of the target format for the content body. */ + to: string; + /** + * The space key used for resolving embedded content (page includes, files, and links) in the content body. For + * example, if the source content contains the link `` + * and the `spaceKeyContext=TEST` parameter is provided, then the link will be converted to a link to the "Example + * page" page in the "TEST" space. + */ + spaceKeyContext?: string; + /** + * The content ID used to find the space for resolving embedded content (page includes, files, and links) in the + * content body. For example, if the source content contains the link `` and the `contentIdContext=123` parameter is provided, then the link will be converted to a link + * to the "Example page" page in the same space that has the content with ID=123. Note, `spaceKeyContext` will be + * ignored if this parameter is provided. + */ + contentIdContext?: string; + /** + * If this field is false, the cache will erase its current value and begin a new conversion. If this field is true, + * the cache will not erase its current value, and will set the status of the async conversion to RERUNNING. Once the + * data is updated, the status will change to COMPLETED. Large macros that take long to convert, and whose data need + * not immediately up to date (same as previous conversion's result within last 5 minutes) should set this fields to + * true. Cache values are stored per user per content body and expansions. + */ + allowCache?: boolean; + /** + * Mode used for rendering embedded content, like attachments. + * + * - `current` renders the embedded content using the latest version. + * - `version-at-save` renders the embedded content using the version at + * the time of save. + */ + embeddedContentRender?: string; + /** A multi-value parameter indicating which properties of the content to expand and populate. */ + expand?: + | 'embeddedContent' + | 'mediaToken' + | 'webresource.superbatch.metatags' + | 'webresource.superbatch.tags.all' + | 'webresource.superbatch.tags.css' + | 'webresource.superbatch.tags.data' + | 'webresource.superbatch.tags.js' + | 'webresource.superbatch.uris.all' + | 'webresource.superbatch.uris.css' + | 'webresource.superbatch.uris.data' + | 'webresource.superbatch.uris.js' + | 'webresource.tags.all' + | 'webresource.tags.css' + | 'webresource.tags.data' + | 'webresource.tags.js' + | 'webresource.uris.all' + | 'webresource.uris.css' + | 'webresource.uris.data' + | 'webresource.uris.js' + | ( + | 'embeddedContent' + | 'mediaToken' + | 'webresource.superbatch.metatags' + | 'webresource.superbatch.tags.all' + | 'webresource.superbatch.tags.css' + | 'webresource.superbatch.tags.data' + | 'webresource.superbatch.tags.js' + | 'webresource.superbatch.uris.all' + | 'webresource.superbatch.uris.css' + | 'webresource.superbatch.uris.data' + | 'webresource.superbatch.uris.js' + | 'webresource.tags.all' + | 'webresource.tags.css' + | 'webresource.tags.data' + | 'webresource.tags.js' + | 'webresource.uris.all' + | 'webresource.uris.css' + | 'webresource.uris.data' + | 'webresource.uris.js' + )[] + | string + | string[]; +} diff --git a/src/api/parameters/asyncConvertContentBodyResponse.ts b/src/api/parameters/asyncConvertContentBodyResponse.ts new file mode 100644 index 00000000..9192b061 --- /dev/null +++ b/src/api/parameters/asyncConvertContentBodyResponse.ts @@ -0,0 +1,4 @@ +export interface AsyncConvertContentBodyResponse { + /** The asyncId of the macro task to get the converted body. */ + id: string; +} diff --git a/src/api/parameters/getAndAsyncConvertMacroBodyByMacroId.ts b/src/api/parameters/getAndAsyncConvertMacroBodyByMacroId.ts new file mode 100644 index 00000000..c38aaa9b --- /dev/null +++ b/src/api/parameters/getAndAsyncConvertMacroBodyByMacroId.ts @@ -0,0 +1,88 @@ +export interface GetAndAsyncConvertMacroBodyByMacroId { + /** The ID for the content that contains the macro. */ + id: string; + /** + * The version of the content that contains the macro. Specifying `0` as the `version` will return the macro body for + * the latest content version. + */ + version: number; + /** + * The ID of the macro. For apps, this is passed to the macro by the Connect/Forge framework. Otherwise, find the + * macro ID by querying the desired content and version, then expanding the body in storage format. For example, + * '/content/196611/version/7?expand=content.body.storage'. + */ + macroId: string; + /** + * The content representation to return the macro in. Currently, the following conversions are allowed: + * + * -`export_view` - `styled_view` - `view`; + */ + to: string; + /** + * If this field is false, the cache will erase its current value and begin a conversion. If this field is true, the + * cache will not erase its current value, and will set the status of the result in cache to RERUNNING. Once the data + * is updated, the status will change to COMPLETED. Large macros that take long to convert, and who want to show + * intermediate, but potentially stale data, immediately should set this field to true. Cache values are stored per + * macro per user per content and expansions. + */ + allowCache?: boolean; + /** + * The space key used for resolving embedded content (page includes, files, and links) in the content body. For + * example, if the source content contains the link `` + * and the `spaceKeyContext=TEST` parameter is provided, then the link will be converted to a link to the "Example + * page" page in the "TEST" space. + */ + spaceKeyContext?: string; + /** + * Mode used for rendering embedded content, like attachments. + * + * - `current` renders the embedded content using the latest version. + * - `version-at-save` renders the embedded content using the version at + * the time of save. + */ + embeddedContentRender?: string; + /** A multi-value parameter indicating which properties of the content to expand and populate. */ + expand?: + | 'embeddedContent' + | 'mediaToken' + | 'webresource.superbatch.metatags' + | 'webresource.superbatch.tags.all' + | 'webresource.superbatch.tags.css' + | 'webresource.superbatch.tags.data' + | 'webresource.superbatch.tags.js' + | 'webresource.superbatch.uris.all' + | 'webresource.superbatch.uris.css' + | 'webresource.superbatch.uris.data' + | 'webresource.superbatch.uris.js' + | 'webresource.tags.all' + | 'webresource.tags.css' + | 'webresource.tags.data' + | 'webresource.tags.js' + | 'webresource.uris.all' + | 'webresource.uris.css' + | 'webresource.uris.data' + | 'webresource.uris.js' + | ( + | 'embeddedContent' + | 'mediaToken' + | 'webresource.superbatch.metatags' + | 'webresource.superbatch.tags.all' + | 'webresource.superbatch.tags.css' + | 'webresource.superbatch.tags.data' + | 'webresource.superbatch.tags.js' + | 'webresource.superbatch.uris.all' + | 'webresource.superbatch.uris.css' + | 'webresource.superbatch.uris.data' + | 'webresource.superbatch.uris.js' + | 'webresource.tags.all' + | 'webresource.tags.css' + | 'webresource.tags.data' + | 'webresource.tags.js' + | 'webresource.uris.all' + | 'webresource.uris.css' + | 'webresource.uris.data' + | 'webresource.uris.js' + )[] + | string + | string[]; +} diff --git a/src/api/parameters/getAndConvertMacroBodyByMacroId.ts b/src/api/parameters/getAndConvertMacroBodyByMacroId.ts new file mode 100644 index 00000000..314d1721 --- /dev/null +++ b/src/api/parameters/getAndConvertMacroBodyByMacroId.ts @@ -0,0 +1,104 @@ +export interface GetAndConvertMacroBodyByMacroId { + /** The ID for the content that contains the macro. */ + id: string; + /** + * The version of the content that contains the macro. Specifying `0` as the `version` will return the macro body for + * the latest content version. + */ + version: number; + /** + * The ID of the macro. This is usually passed by the app that the macro is in. Otherwise, find the macro ID by + * querying the desired content and version, then expanding the body in storage format. For example, + * '/content/196611/version/7?expand=content.body.storage'. + */ + macroId: string; + /** The content representation to return the macro in. */ + to: string; + /** + * The space key used for resolving embedded content (page includes, files, and links) in the content body. For + * example, if the source content contains the link `` + * and the `spaceKeyContext=TEST` parameter is provided, then the link will be converted to a link to the "Example + * page" page in the "TEST" space. + */ + spaceKeyContext?: string; + /** + * Mode used for rendering embedded content, like attachments. + * + * - `current` renders the embedded content using the latest version. + * - `version-at-save` renders the embedded content using the version at + * the time of save. + */ + embeddedContentRender?: 'current' | 'version-at-save' | string; + /** A multi-value parameter indicating which properties of the content to expand. */ + expand?: + | 'childTypes.all' + | 'childTypes.attachment' + | 'childTypes.comment' + | 'childTypes.page' + | 'container' + | 'metadata.currentuser' + | 'metadata.properties' + | 'metadata.labels' + | 'metadata.frontend' + | 'operations' + | 'children.page' + | 'children.attachment' + | 'children.comment' + | 'restrictions.read.restrictions.user' + | 'restrictions.read.restrictions.group' + | 'restrictions.update.restrictions.user' + | 'restrictions.update.restrictions.group' + | 'history' + | 'history.lastUpdated' + | 'history.previousVersion' + | 'history.contributors' + | 'history.nextVersion' + | 'ancestors' + | 'body' + | 'body.storage' + | 'body.view' + | 'version' + | 'descendants.page' + | 'descendants.attachment' + | 'descendants.comment' + | 'space' + | 'extensions.inlineProperties' + | 'extensions.resolution' + | ( + | 'childTypes.all' + | 'childTypes.attachment' + | 'childTypes.comment' + | 'childTypes.page' + | 'container' + | 'metadata.currentuser' + | 'metadata.properties' + | 'metadata.labels' + | 'metadata.frontend' + | 'operations' + | 'children.page' + | 'children.attachment' + | 'children.comment' + | 'restrictions.read.restrictions.user' + | 'restrictions.read.restrictions.group' + | 'restrictions.update.restrictions.user' + | 'restrictions.update.restrictions.group' + | 'history' + | 'history.lastUpdated' + | 'history.previousVersion' + | 'history.contributors' + | 'history.nextVersion' + | 'ancestors' + | 'body' + | 'body.storage' + | 'body.view' + | 'version' + | 'descendants.page' + | 'descendants.attachment' + | 'descendants.comment' + | 'space' + | 'extensions.inlineProperties' + | 'extensions.resolution' + )[] + | string + | string[]; +} diff --git a/src/api/parameters/getAvailableContentStates.ts b/src/api/parameters/getAvailableContentStates.ts index 9bf87b81..97a24dfc 100644 --- a/src/api/parameters/getAvailableContentStates.ts +++ b/src/api/parameters/getAvailableContentStates.ts @@ -1,4 +1,7 @@ export interface GetAvailableContentStates { - /** Id of content to get available states for */ - contentId: string; + /**id of content to get available states for*/ + id?: string; + + /** @deprecated Id of content to get available states for */ + contentId?: string; } diff --git a/src/api/parameters/getContentState.ts b/src/api/parameters/getContentState.ts index 4041de4f..344b4606 100644 --- a/src/api/parameters/getContentState.ts +++ b/src/api/parameters/getContentState.ts @@ -1,6 +1,11 @@ export interface GetContentState { - /** The Id of the page whose content state is of interest. */ - contentId: string; - /** Set designation=DRAFT or designation=PUBLISHED. */ - designation?: string; + /** The id of the content whose content state is of interest. */ + id?: string; + /** Set status to one of [current,draft,archived]. */ + status?: 'current' | 'draft' | 'archived' | string; + + /** @deprecated The Id of the page whose content state is of interest. */ + contentId?: string; + /** @deprecated Set designation=DRAFT or designation=PUBLISHED. */ + designation?: 'DRAFT' | 'PUBLISHED' | string; } diff --git a/src/api/parameters/getSpaceContentStates.ts b/src/api/parameters/getSpaceContentStates.ts new file mode 100644 index 00000000..faea9373 --- /dev/null +++ b/src/api/parameters/getSpaceContentStates.ts @@ -0,0 +1,4 @@ +export interface GetSpaceContentStates { + /** The key of the space to be queried for its content state settings. */ + spaceKey: string; +} diff --git a/src/api/parameters/getUser.ts b/src/api/parameters/getUser.ts index 859d1453..91d5c6ed 100644 --- a/src/api/parameters/getUser.ts +++ b/src/api/parameters/getUser.ts @@ -20,12 +20,22 @@ export interface GetUser { * - `operations` returns the operations that the user is allowed to do. * - `details.personal` returns the 'Personal' details in the user's profile, like the 'Email' and 'Phone'. Note that * these fields have been deprecated due to privacy changes. See the [migration - * guide](https://developer.atlassian.com/cloud/confluence/deprecation-notice-user-privacy-api-migration-guide/) for details. + * guide](https://developer.atlassian.com/cloud/confluence/deprecation-notice-user-privacy-api-migration-guide/) for + * details. * - `details.business` returns the 'Company' details in the user's profile, like the 'Position' and 'Department'. Note * that these fields have been deprecated due to privacy changes. See the [migration - * guide](https://developer.atlassian.com/cloud/confluence/deprecation-notice-user-privacy-api-migration-guide/) for details. - * - PersonalSpace returns the user's personal space, if it exists. + * guide](https://developer.atlassian.com/cloud/confluence/deprecation-notice-user-privacy-api-migration-guide/) for + * details. + * - `personalSpace` returns the user's personal space, if it exists. * - `isExternalCollaborator` returns whether the user is an external collaborator user */ - expand?: string[]; + expand?: + | 'operations' + | 'details.personal' + | 'details.business' + | 'personalSpace' + | 'isExternalCollaborator' + | ('operations' | 'details.personal' | 'details.business' | 'personalSpace' | 'isExternalCollaborator')[] + | string + | string[]; } diff --git a/src/api/parameters/index.ts b/src/api/parameters/index.ts index b561205b..45ea1567 100644 --- a/src/api/parameters/index.ts +++ b/src/api/parameters/index.ts @@ -13,6 +13,8 @@ export * from './addUserToContentRestriction'; export * from './addUserToGroup'; export * from './addUserToGroupByGroupId'; export * from './archivePages'; +export * from './asyncConvertContentBodyRequest'; +export * from './asyncConvertContentBodyResponse'; export * from './checkContentPermission'; export * from './convertContentBody'; export * from './copyPage'; @@ -48,6 +50,8 @@ export * from './exportAuditRecords'; export * from './findSourcesForTarget'; export * from './findTargetFromSource'; export * from './getAllLabelContent'; +export * from './getAndAsyncConvertMacroBodyByMacroId'; +export * from './getAndConvertMacroBodyByMacroId'; export * from './getAnonymousUser'; export * from './getAttachments'; export * from './getAuditRecords'; @@ -101,6 +105,7 @@ export * from './getRestrictions'; export * from './getRestrictionsByOperation'; export * from './getRestrictionsForOperation'; export * from './getSpace'; +export * from './getSpaceContentStates'; export * from './getSpaceProperties'; export * from './getSpaceProperty'; export * from './getSpaces'; diff --git a/src/api/parameters/movePage.ts b/src/api/parameters/movePage.ts index d805aa96..7c3a6592 100644 --- a/src/api/parameters/movePage.ts +++ b/src/api/parameters/movePage.ts @@ -1,12 +1,16 @@ export interface MovePage { /** The ID of the page to be moved */ - id: string; + pageId?: string; + /** @deprecated The ID of the page to be moved */ + id?: string; /** - * The position to move the page to relative to the target page: `before` - move the page under the same parent as the - * target, before the target in the list of children `after` - move the page under the same parent as the target, - * after the target in the list of children `append` - move the page to be a child of the target + * The position to move the page to relative to the target page: + * + * - `before` - move the page under the same parent as the target, before the target in the list of children + * - `after` - move the page under the same parent as the target, after the target in the list of children + * - `append` - move the page to be a child of the target */ - position: string; + position: 'before' | 'after' | 'append' | string; /** The ID of the target page for this operation */ targetId: string; } diff --git a/src/api/parameters/removeContentState.ts b/src/api/parameters/removeContentState.ts index ae5605dc..db861fae 100644 --- a/src/api/parameters/removeContentState.ts +++ b/src/api/parameters/removeContentState.ts @@ -1,4 +1,9 @@ export interface RemoveContentState { /** The Id of the content whose content state is to be set. */ - contentId: string; + id?: string; + /** Status of content state from which to delete state. Can be draft or archived */ + status?: string; + + /** @deprecated The Id of the content whose content state is to be set. */ + contentId?: string; } diff --git a/src/api/parameters/setContentState.ts b/src/api/parameters/setContentState.ts index 13ae347a..20d2ac57 100644 --- a/src/api/parameters/setContentState.ts +++ b/src/api/parameters/setContentState.ts @@ -1,8 +1,16 @@ -export interface SetContentState { +import { ContentStateRestInput } from '../models'; + +export interface SetContentState extends ContentStateRestInput { /** The Id of the content whose content state is to be set. */ - contentId: string; - /** The Id of the content */ + id?: string; + /** + * Status of content onto which state will be placed. If draft, then draft state will change. If current, state will + * be placed onto a new version of the content with same body as previous version. + */ + status?: 'current' | 'draft' | string; + + /** @deprecated The Id of the content whose content state is to be set. */ + contentId?: string; + /** @deprecated The Id of the content */ contentStateId?: number; - name?: string; - color?: string; } diff --git a/src/api/settings.ts b/src/api/settings.ts index 5a52f2e1..b16b6f78 100644 --- a/src/api/settings.ts +++ b/src/api/settings.ts @@ -233,12 +233,12 @@ export class Settings { return this.client.sendRequest(config, callback); } - /** Gets Content State settings for a space */ + /** @deprecated Gets Content State settings for a space */ async getContentStateSettings( parameters: Parameters.GetContentStateSettings, callback: Callback ): Promise; - /** Gets Content State settings for a space */ + /** @deprecated Gets Content State settings for a space */ async getContentStateSettings( parameters: Parameters.GetContentStateSettings, callback?: never diff --git a/src/api/space.ts b/src/api/space.ts index 7de86eac..88f0d53a 100644 --- a/src/api/space.ts +++ b/src/api/space.ts @@ -181,7 +181,7 @@ export class Space { * * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: 'Admin' permission for the space. */ - async deleteSpace(parameters: Parameters.DeleteSpace, callback: Callback): Promise; + async deleteSpace(parameters: Parameters.DeleteSpace, callback: Callback): Promise; /** * Deletes a space. Note, the space will be deleted in a long running task. Therefore, the space may not be deleted * yet when this method has returned. Clients should poll the status link that is returned in the response until the @@ -189,8 +189,8 @@ export class Space { * * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: 'Admin' permission for the space. */ - async deleteSpace(parameters: Parameters.DeleteSpace, callback?: never): Promise; - async deleteSpace( + async deleteSpace(parameters: Parameters.DeleteSpace, callback?: never): Promise; + async deleteSpace( parameters: Parameters.DeleteSpace, callback?: Callback, ): Promise { diff --git a/src/api/spaceProperties.ts b/src/api/spaceProperties.ts index f0d21d18..54348031 100644 --- a/src/api/spaceProperties.ts +++ b/src/api/spaceProperties.ts @@ -111,8 +111,8 @@ export class SpaceProperties { } /** - * Creates a new space property. This is the same as `POST /wiki/rest/api/space/{spaceKey}/property` but the key for - * the property is passed as a path parameter, rather than in the request body. + * Creates a new space property. This is the same as `POST /api/space/{spaceKey}/property` but the key for the + * property is passed as a path parameter, rather than in the request body. * * **[Permissions required](https://confluence.atlassian.com/x/_AozKw)**: ‘Admin’ permission for the space. */ @@ -121,8 +121,8 @@ export class SpaceProperties { callback: Callback ): Promise; /** - * Creates a new space property. This is the same as `POST /wiki/rest/api/space/{spaceKey}/property` but the key for - * the property is passed as a path parameter, rather than in the request body. + * Creates a new space property. This is the same as `POST /api/space/{spaceKey}/property` but the key for the + * property is passed as a path parameter, rather than in the request body. * * **[Permissions required](https://confluence.atlassian.com/x/_AozKw)**: ‘Admin’ permission for the space. */ diff --git a/src/clients/confluenceClient.ts b/src/clients/confluenceClient.ts index c036a9d0..a65a5de6 100644 --- a/src/clients/confluenceClient.ts +++ b/src/clients/confluenceClient.ts @@ -13,6 +13,7 @@ import { ContentPermissions, ContentProperties, ContentRestrictions, + ContentStates, ContentVersions, ContentWatches, DynamicModules, @@ -47,6 +48,7 @@ export class ConfluenceClient extends BaseClient { contentPermissions = new ContentPermissions(this); contentProperties = new ContentProperties(this); contentRestrictions = new ContentRestrictions(this); + contentStates = new ContentStates(this); contentVersions = new ContentVersions(this); contentWatches = new ContentWatches(this); dynamicModules = new DynamicModules(this); diff --git a/tests/e2e/e2e.test.ts b/tests/e2e/e2e.test.ts index 59a9eb90..e0b2d1d1 100644 --- a/tests/e2e/e2e.test.ts +++ b/tests/e2e/e2e.test.ts @@ -55,7 +55,7 @@ test.serial('should create content', async t => { }); test.serial('should add attachment', async t => { - const file = await fs.readFileSync('./tests/unit/serverApiClient.test.ts'); + const file = await fs.readFileSync('./tests/unit/clients/serverClient.test.ts'); const attachment = await client.contentAttachments.createAttachments({ id: createdContentId, diff --git a/tests/unit/clients/confluenceClient.test.ts b/tests/unit/clients/confluenceClient.test.ts new file mode 100644 index 00000000..2c0e2491 --- /dev/null +++ b/tests/unit/clients/confluenceClient.test.ts @@ -0,0 +1,9 @@ +import { ConfluenceClient } from '../../../src'; +import test from 'ava'; + +test('Confluence Client properties should be defined', t => { + const client = new ConfluenceClient({ host: '' }); + + t.truthy(!!client.contentContentState); + t.truthy(!!client.contentStates); +}); diff --git a/tests/unit/serverApiClient.test.ts b/tests/unit/clients/serverClient.test.ts similarity index 97% rename from tests/unit/serverApiClient.test.ts rename to tests/unit/clients/serverClient.test.ts index e1b8ecb3..23a02dab 100644 --- a/tests/unit/serverApiClient.test.ts +++ b/tests/unit/clients/serverClient.test.ts @@ -1,5 +1,5 @@ import * as sinon from 'sinon'; -import { ServerClient } from '../../src'; +import { ServerClient } from '../../../src'; import test from 'ava'; const config = {