From 0b6e84324b12f802f61dfa9caad6e38da635711e Mon Sep 17 00:00:00 2001 From: Vladislav Tupikin Date: Tue, 28 Sep 2021 00:40:45 +0300 Subject: [PATCH 1/2] 1.2.0 --- .github/workflows/publish.yml | 8 - CHANGELOG.md | 31 +++ README.md | 1 + package-lock.json | 99 +++---- package.json | 12 +- src/api/content.ts | 109 ++++---- src/api/contentAttachments.ts | 34 ++- src/api/contentChildrenAndDescendants.ts | 52 ++-- src/api/contentPermissions.ts | 31 ++- src/api/contentProperties.ts | 1 + src/api/contentWatches.ts | 6 +- src/api/experimental.ts | 44 ++++ src/api/group.ts | 90 +++++-- src/api/index.ts | 1 + src/api/inlineTasks.ts | 52 ++++ src/api/models/getViewers.ts | 6 + src/api/models/getViews.ts | 6 + src/api/models/groupCreate.ts | 4 + src/api/models/horizontalHeaderLookAndFeel.ts | 12 + src/api/models/index.ts | 17 +- src/api/models/lookAndFeel.ts | 3 + src/api/models/spacePermissionCreate.ts | 34 +++ .../models/spacePermissionCustomContent.ts | 17 ++ src/api/models/spacePermissionRequest.ts | 42 +++ src/api/models/spacePrivateCreate.ts | 9 + src/api/models/spacePropertyCreate.ts | 4 + src/api/models/spaceUpdate.ts | 4 + src/api/models/taskStatusUpdate.ts | 3 + src/api/models/topNavigationLookAndFeel.ts | 8 + .../parameters/addCustomContentPermissions.ts | 6 + src/api/parameters/addPermissionToSpace.ts | 6 + src/api/parameters/addUserToGroup.ts | 4 +- src/api/parameters/addUserToGroupByGroupId.ts | 4 +- src/api/parameters/archivePages.ts | 6 + src/api/parameters/checkContentPermission.ts | 6 + src/api/parameters/deleteRelationship.ts | 38 +++ src/api/parameters/downloadAttachment.ts | 11 + src/api/parameters/getContentProperties.ts | 2 + src/api/parameters/getDescendantsOfType.ts | 102 ++++++++ src/api/parameters/getGroupByName.ts | 4 + src/api/parameters/getGroups.ts | 2 + src/api/parameters/getTaskById.ts | 4 + src/api/parameters/getViewers.ts | 6 + src/api/parameters/getViews.ts | 6 + src/api/parameters/index.ts | 247 ++++++++++-------- src/api/parameters/publishLegacyDraft.ts | 5 +- src/api/parameters/publishSharedDraft.ts | 5 +- src/api/parameters/searchByCQL.ts | 34 +++ src/api/parameters/searchGroups.ts | 8 + src/api/parameters/searchUser.ts | 20 ++ src/api/parameters/updateTaskById.ts | 6 + src/api/relation.ts | 41 ++- src/api/search.ts | 126 ++++----- src/api/settings.ts | 9 +- src/api/space.ts | 3 + src/api/spacePermissions.ts | 74 +++++- src/api/spaceProperties.ts | 9 +- src/clients/baseClient.ts | 4 +- src/clients/confluenceClient.ts | 2 + 59 files changed, 1140 insertions(+), 400 deletions(-) create mode 100644 src/api/experimental.ts create mode 100644 src/api/models/getViewers.ts create mode 100644 src/api/models/getViews.ts create mode 100644 src/api/models/groupCreate.ts create mode 100644 src/api/models/horizontalHeaderLookAndFeel.ts create mode 100644 src/api/models/spacePermissionCreate.ts create mode 100644 src/api/models/spacePermissionCustomContent.ts create mode 100644 src/api/models/spacePermissionRequest.ts create mode 100644 src/api/models/taskStatusUpdate.ts create mode 100644 src/api/models/topNavigationLookAndFeel.ts create mode 100644 src/api/parameters/addCustomContentPermissions.ts create mode 100644 src/api/parameters/addPermissionToSpace.ts create mode 100644 src/api/parameters/archivePages.ts create mode 100644 src/api/parameters/checkContentPermission.ts create mode 100644 src/api/parameters/deleteRelationship.ts create mode 100644 src/api/parameters/downloadAttachment.ts create mode 100644 src/api/parameters/getDescendantsOfType.ts create mode 100644 src/api/parameters/getGroupByName.ts create mode 100644 src/api/parameters/getTaskById.ts create mode 100644 src/api/parameters/getViewers.ts create mode 100644 src/api/parameters/getViews.ts create mode 100644 src/api/parameters/searchByCQL.ts create mode 100644 src/api/parameters/searchGroups.ts create mode 100644 src/api/parameters/searchUser.ts create mode 100644 src/api/parameters/updateTaskById.ts diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 027bad9f..48a87f4e 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -20,14 +20,6 @@ jobs: echo HOST=${{ secrets.HOST }} >> .env echo EMAIL=${{ secrets.EMAIL }} >> .env echo API_TOKEN=${{ secrets.API_TOKEN }} >> .env - - name: Building sources - run: npm run build - - name: Tests - run: npm run test - - name: Linting - run: npm run lint - env: - CI: true - name: Publishing run: npm publish env: diff --git a/CHANGELOG.md b/CHANGELOG.md index 90964ea9..c63d3e7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,36 @@ # Changelog +### 1.2.0 + +- Cloud API + - `archivePages` method added to `Content`. + - `publishLegacyDraft` request fixed in `Content` class. + - `publishSharedDraft` request fixed in `Content` class. + - `downloadAttachment` method added to `ContentAttachments`. + - `descendantsOfType` renamed to `getDescendantsOfType` in `ContentChildrenAndDescendants`. + - `permissionCheck` renamed to `checkContentPermission` in `ContentPermissions`. + - `key` property added to `getContentProperties` request in `ContentProperties`. + - Added `Experemental` API. + - `accessType` property added to `getGroups` request in `Group`. + - `removeGroupById` method added to `Group`. + - `getGroup` renamed to `getGroupByName` in `Group`. + - `getGroupsSearch` renamed to `searchGroups` in `Group`. + - `accountId` property added to `addUserToGroupByGroupId` in `Group`. + - `accountId` property added to `addUserToGroup` in `Group`. + - `getTaskById` method added to `InlineTasks`. + - `updateTaskById` method added to `InlineTasks`. + - `GetRelationship` renamed to `getRelationship` in `Relation`. + - `delete` renamed to `deleteRelationship` in `Relation`. + - `search` renamed to `searchByCQL` in `Search`. + - `userSearch` renamed to `searchUser` in `Search`. + - `horizontalHeader`, `spaceReference`, `links` properties added to `updateLookAndFeelSettings` in `Settings`. + - `permissions` property added to `createPrivateSpace` in `Space`. + - `type` and `status` properties added to `updateSpace` in `Space`. + - `addPermission` renamed to `addPermissionToSpace` in `SpacePermissions`. + - `addCustomContentPermissions` method added to `SpacePermissions`. + - `space` property added to `createSpaceProperty` in `SpaceProperties`. + - + ### 1.1.3 - Vulnerabilities fixed diff --git a/README.md b/README.md index 3c045e69..86a00b2b 100644 --- a/README.md +++ b/README.md @@ -292,6 +292,7 @@ Available groups: - [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) +- [experimental](https://developer.atlassian.com/cloud/confluence/rest/api-group-experimental/#api-group-experimental) - [group](https://developer.atlassian.com/cloud/confluence/rest/api-group-group/#api-group-group) - [inlineTasks](https://developer.atlassian.com/cloud/confluence/rest/api-group-inline-tasks/#api-group-inline-tasks) - [labelInfo](https://developer.atlassian.com/cloud/confluence/rest/api-group-label-info/#api-group-label-info) diff --git a/package-lock.json b/package-lock.json index 1e3f5dfb..ca607222 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "confluence.js", - "version": "1.1.3", + "version": "1.2.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -1179,9 +1179,9 @@ } }, "@types/sinon": { - "version": "10.0.2", - "resolved": "https://registry.npmjs.org/@types/sinon/-/sinon-10.0.2.tgz", - "integrity": "sha512-BHn8Bpkapj8Wdfxvh2jWIUoaYB/9/XhsL0oOvBfRagJtKlSl9NWPcFOz2lRukI9szwGxFtYZCTejJSqsGDbdmw==", + "version": "10.0.4", + "resolved": "https://registry.npmjs.org/@types/sinon/-/sinon-10.0.4.tgz", + "integrity": "sha512-fOYjrxQv8zJsqOY6V6ecP4eZhQBxtY80X0er1VVnUIAIZo74jHm8e1vguG5Yt4Iv8W2Wr7TgibB8MfRe32k9pA==", "dev": true, "requires": { "@sinonjs/fake-timers": "^7.1.0" @@ -1215,70 +1215,71 @@ "dev": true }, "@typescript-eslint/eslint-plugin": { - "version": "4.31.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.31.1.tgz", - "integrity": "sha512-UDqhWmd5i0TvPLmbK5xY3UZB0zEGseF+DHPghZ37Sb83Qd3p8ujhvAtkU4OF46Ka5Pm5kWvFIx0cCTBFKo0alA==", + "version": "4.32.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.32.0.tgz", + "integrity": "sha512-+OWTuWRSbWI1KDK8iEyG/6uK2rTm3kpS38wuVifGUTDB6kjEuNrzBI1MUtxnkneuWG/23QehABe2zHHrj+4yuA==", "dev": true, "requires": { - "@typescript-eslint/experimental-utils": "4.31.1", - "@typescript-eslint/scope-manager": "4.31.1", + "@typescript-eslint/experimental-utils": "4.32.0", + "@typescript-eslint/scope-manager": "4.32.0", "debug": "^4.3.1", "functional-red-black-tree": "^1.0.1", + "ignore": "^5.1.8", "regexpp": "^3.1.0", "semver": "^7.3.5", "tsutils": "^3.21.0" } }, "@typescript-eslint/experimental-utils": { - "version": "4.31.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.31.1.tgz", - "integrity": "sha512-NtoPsqmcSsWty0mcL5nTZXMf7Ei0Xr2MT8jWjXMVgRK0/1qeQ2jZzLFUh4QtyJ4+/lPUyMw5cSfeeME+Zrtp9Q==", + "version": "4.32.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.32.0.tgz", + "integrity": "sha512-WLoXcc+cQufxRYjTWr4kFt0DyEv6hDgSaFqYhIzQZ05cF+kXfqXdUh+//kgquPJVUBbL3oQGKQxwPbLxHRqm6A==", "dev": true, "requires": { "@types/json-schema": "^7.0.7", - "@typescript-eslint/scope-manager": "4.31.1", - "@typescript-eslint/types": "4.31.1", - "@typescript-eslint/typescript-estree": "4.31.1", + "@typescript-eslint/scope-manager": "4.32.0", + "@typescript-eslint/types": "4.32.0", + "@typescript-eslint/typescript-estree": "4.32.0", "eslint-scope": "^5.1.1", "eslint-utils": "^3.0.0" } }, "@typescript-eslint/parser": { - "version": "4.31.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.31.1.tgz", - "integrity": "sha512-dnVZDB6FhpIby6yVbHkwTKkn2ypjVIfAR9nh+kYsA/ZL0JlTsd22BiDjouotisY3Irmd3OW1qlk9EI5R8GrvRQ==", + "version": "4.32.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.32.0.tgz", + "integrity": "sha512-lhtYqQ2iEPV5JqV7K+uOVlPePjClj4dOw7K4/Z1F2yvjIUvyr13yJnDzkK6uon4BjHYuHy3EG0c2Z9jEhFk56w==", "dev": true, "requires": { - "@typescript-eslint/scope-manager": "4.31.1", - "@typescript-eslint/types": "4.31.1", - "@typescript-eslint/typescript-estree": "4.31.1", + "@typescript-eslint/scope-manager": "4.32.0", + "@typescript-eslint/types": "4.32.0", + "@typescript-eslint/typescript-estree": "4.32.0", "debug": "^4.3.1" } }, "@typescript-eslint/scope-manager": { - "version": "4.31.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.31.1.tgz", - "integrity": "sha512-N1Uhn6SqNtU2XpFSkD4oA+F0PfKdWHyr4bTX0xTj8NRx1314gBDRL1LUuZd5+L3oP+wo6hCbZpaa1in6SwMcVQ==", + "version": "4.32.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.32.0.tgz", + "integrity": "sha512-DK+fMSHdM216C0OM/KR1lHXjP1CNtVIhJ54kQxfOE6x8UGFAjha8cXgDMBEIYS2XCYjjCtvTkjQYwL3uvGOo0w==", "dev": true, "requires": { - "@typescript-eslint/types": "4.31.1", - "@typescript-eslint/visitor-keys": "4.31.1" + "@typescript-eslint/types": "4.32.0", + "@typescript-eslint/visitor-keys": "4.32.0" } }, "@typescript-eslint/types": { - "version": "4.31.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.31.1.tgz", - "integrity": "sha512-kixltt51ZJGKENNW88IY5MYqTBA8FR0Md8QdGbJD2pKZ+D5IvxjTYDNtJPDxFBiXmka2aJsITdB1BtO1fsgmsQ==", + "version": "4.32.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.32.0.tgz", + "integrity": "sha512-LE7Z7BAv0E2UvqzogssGf1x7GPpUalgG07nGCBYb1oK4mFsOiFC/VrSMKbZQzFJdN2JL5XYmsx7C7FX9p9ns0w==", "dev": true }, "@typescript-eslint/typescript-estree": { - "version": "4.31.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.31.1.tgz", - "integrity": "sha512-EGHkbsUvjFrvRnusk6yFGqrqMBTue5E5ROnS5puj3laGQPasVUgwhrxfcgkdHNFECHAewpvELE1Gjv0XO3mdWg==", + "version": "4.32.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.32.0.tgz", + "integrity": "sha512-tRYCgJ3g1UjMw1cGG8Yn1KzOzNlQ6u1h9AmEtPhb5V5a1TmiHWcRyF/Ic+91M4f43QeChyYlVTcf3DvDTZR9vw==", "dev": true, "requires": { - "@typescript-eslint/types": "4.31.1", - "@typescript-eslint/visitor-keys": "4.31.1", + "@typescript-eslint/types": "4.32.0", + "@typescript-eslint/visitor-keys": "4.32.0", "debug": "^4.3.1", "globby": "^11.0.3", "is-glob": "^4.0.1", @@ -1287,12 +1288,12 @@ } }, "@typescript-eslint/visitor-keys": { - "version": "4.31.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.31.1.tgz", - "integrity": "sha512-PCncP8hEqKw6SOJY+3St4LVtoZpPPn+Zlpm7KW5xnviMhdqcsBty4Lsg4J/VECpJjw1CkROaZhH4B8M1OfnXTQ==", + "version": "4.32.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.32.0.tgz", + "integrity": "sha512-e7NE0qz8W+atzv3Cy9qaQ7BTLwWsm084Z0c4nIO2l3Bp6u9WIgdqCgyPyV5oSPDMIW3b20H59OOCmVk3jw3Ptw==", "dev": true, "requires": { - "@typescript-eslint/types": "4.31.1", + "@typescript-eslint/types": "4.32.0", "eslint-visitor-keys": "^2.0.0" } }, @@ -5261,9 +5262,9 @@ "dev": true }, "prettier": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.4.0.tgz", - "integrity": "sha512-DsEPLY1dE5HF3BxCRBmD4uYZ+5DCbvatnolqTqcxEgKVZnL2kUfyu7b8pPQ5+hTBkdhU9SLUmK0/pHb07RE4WQ==", + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.4.1.tgz", + "integrity": "sha512-9fbDAXSBcc6Bs1mZrDYb3XKzDLm4EXXL9sC1LqKP5rZkT6KRr/rf9amVUcODVXgguK/isJz0d0hP72WeaKWsvA==", "dev": true }, "prettier-plugin-jsdoc": { @@ -6476,22 +6477,22 @@ } }, "typedoc": { - "version": "0.22.3", - "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.22.3.tgz", - "integrity": "sha512-EOWf9Vf3Vfb/jzBzr87uoLybQw9fx3iyXLUcpQn9F2Ks1/ZJN9iGeBbYRU+VNqrWvV4T+aS7Ife7GFEJUf0ohQ==", + "version": "0.22.4", + "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.22.4.tgz", + "integrity": "sha512-M/a8NnPxq3/iZNNVjzFCK5gu4m//HTJIPbSS0JQVbkHJPP9wyepR12agylWTSqeVZe0xsbidVtO26+PP7iD/jw==", "dev": true, "requires": { "glob": "^7.1.7", "lunr": "^2.3.9", - "marked": "^3.0.3", + "marked": "^3.0.4", "minimatch": "^3.0.4", - "shiki": "^0.9.10" + "shiki": "^0.9.11" }, "dependencies": { "glob": { - "version": "7.1.7", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz", - "integrity": "sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", + "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", "dev": true, "requires": { "fs.realpath": "^1.0.0", diff --git a/package.json b/package.json index f2eac1d9..d6615970 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "confluence.js", - "version": "1.1.3", + "version": "1.2.0", "description": "confluence.js is a powerful Node.JS/Browser module that allows you to interact with the Confluence API very easily", "main": "out/index.js", "types": "out/index.d.ts", @@ -36,9 +36,9 @@ "@types/express": "^4.17.13", "@types/jest": "^26.0.24", "@types/oauth": "^0.9.1", - "@types/sinon": "^10.0.2", - "@typescript-eslint/eslint-plugin": "^4.31.1", - "@typescript-eslint/parser": "^4.31.1", + "@types/sinon": "^10.0.4", + "@typescript-eslint/eslint-plugin": "^4.32.0", + "@typescript-eslint/parser": "^4.32.0", "dotenv": "^10.0.0", "eslint": "^7.32.0", "eslint-config-airbnb": "^18.2.1", @@ -46,11 +46,11 @@ "eslint-import-resolver-typescript": "^2.5.0", "eslint-plugin-import": "^2.24.2", "jest": "^26.6.3", - "prettier": "^2.4.0", + "prettier": "^2.4.1", "prettier-plugin-jsdoc": "^0.3.24", "sinon": "^11.1.2", "ts-jest": "^26.5.6", - "typedoc": "^0.22.3", + "typedoc": "^0.22.4", "typescript": "^4.4.3" }, "dependencies": { diff --git a/src/api/content.ts b/src/api/content.ts index 1ae9afff..58d141be 100644 --- a/src/api/content.ts +++ b/src/api/content.ts @@ -102,6 +102,45 @@ export class Content { return this.client.sendRequest(config, callback, { methodName: 'createContent' }); } + /** + * Archives a list of pages. The pages to be archived are specified as a list of content IDs. This API accepts the + * archival request and returns a task ID. The archival process happens asynchronously. Use the /longtask/ + * REST API to get the copy task status. + * + * Each content ID needs to resolve to page objects that are not already in an archived state. The content IDs need + * not belong to the same space. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: 'Archive' permission for each of the pages + * in the corresponding space it belongs to. + */ + async archivePages( + parameters: Parameters.ArchivePages, + callback: Callback + ): Promise; + /** + * Archives a list of pages. The pages to be archived are specified as a list of content IDs. This API accepts the + * archival request and returns a task ID. The archival process happens asynchronously. Use the /longtask/ + * REST API to get the copy task status. + * + * Each content ID needs to resolve to page objects that are not already in an archived state. The content IDs need + * not belong to the same space. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: 'Archive' permission for each of the pages + * in the corresponding space it belongs to. + */ + async archivePages(parameters: Parameters.ArchivePages, callback?: never): Promise; + async archivePages(parameters: Parameters.ArchivePages, callback?: Callback): Promise { + const config: RequestConfig = { + url: '/api/content/archive', + method: 'POST', + data: { + pages: parameters.pages, + }, + }; + + return this.client.sendRequest(config, callback, { methodName: 'archivePages' }); + } + /** * Publishes a legacy draft of a page created from a blueprint. Legacy drafts will eventually be removed in favor of * shared drafts. For now, this method works the same as [Publish shared draft](#api-content-blueprint-instance-draftId-put). @@ -135,6 +174,15 @@ export class Content { params: { status: parameters.status, }, + data: { + ...parameters, + version: parameters.version, + title: parameters.title, + type: parameters.type, + status: parameters.bodyStatus, + space: parameters.space, + ancestors: parameters.ancestors, + }, }; return this.client.sendRequest(config, callback, { methodName: 'publishLegacyDraft' }); @@ -171,6 +219,15 @@ export class Content { params: { status: parameters.status, }, + data: { + ...parameters, + version: parameters.version, + title: parameters.title, + type: parameters.type, + status: parameters.bodyStatus, + space: parameters.space, + ancestors: parameters.ancestors, + }, }; return this.client.sendRequest(config, callback, { methodName: 'publishSharedDraft' }); @@ -180,32 +237,6 @@ export class Content { * Returns the list of content that matches a Confluence Query Language (CQL) query. For information on CQL, see: * [Advanced searching using CQL](https://developer.atlassian.com/cloud/confluence/advanced-searching-using-cql/). * - * Example initial call: - * ``` - * https://your-domain.atlassian.net/wiki/rest/api/content/search?cql=type=page&limit=25 - * ``` - * - * Example response: - * ``` - * { - * "results": [ - * { ... }, - * { ... }, - * ... - * { ... } - * ], - * "limit": 25, - * "size": 25, - * ... - * "_links": { - * "base": "", - * "context": "", - * "next": "/rest/api/content/search?cql=type=page&limit=25&cursor=raNDoMsTRiNg", - * "self": "" - * } - * } - * ``` - * * When additional results are available, returns `next` and `prev` URLs to retrieve them in subsequent calls. The * URLs each contain a cursor that points to the appropriate set of results. Use `limit` to specify the number of * results returned in each call. Example subsequent call (taken from example response): @@ -225,32 +256,6 @@ export class Content { * Returns the list of content that matches a Confluence Query Language (CQL) query. For information on CQL, see: * [Advanced searching using CQL](https://developer.atlassian.com/cloud/confluence/advanced-searching-using-cql/). * - * Example initial call: - * ``` - * https://your-domain.atlassian.net/wiki/rest/api/content/search?cql=type=page&limit=25 - * ``` - * - * Example response: - * ``` - * { - * "results": [ - * { ... }, - * { ... }, - * ... - * { ... } - * ], - * "limit": 25, - * "size": 25, - * ... - * "_links": { - * "base": "", - * "context": "", - * "next": "/rest/api/content/search?cql=type=page&limit=25&cursor=raNDoMsTRiNg", - * "self": "" - * } - * } - * ``` - * * When additional results are available, returns `next` and `prev` URLs to retrieve them in subsequent calls. The * URLs each contain a cursor that points to the appropriate set of results. Use `limit` to specify the number of * results returned in each call. Example subsequent call (taken from example response): diff --git a/src/api/contentAttachments.ts b/src/api/contentAttachments.ts index 62550834..24043696 100644 --- a/src/api/contentAttachments.ts +++ b/src/api/contentAttachments.ts @@ -56,7 +56,7 @@ export class ContentAttachments { * * The media type 'multipart/form-data' is defined in [RFC 7578](https://www.ietf.org/rfc/rfc7578.txt). Most client * libraries have classes that make it easier to implement multipart posts, like the - * [MultipartEntityBuilder](http://hc.apache.org/httpcomponents-client-5.0.x/current/httpclient5/apidocs/) Java class + * [MultipartEntityBuilder](https://hc.apache.org/httpcomponents-client-5.1.x/current/httpclient5/apidocs/) Java class * provided by Apache HTTP Components. * * Note, according to [RFC 7578](https://tools.ietf.org/html/rfc7578#section-4.5), in the case where the form data is @@ -92,7 +92,7 @@ export class ContentAttachments { * * The media type 'multipart/form-data' is defined in [RFC 7578](https://www.ietf.org/rfc/rfc7578.txt). Most client * libraries have classes that make it easier to implement multipart posts, like the - * [MultipartEntityBuilder](http://hc.apache.org/httpcomponents-client-5.0.x/current/httpclient5/apidocs/) Java class + * [MultipartEntityBuilder](https://hc.apache.org/httpcomponents-client-5.1.x/current/httpclient5/apidocs/) Java class * provided by Apache HTTP Components. * * Note, according to [RFC 7578](https://tools.ietf.org/html/rfc7578#section-4.5), in the case where the form data is @@ -148,7 +148,7 @@ export class ContentAttachments { * * The media type 'multipart/form-data' is defined in [RFC 7578](https://www.ietf.org/rfc/rfc7578.txt). Most client * libraries have classes that make it easier to implement multipart posts, like the - * [MultipartEntityBuilder](http://hc.apache.org/httpcomponents-client-5.0.x/current/httpclient5/apidocs/) Java class + * [MultipartEntityBuilder](https://hc.apache.org/httpcomponents-client-5.1.x/current/httpclient5/apidocs/) Java class * provided by Apache HTTP Components. * * Note, according to [RFC 7578](https://tools.ietf.org/html/rfc7578#section-4.5), in the case where the form data is @@ -185,7 +185,7 @@ export class ContentAttachments { * * The media type 'multipart/form-data' is defined in [RFC 7578](https://www.ietf.org/rfc/rfc7578.txt). Most client * libraries have classes that make it easier to implement multipart posts, like the - * [MultipartEntityBuilder](http://hc.apache.org/httpcomponents-client-5.0.x/current/httpclient5/apidocs/) Java class + * [MultipartEntityBuilder](https://hc.apache.org/httpcomponents-client-5.1.x/current/httpclient5/apidocs/) Java class * provided by Apache HTTP Components. * * Note, according to [RFC 7578](https://tools.ietf.org/html/rfc7578#section-4.5), in the case where the form data is @@ -277,7 +277,7 @@ export class ContentAttachments { * * The media type 'multipart/form-data' is defined in [RFC 7578](https://www.ietf.org/rfc/rfc7578.txt). Most client * libraries have classes that make it easier to implement multipart posts, like the - * [MultipartEntityBuilder](http://hc.apache.org/httpcomponents-client-5.0.x/current/httpclient5/apidocs/) Java class + * [MultipartEntityBuilder](https://hc.apache.org/httpcomponents-client-5.1.x/current/httpclient5/apidocs/) Java class * provided by Apache HTTP Components. * * Note, according to [RFC 7578](https://tools.ietf.org/html/rfc7578#section-4.5), in the case where the form data is @@ -316,7 +316,7 @@ export class ContentAttachments { * * The media type 'multipart/form-data' is defined in [RFC 7578](https://www.ietf.org/rfc/rfc7578.txt). Most client * libraries have classes that make it easier to implement multipart posts, like the - * [MultipartEntityBuilder](http://hc.apache.org/httpcomponents-client-5.0.x/current/httpclient5/apidocs/) Java class + * [MultipartEntityBuilder](https://hc.apache.org/httpcomponents-client-5.1.x/current/httpclient5/apidocs/) Java class * provided by Apache HTTP Components. * * Note, according to [RFC 7578](https://tools.ietf.org/html/rfc7578#section-4.5), in the case where the form data is @@ -360,4 +360,26 @@ export class ContentAttachments { return this.client.sendRequest(config, callback, { methodName: 'updateAttachmentData' }); } + + /** Redirects the client to a URL that serves an attachment's binary data. */ + async downloadAttachment( + parameters: Parameters.DownloadAttachment, + callback: Callback + ): Promise; + /** Redirects the client to a URL that serves an attachment's binary data. */ + async downloadAttachment(parameters: Parameters.DownloadAttachment, callback?: never): Promise; + async downloadAttachment( + parameters: Parameters.DownloadAttachment, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/api/content/${parameters.id}/child/attachment/${parameters.attachmentId}/download`, + method: 'GET', + params: { + version: parameters.version, + }, + }; + + return this.client.sendRequest(config, callback, { methodName: 'downloadAttachment' }); + } } diff --git a/src/api/contentChildrenAndDescendants.ts b/src/api/contentChildrenAndDescendants.ts index 06cd04c0..a8c7196a 100644 --- a/src/api/contentChildrenAndDescendants.ts +++ b/src/api/contentChildrenAndDescendants.ts @@ -218,6 +218,23 @@ export class ContentChildrenAndDescendants { return this.client.sendRequest(config, callback, { methodName: 'getContentDescendants' }); } + /** @deprecated This API will be removed in the next major version. Use `getDescendantsOfType` method instead. */ + async descendantsOfType( + parameters: Parameters.DescendantsOfType, + callback: Callback + ): Promise; + /** @deprecated This API will be removed in the next major version. Use `getDescendantsOfType` method instead. */ + async descendantsOfType( + parameters: Parameters.DescendantsOfType, + callback?: never + ): Promise; + async descendantsOfType( + parameters: Parameters.DescendantsOfType, + callback?: Callback, + ): Promise { + return this.getDescendantsOfType(parameters, callback!); + } + /** * Returns all descendants of a given type, for a piece of content. This is similar to [Get content children by * type](#api-content-id-child-type-get), except that this method returns child pages at all levels, rather than just @@ -235,8 +252,8 @@ export class ContentChildrenAndDescendants { * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: 'View' permission for the space, and * permission to view the content if it is a page. */ - async descendantsOfType( - parameters: Parameters.DescendantsOfType, + async getDescendantsOfType( + parameters: Parameters.GetDescendantsOfType, callback: Callback ): Promise; /** @@ -256,12 +273,12 @@ export class ContentChildrenAndDescendants { * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: 'View' permission for the space, and * permission to view the content if it is a page. */ - async descendantsOfType( - parameters: Parameters.DescendantsOfType, + async getDescendantsOfType( + parameters: Parameters.GetDescendantsOfType, callback?: never ): Promise; - async descendantsOfType( - parameters: Parameters.DescendantsOfType, + async getDescendantsOfType( + parameters: Parameters.GetDescendantsOfType, callback?: Callback, ): Promise { const config: RequestConfig = { @@ -271,6 +288,7 @@ export class ContentChildrenAndDescendants { depth: parameters.depth, start: parameters.start, limit: parameters.limit, + expand: parameters.expand, }, }; @@ -283,17 +301,6 @@ export class ContentChildrenAndDescendants { * copied page is defined using the destinationPageId in the request body. The titleOptions object defines the rules * of renaming page titles during the copy; for example, search and replace can be used in conjunction to rewrite the * copied page titles. - * - * Response example: - *
-   *  {
-   *       "id" : "1180606",
-   *       "links" : {
-   *            "status" : "/rest/api/longtask/1180606"
-   *       }
-   *  }
-   *  
- * Use the /longtask/ REST API to get the copy task status. */ async copyPageHierarchy(parameters: Parameters.CopyPageHierarchy, callback: Callback): Promise; /** @@ -302,17 +309,6 @@ export class ContentChildrenAndDescendants { * copied page is defined using the destinationPageId in the request body. The titleOptions object defines the rules * of renaming page titles during the copy; for example, search and replace can be used in conjunction to rewrite the * copied page titles. - * - * Response example: - *
-   *  {
-   *       "id" : "1180606",
-   *       "links" : {
-   *            "status" : "/rest/api/longtask/1180606"
-   *       }
-   *  }
-   *  
- * Use the /longtask/ REST API to get the copy task status. */ async copyPageHierarchy(parameters: Parameters.CopyPageHierarchy, callback?: never): Promise; async copyPageHierarchy( diff --git a/src/api/contentPermissions.ts b/src/api/contentPermissions.ts index 747c4d7a..7e7bfbf0 100644 --- a/src/api/contentPermissions.ts +++ b/src/api/contentPermissions.ts @@ -7,6 +7,23 @@ import { RequestConfig } from '../requestConfig'; export class ContentPermissions { constructor(private client: Client) {} + /** @deprecated Will be removed in the next major version. Use `checkContentPermission` method instead. */ + async permissionCheck( + parameters: Parameters.PermissionCheck, + callback: Callback + ): Promise; + /** @deprecated Will be removed in the next major version. Use `checkContentPermission` method instead. */ + async permissionCheck( + parameters: Parameters.PermissionCheck, + callback?: never + ): Promise; + async permissionCheck( + parameters: Parameters.PermissionCheck, + callback?: Callback, + ): Promise { + return this.checkContentPermission(parameters, callback!); + } + /** * Check if a user or a group can perform an operation to the specified content. The `operation` to check must be * provided. The user’s account ID or the ID of the group can be provided in the `subject` to check permissions @@ -21,8 +38,8 @@ export class ContentPermissions { * ('Can use' global permission) if checking permission for self, otherwise 'Confluence Administrator' global * permission is required. */ - async permissionCheck( - parameters: Parameters.PermissionCheck, + async checkContentPermission( + parameters: Parameters.CheckContentPermission, callback: Callback ): Promise; /** @@ -39,12 +56,12 @@ export class ContentPermissions { * ('Can use' global permission) if checking permission for self, otherwise 'Confluence Administrator' global * permission is required. */ - async permissionCheck( - parameters: Parameters.PermissionCheck, + async checkContentPermission( + parameters: Parameters.CheckContentPermission, callback?: never ): Promise; - async permissionCheck( - parameters: Parameters.PermissionCheck, + async checkContentPermission( + parameters: Parameters.CheckContentPermission, callback?: Callback, ): Promise { const config: RequestConfig = { @@ -56,6 +73,6 @@ export class ContentPermissions { }, }; - return this.client.sendRequest(config, callback, { methodName: 'permissionCheck' }); + return this.client.sendRequest(config, callback, { methodName: 'checkContentPermission' }); } } diff --git a/src/api/contentProperties.ts b/src/api/contentProperties.ts index 8ae6b042..a602df41 100644 --- a/src/api/contentProperties.ts +++ b/src/api/contentProperties.ts @@ -37,6 +37,7 @@ export class ContentProperties { url: `/api/content/${parameters.id}/property`, method: 'GET', params: { + key: parameters.key, expand: parameters.expand, start: parameters.start, limit: parameters.limit, diff --git a/src/api/contentWatches.ts b/src/api/contentWatches.ts index 3a094bb0..55dd8144 100644 --- a/src/api/contentWatches.ts +++ b/src/api/contentWatches.ts @@ -68,7 +68,7 @@ export class ContentWatches { * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to access the Confluence site * ('Can use' global permission). */ - async getWatchesForSpace( + async getWatchesForSpace( parameters: Parameters.GetWatchesForSpace, callback: Callback ): Promise; @@ -85,11 +85,11 @@ export class ContentWatches { * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to access the Confluence site * ('Can use' global permission). */ - async getWatchesForSpace( + async getWatchesForSpace( parameters: Parameters.GetWatchesForSpace, callback?: never ): Promise; - async getWatchesForSpace( + async getWatchesForSpace( parameters: Parameters.GetWatchesForSpace, callback?: Callback, ): Promise { diff --git a/src/api/experimental.ts b/src/api/experimental.ts new file mode 100644 index 00000000..d2b32152 --- /dev/null +++ b/src/api/experimental.ts @@ -0,0 +1,44 @@ +import * as Models from './models'; +import * as Parameters from './parameters'; +import { Client } from '../clients'; +import { Callback } from '../callback'; +import { RequestConfig } from '../requestConfig'; + +export class Experimental { + constructor(private client: Client) {} + + /** Get the total number of views a piece of content has. */ + async getViews(parameters: Parameters.GetViews, callback: Callback): Promise; + /** Get the total number of views a piece of content has. */ + async getViews(parameters: Parameters.GetViews, callback?: never): Promise; + async getViews(parameters: Parameters.GetViews, callback?: Callback): Promise { + const config: RequestConfig = { + url: `/api/analytics/content/${parameters.contentId}/views`, + method: 'GET', + params: { + fromDate: parameters.fromDate, + }, + }; + + return this.client.sendRequest(config, callback, { methodName: 'getViews' }); + } + + /** 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. */ + async getViewers(parameters: Parameters.GetViewers, callback?: never): Promise; + async getViewers( + parameters: Parameters.GetViewers, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/api/analytics/content/${parameters.contentId}/viewers`, + method: 'GET', + params: { + fromDate: parameters.fromDate, + }, + }; + + return this.client.sendRequest(config, callback, { methodName: 'getViewers' }); + } +} diff --git a/src/api/group.ts b/src/api/group.ts index 381c7fbb..1bedb539 100644 --- a/src/api/group.ts +++ b/src/api/group.ts @@ -34,6 +34,7 @@ export class Group { params: { start: parameters?.start, limit: parameters?.limit, + accessType: parameters?.accessType, }, }; @@ -158,6 +159,37 @@ export class Group { return this.client.sendRequest(config, callback, { methodName: 'getGroupByGroupId' }); } + /** + * Delete user group. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: User must be a site admin. + */ + async removeGroupById(parameters: Parameters.RemoveGroupById, callback: Callback): Promise; + /** + * Delete user group. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: User must be a site admin. + */ + async removeGroupById(parameters: Parameters.RemoveGroupById, callback?: never): Promise; + async removeGroupById(parameters: Parameters.RemoveGroupById, callback?: Callback): Promise { + const config: RequestConfig = { + url: '/api/group/by-id', + method: 'DELETE', + params: { + id: parameters.id, + }, + }; + + return this.client.sendRequest(config, callback, { methodName: 'removeGroupById' }); + } + + /** @deprecated Will be removed in the next major version. Use `getGroupByName` instead. */ + async getGroup(parameters: Parameters.GetGroup, callback: Callback): Promise; + /** @deprecated Will be removed in the next major version. Use `getGroupByName` instead. */ + async getGroup(parameters: Parameters.GetGroup, callback?: never): Promise; + async getGroup(parameters: Parameters.GetGroup, callback?: Callback): Promise { + return this.getGroupByName(parameters, callback!); + } /** * Returns a user group for a given group name. * @@ -166,7 +198,7 @@ export class Group { * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to access the Confluence site * ('Can use' global permission). */ - async getGroup(parameters: Parameters.GetGroup, callback: Callback): Promise; + async getGroupByName(parameters: Parameters.GetGroupByName, callback: Callback): Promise; /** * Returns a user group for a given group name. * @@ -175,14 +207,17 @@ export class Group { * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to access the Confluence site * ('Can use' global permission). */ - async getGroup(parameters: Parameters.GetGroup, callback?: never): Promise; - async getGroup(parameters: Parameters.GetGroup, callback?: Callback): Promise { + async getGroupByName(parameters: Parameters.GetGroupByName, callback?: never): Promise; + async getGroupByName( + parameters: Parameters.GetGroupByName, + callback?: Callback, + ): Promise { const config: RequestConfig = { url: `/api/group/${parameters.groupName}`, method: 'GET', }; - return this.client.sendRequest(config, callback, { methodName: 'getGroup' }); + return this.client.sendRequest(config, callback, { methodName: 'getGroupByName' }); } /** @@ -191,7 +226,7 @@ export class Group { * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to access the Confluence site * ('Can use' global permission). */ - async getMembersByQueryParam( + async getMembersByQueryParam( parameters: Parameters.GetMembersByQueryParam, callback: Callback ): Promise; @@ -201,11 +236,11 @@ export class Group { * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to access the Confluence site * ('Can use' global permission). */ - async getMembersByQueryParam( + async getMembersByQueryParam( parameters: Parameters.GetMembersByQueryParam, callback?: never ): Promise; - async getMembersByQueryParam( + async getMembersByQueryParam( parameters: Parameters.GetMembersByQueryParam, callback?: Callback, ): Promise { @@ -230,7 +265,7 @@ export class Group { * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to access the Confluence site * ('Can use' global permission). */ - async getGroupMembers( + async getGroupMembers( parameters: Parameters.GetGroupMembers, callback: Callback ): Promise; @@ -242,11 +277,8 @@ export class Group { * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to access the Confluence site * ('Can use' global permission). */ - async getGroupMembers( - parameters: Parameters.GetGroupMembers, - callback?: never - ): Promise; - async getGroupMembers( + async getGroupMembers(parameters: Parameters.GetGroupMembers, callback?: never): Promise; + async getGroupMembers( parameters: Parameters.GetGroupMembers, callback?: Callback, ): Promise { @@ -262,12 +294,12 @@ export class Group { return this.client.sendRequest(config, callback, { methodName: 'getGroupMembers' }); } - /** Get search results of groups by partial query provided. */ + /** @deprecated Will be removed in the next major version. Use `searchGroups` instead. */ async getGroupsSearch( parameters: Parameters.GetGroupsSearch, callback: Callback ): Promise; - /** Get search results of groups by partial query provided. */ + /** @deprecated Will be removed in the next major version. Use `searchGroups` instead. */ async getGroupsSearch( parameters: Parameters.GetGroupsSearch, callback?: never @@ -275,6 +307,20 @@ export class Group { async getGroupsSearch( parameters: Parameters.GetGroupsSearch, callback?: Callback, + ): Promise { + return this.searchGroups(parameters, callback!); + } + + /** Get search results of groups by partial query provided. */ + async searchGroups( + parameters: Parameters.SearchGroups, + callback: Callback + ): Promise; + /** Get search results of groups by partial query provided. */ + async searchGroups(parameters: Parameters.SearchGroups, callback?: never): Promise; + async searchGroups( + parameters: Parameters.SearchGroups, + callback?: Callback, ): Promise { const config: RequestConfig = { url: '/api/group/picker', @@ -286,7 +332,7 @@ export class Group { }, }; - return this.client.sendRequest(config, callback, { methodName: 'getGroupsSearch' }); + return this.client.sendRequest(config, callback, { methodName: 'searchGroups' }); } /** @@ -317,6 +363,9 @@ export class Group { params: { groupId: parameters.groupId, }, + data: { + accountId: parameters.accountId, + }, }; return this.client.sendRequest(config, callback, { methodName: 'addUserToGroupByGroupId' }); @@ -364,7 +413,7 @@ export class Group { * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to access the Confluence site * ('Can use' global permission). */ - async getGroupMembersByGroupId( + async getGroupMembersByGroupId( parameters: Parameters.GetGroupMembersByGroupId, callback: Callback ): Promise; @@ -376,11 +425,11 @@ export class Group { * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to access the Confluence site * ('Can use' global permission). */ - async getGroupMembersByGroupId( + async getGroupMembersByGroupId( parameters: Parameters.GetGroupMembersByGroupId, callback?: never ): Promise; - async getGroupMembersByGroupId( + async getGroupMembersByGroupId( parameters: Parameters.GetGroupMembersByGroupId, callback?: Callback, ): Promise { @@ -415,6 +464,9 @@ export class Group { params: { name: parameters.name, }, + data: { + accountId: parameters.accountId, + }, }; return this.client.sendRequest(config, callback, { methodName: 'addUserToGroup' }); diff --git a/src/api/index.ts b/src/api/index.ts index a1a56b58..41e5aec5 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -12,6 +12,7 @@ export * from './contentRestrictions'; export * from './contentVersions'; export * from './contentWatches'; export * from './dynamicModules'; +export * from './experimental'; export * from './group'; export * from './inlineTasks'; export * from './labelInfo'; diff --git a/src/api/inlineTasks.ts b/src/api/inlineTasks.ts index 40ca361f..3675b0af 100644 --- a/src/api/inlineTasks.ts +++ b/src/api/inlineTasks.ts @@ -51,4 +51,56 @@ export class InlineTasks { return this.client.sendRequest(config, callback, { methodName: 'searchTasks' }); } + + /** + * Returns inline task based on the global ID. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content associated + * with the task. + */ + async getTaskById(parameters: Parameters.GetTaskById, callback: Callback): Promise; + /** + * Returns inline task based on the global ID. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content associated + * with the task. + */ + async getTaskById(parameters: Parameters.GetTaskById, callback?: never): Promise; + async getTaskById(parameters: Parameters.GetTaskById, callback?: Callback): Promise { + const config: RequestConfig = { + url: `/api/inlinetasks/${parameters.inlineTaskId}`, + method: 'GET', + }; + + return this.client.sendRequest(config, callback, { methodName: 'getTaskById' }); + } + + /** + * Updates an inline tasks status given its global ID + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to update the content associated + * with the task. + */ + async updateTaskById(parameters: Parameters.UpdateTaskById, callback: Callback): Promise; + /** + * Updates an inline tasks status given its global ID + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to update the content associated + * with the task. + */ + async updateTaskById(parameters: Parameters.UpdateTaskById, callback?: never): Promise; + async updateTaskById( + parameters: Parameters.UpdateTaskById, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/api/inlinetasks/${parameters.inlineTaskId}`, + method: 'PUT', + data: { + status: parameters.status, + }, + }; + + return this.client.sendRequest(config, callback, { methodName: 'updateTaskById' }); + } } diff --git a/src/api/models/getViewers.ts b/src/api/models/getViewers.ts new file mode 100644 index 00000000..731dadcc --- /dev/null +++ b/src/api/models/getViewers.ts @@ -0,0 +1,6 @@ +export interface GetViewers { + /** The content ID. */ + id?: number; + /** The total number of distinct viewers for the content. */ + count?: number; +} diff --git a/src/api/models/getViews.ts b/src/api/models/getViews.ts new file mode 100644 index 00000000..7cdd3f8d --- /dev/null +++ b/src/api/models/getViews.ts @@ -0,0 +1,6 @@ +export interface GetViews { + /** The content ID. */ + id?: number; + /** The total number of views for the content. */ + count?: number; +} diff --git a/src/api/models/groupCreate.ts b/src/api/models/groupCreate.ts new file mode 100644 index 00000000..fe2b9462 --- /dev/null +++ b/src/api/models/groupCreate.ts @@ -0,0 +1,4 @@ +export interface GroupCreate { + type: string; + name: string; +} diff --git a/src/api/models/horizontalHeaderLookAndFeel.ts b/src/api/models/horizontalHeaderLookAndFeel.ts new file mode 100644 index 00000000..bf990fb4 --- /dev/null +++ b/src/api/models/horizontalHeaderLookAndFeel.ts @@ -0,0 +1,12 @@ +import { ButtonLookAndFeel } from './buttonLookAndFeel'; +import { TopNavigationLookAndFeel } from './topNavigationLookAndFeel'; +import { NavigationLookAndFeel } from './navigationLookAndFeel'; +import { SearchFieldLookAndFeel } from './searchFieldLookAndFeel'; + +export interface HorizontalHeaderLookAndFeel { + backgroundColor: string; + button?: ButtonLookAndFeel; + primaryNavigation: TopNavigationLookAndFeel; + secondaryNavigation?: NavigationLookAndFeel; + search?: SearchFieldLookAndFeel; +} diff --git a/src/api/models/index.ts b/src/api/models/index.ts index fec7c089..4feae3a8 100644 --- a/src/api/models/index.ts +++ b/src/api/models/index.ts @@ -14,8 +14,6 @@ export * from './breadcrumb'; export * from './bulkUserLookup'; export * from './bulkUserLookupArray'; export * from './buttonLookAndFeel'; -export * from './cQLPersonalDataConvertedQueries'; -export * from './cQLPersonalDataMigrationRequest'; export * from './changedValue'; export * from './connectModule'; export * from './connectModules'; @@ -30,8 +28,8 @@ export * from './contentBlueprintDraft'; export * from './contentBody'; export * from './contentBodyCreate'; export * from './contentBodyCreateStorage'; -export * from './contentChildType'; export * from './contentChildren'; +export * from './contentChildType'; export * from './contentComment'; export * from './contentCreate'; export * from './contentHistory'; @@ -59,17 +57,23 @@ export * from './copyPageHierarchyRequest'; export * from './copyPageHierarchyTitleOptions'; export * from './copyPageRequest'; export * from './copyPageRequestDestination'; +export * from './cQLPersonalDataConvertedQueries'; +export * from './cQLPersonalDataMigrationRequest'; export * from './deletedSpace'; export * from './dynamicModulesErrorMessage'; export * from './embeddable'; export * from './embeddedContent'; export * from './genericLinks'; export * from './getRestrictionsByOperation'; +export * from './getViewers'; +export * from './getViews'; export * from './group'; export * from './groupArray'; export * from './groupArrayWithLinks'; +export * from './groupCreate'; export * from './groupName'; export * from './headerLookAndFeel'; +export * from './horizontalHeaderLookAndFeel'; export * from './icon'; export * from './label'; export * from './labelArray'; @@ -112,6 +116,9 @@ export * from './spaceCreate'; export * from './spaceDescription'; export * from './spaceDescriptionCreate'; export * from './spacePermission'; +export * from './spacePermissionCreate'; +export * from './spacePermissionCustomContent'; +export * from './spacePermissionRequest'; export * from './spacePermissionV2'; export * from './spacePrivateCreate'; export * from './spaceProperty'; @@ -129,17 +136,19 @@ export * from './superBatchWebResources'; export * from './systemInfoEntity'; export * from './task'; export * from './taskPageResponse'; +export * from './taskStatusUpdate'; export * from './theme'; export * from './themeArray'; export * from './themeNoLinks'; export * from './themeUpdate'; +export * from './topNavigationLookAndFeel'; export * from './user'; export * from './userAnonymous'; export * from './userArray'; export * from './userArrayWithLinks'; export * from './userDetails'; -export * from './userWatch'; export * from './usersUserKeys'; +export * from './userWatch'; export * from './version'; export * from './versionArray'; export * from './versionRestore'; diff --git a/src/api/models/lookAndFeel.ts b/src/api/models/lookAndFeel.ts index 744c6614..a1e91d61 100644 --- a/src/api/models/lookAndFeel.ts +++ b/src/api/models/lookAndFeel.ts @@ -1,6 +1,7 @@ import { MenusLookAndFeel } from './menusLookAndFeel'; import { HeaderLookAndFeel } from './headerLookAndFeel'; import { ContentLookAndFeel } from './contentLookAndFeel'; +import { HorizontalHeaderLookAndFeel } from './horizontalHeaderLookAndFeel'; export interface LookAndFeel { headings: { @@ -15,4 +16,6 @@ export interface LookAndFeel { bordersAndDividers: { color: string; }; + horizontalHeader?: HorizontalHeaderLookAndFeel; + spaceReference?: unknown; } diff --git a/src/api/models/spacePermissionCreate.ts b/src/api/models/spacePermissionCreate.ts new file mode 100644 index 00000000..e634a81c --- /dev/null +++ b/src/api/models/spacePermissionCreate.ts @@ -0,0 +1,34 @@ +import { User } from './user'; +import { GroupCreate } from './groupCreate'; +import { OperationCheckResult } from './operationCheckResult'; + +/** + * This object represents a permission for given space. Permissions consist of* at least one operation object with an + * accompanying subjects object. + * + * The following combinations of `operation` and `targetType` values are valid for the `operation` object: + * + * - 'create': 'page', 'blogpost', 'comment', 'attachment' + * - 'read': 'space' + * - 'delete': 'page', 'blogpost', 'comment', 'attachment' + * - 'export': 'space' + * - 'administer': 'space' + */ +export interface SpacePermissionCreate { + /** The users and/or groups that the permission applies to. */ + subjects: { + user?: { + results: User[]; + size: number; + }; + group?: { + results: GroupCreate[]; + size: number; + }; + }; + operation: OperationCheckResult; + /** Grant anonymous users permission to use the operation. */ + anonymousAccess: boolean; + /** Grants access to unlicensed users from JIRA Service Desk when used with the 'read space' operation. */ + unlicensedAccess: boolean; +} diff --git a/src/api/models/spacePermissionCustomContent.ts b/src/api/models/spacePermissionCustomContent.ts new file mode 100644 index 00000000..99dbff84 --- /dev/null +++ b/src/api/models/spacePermissionCustomContent.ts @@ -0,0 +1,17 @@ +import { PermissionSubject } from './permissionSubject'; + +/** + * This object represents a list of space permissions for custom content type for an individual user. Permissions + * consist of* a subjects object and a list with at least one operation object. + */ +export interface SpacePermissionCustomContent { + subject: PermissionSubject; + operations: { + /** The operation type */ + key: string; + /** The custom content type */ + target: string; + /** Grant or restrict access */ + access: boolean; + }[]; +} diff --git a/src/api/models/spacePermissionRequest.ts b/src/api/models/spacePermissionRequest.ts new file mode 100644 index 00000000..aad211a2 --- /dev/null +++ b/src/api/models/spacePermissionRequest.ts @@ -0,0 +1,42 @@ +import { PermissionSubject } from './permissionSubject'; +import { GenericLinks } from './genericLinks'; + +/** + * This object represents the request for the single space permission. Permissions consist of* at least one operation + * object with an accompanying subjects object. + * + * The following combinations of `operation.key` and `operation.target` values are valid for the `operation` object: + * + * ```bash + * 'create': 'page', 'blogpost', 'comment', 'attachment' + * 'read': 'space' + * 'delete': 'page', 'blogpost', 'comment', 'attachment', 'space' + * 'export': 'space' + * 'administer': 'space' + * 'archive': 'page' + * 'restrict_content': 'space' + * ``` + * + * For example, to enable Delete Own permission, set the `operation` object to the following: + * + * "operation": { + * "key": "delete", + * "target": "space" + * } + * + * To enable Add/Delete Restrictions permissions, set the `operation` object to the following: + * + * "operation": { + * "key": "restrict_content", + * "target": "space" + * } + */ +export interface SpacePermissionRequest { + subject: PermissionSubject; + operation: { + key: string; + /** The space or content type that the operation applies to. */ + target: string; + }; + links?: GenericLinks; +} diff --git a/src/api/models/spacePrivateCreate.ts b/src/api/models/spacePrivateCreate.ts index ae8fd92a..62fa976b 100644 --- a/src/api/models/spacePrivateCreate.ts +++ b/src/api/models/spacePrivateCreate.ts @@ -1,4 +1,5 @@ import { SpaceDescriptionCreate } from './spaceDescriptionCreate'; +import { SpacePermissionCreate } from './spacePermissionCreate'; /** This is the request object used when creating a new private space. */ export interface SpacePrivateCreate { @@ -7,4 +8,12 @@ export interface SpacePrivateCreate { /** The name of the new space. */ name: string; description?: SpaceDescriptionCreate; + /** + * The permissions for the new space. If no permissions are provided, the [Confluence default space + * permissions](https://confluence.atlassian.com/x/UAgzKw#CreateaSpace-Spacepermissions) are applied. Note that if + * permissions are provided, the space is created with only the provided set of permissions, not including the default + * space permissions. Space permissions can be modified after creation using the space permissions endpoints, and a + * private space can be created using the create private space endpoint. + */ + permissions?: SpacePermissionCreate[]; } diff --git a/src/api/models/spacePropertyCreate.ts b/src/api/models/spacePropertyCreate.ts index 90f93871..e31764f9 100644 --- a/src/api/models/spacePropertyCreate.ts +++ b/src/api/models/spacePropertyCreate.ts @@ -4,4 +4,8 @@ export interface SpacePropertyCreate { /** The key of the new property. */ key: string; value: PropertyValue; + space?: { + /** The key of the space */ + key?: string; + }; } diff --git a/src/api/models/spaceUpdate.ts b/src/api/models/spaceUpdate.ts index 6d7c25f2..1177903d 100644 --- a/src/api/models/spaceUpdate.ts +++ b/src/api/models/spaceUpdate.ts @@ -9,4 +9,8 @@ export interface SpaceUpdate { /** The ID of the page. */ id: string; }; + /** The updated type for this space. */ + type?: string; + /** The updated status for this space. */ + status?: string; } diff --git a/src/api/models/taskStatusUpdate.ts b/src/api/models/taskStatusUpdate.ts new file mode 100644 index 00000000..1178e6d5 --- /dev/null +++ b/src/api/models/taskStatusUpdate.ts @@ -0,0 +1,3 @@ +export interface TaskStatusUpdate { + status: string; +} diff --git a/src/api/models/topNavigationLookAndFeel.ts b/src/api/models/topNavigationLookAndFeel.ts new file mode 100644 index 00000000..445f13b0 --- /dev/null +++ b/src/api/models/topNavigationLookAndFeel.ts @@ -0,0 +1,8 @@ +export interface TopNavigationLookAndFeel { + color?: string; + highlightColor: string; + hoverOrFocus?: { + backgroundColor?: string; + color?: string; + }; +} diff --git a/src/api/parameters/addCustomContentPermissions.ts b/src/api/parameters/addCustomContentPermissions.ts new file mode 100644 index 00000000..3c1e2157 --- /dev/null +++ b/src/api/parameters/addCustomContentPermissions.ts @@ -0,0 +1,6 @@ +import { SpacePermissionCustomContent } from '../models'; + +export interface AddCustomContentPermissions extends SpacePermissionCustomContent { + /** The key of the space to be queried for its content. */ + spaceKey: string; +} diff --git a/src/api/parameters/addPermissionToSpace.ts b/src/api/parameters/addPermissionToSpace.ts new file mode 100644 index 00000000..825a05a3 --- /dev/null +++ b/src/api/parameters/addPermissionToSpace.ts @@ -0,0 +1,6 @@ +import { SpacePermissionRequest } from '../models'; + +export interface AddPermissionToSpace extends SpacePermissionRequest { + /** The key of the space to be queried for its content. */ + spaceKey: string; +} diff --git a/src/api/parameters/addUserToGroup.ts b/src/api/parameters/addUserToGroup.ts index c52c6bd3..472be16a 100644 --- a/src/api/parameters/addUserToGroup.ts +++ b/src/api/parameters/addUserToGroup.ts @@ -1,4 +1,6 @@ -export interface AddUserToGroup { +import { AccountId } from '../models'; + +export interface AddUserToGroup extends AccountId { /** Name of the group whose membership is updated */ name: string; } diff --git a/src/api/parameters/addUserToGroupByGroupId.ts b/src/api/parameters/addUserToGroupByGroupId.ts index 9978a18c..86a4a3cd 100644 --- a/src/api/parameters/addUserToGroupByGroupId.ts +++ b/src/api/parameters/addUserToGroupByGroupId.ts @@ -1,4 +1,6 @@ -export interface AddUserToGroupByGroupId { +import { AccountId } from '../models'; + +export interface AddUserToGroupByGroupId extends AccountId { /** GroupId of the group whose membership is updated */ groupId: string; } diff --git a/src/api/parameters/archivePages.ts b/src/api/parameters/archivePages.ts new file mode 100644 index 00000000..72624158 --- /dev/null +++ b/src/api/parameters/archivePages.ts @@ -0,0 +1,6 @@ +export interface ArchivePages { + pages: Array<{ + /** The `id` of the page to be archived. */ + id: number; + }>; +} diff --git a/src/api/parameters/checkContentPermission.ts b/src/api/parameters/checkContentPermission.ts new file mode 100644 index 00000000..0cd99970 --- /dev/null +++ b/src/api/parameters/checkContentPermission.ts @@ -0,0 +1,6 @@ +import { ContentPermissionRequest } from '../models'; + +export interface CheckContentPermission extends ContentPermissionRequest { + /** The ID of the content to check permissions against. */ + id: string; +} diff --git a/src/api/parameters/deleteRelationship.ts b/src/api/parameters/deleteRelationship.ts new file mode 100644 index 00000000..f639368d --- /dev/null +++ b/src/api/parameters/deleteRelationship.ts @@ -0,0 +1,38 @@ +export interface DeleteRelationship { + /** The name of the relationship. */ + relationName: string; + /** The source entity type of the relationship. This must be 'user', if the `relationName` is 'favourite'. */ + sourceType: string; + /** + * - The identifier for the source entity: + * + * - If `sourceType` is 'user', then specify either 'current' (logged-in user) or the user key. + * - If `sourceType` is 'content', then specify the content ID. + * - If `sourceType` is 'space', then specify the space key. + */ + sourceKey: string; + /** The target entity type of the relationship. This must be 'space' or 'content', if the `relationName` is 'favourite'. */ + targetType: string; + /** + * - The identifier for the target entity: + * + * - If `sourceType` is 'user', then specify either 'current' (logged-in user) or the user key. + * - If `sourceType` is 'content', then specify the content ID. + * - If `sourceType` is 'space', then specify the space key. + */ + targetKey: string; + /** The status of the source. This parameter is only used when the `sourceType` is 'content'. */ + sourceStatus?: string; + /** The status of the target. This parameter is only used when the `targetType` is 'content'. */ + targetStatus?: string; + /** + * The version of the source. This parameter is only used when the `sourceType` is 'content' and the `sourceStatus` + * is 'historical'. + */ + sourceVersion?: number; + /** + * The version of the target. This parameter is only used when the `targetType` is 'content' and the `targetStatus` + * is 'historical'. + */ + targetVersion?: number; +} diff --git a/src/api/parameters/downloadAttachment.ts b/src/api/parameters/downloadAttachment.ts new file mode 100644 index 00000000..dc88dbf8 --- /dev/null +++ b/src/api/parameters/downloadAttachment.ts @@ -0,0 +1,11 @@ +export interface DownloadAttachment { + /** The ID of the content that the attachment is attached to. */ + id: string; + /** The ID of the attachment to download. */ + attachmentId: string; + /** + * The version of the attachment. If this parameter is absent, the redirect URI will download the latest version of + * the attachment. + */ + version?: number; +} diff --git a/src/api/parameters/getContentProperties.ts b/src/api/parameters/getContentProperties.ts index d5ba738d..bfeb0c16 100644 --- a/src/api/parameters/getContentProperties.ts +++ b/src/api/parameters/getContentProperties.ts @@ -1,6 +1,8 @@ export interface GetContentProperties { /** The ID of the content to be queried for its properties. */ id: string; + /**The key of the content property.*/ + key?: string[]; /** * A multi-value parameter indicating which properties of the content to expand. By default, the `version` object is expanded. * diff --git a/src/api/parameters/getDescendantsOfType.ts b/src/api/parameters/getDescendantsOfType.ts new file mode 100644 index 00000000..5d06db81 --- /dev/null +++ b/src/api/parameters/getDescendantsOfType.ts @@ -0,0 +1,102 @@ +export interface GetDescendantsOfType { + /** The ID of the content to be queried for its descendants. */ + id: string; + /** The type of descendants to return. */ + type: string | 'page' | 'comment' | 'attachment'; + /** + * Filter the results to descendants upto a desired level of the content. Note, the maximum value supported is 100. + * root level of the content means immediate (level 1) descendants of the type requested. all represents returning all + * descendants of the type requested. + */ + depth?: string; + /** The starting index of the returned content. */ + start?: number; + /** The maximum number of content to return per page. Note, this may be restricted by fixed system limits. */ + limit?: number; + expand?: string | string[] | GetDescendantsOfType.Expand | GetDescendantsOfType.Expand[]; +} + +export namespace GetDescendantsOfType { + export enum Expand { + /** + * Returns whether the content has attachments, comments, or child pages. Use this if you only need to check whether + * the content has children of a particular type. + */ + AllChildTypes = 'childTypes.all', + /** Returns whether the content has attachments. */ + AttachmentChildType = 'childTypes.attachment', + /** Returns whether the content has comments. */ + CommentChildType = 'childTypes.comment', + /** Returns whether the content has child pages. */ + PageChildType = 'childTypes.page', + /** + * Returns the space that the content is in. This is the same as the information returned by [Get + * space](https://developer.atlassian.com/cloud/confluence/rest/api-group-content---attachments/). + */ + Container = 'container', + /** + * Returns information about the current user in relation to the content, including when they last viewed it, + * modified it, contributed to it, or added it as a favorite. + */ + CurrentUserMetadata = 'metadata.currentuser', + /** Returns content properties that have been set via the Confluence REST API. */ + PropertiesMetadata = 'metadata.properties', + /** Returns the labels that have been added to the content. */ + LabelsMetadata = 'metadata.labels', + /** This property is only used by Atlassian. */ + FrontendMetadata = 'metadata.frontend', + /** Returns the operations for the content, which are used when setting permissions. */ + Operations = 'operations', + /** Returns pages that are descendants at the level immediately below the content. */ + PageChildren = 'children.page', + /** Returns all attachments for the content. */ + AttachmentChildren = 'children.attachment', + /** Returns all comments on the content. */ + CommentChildren = 'children.comment', + /** Returns the users that have permission to read the content. */ + ReadUserRestriction = 'restrictions.read.restrictions.user', + /** + * Returns the groups that have permission to read the content. Note that this may return deleted groups, because + * deleting a group doesn't remove associated restrictions. + */ + ReadGroupRestriction = 'restrictions.read.restrictions.group', + /** Returns the users that have permission to update the content. */ + UpdateUserRestriction = 'restrictions.update.restrictions.user', + /** + * Returns the groups that have permission to update the content. Note that this may return deleted groups because + * deleting a group doesn't remove associated restrictions. + */ + UpdateGroupRestriction = 'restrictions.update.restrictions.group', + /** Returns the history of the content, including the date it was created. */ + History = 'history', + /** Returns information about the most recent update of the content, including who updated it and when it was updated. */ + LastUpdated = 'history.lastUpdated', + /** Returns information about the update prior to the current content update. */ + PreviousVersion = 'history.previousVersion', + /** Returns all of the users who have contributed to the content. */ + Contributors = 'history.contributors', + /** Returns information about the update after to the current content update. */ + NextVersion = 'history.nextVersion', + /** Returns the parent page, if the content is a page. */ + Ancestors = 'ancestors', + /** Returns the body of the content in different formats, including the editor format, view format, and export format. */ + Body = 'body', + /** Returns information about the most recent update of the content, including who updated it and when it was updated. */ + Version = 'version', + /** Returns pages that are descendants at any level below the content. */ + PageDescendant = 'descendants.page', + /** Returns all attachments for the content, same as `children.attachment`. */ + AttachmentDescendant = 'descendants.attachment', + /** Returns all comments on the content, same as `children.comment`. */ + CommentDescendant = 'descendants.comment', + /** + * Returns the space that the content is in. This is the same as the information returned by [Get + * space](https://developer.atlassian.com/cloud/confluence/rest/api-group-content---attachments/). + */ + Space = 'space', + /** Returns inline comment-specific properties. */ + InlineProperties = 'extensions.inlineProperties', + /** Returns the resolution status of each comment. */ + Resolution = 'extensions.resolution', + } +} diff --git a/src/api/parameters/getGroupByName.ts b/src/api/parameters/getGroupByName.ts new file mode 100644 index 00000000..99a9aaad --- /dev/null +++ b/src/api/parameters/getGroupByName.ts @@ -0,0 +1,4 @@ +export interface GetGroupByName { + /** The name of the group. This is the same as the group name shown in the Confluence administration console. */ + groupName: string; +} diff --git a/src/api/parameters/getGroups.ts b/src/api/parameters/getGroups.ts index 87d13011..9c4d8830 100644 --- a/src/api/parameters/getGroups.ts +++ b/src/api/parameters/getGroups.ts @@ -3,4 +3,6 @@ export interface GetGroups { start?: number; /** The maximum number of groups to return per page. Note, this may be restricted by fixed system limits. */ limit?: number; + /** The group permission level for which to filter results. */ + accessType?: string; } diff --git a/src/api/parameters/getTaskById.ts b/src/api/parameters/getTaskById.ts new file mode 100644 index 00000000..e4434d15 --- /dev/null +++ b/src/api/parameters/getTaskById.ts @@ -0,0 +1,4 @@ +export interface GetTaskById { + /** Global ID of the inline task */ + inlineTaskId: string; +} diff --git a/src/api/parameters/getViewers.ts b/src/api/parameters/getViewers.ts new file mode 100644 index 00000000..5be1ce0f --- /dev/null +++ b/src/api/parameters/getViewers.ts @@ -0,0 +1,6 @@ +export interface GetViewers { + /** The ID of the content to get the viewers for. */ + contentId: string; + /** The number of views for the content since the date. */ + fromDate?: string; +} diff --git a/src/api/parameters/getViews.ts b/src/api/parameters/getViews.ts new file mode 100644 index 00000000..5048ec64 --- /dev/null +++ b/src/api/parameters/getViews.ts @@ -0,0 +1,6 @@ +export interface GetViews { + /** The ID of the content to get the views for. */ + contentId: string; + /** The number of views for the content since the date. */ + fromDate?: string; +} diff --git a/src/api/parameters/index.ts b/src/api/parameters/index.ts index 884af8a3..288ab2b9 100644 --- a/src/api/parameters/index.ts +++ b/src/api/parameters/index.ts @@ -1,140 +1,155 @@ -export * from './getAuditRecords'; +export * from './addContentWatcher'; +export * from './addCustomContentPermissions'; +export * from './addGroupToContentRestriction'; +export * from './addGroupToContentRestrictionByGroupId'; +export * from './addLabelsToContent'; +export * from './addLabelWatcher'; +export * from './addPermission'; +export * from './addPermissionToSpace'; +export * from './addRestrictions'; +export * from './addSpaceWatcher'; +export * from './addUserToContentRestriction'; +export * from './addUserToGroup'; +export * from './addUserToGroupByGroupId'; +export * from './archivePages'; +export * from './checkContentPermission'; +export * from './convertContentBody'; +export * from './copyPage'; +export * from './copyPageHierarchy'; +export * from './createAttachments'; export * from './createAuditRecord'; +export * from './createContent'; +export * from './createContentProperty'; +export * from './createContentPropertyForKey'; +export * from './createContentTemplate'; +export * from './createGroup'; +export * from './createOrUpdateAttachments'; +export * from './createPrivateSpace'; +export * from './createRelationship'; +export * from './createSpace'; +export * from './createSpaceProperty'; +export * from './createSpacePropertyForKey'; +export * from './delete'; +export * from './deleteContent'; +export * from './deleteContentProperty'; +export * from './deleteContentVersion'; +export * from './deleteRelationship'; +export * from './deleteRestrictions'; +export * from './deleteSpace'; +export * from './deleteSpaceProperty'; +export * from './descendantsOfType'; +export * from './downloadAttachment'; export * from './exportAuditRecords'; -export * from './setRetentionPeriod'; +export * from './findSourcesForTarget'; +export * from './findTargetFromSource'; +export * from './getAllLabelContent'; +export * from './getAnonymousUser'; +export * from './getAttachments'; +export * from './getAuditRecords'; export * from './getAuditRecordsForTimePeriod'; +export * from './getBlueprintTemplates'; +export * from './getBulkUserLookup'; +export * from './getBulkUserMigration'; export * from './getContent'; -export * from './createContent'; -export * from './publishLegacyDraft'; -export * from './publishSharedDraft'; -export * from './searchContentByCQL'; export * from './getContentById'; -export * from './updateContent'; -export * from './deleteContent'; -export * from './getHistoryForContent'; +export * from './getContentByTypeForSpace'; export * from './getContentChildren'; -export * from './movePage'; export * from './getContentChildrenByType'; -export * from './getContentDescendants'; -export * from './descendantsOfType'; -export * from './copyPageHierarchy'; -export * from './copyPage'; -export * from './getAttachments'; -export * from './createAttachments'; -export * from './createOrUpdateAttachments'; -export * from './updateAttachmentProperties'; -export * from './updateAttachmentData'; export * from './getContentComments'; -export * from './getMacroBodyByMacroId'; -export * from './getLabelsForContent'; -export * from './addLabelsToContent'; -export * from './removeLabelFromContentUsingQueryParameter'; -export * from './removeLabelFromContent'; -export * from './getWatchesForPage'; -export * from './getWatchesForSpace'; -export * from './getWatchersForSpace'; -export * from './getContentWatchStatus'; -export * from './addContentWatcher'; -export * from './removeContentWatcher'; -export * from './isWatchingLabel'; -export * from './addLabelWatcher'; -export * from './removeLabelWatcher'; -export * from './isWatchingSpace'; -export * from './addSpaceWatcher'; -export * from './removeSpaceWatch'; -export * from './permissionCheck'; +export * from './getContentDescendants'; +export * from './getContentForSpace'; export * from './getContentProperties'; -export * from './createContentProperty'; export * from './getContentProperty'; -export * from './createContentPropertyForKey'; -export * from './updateContentProperty'; -export * from './deleteContentProperty'; -export * from './getRestrictions'; -export * from './addRestrictions'; -export * from './updateRestrictions'; -export * from './deleteRestrictions'; -export * from './getRestrictionsByOperation'; -export * from './getRestrictionsForOperation'; export * from './getContentRestrictionStatusForGroup'; -export * from './addGroupToContentRestriction'; -export * from './getIndividualGroupRestrictionStatusByGroupId'; -export * from './addGroupToContentRestrictionByGroupId'; -export * from './removeGroupByName'; -export * from './removeGroupById'; export * from './getContentRestrictionStatusForUser'; -export * from './addUserToContentRestriction'; -export * from './removeUserFromContentRestriction'; -export * from './getContentVersions'; -export * from './restoreContentVersion'; +export * from './getContentTemplate'; +export * from './getContentTemplates'; export * from './getContentVersion'; -export * from './deleteContentVersion'; -export * from './convertContentBody'; -export * from './searchTasks'; -export * from './getAllLabelContent'; -export * from './getGroups'; -export * from './createGroup'; -export * from './removeGroup'; -export * from './getGroupByQueryParam'; -export * from './getGroupByGroupId'; +export * from './getContentVersions'; +export * from './getContentWatchStatus'; +export * from './getCurrentUser'; +export * from './getDescendantsOfType'; export * from './getGroup'; -export * from './getMembersByQueryParam'; +export * from './getGroupByGroupId'; +export * from './getGroupByName'; +export * from './getGroupByQueryParam'; export * from './getGroupMembers'; -export * from './getGroupsSearch'; -export * from './addUserToGroupByGroupId'; -export * from './removeMemberFromGroupByGroupId'; export * from './getGroupMembersByGroupId'; -export * from './addUserToGroup'; -export * from './removeMemberFromGroup'; -export * from './getTasks'; -export * from './getTask'; -export * from './findTargetFromSource'; -export * from './getRelationship'; -export * from './createRelationship'; -export * from './delete'; -export * from './findSourcesForTarget'; -export * from './search'; -export * from './userSearch'; +export * from './getGroupMembershipsForUser'; +export * from './getGroups'; +export * from './getGroupsSearch'; +export * from './getHistoryForContent'; +export * from './getIndividualGroupRestrictionStatusByGroupId'; +export * from './getLabelsForContent'; export * from './getLookAndFeelSettings'; -export * from './updateLookAndFeel'; -export * from './updateLookAndFeelSettings'; -export * from './resetLookAndFeelSettings'; -export * from './setLookAndFeelSettings'; -export * from './getThemes'; -export * from './getTheme'; -export * from './getSpaceTheme'; -export * from './setSpaceTheme'; -export * from './resetSpaceTheme'; -export * from './getSpaces'; -export * from './createSpace'; -export * from './createPrivateSpace'; +export * from './getMacroBodyByMacroId'; +export * from './getMembersByQueryParam'; +export * from './getPrivacyUnsafeUserEmail'; +export * from './getPrivacyUnsafeUserEmailBulk'; +export * from './getRelationship'; +export * from './getRestrictions'; +export * from './getRestrictionsByOperation'; +export * from './getRestrictionsForOperation'; export * from './getSpace'; -export * from './updateSpace'; -export * from './deleteSpace'; -export * from './getContentForSpace'; -export * from './getContentByTypeForSpace'; -export * from './addPermission'; -export * from './removePermission'; export * from './getSpaceProperties'; -export * from './createSpaceProperty'; export * from './getSpaceProperty'; -export * from './createSpacePropertyForKey'; -export * from './updateSpaceProperty'; -export * from './deleteSpaceProperty'; +export * from './getSpaces'; export * from './getSpaceSettings'; -export * from './updateSpaceSettings'; -export * from './createContentTemplate'; -export * from './updateContentTemplate'; -export * from './getBlueprintTemplates'; -export * from './getContentTemplates'; -export * from './getContentTemplate'; -export * from './removeTemplate'; +export * from './getSpaceTheme'; +export * from './getTask'; +export * from './getTaskById'; +export * from './getTasks'; +export * from './getTheme'; +export * from './getThemes'; export * from './getUser'; -export * from './getAnonymousUser'; -export * from './getCurrentUser'; -export * from './getGroupMembershipsForUser'; -export * from './getBulkUserLookup'; -export * from './getPrivacyUnsafeUserEmail'; -export * from './getPrivacyUnsafeUserEmailBulk'; -export * from './getBulkUserMigration'; +export * from './getViewers'; +export * from './getViews'; +export * from './getWatchersForSpace'; +export * from './getWatchesForPage'; +export * from './getWatchesForSpace'; +export * from './isWatchingLabel'; +export * from './isWatchingSpace'; +export * from './movePage'; +export * from './permissionCheck'; +export * from './publishLegacyDraft'; +export * from './publishSharedDraft'; export * from './registerModules'; +export * from './removeContentWatcher'; +export * from './removeGroup'; +export * from './removeGroupById'; +export * from './removeGroupByName'; +export * from './removeLabelFromContent'; +export * from './removeLabelFromContentUsingQueryParameter'; +export * from './removeLabelWatcher'; +export * from './removeMemberFromGroup'; +export * from './removeMemberFromGroupByGroupId'; export * from './removeModules'; +export * from './removePermission'; +export * from './removeSpaceWatch'; +export * from './removeTemplate'; +export * from './removeUserFromContentRestriction'; +export * from './resetLookAndFeelSettings'; +export * from './resetSpaceTheme'; +export * from './restoreContentVersion'; +export * from './search'; +export * from './searchByCQL'; +export * from './searchContentByCQL'; +export * from './searchGroups'; +export * from './searchTasks'; +export * from './searchUser'; +export * from './setLookAndFeelSettings'; +export * from './setRetentionPeriod'; +export * from './setSpaceTheme'; +export * from './updateAttachmentData'; +export * from './updateAttachmentProperties'; +export * from './updateContent'; +export * from './updateContentProperty'; +export * from './updateContentTemplate'; +export * from './updateLookAndFeel'; +export * from './updateLookAndFeelSettings'; +export * from './updateRestrictions'; +export * from './updateSpace'; +export * from './updateSpaceProperty'; +export * from './updateSpaceSettings'; +export * from './updateTaskById'; +export * from './userSearch'; diff --git a/src/api/parameters/publishLegacyDraft.ts b/src/api/parameters/publishLegacyDraft.ts index 3e8e111c..e394cd8e 100644 --- a/src/api/parameters/publishLegacyDraft.ts +++ b/src/api/parameters/publishLegacyDraft.ts @@ -1,4 +1,6 @@ -export interface PublishLegacyDraft { +import { ContentBlueprintDraft } from '../models'; + +export interface PublishLegacyDraft extends ContentBlueprintDraft { /** * The ID of the draft page that was created from a blueprint. You can find the `draftId` in the Confluence * application by opening the draft page and checking the page URL. @@ -11,4 +13,5 @@ export interface PublishLegacyDraft { status?: string; /** A multi-value parameter indicating which properties of the content to expand. */ expand?: string[]; + bodyStatus?: string; } diff --git a/src/api/parameters/publishSharedDraft.ts b/src/api/parameters/publishSharedDraft.ts index 7faca71d..2cf03444 100644 --- a/src/api/parameters/publishSharedDraft.ts +++ b/src/api/parameters/publishSharedDraft.ts @@ -1,4 +1,6 @@ -export interface PublishSharedDraft { +import { ContentBlueprintDraft } from '../models'; + +export interface PublishSharedDraft extends ContentBlueprintDraft { /** * The ID of the draft page that was created from a blueprint. You can find the `draftId` in the Confluence * application by opening the draft page and checking the page URL. @@ -11,4 +13,5 @@ export interface PublishSharedDraft { status?: string; /** A multi-value parameter indicating which properties of the content to expand. */ expand?: string[]; + bodyStatus?: string; } diff --git a/src/api/parameters/searchByCQL.ts b/src/api/parameters/searchByCQL.ts new file mode 100644 index 00000000..6304988a --- /dev/null +++ b/src/api/parameters/searchByCQL.ts @@ -0,0 +1,34 @@ +export interface SearchByCQL { + /** + * The CQL query to be used for the search. See [Advanced Searching using + * CQL](https://developer.atlassian.com/cloud/confluence/advanced-searching-using-cql/) for instructions on how to + * build a CQL query. + */ + cql: string; + /** + * The space, content, and content status to execute the search against. + * + * - `spaceKey` Key of the space to search against. Optional. + * - `contentId` ID of the content to search against. Optional. Must be in the space specified by `spaceKey`. + * - `contentStatuses` Content statuses to search against. Optional. + * + * Specify these values in an object. For example, `cqlcontext={%22spaceKey%22:%22TEST%22, %22contentId%22:%22123%22}` + */ + cqlcontext?: string; + /** Pointer to a set of search results, returned as part of the `next` or `prev` URL from the previous search call. */ + cursor?: string; + next?: boolean; + prev?: boolean; + /** The maximum number of content objects to return per page. Note, this may be restricted by fixed system limits. */ + limit?: number; + /** The start point of the collection to return */ + start?: number; + /** Whether to include content from archived spaces in the results. */ + includeArchivedSpaces?: boolean; + /** Whether to exclude current spaces and only show archived spaces. */ + excludeCurrentSpaces?: boolean; + /** The excerpt strategy to apply to the result */ + excerpt?: string; + sitePermissionTypeFilter?: string; + expand?: string[]; +} diff --git a/src/api/parameters/searchGroups.ts b/src/api/parameters/searchGroups.ts new file mode 100644 index 00000000..8f69001c --- /dev/null +++ b/src/api/parameters/searchGroups.ts @@ -0,0 +1,8 @@ +export interface SearchGroups { + /** The search term used to query results. */ + query: string; + /** The starting index of the returned groups. */ + start?: number; + /** The maximum number of groups to return per page. Note, this is restricted to a maximum limit of 200 groups. */ + limit?: number; +} diff --git a/src/api/parameters/searchUser.ts b/src/api/parameters/searchUser.ts new file mode 100644 index 00000000..07bbdba5 --- /dev/null +++ b/src/api/parameters/searchUser.ts @@ -0,0 +1,20 @@ +export interface SearchUser { + /** + * The CQL query to be used for the search. See [Advanced Searching using + * CQL](https://developer.atlassian.com/cloud/confluence/advanced-searching-using-cql/) for instructions on how to + * build a CQL query. + * + * Example queries: + * - cql=type=user will return all users + * - cql=user=“1234” will return user with accountId “1234” + * - You can also use IN, NOT IN, != operators + * - cql=user IN (“12”, “34") will return users with accountids “12” and “34” + * - cql=user.fullname~jo will return users with nickname/full name starting with “jo” + * - cql=user.accountid=“123” will return user with accountId “123” + */ + cql: string; + /** The starting index of the returned users. */ + start?: number; + /** The maximum number of user objects to return per page. Note, this may be restricted by fixed system limits. */ + limit?: number; +} diff --git a/src/api/parameters/updateTaskById.ts b/src/api/parameters/updateTaskById.ts new file mode 100644 index 00000000..6b6906e0 --- /dev/null +++ b/src/api/parameters/updateTaskById.ts @@ -0,0 +1,6 @@ +import { TaskStatusUpdate } from '../models'; + +export interface UpdateTaskById extends TaskStatusUpdate { + /** Global ID of the inline task to update */ + inlineTaskId: string; +} diff --git a/src/api/relation.ts b/src/api/relation.ts index b370dfd1..20551352 100644 --- a/src/api/relation.ts +++ b/src/api/relation.ts @@ -56,6 +56,20 @@ export class Relation { return this.client.sendRequest(config, callback, { methodName: 'findTargetFromSource' }); } + /** @deprecated Will be removed in the next major version. Use `getRelationship` instead. */ + async GetRelationship( + parameters: Parameters.GetRelationship, + callback: Callback + ): Promise; + /** @deprecated Will be removed in the next major version. Use `getRelationship` instead. */ + async GetRelationship(parameters: Parameters.GetRelationship, callback?: never): Promise; + async GetRelationship( + parameters: Parameters.GetRelationship, + callback?: Callback, + ): Promise { + return this.getRelationship(parameters, callback!); + } + /** * Find whether a particular type of relationship exists from a source entity to a target entity. Note, relationships * are one way. @@ -67,7 +81,7 @@ export class Relation { * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view both the target entity * and source entity. */ - async GetRelationship( + async getRelationship( parameters: Parameters.GetRelationship, callback: Callback ): Promise; @@ -82,8 +96,8 @@ export class Relation { * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view both the target entity * and source entity. */ - async GetRelationship(parameters: Parameters.GetRelationship, callback?: never): Promise; - async GetRelationship( + async getRelationship(parameters: Parameters.GetRelationship, callback?: never): Promise; + async getRelationship( parameters: Parameters.GetRelationship, callback?: Callback, ): Promise { @@ -99,7 +113,7 @@ export class Relation { }, }; - return this.client.sendRequest(config, callback, { methodName: 'GetRelationship' }); + return this.client.sendRequest(config, callback, { methodName: 'getRelationship' }); } /** @@ -148,6 +162,14 @@ export class Relation { return this.client.sendRequest(config, callback, { methodName: 'createRelationship' }); } + /** @deprecated Will be removed in the next major version. Use `deleteRelationship` instead. */ + async delete(parameters: Parameters.Delete, callback: Callback): Promise; + /** @deprecated Will be removed in the next major version. Use `deleteRelationship` instead. */ + async delete(parameters: Parameters.Delete, callback?: never): Promise; + async delete(parameters: Parameters.Delete, callback?: Callback): Promise { + return this.deleteRelationship(parameters, callback!); + } + /** * Deletes a relationship between two entities (user, space, content). * @@ -155,7 +177,7 @@ export class Relation { * ('Can use' global permission). For favourite relationships, the current user can only delete their own favourite * relationships. A space administrator can delete favourite relationships for any user. */ - async delete(parameters: Parameters.Delete, callback: Callback): Promise; + async deleteRelationship(parameters: Parameters.DeleteRelationship, callback: Callback): Promise; /** * Deletes a relationship between two entities (user, space, content). * @@ -163,8 +185,11 @@ export class Relation { * ('Can use' global permission). For favourite relationships, the current user can only delete their own favourite * relationships. A space administrator can delete favourite relationships for any user. */ - async delete(parameters: Parameters.Delete, callback?: never): Promise; - async delete(parameters: Parameters.Delete, callback?: Callback): Promise { + async deleteRelationship(parameters: Parameters.DeleteRelationship, callback?: never): Promise; + async deleteRelationship( + parameters: Parameters.DeleteRelationship, + callback?: Callback, + ): Promise { const config: RequestConfig = { url: `/api/relation/${parameters.relationName}/from/${parameters.sourceType}/${parameters.sourceKey}/to/${parameters.targetType}/${parameters.targetKey}`, method: 'DELETE', @@ -176,7 +201,7 @@ export class Relation { }, }; - return this.client.sendRequest(config, callback, { methodName: 'delete' }); + return this.client.sendRequest(config, callback, { methodName: 'deleteRelationship' }); } /** diff --git a/src/api/search.ts b/src/api/search.ts index 344bde8f..d2d11caa 100644 --- a/src/api/search.ts +++ b/src/api/search.ts @@ -7,95 +7,52 @@ import { RequestConfig } from '../requestConfig'; export class Search { constructor(private client: Client) {} + /** @deprecated Will be removed in the next major version. Use `searchByCQL` instead. */ + async search( + parameters: Parameters.Search, + callback: Callback + ): Promise; + /** @deprecated Will be removed in the next major version. Use `searchByCQL` instead. */ + async search(parameters: Parameters.Search, callback?: never): Promise; + async search( + parameters: Parameters.Search, + callback?: Callback, + ): Promise { + return this.searchByCQL(parameters, callback!); + } + /** * Searches for content using the [Confluence Query Language * (CQL)](https://developer.atlassian.com/cloud/confluence/advanced-searching-using-cql/) * - * Example initial call: - * - * https://your-domain.atlassian.net/wiki/rest/api/search?cql=type=page&limit=25 - * - * Example response: - * - * { - * "results": [ - * { ... }, - * { ... }, - * ... - * { ... } - * ], - * "limit": 25, - * "size": 25, - * ... - * "_links": { - * "base": "", - * "context": "", - * "next": "/rest/api/search?cql=type=page&limit=25&cursor=raNDoMsTRiNg", - * "self": "" - * } - * } - * * When additional results are available, returns `next` and `prev` URLs to retrieve them in subsequent calls. The * URLs each contain a cursor that points to the appropriate set of results. Use `limit` to specify the number of * results returned in each call. * - * Example subsequent call (taken from example response): - * - * https://your-domain.atlassian.net/wiki/rest/api/search?cql=type=page&limit=25&cursor=raNDoMsTRiNg - * - * The response to this will have a `prev` URL similar to the `next` in the example response. - * * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the entities. Note, only * entities that the user has permission to view will be returned. */ - async search( - parameters: Parameters.Search, + async searchByCQL( + parameters: Parameters.SearchByCQL, callback: Callback ): Promise; /** * Searches for content using the [Confluence Query Language * (CQL)](https://developer.atlassian.com/cloud/confluence/advanced-searching-using-cql/) * - * Example initial call: - * - * https://your-domain.atlassian.net/wiki/rest/api/search?cql=type=page&limit=25 - * - * Example response: - * - * { - * "results": [ - * { ... }, - * { ... }, - * ... - * { ... } - * ], - * "limit": 25, - * "size": 25, - * ... - * "_links": { - * "base": "", - * "context": "", - * "next": "/rest/api/search?cql=type=page&limit=25&cursor=raNDoMsTRiNg", - * "self": "" - * } - * } - * * When additional results are available, returns `next` and `prev` URLs to retrieve them in subsequent calls. The * URLs each contain a cursor that points to the appropriate set of results. Use `limit` to specify the number of * results returned in each call. * - * Example subsequent call (taken from example response): - * - * https://your-domain.atlassian.net/wiki/rest/api/search?cql=type=page&limit=25&cursor=raNDoMsTRiNg - * - * The response to this will have a `prev` URL similar to the `next` in the example response. - * * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the entities. Note, only * entities that the user has permission to view will be returned. */ - async search(parameters: Parameters.Search, callback?: never): Promise; - async search( - parameters: Parameters.Search, + async searchByCQL( + parameters: Parameters.SearchByCQL, + callback?: never + ): Promise; + async searchByCQL( + parameters: Parameters.SearchByCQL, callback?: Callback, ): Promise { const config: RequestConfig = { @@ -105,14 +62,37 @@ export class Search { cql: parameters.cql, cqlcontext: parameters.cqlcontext, cursor: parameters.cursor, + next: parameters.next, + prev: parameters.prev, limit: parameters.limit, + start: parameters.start, includeArchivedSpaces: parameters.includeArchivedSpaces, + excludeCurrentSpaces: parameters.excludeCurrentSpaces, + excerpt: parameters.excerpt, + sitePermissionTypeFilter: parameters.sitePermissionTypeFilter, + expand: parameters.expand, }, }; - return this.client.sendRequest(config, callback, { methodName: 'search' }); + return this.client.sendRequest(config, callback, { methodName: 'searchByCQL' }); } + /** @deprecated Will be removed in the next major version. Use `searchUser` instead. */ + async userSearch( + parameters: Parameters.UserSearch, + callback: Callback + ): Promise; + /** @deprecated Will be removed in the next major version. Use `searchUser` instead. */ + async userSearch( + parameters: Parameters.UserSearch, + callback?: never + ): Promise; + async userSearch( + parameters: Parameters.UserSearch, + callback?: Callback, + ): Promise { + return this.searchUser(parameters, callback!); + } /** * Searches for users using user-specific queries from the [Confluence Query Language * (CQL)](https://developer.atlassian.com/cloud/confluence/advanced-searching-using-cql/). @@ -120,8 +100,8 @@ export class Search { * Note that some user fields may be set to null depending on the user's privacy settings. These are: email, * profilePicture, and displayName. */ - async userSearch( - parameters: Parameters.UserSearch, + async searchUser( + parameters: Parameters.SearchUser, callback: Callback ): Promise; /** @@ -131,12 +111,12 @@ export class Search { * Note that some user fields may be set to null depending on the user's privacy settings. These are: email, * profilePicture, and displayName. */ - async userSearch( - parameters: Parameters.UserSearch, + async searchUser( + parameters: Parameters.SearchUser, callback?: never ): Promise; - async userSearch( - parameters: Parameters.UserSearch, + async searchUser( + parameters: Parameters.SearchUser, callback?: Callback, ): Promise { const config: RequestConfig = { @@ -149,6 +129,6 @@ export class Search { }, }; - return this.client.sendRequest(config, callback, { methodName: 'search' }); + return this.client.sendRequest(config, callback, { methodName: 'searchUser' }); } } diff --git a/src/api/settings.ts b/src/api/settings.ts index 674f7b2d..e4e445a7 100644 --- a/src/api/settings.ts +++ b/src/api/settings.ts @@ -93,7 +93,7 @@ export class Settings { * * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: 'Admin' permission for the space. */ - async updateLookAndFeelSettings( + async updateLookAndFeelSettings( parameters: Parameters.UpdateLookAndFeelSettings | undefined, callback: Callback ): Promise; @@ -106,11 +106,11 @@ export class Settings { * * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: 'Admin' permission for the space. */ - async updateLookAndFeelSettings( + async updateLookAndFeelSettings( parameters?: Parameters.UpdateLookAndFeelSettings, callback?: never ): Promise; - async updateLookAndFeelSettings( + async updateLookAndFeelSettings( parameters?: Parameters.UpdateLookAndFeelSettings, callback?: Callback, ): Promise { @@ -125,8 +125,11 @@ export class Settings { links: parameters?.links, menus: parameters?.menus, header: parameters?.header, + horizontalHeader: parameters?.horizontalHeader, content: parameters?.content, bordersAndDividers: parameters?.bordersAndDividers, + spaceReference: parameters?.spaceReference, + _links: parameters?.links, }, }; diff --git a/src/api/space.ts b/src/api/space.ts index 2170ac5a..f1d5140e 100644 --- a/src/api/space.ts +++ b/src/api/space.ts @@ -106,6 +106,7 @@ export class Space { key: parameters?.key, name: parameters?.name, description: parameters?.description, + permissions: parameters?.permissions, }, }; @@ -159,6 +160,8 @@ export class Space { name: parameters.name, description: parameters.description, homepage: parameters.homepage, + type: parameters.type, + status: parameters.status, }, }; diff --git a/src/api/spacePermissions.ts b/src/api/spacePermissions.ts index dd73d895..fead3d32 100644 --- a/src/api/spacePermissions.ts +++ b/src/api/spacePermissions.ts @@ -7,6 +7,20 @@ import { RequestConfig } from '../requestConfig'; export class SpacePermissions { constructor(private client: Client) {} + /** @deprecated Will be removed in the next major version. Use `addPermissionToSpace` instead. */ + async addPermission( + parameters: Parameters.AddPermission, + callback: Callback + ): Promise; + /** @deprecated Will be removed in the next major version. Use `addPermissionToSpace` instead. */ + async addPermission(parameters: Parameters.AddPermission, callback?: never): Promise; + async addPermission( + parameters: Parameters.AddPermission, + callback?: Callback, + ): Promise { + return this.addPermissionToSpace(parameters, callback!); + } + /** * Adds new permission to space. * @@ -16,8 +30,8 @@ export class SpacePermissions { * * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: 'Admin' permission for the space. */ - async addPermission( - parameters: Parameters.AddPermission, + async addPermissionToSpace( + parameters: Parameters.AddPermissionToSpace, callback: Callback ): Promise; /** @@ -29,23 +43,67 @@ export class SpacePermissions { * * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: 'Admin' permission for the space. */ - async addPermission(parameters: Parameters.AddPermission, callback?: never): Promise; - async addPermission( - parameters: Parameters.AddPermission, + async addPermissionToSpace( + parameters: Parameters.AddPermissionToSpace, + callback?: never + ): Promise; + async addPermissionToSpace( + parameters: Parameters.AddPermissionToSpace, callback?: Callback, ): Promise { const config: RequestConfig = { url: `/api/space/${parameters.spaceKey}/permission`, method: 'POST', data: { - id: parameters.id, subject: parameters.subject, operation: parameters.operation, - _links: parameters._links, + _links: parameters.links, + }, + }; + + return this.client.sendRequest(config, callback, { methodName: 'addPermissionToSpace' }); + } + + /** + * Adds new custom content permission to space. + * + * If the permission to be added is a group permission, the group can be identified by its group name or group id. + * + * Note: Only apps can access this REST resource and only make changes to the respective app permissions. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: 'Admin' permission for the space. + */ + async addCustomContentPermissions( + parameters: Parameters.AddCustomContentPermissions, + callback: Callback + ): Promise; + /** + * Adds new custom content permission to space. + * + * If the permission to be added is a group permission, the group can be identified by its group name or group id. + * + * Note: Only apps can access this REST resource and only make changes to the respective app permissions. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: 'Admin' permission for the space. + */ + async addCustomContentPermissions( + parameters: Parameters.AddCustomContentPermissions, + callback?: never + ): Promise; + async addCustomContentPermissions( + parameters: Parameters.AddCustomContentPermissions, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/api/space/${parameters.spaceKey}/permission/custom-content`, + method: 'POST', + data: { + subject: parameters.subject, + operations: parameters.operations, }, }; - return this.client.sendRequest(config, callback, { methodName: 'addPermission' }); + return this.client.sendRequest(config, callback, { methodName: 'addCustomContentPermissions' }); } /** diff --git a/src/api/spaceProperties.ts b/src/api/spaceProperties.ts index f9cd80fd..2757b267 100644 --- a/src/api/spaceProperties.ts +++ b/src/api/spaceProperties.ts @@ -70,6 +70,7 @@ export class SpaceProperties { data: { key: parameters.key, value: parameters.value, + space: parameters.space, }, }; @@ -110,8 +111,8 @@ export class SpaceProperties { } /** - * 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. + * 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. * * **[Permissions required](https://confluence.atlassian.com/x/_AozKw)**: ‘Admin’ permission for the space. */ @@ -120,8 +121,8 @@ export class SpaceProperties { callback: Callback ): Promise; /** - * 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. + * 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. * * **[Permissions required](https://confluence.atlassian.com/x/_AozKw)**: ‘Admin’ permission for the space. */ diff --git a/src/clients/baseClient.ts b/src/clients/baseClient.ts index b07c9bc1..65b33dfb 100644 --- a/src/clients/baseClient.ts +++ b/src/clients/baseClient.ts @@ -101,8 +101,8 @@ export class BaseClient implements Client { bodyExists: !!requestConfig.data, callbackUsed: !!callback, headersExists: !!requestConfig.headers, - libVersion: '1.1.3', - libVersionHash: '6d8c23a768aec9eefc52917e68aa3926', + libVersion: '1.2.0', + libVersionHash: '0ba4439ee9a46d9d9f14c60f88f45f87', methodName: telemetryData?.methodName || 'sendRequest', onErrorMiddlewareUsed: !!this.config.middlewares?.onError, onResponseMiddlewareUsed: !!this.config.middlewares?.onResponse, diff --git a/src/clients/confluenceClient.ts b/src/clients/confluenceClient.ts index 673d34a4..60916d8f 100644 --- a/src/clients/confluenceClient.ts +++ b/src/clients/confluenceClient.ts @@ -14,6 +14,7 @@ import { ContentVersions, ContentWatches, DynamicModules, + Experimental, Group, InlineTasks, LabelInfo, @@ -45,6 +46,7 @@ export class ConfluenceClient extends BaseClient { contentVersions = new ContentVersions(this); contentWatches = new ContentWatches(this); dynamicModules = new DynamicModules(this); + experimental = new Experimental(this); group = new Group(this); inlineTasks = new InlineTasks(this); labelInfo = new LabelInfo(this); From ffde26ed3202aba4e2f41f02c7040f9420b45669 Mon Sep 17 00:00:00 2001 From: Vladislav Tupikin Date: Tue, 28 Sep 2021 00:43:37 +0300 Subject: [PATCH 2/2] changelog fixed --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c63d3e7b..860934bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,7 +29,6 @@ - `addPermission` renamed to `addPermissionToSpace` in `SpacePermissions`. - `addCustomContentPermissions` method added to `SpacePermissions`. - `space` property added to `createSpaceProperty` in `SpaceProperties`. - - ### 1.1.3