diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 60e5cbd5..3e7ef50a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -23,7 +23,7 @@ jobs: echo API_TOKEN=${{ secrets.API_TOKEN }} >> .env - run: npm run build - run: npm run test:unit - - run: npm run test:e2e + - run: npm run test:integration - run: npm run lint env: CI: true diff --git a/package-lock.json b/package-lock.json index 72f81d33..28b9e75a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,35 +13,44 @@ "axios": "^1.4.0", "form-data": "^4.0.0", "oauth": "^0.10.0", - "tslib": "^2.5.3" + "tslib": "^2.6.0" }, "devDependencies": { - "@swc-node/register": "^1.6.5", + "@swc-node/register": "^1.6.6", "@swc/helpers": "^0.5.1", "@types/express": "^4.17.17", "@types/oauth": "^0.9.1", "@types/sinon": "^10.0.15", - "@typescript-eslint/eslint-plugin": "^5.59.9", - "@typescript-eslint/parser": "^5.59.9", - "ava": "^5.3.0", - "dotenv": "^16.1.4", - "eslint": "^8.42.0", + "@typescript-eslint/eslint-plugin": "^5.60.1", + "@typescript-eslint/parser": "^5.60.1", + "ava": "^5.3.1", + "dotenv": "^16.3.1", + "eslint": "^8.44.0", "eslint-config-airbnb": "^19.0.4", "eslint-config-airbnb-typescript": "^17.0.0", "eslint-import-resolver-typescript": "^3.5.5", "eslint-plugin-import": "^2.27.5", "prettier": "^2.8.8", "prettier-plugin-jsdoc": "^0.4.2", - "sinon": "^15.1.0", + "sinon": "^15.2.0", "typedoc": "^0.24.8", "typedoc-plugin-extras": "^2.3.3", - "typescript": "^5.1.3" + "typescript": "^5.1.6" + } + }, + "node_modules/@aashutoshrathi/word-wrap": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz", + "integrity": "sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA==", + "dev": true, + "engines": { + "node": ">=0.10.0" } }, "node_modules/@babel/runtime": { - "version": "7.22.3", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.22.3.tgz", - "integrity": "sha512-XsDuspWKLUsxwCp6r7EhsExHtYfbe5oAGQ19kqngTdCPUoPQzOPdUbD/pB9PJiwb2ptYKQDjSJT3R6dC+EPqfQ==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.22.5.tgz", + "integrity": "sha512-ecjvYlnAaZ/KVneE/OdKYBYfgXV3Ptu6zQWmgEF7vwKhQnvVS6bjMD2XYgj+SNvQ1GfK/pjgokfPkC/2CO8CuA==", "dev": true, "peer": true, "dependencies": { @@ -76,14 +85,14 @@ } }, "node_modules/@eslint/eslintrc": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.0.3.tgz", - "integrity": "sha512-+5gy6OQfk+xx3q0d6jGZZC3f3KzAkXc/IanVxd1is/VIIziRqqt3ongQz0FiTUXqTk0c7aDB3OaFuKnuSoJicQ==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.0.tgz", + "integrity": "sha512-Lj7DECXqIVCqnqjjHMPna4vn6GJcMgul/wuS0je9OZ9gsL0zzDpKPVtcG1HaDVc+9y+qgXneTeUMbCqXJNpH1A==", "dev": true, "dependencies": { "ajv": "^6.12.4", "debug": "^4.3.2", - "espree": "^9.5.2", + "espree": "^9.6.0", "globals": "^13.19.0", "ignore": "^5.2.0", "import-fresh": "^3.2.1", @@ -99,9 +108,9 @@ } }, "node_modules/@eslint/js": { - "version": "8.42.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.42.0.tgz", - "integrity": "sha512-6SWlXpWU5AvId8Ac7zjzmIOqMOba/JWY8XZ4A7q7Gn1Vlfg/SFFIlrtHXt9nPn4op9ZPAkl91Jao+QQv3r/ukw==", + "version": "8.44.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.44.0.tgz", + "integrity": "sha512-Ag+9YM4ocKQx9AarydN0KY2j0ErMHNIocPDrVo8zAE44xLTjEtz81OdR68/cydGtk6m6jDb5Za3r2useMzYmSw==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -205,9 +214,9 @@ } }, "node_modules/@sinonjs/fake-timers": { - "version": "10.2.0", - "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-10.2.0.tgz", - "integrity": "sha512-OPwQlEdg40HAj5KNF8WW6q2KG4Z+cBCZb3m4ninfTZKaBmbIJodviQsDBoYMPHkOyJJMHnOJo5j2+LKDOhOACg==", + "version": "10.3.0", + "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-10.3.0.tgz", + "integrity": "sha512-V4BG07kuYSUkTCSBHG8G8TNhM+F19jXFWnQtzj+we8DrkpSBCee9Z3Ms8yiGer/dlmhe35/Xdgyo3/0rQKg7YA==", "dev": true, "dependencies": { "@sinonjs/commons": "^3.0.0" @@ -240,9 +249,9 @@ "dev": true }, "node_modules/@swc-node/core": { - "version": "1.10.3", - "resolved": "https://registry.npmjs.org/@swc-node/core/-/core-1.10.3.tgz", - "integrity": "sha512-8rpv1DXzsQjN/C8ZXuaTSmJ4M/lRr6geUlbOQ861DLC+sKWcEEvxRjK9cXQ28GserHuEcFDA3wlF9rD1YD0x+Q==", + "version": "1.10.4", + "resolved": "https://registry.npmjs.org/@swc-node/core/-/core-1.10.4.tgz", + "integrity": "sha512-ixZCb4LsSUPflnOxj4a8T5yTPzKbgvP+tF0N59Rk2+68ikFRt9Qci2qy9xfuDIQbuiONzXersrNpd+p598uH0A==", "dev": true, "engines": { "node": ">= 10" @@ -256,12 +265,12 @@ } }, "node_modules/@swc-node/register": { - "version": "1.6.5", - "resolved": "https://registry.npmjs.org/@swc-node/register/-/register-1.6.5.tgz", - "integrity": "sha512-yMxXlzthI0aMadYYKDhx7xvtjljB1qoD8Tv0djqSJ1ttTkoDxg6MhG5A5pIahiUT2neVrkWb9lCavoUwXAe/zQ==", + "version": "1.6.6", + "resolved": "https://registry.npmjs.org/@swc-node/register/-/register-1.6.6.tgz", + "integrity": "sha512-KgnQrWLgtJzEgPpxvhOPUDonv1xreVumGdzXDQlDVIqU3vH+spW8ZYxxyjJVMh3G/mQG8E3bFvUMHIS+E3FL2w==", "dev": true, "dependencies": { - "@swc-node/core": "^1.10.3", + "@swc-node/core": "^1.10.4", "@swc-node/sourcemap-support": "^0.3.0", "colorette": "^2.0.19", "debug": "^4.3.4", @@ -288,9 +297,9 @@ } }, "node_modules/@swc/core": { - "version": "1.3.62", - "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.3.62.tgz", - "integrity": "sha512-J58hWY+/G8vOr4J6ZH9hLg0lMSijZtqIIf4HofZezGog/pVX6sJyBJ40dZ1ploFkDIlWTWvJyqtpesBKS73gkQ==", + "version": "1.3.67", + "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.3.67.tgz", + "integrity": "sha512-9DROjzfAEt0xt0CDkOYsWpkUPyne8fl5ggWGon049678BOM7p0R0dmaalZGAsKatG5vYP1IWSKWsKhJIubDCsQ==", "dev": true, "hasInstallScript": true, "peer": true, @@ -302,16 +311,16 @@ "url": "https://opencollective.com/swc" }, "optionalDependencies": { - "@swc/core-darwin-arm64": "1.3.62", - "@swc/core-darwin-x64": "1.3.62", - "@swc/core-linux-arm-gnueabihf": "1.3.62", - "@swc/core-linux-arm64-gnu": "1.3.62", - "@swc/core-linux-arm64-musl": "1.3.62", - "@swc/core-linux-x64-gnu": "1.3.62", - "@swc/core-linux-x64-musl": "1.3.62", - "@swc/core-win32-arm64-msvc": "1.3.62", - "@swc/core-win32-ia32-msvc": "1.3.62", - "@swc/core-win32-x64-msvc": "1.3.62" + "@swc/core-darwin-arm64": "1.3.67", + "@swc/core-darwin-x64": "1.3.67", + "@swc/core-linux-arm-gnueabihf": "1.3.67", + "@swc/core-linux-arm64-gnu": "1.3.67", + "@swc/core-linux-arm64-musl": "1.3.67", + "@swc/core-linux-x64-gnu": "1.3.67", + "@swc/core-linux-x64-musl": "1.3.67", + "@swc/core-win32-arm64-msvc": "1.3.67", + "@swc/core-win32-ia32-msvc": "1.3.67", + "@swc/core-win32-x64-msvc": "1.3.67" }, "peerDependencies": { "@swc/helpers": "^0.5.0" @@ -323,9 +332,9 @@ } }, "node_modules/@swc/core-darwin-arm64": { - "version": "1.3.62", - "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.3.62.tgz", - "integrity": "sha512-MmGilibITz68LEje6vJlKzc2gUUSgzvB3wGLSjEORikTNeM7P8jXVxE4A8fgZqDeudJUm9HVWrxCV+pHDSwXhA==", + "version": "1.3.67", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.3.67.tgz", + "integrity": "sha512-zCT2mCkOBVNf5uJDcQ3A9KDoO1OEaGdfjsRTZTo7sejDd9AXLfJg+xgyCBBrK2jNS/uWcT21IvSv3LqKp4K8pA==", "cpu": [ "arm64" ], @@ -340,9 +349,9 @@ } }, "node_modules/@swc/core-darwin-x64": { - "version": "1.3.62", - "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.3.62.tgz", - "integrity": "sha512-Xl93MMB3sCWVlYWuQIB+v6EQgzoiuQYK5tNt9lsHoIEVu2zLdkQjae+5FUHZb1VYqCXIiWcULFfVz0R4Sjb7JQ==", + "version": "1.3.67", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.3.67.tgz", + "integrity": "sha512-hXTVsfTatPEec5gFVyjGj3NccKZsYj/OXyHn6XA+l3Q76lZzGm2ISHdku//XNwXu8OmJ0HhS7LPsC4XXwxXQhg==", "cpu": [ "x64" ], @@ -357,9 +366,9 @@ } }, "node_modules/@swc/core-linux-arm-gnueabihf": { - "version": "1.3.62", - "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.3.62.tgz", - "integrity": "sha512-nJsp6O7kCtAjTTMcIjVB0g5y1JNiYAa5q630eiwrnaHUusEFoANDdORI3Z9vXeikMkng+6yIv9/V8Rb093xLjQ==", + "version": "1.3.67", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.3.67.tgz", + "integrity": "sha512-l8AKL0RkDL5FRTeWMmjoz9zvAc37amxC+0rheaNwE+gZya7ObyNjnIYz5FwN+3y+z6JFU7LS2x/5f6iwruv6pg==", "cpu": [ "arm" ], @@ -374,9 +383,9 @@ } }, "node_modules/@swc/core-linux-arm64-gnu": { - "version": "1.3.62", - "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.3.62.tgz", - "integrity": "sha512-XGsV93vpUAopDt5y6vPwbK1Nc/MlL55L77bAZUPIiosWD1cWWPHNtNSpriE6+I+JiMHe0pqtfS/SSTk6ZkFQVw==", + "version": "1.3.67", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.3.67.tgz", + "integrity": "sha512-S8zOB1AXEpb7kmtgMaFNeLAj01VOky4B0RNZ+uJWigdrDiFT67FeZzNHUNmNSOU0QM79G+Lie/xD/beqEw0vDg==", "cpu": [ "arm64" ], @@ -391,9 +400,9 @@ } }, "node_modules/@swc/core-linux-arm64-musl": { - "version": "1.3.62", - "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.3.62.tgz", - "integrity": "sha512-ESUmJjSlTTkoBy9dMG49opcNn8BmviqStMhwyeD1G8XRnmRVCZZgoBOKdvCXmJhw8bQXDhZumeaTUB+OFUKVXg==", + "version": "1.3.67", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.3.67.tgz", + "integrity": "sha512-Fex8J8ASrt13pmOr2xWh41tEeKWwXYGk3sV8L/aGHiYtIJEUi2f+RtMx3jp7LIdOD8pQptor7i5WBlfR9jhp8A==", "cpu": [ "arm64" ], @@ -408,9 +417,9 @@ } }, "node_modules/@swc/core-linux-x64-gnu": { - "version": "1.3.62", - "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.3.62.tgz", - "integrity": "sha512-wnHJkt3ZBrax3SFnUHDcncG6mrSg9ZZjMhQV9Mc3JL1x1s1Gy9rGZCoBNnV/BUZWTemxIBcQbANRSDut/WO+9A==", + "version": "1.3.67", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.3.67.tgz", + "integrity": "sha512-9bz9/bMphrv5vDg0os/d8ve0QgFpDzJgZgHUaHiGwcmfnlgdOSAaYJLIvWdcGTjZuQeV4L0m+iru357D9TXEzA==", "cpu": [ "x64" ], @@ -425,9 +434,9 @@ } }, "node_modules/@swc/core-linux-x64-musl": { - "version": "1.3.62", - "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.3.62.tgz", - "integrity": "sha512-9oRbuTC/VshB66Rgwi3pTq3sPxSTIb8k9L1vJjES+dDMKa29DAjPtWCXG/pyZ00ufpFZgkGEuAHH5uqUcr1JQg==", + "version": "1.3.67", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.3.67.tgz", + "integrity": "sha512-ED0H6oLvQmhgo9zs8usmEA/lcZPGTu7K9og9K871b7HhHX0h/R+Xg2pb5KD7S/GyUHpfuopxjVROm+h6X1jMUA==", "cpu": [ "x64" ], @@ -442,9 +451,9 @@ } }, "node_modules/@swc/core-win32-arm64-msvc": { - "version": "1.3.62", - "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.3.62.tgz", - "integrity": "sha512-zv14vlF2VRrxS061XkfzGjCYnOrEo5glKJjLK5PwUKysIoVrx/L8nAbFxjkX5cObdlyoqo+ekelyBPAO+4bS0w==", + "version": "1.3.67", + "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.3.67.tgz", + "integrity": "sha512-J1yFDLgPFeRtA8t5E159OXX+ww1gbkFg70yr4OP7EsOkOD1uMkuTf9yK/woHfsaVJlUYjJHzw7MkUIEgQBucqQ==", "cpu": [ "arm64" ], @@ -459,9 +468,9 @@ } }, "node_modules/@swc/core-win32-ia32-msvc": { - "version": "1.3.62", - "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.3.62.tgz", - "integrity": "sha512-8MC/PZQSsOP2iA/81tAfNRqMWyEqTS/8zKUI67vPuLvpx6NAjRn3E9qBv7iFqH79iqZNzqSMo3awnLrKZyFbcw==", + "version": "1.3.67", + "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.3.67.tgz", + "integrity": "sha512-bK11/KtasewqHxzkjKUBXRE9MSAidbZCxrgJUd49bItG2N/DHxkwMYu8Xkh5VDHdTYWv/2idYtf/VM9Yi+53qw==", "cpu": [ "ia32" ], @@ -476,9 +485,9 @@ } }, "node_modules/@swc/core-win32-x64-msvc": { - "version": "1.3.62", - "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.3.62.tgz", - "integrity": "sha512-GJSmUJ95HKHZXAxiuPUmrcm/S3ivQvEzXhOZaIqYBIwUsm02vFZkClsV7eIKzWjso1t0+I/8MjrnUNaSWqh1rQ==", + "version": "1.3.67", + "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.3.67.tgz", + "integrity": "sha512-GxzUU3+NA3cPcYxCxtfSQIS2ySD7Z8IZmKTVaWA9GOUQbKLyCE8H5js31u39+0op/1gNgxOgYFDoj2lUyvLCqw==", "cpu": [ "x64" ], @@ -553,6 +562,12 @@ "@types/send": "*" } }, + "node_modules/@types/http-errors": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@types/http-errors/-/http-errors-2.0.1.tgz", + "integrity": "sha512-/K3ds8TRAfBvi5vfjuz8y6+GiAYBZ0x4tXv1Av6CWBWn0IlADc+ZX9pMq7oU0fNQPnBwIZl3rmeLp6SBApbxSQ==", + "dev": true + }, "node_modules/@types/json-schema": { "version": "7.0.12", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.12.tgz", @@ -587,9 +602,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "20.2.5", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.2.5.tgz", - "integrity": "sha512-JJulVEQXmiY9Px5axXHeYGLSjhkZEnD+MDPDGbCbIAbMslkKwmygtZFy1X6s/075Yo94sf8GuSlFfPzysQrWZQ==", + "version": "20.3.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.3.3.tgz", + "integrity": "sha512-wheIYdr4NYML61AjC8MKj/2jrR/kDQri/CIpVoZwldwhnIrD/j9jIU5bJ8yBKuB2VhpFV7Ab6G2XkBjv9r9Zzw==", "dev": true }, "node_modules/@types/oauth": { @@ -630,11 +645,12 @@ } }, "node_modules/@types/serve-static": { - "version": "1.15.1", - "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.1.tgz", - "integrity": "sha512-NUo5XNiAdULrJENtJXZZ3fHtfMolzZwczzBbnAeBbqBwG+LaG6YaJtuwzwGSQZ2wsCrxjEhNNjAkKigy3n8teQ==", + "version": "1.15.2", + "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.2.tgz", + "integrity": "sha512-J2LqtvFYCzaj8pVYKw8klQXrLLk7TBZmQ4ShlcdkELFKGwGMfevMLneMMRkMgZxotOD9wg497LpC7O8PcvAmfw==", "dev": true, "dependencies": { + "@types/http-errors": "*", "@types/mime": "*", "@types/node": "*" } @@ -661,15 +677,15 @@ "dev": true }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "5.59.9", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.59.9.tgz", - "integrity": "sha512-4uQIBq1ffXd2YvF7MAvehWKW3zVv/w+mSfRAu+8cKbfj3nwzyqJLNcZJpQ/WZ1HLbJDiowwmQ6NO+63nCA+fqA==", + "version": "5.60.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.60.1.tgz", + "integrity": "sha512-KSWsVvsJsLJv3c4e73y/Bzt7OpqMCADUO846bHcuWYSYM19bldbAeDv7dYyV0jwkbMfJ2XdlzwjhXtuD7OY6bw==", "dev": true, "dependencies": { "@eslint-community/regexpp": "^4.4.0", - "@typescript-eslint/scope-manager": "5.59.9", - "@typescript-eslint/type-utils": "5.59.9", - "@typescript-eslint/utils": "5.59.9", + "@typescript-eslint/scope-manager": "5.60.1", + "@typescript-eslint/type-utils": "5.60.1", + "@typescript-eslint/utils": "5.60.1", "debug": "^4.3.4", "grapheme-splitter": "^1.0.4", "ignore": "^5.2.0", @@ -695,14 +711,14 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "5.59.9", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.59.9.tgz", - "integrity": "sha512-FsPkRvBtcLQ/eVK1ivDiNYBjn3TGJdXy2fhXX+rc7czWl4ARwnpArwbihSOHI2Peg9WbtGHrbThfBUkZZGTtvQ==", + "version": "5.60.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.60.1.tgz", + "integrity": "sha512-pHWlc3alg2oSMGwsU/Is8hbm3XFbcrb6P5wIxcQW9NsYBfnrubl/GhVVD/Jm/t8HXhA2WncoIRfBtnCgRGV96Q==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "5.59.9", - "@typescript-eslint/types": "5.59.9", - "@typescript-eslint/typescript-estree": "5.59.9", + "@typescript-eslint/scope-manager": "5.60.1", + "@typescript-eslint/types": "5.60.1", + "@typescript-eslint/typescript-estree": "5.60.1", "debug": "^4.3.4" }, "engines": { @@ -722,13 +738,13 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "5.59.9", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.59.9.tgz", - "integrity": "sha512-8RA+E+w78z1+2dzvK/tGZ2cpGigBZ58VMEHDZtpE1v+LLjzrYGc8mMaTONSxKyEkz3IuXFM0IqYiGHlCsmlZxQ==", + "version": "5.60.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.60.1.tgz", + "integrity": "sha512-Dn/LnN7fEoRD+KspEOV0xDMynEmR3iSHdgNsarlXNLGGtcUok8L4N71dxUgt3YvlO8si7E+BJ5Fe3wb5yUw7DQ==", "dev": true, "dependencies": { - "@typescript-eslint/types": "5.59.9", - "@typescript-eslint/visitor-keys": "5.59.9" + "@typescript-eslint/types": "5.60.1", + "@typescript-eslint/visitor-keys": "5.60.1" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -739,13 +755,13 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "5.59.9", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.59.9.tgz", - "integrity": "sha512-ksEsT0/mEHg9e3qZu98AlSrONAQtrSTljL3ow9CGej8eRo7pe+yaC/mvTjptp23Xo/xIf2mLZKC6KPv4Sji26Q==", + "version": "5.60.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.60.1.tgz", + "integrity": "sha512-vN6UztYqIu05nu7JqwQGzQKUJctzs3/Hg7E2Yx8rz9J+4LgtIDFWjjl1gm3pycH0P3mHAcEUBd23LVgfrsTR8A==", "dev": true, "dependencies": { - "@typescript-eslint/typescript-estree": "5.59.9", - "@typescript-eslint/utils": "5.59.9", + "@typescript-eslint/typescript-estree": "5.60.1", + "@typescript-eslint/utils": "5.60.1", "debug": "^4.3.4", "tsutils": "^3.21.0" }, @@ -766,9 +782,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "5.59.9", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.59.9.tgz", - "integrity": "sha512-uW8H5NRgTVneSVTfiCVffBb8AbwWSKg7qcA4Ot3JI3MPCJGsB4Db4BhvAODIIYE5mNj7Q+VJkK7JxmRhk2Lyjw==", + "version": "5.60.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.60.1.tgz", + "integrity": "sha512-zDcDx5fccU8BA0IDZc71bAtYIcG9PowaOwaD8rjYbqwK7dpe/UMQl3inJ4UtUK42nOCT41jTSCwg76E62JpMcg==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -779,13 +795,13 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "5.59.9", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.59.9.tgz", - "integrity": "sha512-pmM0/VQ7kUhd1QyIxgS+aRvMgw+ZljB3eDb+jYyp6d2bC0mQWLzUDF+DLwCTkQ3tlNyVsvZRXjFyV0LkU/aXjA==", + "version": "5.60.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.60.1.tgz", + "integrity": "sha512-hkX70J9+2M2ZT6fhti5Q2FoU9zb+GeZK2SLP1WZlvUDqdMbEKhexZODD1WodNRyO8eS+4nScvT0dts8IdaBzfw==", "dev": true, "dependencies": { - "@typescript-eslint/types": "5.59.9", - "@typescript-eslint/visitor-keys": "5.59.9", + "@typescript-eslint/types": "5.60.1", + "@typescript-eslint/visitor-keys": "5.60.1", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -806,17 +822,17 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "5.59.9", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.59.9.tgz", - "integrity": "sha512-1PuMYsju/38I5Ggblaeb98TOoUvjhRvLpLa1DoTOFaLWqaXl/1iQ1eGurTXgBY58NUdtfTXKP5xBq7q9NDaLKg==", + "version": "5.60.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.60.1.tgz", + "integrity": "sha512-tiJ7FFdFQOWssFa3gqb94Ilexyw0JVxj6vBzaSpfN/8IhoKkDuSAenUKvsSHw2A/TMpJb26izIszTXaqygkvpQ==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@types/json-schema": "^7.0.9", "@types/semver": "^7.3.12", - "@typescript-eslint/scope-manager": "5.59.9", - "@typescript-eslint/types": "5.59.9", - "@typescript-eslint/typescript-estree": "5.59.9", + "@typescript-eslint/scope-manager": "5.60.1", + "@typescript-eslint/types": "5.60.1", + "@typescript-eslint/typescript-estree": "5.60.1", "eslint-scope": "^5.1.1", "semver": "^7.3.7" }, @@ -832,12 +848,12 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "5.59.9", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.59.9.tgz", - "integrity": "sha512-bT7s0td97KMaLwpEBckbzj/YohnvXtqbe2XgqNvTl6RJVakY5mvENOTPvw5u66nljfZxthESpDozs86U+oLY8Q==", + "version": "5.60.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.60.1.tgz", + "integrity": "sha512-xEYIxKcultP6E/RMKqube11pGjXH1DCo60mQoWhVYyKfLkwbIVVjYxmOenNMxILx0TjCujPTjjnTIVzm09TXIw==", "dev": true, "dependencies": { - "@typescript-eslint/types": "5.59.9", + "@typescript-eslint/types": "5.60.1", "eslint-visitor-keys": "^3.3.0" }, "engines": { @@ -849,9 +865,9 @@ } }, "node_modules/acorn": { - "version": "8.8.2", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz", - "integrity": "sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==", + "version": "8.9.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.9.0.tgz", + "integrity": "sha512-jaVNAFBHNLXspO543WnNNPZFRtavh3skAkITqD0/2aeMkKZTN+254PyhwxFYrk3vQ1xfY+2wbesJMs/JC8/PwQ==", "dev": true, "bin": { "acorn": "bin/acorn" @@ -960,13 +976,13 @@ "dev": true }, "node_modules/aria-query": { - "version": "5.1.3", - "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.1.3.tgz", - "integrity": "sha512-R5iJ5lkuHybztUfuOAznmboyjWq8O6sqNqtK7CLOqdydi54VNbORp49mb14KbWgG1QD3JFO9hJdZ+y4KutfdOQ==", + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.0.tgz", + "integrity": "sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A==", "dev": true, "peer": true, "dependencies": { - "deep-equal": "^2.0.5" + "dequal": "^2.0.3" } }, "node_modules/array-buffer-byte-length": { @@ -1115,9 +1131,9 @@ } }, "node_modules/ava": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/ava/-/ava-5.3.0.tgz", - "integrity": "sha512-QYvBdyygl1LGX13IuYsC4bkwVCzZeovMGbxYkD73i7DVJxNlWnFa06YgrBOTbjw2QvSKUl5fOJ92Kj5WK9hSeg==", + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/ava/-/ava-5.3.1.tgz", + "integrity": "sha512-Scv9a4gMOXB6+ni4toLuhAm9KYWEjsgBglJl+kMGI5+IVDt120CCDZyB5HNU9DjmLI2t4I0GbnxGLmmRfGTJGg==", "dev": true, "dependencies": { "acorn": "^8.8.2", @@ -1180,9 +1196,9 @@ } }, "node_modules/ava/node_modules/globby": { - "version": "13.1.4", - "resolved": "https://registry.npmjs.org/globby/-/globby-13.1.4.tgz", - "integrity": "sha512-iui/IiiW+QrJ1X1hKH5qwlMQyv34wJAYwH1vrf8b9kBA4sNiif3gKsMHa+BrdnOpEudWjpotfa7LrTzB1ERS/g==", + "version": "13.2.1", + "resolved": "https://registry.npmjs.org/globby/-/globby-13.2.1.tgz", + "integrity": "sha512-DPCBxctI7dN4EeIqjW2KGqgdcUMbrhJ9AzON+PlxCtvppWhubTLD4+a0GFxiym14ZvacUydTPjLPc2DlKz7EIg==", "dev": true, "dependencies": { "dir-glob": "^3.0.1", @@ -1243,13 +1259,13 @@ } }, "node_modules/axobject-query": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-3.1.1.tgz", - "integrity": "sha512-goKlv8DZrK9hUh975fnHzhNIO4jUnFCfv/dszV5VwUGDFjI6vQ2VwoyjYjYNEbBE8AH87TduWP5uyDR1D+Iteg==", + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-3.2.1.tgz", + "integrity": "sha512-jsyHu61e6N4Vbz/v18DHwWYKK0bSWLqn47eeDSKPB7m8tqMHF9YJ+mhIk2lVteyZrY8tnSj/jHOv4YiTCuCJgg==", "dev": true, "peer": true, "dependencies": { - "deep-equal": "^2.0.5" + "dequal": "^2.0.3" } }, "node_modules/balanced-match": { @@ -1381,9 +1397,9 @@ } }, "node_modules/chalk": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.2.0.tgz", - "integrity": "sha512-ree3Gqw/nazQAPuJJEy+avdl7QfZMcUvmHIKgEZkGL+xOBzRvup5Hxo6LHuMceSxOabuJLJm5Yp/92R9eMmMvA==", + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.3.0.tgz", + "integrity": "sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==", "dev": true, "engines": { "node": "^12.17.0 || ^14.13 || >=16.0.0" @@ -1755,36 +1771,6 @@ "url": "https://github.com/sponsors/wooorm" } }, - "node_modules/deep-equal": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-2.2.1.tgz", - "integrity": "sha512-lKdkdV6EOGoVn65XaOsPdH4rMxTZOnmFyuIkMjM1i5HHCbfjC97dawgTAy0deYNfuqUqW+Q5VrVaQYtUpSd6yQ==", - "dev": true, - "peer": true, - "dependencies": { - "array-buffer-byte-length": "^1.0.0", - "call-bind": "^1.0.2", - "es-get-iterator": "^1.1.3", - "get-intrinsic": "^1.2.0", - "is-arguments": "^1.1.1", - "is-array-buffer": "^3.0.2", - "is-date-object": "^1.0.5", - "is-regex": "^1.1.4", - "is-shared-array-buffer": "^1.0.2", - "isarray": "^2.0.5", - "object-is": "^1.1.5", - "object-keys": "^1.1.1", - "object.assign": "^4.1.4", - "regexp.prototype.flags": "^1.5.0", - "side-channel": "^1.0.4", - "which-boxed-primitive": "^1.0.2", - "which-collection": "^1.0.1", - "which-typed-array": "^1.1.9" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/deep-is": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", @@ -1904,9 +1890,9 @@ } }, "node_modules/dotenv": { - "version": "16.1.4", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.1.4.tgz", - "integrity": "sha512-m55RtE8AsPeJBpOIFKihEmqUcoVncQIwo7x9U8ZwLEZw9ZpXboz2c+rvog+jUaJvVrZ5kBOeYQBX5+8Aa/OZQw==", + "version": "16.3.1", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz", + "integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==", "dev": true, "engines": { "node": ">=12" @@ -1940,9 +1926,9 @@ "dev": true }, "node_modules/enhanced-resolve": { - "version": "5.14.1", - "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.14.1.tgz", - "integrity": "sha512-Vklwq2vDKtl0y/vtwjSesgJ5MYS7Etuk5txS8VdKL4AOS1aUlD96zqIfsOSLQsdv3xgMRbtkWM8eG9XDfKUPow==", + "version": "5.15.0", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.15.0.tgz", + "integrity": "sha512-LXYT42KJ7lpIKECr2mAXIaMldcNCh/7E0KBKOu4KSfkHmP+mZmSs+8V5gBAqisWBy0OO4W5Oyys0GO1Y8KtdKg==", "dev": true, "dependencies": { "graceful-fs": "^4.2.4", @@ -2000,27 +1986,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/es-get-iterator": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/es-get-iterator/-/es-get-iterator-1.1.3.tgz", - "integrity": "sha512-sPZmqHBe6JIiTfN5q2pEi//TwxmAFHwj/XEuYjTuse78i8KxaqMTTzxPoFKuzRpDpTJ+0NAbpfenkmH2rePtuw==", - "dev": true, - "peer": true, - "dependencies": { - "call-bind": "^1.0.2", - "get-intrinsic": "^1.1.3", - "has-symbols": "^1.0.3", - "is-arguments": "^1.1.1", - "is-map": "^2.0.2", - "is-set": "^2.0.2", - "is-string": "^1.0.7", - "isarray": "^2.0.5", - "stop-iteration-iterator": "^1.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/es-set-tostringtag": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.0.1.tgz", @@ -2083,15 +2048,15 @@ } }, "node_modules/eslint": { - "version": "8.42.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.42.0.tgz", - "integrity": "sha512-ulg9Ms6E1WPf67PHaEY4/6E2tEn5/f7FXGzr3t9cBMugOmf1INYvuUwwh1aXQN4MfJ6a5K2iNwP3w4AColvI9A==", + "version": "8.44.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.44.0.tgz", + "integrity": "sha512-0wpHoUbDUHgNCyvFB5aXLiQVfK9B0at6gUvzy83k4kAsQ/u769TQDX6iKC+aO4upIHO9WSaA3QoXYQDHbNwf1A==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.4.0", - "@eslint/eslintrc": "^2.0.3", - "@eslint/js": "8.42.0", + "@eslint/eslintrc": "^2.1.0", + "@eslint/js": "8.44.0", "@humanwhocodes/config-array": "^0.11.10", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", @@ -2103,7 +2068,7 @@ "escape-string-regexp": "^4.0.0", "eslint-scope": "^7.2.0", "eslint-visitor-keys": "^3.4.1", - "espree": "^9.5.2", + "espree": "^9.6.0", "esquery": "^1.4.2", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", @@ -2123,7 +2088,7 @@ "lodash.merge": "^4.6.2", "minimatch": "^3.1.2", "natural-compare": "^1.4.0", - "optionator": "^0.9.1", + "optionator": "^0.9.3", "strip-ansi": "^6.0.1", "strip-json-comments": "^3.1.0", "text-table": "^0.2.0" @@ -2249,9 +2214,9 @@ } }, "node_modules/eslint-import-resolver-typescript/node_modules/globby": { - "version": "13.1.4", - "resolved": "https://registry.npmjs.org/globby/-/globby-13.1.4.tgz", - "integrity": "sha512-iui/IiiW+QrJ1X1hKH5qwlMQyv34wJAYwH1vrf8b9kBA4sNiif3gKsMHa+BrdnOpEudWjpotfa7LrTzB1ERS/g==", + "version": "13.2.1", + "resolved": "https://registry.npmjs.org/globby/-/globby-13.2.1.tgz", + "integrity": "sha512-DPCBxctI7dN4EeIqjW2KGqgdcUMbrhJ9AzON+PlxCtvppWhubTLD4+a0GFxiym14ZvacUydTPjLPc2DlKz7EIg==", "dev": true, "dependencies": { "dir-glob": "^3.0.1", @@ -2604,12 +2569,12 @@ } }, "node_modules/espree": { - "version": "9.5.2", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.5.2.tgz", - "integrity": "sha512-7OASN1Wma5fum5SrNhFMAMJxOUAbhyfQ8dQ//PJaJbNw0URTPWqIghHWt1MmAANKhHZIYOHruW4Kw4ruUWOdGw==", + "version": "9.6.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.0.tgz", + "integrity": "sha512-1FH/IiruXZ84tpUlm0aCUEwMl2Ho5ilqVh0VvQXw+byAz/4SAciyHLlfmL5WYqsvD38oymdUwBss0LtK8m4s/A==", "dev": true, "dependencies": { - "acorn": "^8.8.0", + "acorn": "^8.9.0", "acorn-jsx": "^5.3.2", "eslint-visitor-keys": "^3.4.1" }, @@ -2711,9 +2676,9 @@ "dev": true }, "node_modules/fast-glob": { - "version": "3.2.12", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.12.tgz", - "integrity": "sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.0.tgz", + "integrity": "sha512-ChDuvbOypPuNjO8yIDf36x7BlZX1smcUMTTcyoIjycexOxd6DFsKsg21qVBzEmr3G7fUKIRy2/psii+CIUt7FA==", "dev": true, "dependencies": { "@nodelib/fs.stat": "^2.0.2", @@ -2981,9 +2946,9 @@ } }, "node_modules/get-tsconfig": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.6.0.tgz", - "integrity": "sha512-lgbo68hHTQnFddybKbbs/RDRJnJT5YyGy2kQzVwbq+g67X73i+5MVTval34QxGkOe9X5Ujf1UYpCaphLyltjEg==", + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.6.2.tgz", + "integrity": "sha512-E5XrT4CbbXcXWy+1jChlZmrmCwd5KGx502kDCXJJ7y898TtWW9FwoG5HfOLVRKmlmDGkWN2HM9Ho+/Y8F0sJDg==", "dev": true, "dependencies": { "resolve-pkg-maps": "^1.0.0" @@ -3288,23 +3253,6 @@ "node": ">=8" } }, - "node_modules/is-arguments": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.1.1.tgz", - "integrity": "sha512-8Q7EARjzEnKpt/PCD7e1cgUS0a6X8u5tdSiMqXhojOdoV9TsMsiO+9VLC5vAmO8N7/GmXn7yjR8qnA6bVAEzfA==", - "dev": true, - "peer": true, - "dependencies": { - "call-bind": "^1.0.2", - "has-tostringtag": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/is-array-buffer": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.2.tgz", @@ -3470,16 +3418,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/is-map": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/is-map/-/is-map-2.0.2.tgz", - "integrity": "sha512-cOZFQQozTha1f4MxLFzlgKYPTyj26picdZTx82hbc/Xf4K/tZOOXSCkMvU4pKioRXGDLJRn0GM7Upe7kR721yg==", - "dev": true, - "peer": true, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/is-negative-zero": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.2.tgz", @@ -3556,16 +3494,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-set": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/is-set/-/is-set-2.0.2.tgz", - "integrity": "sha512-+2cnTEZeY5z/iXGbLhPrOAaK/Mau5k5eXq9j14CpRTftq0pAJu2MwVRSZhyZWBzx3o6X795Lz6Bpb6R0GKf37g==", - "dev": true, - "peer": true, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/is-shared-array-buffer": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-shared-array-buffer/-/is-shared-array-buffer-1.0.2.tgz", @@ -3651,16 +3579,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/is-weakmap": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-weakmap/-/is-weakmap-2.0.1.tgz", - "integrity": "sha512-NSBR4kH5oVj1Uwvv970ruUkCV7O1mzgVFO4/rev2cLRda9Tm9HrL70ZPut4rOHgY0FNrUu9BCbXA2sdQ+x0chA==", - "dev": true, - "peer": true, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/is-weakref": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-weakref/-/is-weakref-1.0.2.tgz", @@ -3673,20 +3591,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-weakset": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/is-weakset/-/is-weakset-2.0.2.tgz", - "integrity": "sha512-t2yVvttHkQktwnNNmBQ98AhENLdPUTDTE21uPqAQ0ARwQfGeQKRVS0NNurH7bTf7RrvcVn1OOge45CnBeHCSmg==", - "dev": true, - "peer": true, - "dependencies": { - "call-bind": "^1.0.2", - "get-intrinsic": "^1.1.1" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/is-wsl": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", @@ -3715,11 +3619,10 @@ } }, "node_modules/isarray": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz", - "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==", - "dev": true, - "peer": true + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==", + "dev": true }, "node_modules/isexe": { "version": "2.0.0", @@ -3794,14 +3697,16 @@ } }, "node_modules/jsx-ast-utils": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-3.3.3.tgz", - "integrity": "sha512-fYQHZTZ8jSfmWZ0iyzfwiU4WDX4HpHbMCZ3gPlWYiCl3BoeOTsqKBqnTVfH2rYT7eP5c3sVbeSPHnnJOaTrWiw==", + "version": "3.3.4", + "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-3.3.4.tgz", + "integrity": "sha512-fX2TVdCViod6HwKEtSWGHs57oFhVfCMwieb9PuRDgjDPh5XeqJiHFFFJCHxU5cnTc3Bu/GRL+kPiFmw8XWOfKw==", "dev": true, "peer": true, "dependencies": { - "array-includes": "^3.1.5", - "object.assign": "^4.1.3" + "array-includes": "^3.1.6", + "array.prototype.flat": "^1.3.1", + "object.assign": "^4.1.4", + "object.values": "^1.1.6" }, "engines": { "node": ">=4.0" @@ -4683,23 +4588,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/object-is": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/object-is/-/object-is-1.1.5.tgz", - "integrity": "sha512-3cyDsyHgtmi7I7DfSSI2LDp6SK2lwvtbg0p0R1e0RvTqF5ceGx+K2dfSjm1bKDMVCFEDAQvy+o8c6a7VujOddw==", - "dev": true, - "peer": true, - "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.3" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/object-keys": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", @@ -4833,17 +4721,17 @@ } }, "node_modules/optionator": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", - "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==", + "version": "0.9.3", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.3.tgz", + "integrity": "sha512-JjCoypp+jKn1ttEFExxhetCKeJt9zhAgAve5FXHixTvFDW/5aEktX9bufBKLRRMdU7bNtpLfcGu94B3cdEJgjg==", "dev": true, "dependencies": { + "@aashutoshrathi/word-wrap": "^1.2.3", "deep-is": "^0.1.3", "fast-levenshtein": "^2.0.6", "levn": "^0.4.1", "prelude-ls": "^1.2.1", - "type-check": "^0.4.0", - "word-wrap": "^1.2.3" + "type-check": "^0.4.0" }, "engines": { "node": ">= 0.8.0" @@ -5005,12 +4893,6 @@ "isarray": "0.0.1" } }, - "node_modules/path-to-regexp/node_modules/isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==", - "dev": true - }, "node_modules/path-type": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", @@ -5039,9 +4921,9 @@ } }, "node_modules/pirates": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.5.tgz", - "integrity": "sha512-8V9+HQPupnaXMA23c5hvl69zXvTwTzyAYasnkb0Tts4XvO4CliqONMOnvlq26rkhLC3nWDFBJf73LU1e1VZLaQ==", + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.6.tgz", + "integrity": "sha512-saLsH7WeYYPiD25LDuLRRY/i+6HaPYr6G1OUlN39otzkSTxKnubR9RTxS3/Kk50s1g2JTgFwWQDQyplC5/SHZg==", "dev": true, "engines": { "node": ">= 6" @@ -5549,9 +5431,9 @@ } }, "node_modules/semver": { - "version": "7.5.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.1.tgz", - "integrity": "sha512-Wvss5ivl8TMRZXXESstBA4uR5iXgEN/VC5/sOcuXdVLzcdkz4HWetIoRfG5gb5X+ij/G9rw9YoGn3QoQ8OCSpw==", + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.3.tgz", + "integrity": "sha512-QBlUtyVk/5EeHbi7X0fw6liDZc7BBmEaSYn01fMU1OUYbf6GPsbTtd8WmnqbI20SeycoHSeiybkE/q1Q+qlThQ==", "dev": true, "dependencies": { "lru-cache": "^6.0.0" @@ -5612,9 +5494,9 @@ } }, "node_modules/shiki": { - "version": "0.14.2", - "resolved": "https://registry.npmjs.org/shiki/-/shiki-0.14.2.tgz", - "integrity": "sha512-ltSZlSLOuSY0M0Y75KA+ieRaZ0Trf5Wl3gutE7jzLuIcWxLp5i/uEnLoQWNvgKXQ5OMpGkJnVMRLAuzjc0LJ2A==", + "version": "0.14.3", + "resolved": "https://registry.npmjs.org/shiki/-/shiki-0.14.3.tgz", + "integrity": "sha512-U3S/a+b0KS+UkTyMjoNojvTgrBHjgp7L6ovhFVZsXmBGnVdQ4K4U9oK0z63w538S91ATngv1vXigHCSWOwnr+g==", "dev": true, "dependencies": { "ansi-sequence-parser": "^1.1.0", @@ -5644,13 +5526,13 @@ "dev": true }, "node_modules/sinon": { - "version": "15.1.0", - "resolved": "https://registry.npmjs.org/sinon/-/sinon-15.1.0.tgz", - "integrity": "sha512-cS5FgpDdE9/zx7no8bxROHymSlPLZzq0ChbbLk1DrxBfc+eTeBK3y8nIL+nu/0QeYydhhbLIr7ecHJpywjQaoQ==", + "version": "15.2.0", + "resolved": "https://registry.npmjs.org/sinon/-/sinon-15.2.0.tgz", + "integrity": "sha512-nPS85arNqwBXaIsFCkolHjGIkFo+Oxu9vbgmBJizLAhqe6P2o3Qmj3KCUoRkfhHtvgDhZdWD3risLHAUJ8npjw==", "dev": true, "dependencies": { "@sinonjs/commons": "^3.0.0", - "@sinonjs/fake-timers": "^10.2.0", + "@sinonjs/fake-timers": "^10.3.0", "@sinonjs/samsam": "^8.0.0", "diff": "^5.1.0", "nise": "^5.1.4", @@ -5732,19 +5614,6 @@ "node": ">=8" } }, - "node_modules/stop-iteration-iterator": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/stop-iteration-iterator/-/stop-iteration-iterator-1.0.0.tgz", - "integrity": "sha512-iCGQj+0l0HOdZ2AEeBADlsRC+vsnDsZsbdSiH1yNSjcfKM7fdpCMfqAL/dwF5BLiw/XhRft/Wax6zQbhq2BcjQ==", - "dev": true, - "peer": true, - "dependencies": { - "internal-slot": "^1.0.4" - }, - "engines": { - "node": ">= 0.4" - } - }, "node_modules/string-width": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", @@ -6022,9 +5891,9 @@ } }, "node_modules/tslib": { - "version": "2.5.3", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.3.tgz", - "integrity": "sha512-mSxlJJwl3BMEQCUNnxXBU9jP4JBktcEGhURcPR6VQVlnP0FdDEsIaz0C35dXNGLyRfrATNofF0F5p2KPxQgB+w==" + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.0.tgz", + "integrity": "sha512-7At1WUettjcSRHXCyYtTselblcHl9PJFFVKiCAy/bY97+BPZXSQ2wbq0P9s8tK2G7dFQfNnlJnPAiArVBVBsfA==" }, "node_modules/tsutils": { "version": "3.21.0", @@ -6134,9 +6003,9 @@ } }, "node_modules/typedoc/node_modules/minimatch": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.1.tgz", - "integrity": "sha512-0jWhJpD/MdhPXwPuiRkCbfYfSKp2qnn2eOc279qI7f+osl/l+prKSrvhg157zSYvx/1nmgn2NqdT6k2Z7zSH9w==", + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.2.tgz", + "integrity": "sha512-PZOT9g5v2ojiTL7r1xF6plNHLtOeTpSlDI007As2NlA2aYBMfVom17yqa6QzhmDP8QOhn7LjHTg7DFCVSSa6yg==", "dev": true, "dependencies": { "brace-expansion": "^2.0.1" @@ -6149,9 +6018,9 @@ } }, "node_modules/typescript": { - "version": "5.1.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.1.3.tgz", - "integrity": "sha512-XH627E9vkeqhlZFQuL+UsyAXEnibT0kWR2FWONlr4sTjvxyJYnyefgrkyECLzM5NenmKzRAy2rR/OlYLA1HkZw==", + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.1.6.tgz", + "integrity": "sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==", "dev": true, "bin": { "tsc": "bin/tsc", @@ -6277,22 +6146,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/which-collection": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/which-collection/-/which-collection-1.0.1.tgz", - "integrity": "sha512-W8xeTUwaln8i3K/cY1nGXzdnVZlidBcagyNFtBdD5kxnb4TvGKR7FfSIS3mYpwWS1QUCutfKz8IY8RjftB0+1A==", - "dev": true, - "peer": true, - "dependencies": { - "is-map": "^2.0.1", - "is-set": "^2.0.1", - "is-weakmap": "^2.0.1", - "is-weakset": "^2.0.1" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/which-typed-array": { "version": "1.1.9", "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.9.tgz", @@ -6313,15 +6166,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/word-wrap": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", - "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/wrap-ansi": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", diff --git a/package.json b/package.json index c4cbea35..60415f4f 100644 --- a/package.json +++ b/package.json @@ -11,13 +11,13 @@ "scripts": { "build": "tsc", "prepublishOnly": "npm run build && npm run test && npm run lint", - "test": "npm run test:unit && npm run test:e2e", "prettier": "prettier --write src", "doc": "typedoc --name \"Confluence.js - Cloud and Server API library\" --out docs ./src/index.ts --plugin typedoc-plugin-extras --footerDate --footerTime --footerTypedocVersion --favicon https://svgshare.com/i/bVi.svg", "lint": "eslint src tests --ext .ts", "lint:fix": "npm run lint -- --fix", + "test": "npm run test:unit && npm run test:integration", "test:unit": "ava tests/unit", - "test:e2e": "ava --timeout=2m --fail-fast --no-worker-threads -c 1 -s tests/e2e/**/*.test.ts" + "test:integration": "ava --timeout=2m --fail-fast --no-worker-threads -c 1 -s tests/integration/**.test.ts" }, "ava": { "extensions": [ @@ -42,32 +42,32 @@ "atlassian" ], "devDependencies": { - "@swc-node/register": "^1.6.5", + "@swc-node/register": "^1.6.6", "@swc/helpers": "^0.5.1", "@types/express": "^4.17.17", "@types/oauth": "^0.9.1", "@types/sinon": "^10.0.15", - "@typescript-eslint/eslint-plugin": "^5.59.9", - "@typescript-eslint/parser": "^5.59.9", - "ava": "^5.3.0", - "dotenv": "^16.1.4", - "eslint": "^8.42.0", + "@typescript-eslint/eslint-plugin": "^5.60.1", + "@typescript-eslint/parser": "^5.60.1", + "ava": "^5.3.1", + "dotenv": "^16.3.1", + "eslint": "^8.44.0", "eslint-config-airbnb": "^19.0.4", "eslint-config-airbnb-typescript": "^17.0.0", "eslint-import-resolver-typescript": "^3.5.5", "eslint-plugin-import": "^2.27.5", "prettier": "^2.8.8", "prettier-plugin-jsdoc": "^0.4.2", - "sinon": "^15.1.0", + "sinon": "^15.2.0", "typedoc": "^0.24.8", "typedoc-plugin-extras": "^2.3.3", - "typescript": "^5.1.3" + "typescript": "^5.1.6" }, "dependencies": { "atlassian-jwt": "^2.0.2", "axios": "^1.4.0", "form-data": "^4.0.0", "oauth": "^0.10.0", - "tslib": "^2.5.3" + "tslib": "^2.6.0" } } diff --git a/src/clients/baseClient.ts b/src/clients/baseClient.ts index be15bc54..8f54ddc8 100644 --- a/src/clients/baseClient.ts +++ b/src/clients/baseClient.ts @@ -1,4 +1,4 @@ -import { AuthenticationService } from '../services/authenticationService'; +import { AuthenticationService } from '../services'; import type { Callback } from '../callback'; import type { Client } from './client'; import type { Config } from '../config'; @@ -84,6 +84,22 @@ export class BaseClient implements Client { return this.#instance; } + getResponseHandler(callback?: Callback) { + const callbackResponseHandler = callback && ((data: T): void => callback(null, data)); + const defaultResponseHandler = (data: T): T => data; + + return callbackResponseHandler ?? defaultResponseHandler; + } + + getErrorHandler(callback?: Callback) { + const callbackErrorHandler = callback && ((error: Config.Error) => callback(error)); + const defaultErrorHandler = (error: Error) => { + throw error; + }; + + return callbackErrorHandler ?? defaultErrorHandler; + } + async sendRequest(requestConfig: RequestConfig, callback: never, telemetryData?: any): Promise; async sendRequest(requestConfig: RequestConfig, callback: Callback, telemetryData?: any): Promise; async sendRequest(requestConfig: RequestConfig, callback: Callback | never): Promise { @@ -102,10 +118,7 @@ export class BaseClient implements Client { const response = await this.instance.request(modifiedRequestConfig); - const callbackResponseHandler = callback && ((data: T): void => callback(null, data)); - const defaultResponseHandler = (data: T): T => data; - - const responseHandler = callbackResponseHandler ?? defaultResponseHandler; + const responseHandler = this.getResponseHandler(callback); this.config.middlewares?.onResponse?.(response.data); @@ -113,12 +126,7 @@ export class BaseClient implements Client { } catch (e: any) { const err = this.config.newErrorHandling && e.isAxiosError ? e.response.data : e; - const callbackErrorHandler = callback && ((error: Config.Error) => callback(error)); - const defaultErrorHandler = (error: Error) => { - throw error; - }; - - const errorHandler = callbackErrorHandler ?? defaultErrorHandler; + const errorHandler = this.getErrorHandler(callback); this.config.middlewares?.onError?.(err); diff --git a/src/clients/client.ts b/src/clients/client.ts index dd2d9ee3..480aea82 100644 --- a/src/clients/client.ts +++ b/src/clients/client.ts @@ -1,7 +1,12 @@ import type { Callback } from '../callback'; +import type { Config } from '../config'; import type { RequestConfig } from '../requestConfig'; export interface Client { + getResponseHandler(callback?: Callback): (data: T) => void; + + getErrorHandler(callback?: Callback): (error: Config.Error) => void; + sendRequest(requestConfig: RequestConfig, callback?: never, telemetryData?: any): Promise; sendRequest(requestConfig: RequestConfig, callback?: Callback, telemetryData?: any): Promise; } diff --git a/src/clients/index.ts b/src/clients/index.ts index 631fe11e..f7919c5f 100644 --- a/src/clients/index.ts +++ b/src/clients/index.ts @@ -2,3 +2,4 @@ export * from './baseClient'; export * from './client'; export * from './confluenceClient'; export * from './serverClient'; +export * from './version2Client'; diff --git a/src/clients/version2Client.ts b/src/clients/version2Client.ts new file mode 100644 index 00000000..4c917e9e --- /dev/null +++ b/src/clients/version2Client.ts @@ -0,0 +1,43 @@ +import { BaseClient } from './baseClient'; +import { Config } from '../config'; +import { + Attachment, + BlogPost, + Children, + Comment, + Content, + ContentProperties, + CustomContent, + Label, + Page, + Space, + SpaceProperties, + Task, + User, + Version, +} from '../version2'; + +export class Version2Client extends BaseClient { + constructor(config: Config) { + super({ + ...config, + newErrorHandling: true, + apiPrefix: config.apiPrefix ?? '/wiki/api/v2', + }); + } + + attachment = new Attachment(this); + blogPost = new BlogPost(this); + children = new Children(this); + comment = new Comment(this); + content = new Content(this); + contentProperties = new ContentProperties(this); + customContent = new CustomContent(this); + label = new Label(this); + page = new Page(this); + space = new Space(this); + spaceProperties = new SpaceProperties(this); + task = new Task(this); + user = new User(this); + version = new Version(this); +} diff --git a/src/config.ts b/src/config.ts index 1a103a27..c360e176 100644 --- a/src/config.ts +++ b/src/config.ts @@ -11,9 +11,18 @@ export interface Config { telemetry?: Config.Telemetry; /** Adds `'X-Atlassian-Token': 'no-check'` to each request header */ noCheckAtlassianToken?: boolean; - /** Enable new API error handling. `false` by default. */ + /** + * Enable new API error handling. For "ConfluenceClient" `false` by default. + * + * For "Version2Client" enabled by default. + */ newErrorHandling?: boolean; - /** Prefix for all API routes. */ + /** + * Prefix for all API routes. + * + * - For "ConfluenceCloud" by default it is "/wiki/rest" + * - For "Version2Client" by default it is "/wiki/api/v2" + */ apiPrefix?: string; } diff --git a/src/index.ts b/src/index.ts index 52e72e14..f2582dff 100644 --- a/src/index.ts +++ b/src/index.ts @@ -12,3 +12,7 @@ export * as Models from './api/models'; export * as Parameters from './api/parameters'; export * as ServerModels from './server/models'; export * as ServerParameters from './server/parameters'; + +export * as Version2 from './version2'; +export * as Version2Models from './version2/models'; +export * as Version2Parameters from './version2/parameters'; diff --git a/src/services/index.ts b/src/services/index.ts new file mode 100644 index 00000000..add416bb --- /dev/null +++ b/src/services/index.ts @@ -0,0 +1,2 @@ +export * from './authenticationService'; +export * from './paginationService'; diff --git a/src/services/paginationService.ts b/src/services/paginationService.ts new file mode 100644 index 00000000..8f8e9566 --- /dev/null +++ b/src/services/paginationService.ts @@ -0,0 +1,90 @@ +import type { Pagination } from '../version2/models'; + +/** This service is responsible for handling pagination. */ +export class PaginationService { + /** + * This method builds a paginated result based on the given pagination object and a function to call for the next + * page. + */ + buildPaginatedResult( + pagination: Pagination, + callFn: (params: any) => Promise>, + ): Pagination { + if (!pagination._links.next) { + return this.buildEmptyPagination(pagination); + } + + const parameters = this.parseParameters(pagination._links.next); + + return { + results: pagination.results, + _links: pagination._links, + parameters, + hasNext: true, + next: () => callFn(parameters), + getAll: () => this.getAll(pagination.results, parameters, callFn), + }; + } + + private parseParameters(urlString: string) { + const url = new URL(urlString, 'http://temp.temp'); + const searchParams = new URLSearchParams(url.search); + const paramsObject: Record = {}; + + searchParams.forEach((value, key) => { + paramsObject[this.toCamelCase(key)] = value; + }); + + return paramsObject; + } + + /** This method retrieves all pages of results. */ + private async getAll( + actualResult: T[], + params: Record, + callFn: (params: Record) => Promise>, + ): Promise { + let hasNext = true; + + while (hasNext) { + const paginationResult: Pagination = await callFn(params); + + actualResult.push(...paginationResult.results); + + if (paginationResult._links.next) { + params = this.parseParameters(paginationResult._links.next); + } else { + hasNext = false; + } + } + + return actualResult; + } + + private toCamelCase(str: string): string { + return str.replace(/([-_][a-z])/gi, piece => { + return piece.toUpperCase().replace('-', '').replace('_', ''); + }); + } + + private buildEmptyPagination(pagination: Pagination): Pagination { + const emptyPagination: Pagination = { + results: pagination.results, + parameters: pagination.parameters, + _links: {}, + hasNext: false, + next: () => + Promise.resolve({ + results: [], + hasNext: false, + parameters: pagination.parameters, + _links: pagination._links, + next: emptyPagination.next, + getAll: () => Promise.resolve([]), + }), + getAll: () => Promise.resolve(pagination.results), + }; + + return emptyPagination; + } +} diff --git a/src/version2/attachment.ts b/src/version2/attachment.ts new file mode 100644 index 00000000..afc9f02e --- /dev/null +++ b/src/version2/attachment.ts @@ -0,0 +1,386 @@ +import * as Models from './models'; +import * as Parameters from './parameters'; +import { Callback } from '../callback'; +import { Client } from '../clients'; +import { PaginationService } from '../services'; +import { RequestConfig } from '../requestConfig'; + +export class Attachment { + private paginationService = new PaginationService(); + + constructor(private client: Client) {} + + /** + * Returns a specific attachment. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the attachment's + * container. + */ + async getAttachmentById( + parameters: Parameters.GetAttachmentById, + callback: Callback, + ): Promise; + /** + * Returns a specific attachment. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the attachment's + * container. + */ + async getAttachmentById( + parameters: Parameters.GetAttachmentById, + callback?: never, + ): Promise; + async getAttachmentById( + parameters: Parameters.GetAttachmentById, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/attachments/${parameters.id}`, + method: 'GET', + params: { + version: parameters.version, + 'serialize-ids-as-strings': true, + }, + }; + + return this.client.sendRequest(config, callback); + } + + /** Fetches all attachments of a blog post. */ + async getAllBlogPostAttachments( + parameters: Parameters.GetBlogpostAttachments, + callback: Callback, + ): Promise; + /** Fetches all attachments of a blog post. */ + async getAllBlogPostAttachments( + parameters: Parameters.GetBlogpostAttachments, + callback?: never, + ): Promise; + async getAllBlogPostAttachments( + parameters: Parameters.GetBlogpostAttachments, + callback?: Callback, + ): Promise { + try { + const { getAll: getAllAttachments } = await this.getBlogPostAttachments(parameters); + + const attachments = await getAllAttachments(); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(attachments as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** + * Returns the attachments of specific blog post. The number of results is limited by the `limit` parameter and + * additional results (if available) will be available through the `next` URL present in the `Link` response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the blog + * post and its corresponding space. + */ + async getBlogPostAttachments>( + parameters: Parameters.GetBlogpostAttachments, + callback: Callback, + ): Promise; + /** + * Returns the attachments of specific blog post. The number of results is limited by the `limit` parameter and + * additional results (if available) will be available through the `next` URL present in the `Link` response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the blog + * post and its corresponding space. + */ + async getBlogPostAttachments>( + parameters: Parameters.GetBlogpostAttachments, + callback?: never, + ): Promise; + async getBlogPostAttachments>( + parameters: Parameters.GetBlogpostAttachments, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/blogposts/${parameters.id}/attachments`, + method: 'GET', + params: { + sort: parameters.sort, + cursor: parameters.cursor, + mediaType: parameters.mediaType, + filename: parameters.filename, + limit: parameters.limit, + 'serialize-ids-as-strings': true, + }, + }; + + try { + const attachments = await this.client.sendRequest>(config); + const paginatedAttachments = this.paginationService.buildPaginatedResult( + attachments, + this.getBlogPostAttachments.bind(this), + ); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(paginatedAttachments as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** Fetches all attachments of a custom content. */ + async getAllCustomContentAttachments( + parameters: Parameters.GetCustomContentAttachments, + callback: Callback, + ): Promise; + /** Fetches all attachments of a custom content. */ + async getAllCustomContentAttachments( + parameters: Parameters.GetCustomContentAttachments, + callback?: never, + ): Promise; + async getAllCustomContentAttachments( + parameters: Parameters.GetCustomContentAttachments, + callback?: Callback, + ): Promise { + try { + const { getAll: getAllAttachments } = await this.getCustomContentAttachments(parameters); + + const attachments = await getAllAttachments(); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(attachments as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** + * Returns the attachments of specific custom content. The number of results is limited by the `limit` parameter and + * additional results (if available) will be available through the `next` URL present in the `Link` response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the custom + * content and its corresponding space. + */ + async getCustomContentAttachments>( + parameters: Parameters.GetCustomContentAttachments, + callback: Callback, + ): Promise; + /** + * Returns the attachments of specific custom content. The number of results is limited by the `limit` parameter and + * additional results (if available) will be available through the `next` URL present in the `Link` response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the custom + * content and its corresponding space. + */ + async getCustomContentAttachments>( + parameters: Parameters.GetCustomContentAttachments, + callback?: never, + ): Promise; + async getCustomContentAttachments>( + parameters: Parameters.GetCustomContentAttachments, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/custom-content/${parameters.id}/attachments`, + method: 'GET', + params: { + sort: parameters.sort, + cursor: parameters.cursor, + mediaType: parameters.mediaType, + filename: parameters.filename, + limit: parameters.limit, + 'serialize-ids-as-strings': true, + }, + }; + + try { + const attachments = await this.client.sendRequest>(config); + const paginatedAttachments = this.paginationService.buildPaginatedResult( + attachments, + this.getCustomContentAttachments.bind(this), + ); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(paginatedAttachments as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** Fetches all attachments of a label. */ + async getAllLabelAttachments( + parameters: Parameters.GetLabelAttachments, + callback: Callback, + ): Promise; + /** Fetches all attachments of a label. */ + async getAllLabelAttachments( + parameters: Parameters.GetLabelAttachments, + callback?: never, + ): Promise; + async getAllLabelAttachments( + parameters: Parameters.GetLabelAttachments, + callback?: Callback, + ): Promise { + try { + const { getAll: getAllAttachments } = await this.getLabelAttachments(parameters); + + const attachments = await getAllAttachments(); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(attachments as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** + * Returns the attachments of specified label. The number of results is limited by the `limit` parameter and + * additional results (if available) will be available through the `next` URL present in the `Link` response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the attachment and its + * corresponding space. + */ + async getLabelAttachments>( + parameters: Parameters.GetLabelAttachments, + callback: Callback, + ): Promise; + /** + * Returns the attachments of specified label. The number of results is limited by the `limit` parameter and + * additional results (if available) will be available through the `next` URL present in the `Link` response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the attachment and its + * corresponding space. + */ + async getLabelAttachments>( + parameters: Parameters.GetLabelAttachments, + callback?: never, + ): Promise; + async getLabelAttachments>( + parameters: Parameters.GetLabelAttachments, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/labels/${parameters.id}/attachments`, + method: 'GET', + params: { + sort: parameters.sort, + cursor: parameters.cursor, + limit: parameters.limit, + 'serialize-ids-as-strings': true, + }, + }; + + try { + const attachments = await this.client.sendRequest>(config); + const paginatedAttachments = this.paginationService.buildPaginatedResult( + attachments, + this.getLabelAttachments.bind(this), + ); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(paginatedAttachments as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** Fetches all attachments of a page. */ + async getAllPageAttachments( + parameters: Parameters.GetPageAttachments, + callback: Callback, + ): Promise; + /** Fetches all attachments of a page. */ + async getAllPageAttachments( + parameters: Parameters.GetPageAttachments, + callback?: never, + ): Promise; + async getAllPageAttachments( + parameters: Parameters.GetPageAttachments, + callback?: Callback, + ): Promise { + try { + const { getAll: getAllAttachments } = await this.getPageAttachments(parameters); + + const attachments = await getAllAttachments(); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(attachments as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** + * Returns the attachments of specific page. The number of results is limited by the `limit` parameter and additional + * results (if available) will be available through the `next` URL present in the `Link` response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the page + * and its corresponding space. + */ + async getPageAttachments>( + parameters: Parameters.GetPageAttachments, + callback: Callback, + ): Promise; + /** + * Returns the attachments of specific page. The number of results is limited by the `limit` parameter and additional + * results (if available) will be available through the `next` URL present in the `Link` response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the page + * and its corresponding space. + */ + async getPageAttachments>( + parameters: Parameters.GetPageAttachments, + callback?: never, + ): Promise; + async getPageAttachments>( + parameters: Parameters.GetPageAttachments, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/pages/${parameters.id}/attachments`, + method: 'GET', + params: { + sort: parameters.sort, + cursor: parameters.cursor, + mediaType: parameters.mediaType, + filename: parameters.filename, + limit: parameters.limit, + 'serialize-ids-as-strings': true, + }, + }; + + try { + const attachments = await this.client.sendRequest>(config); + const paginatedAttachments = this.paginationService.buildPaginatedResult( + attachments, + this.getPageAttachments.bind(this), + ); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(paginatedAttachments as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } +} diff --git a/src/version2/blogPost.ts b/src/version2/blogPost.ts new file mode 100644 index 00000000..dc7be75a --- /dev/null +++ b/src/version2/blogPost.ts @@ -0,0 +1,387 @@ +import * as Models from './models'; +import * as Parameters from './parameters'; +import { Callback } from '../callback'; +import { Client } from '../clients'; +import { PaginationService } from '../services'; +import { RequestConfig } from '../requestConfig'; + +export class BlogPost { + private paginationService = new PaginationService(); + + constructor(private client: Client) {} + + /** Fetches all blog posts. */ + async getAllBlogPosts( + parameters: Parameters.GetBlogPosts | undefined, + callback: Callback, + ): Promise; + /** Fetches all blog posts. */ + async getAllBlogPosts(parameters?: Parameters.GetBlogPosts, callback?: never): Promise; + async getAllBlogPosts( + parameters?: Parameters.GetBlogPosts, + callback?: Callback, + ): Promise { + try { + const { getAll: getAllBlogPosts } = await this.getBlogPosts(parameters); + + const blogPosts = await getAllBlogPosts(); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(blogPosts as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** + * Returns all blog posts. The number of results is limited by the `limit` parameter and additional results (if + * available) will be available through the `next` URL present in the `Link` response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to access the Confluence site + * ('Can use' global permission). Only blog posts that the user has permission to view will be returned. + */ + async getBlogPosts>( + parameters: Parameters.GetBlogPosts | undefined, + callback: Callback, + ): Promise; + /** + * Returns all blog posts. The number of results is limited by the `limit` parameter and additional results (if + * available) will be available through the `next` URL present in the `Link` response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to access the Confluence site + * ('Can use' global permission). Only blog posts that the user has permission to view will be returned. + */ + async getBlogPosts>( + parameters?: Parameters.GetBlogPosts, + callback?: never, + ): Promise; + async getBlogPosts>( + parameters?: Parameters.GetBlogPosts, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: '/blogposts', + method: 'GET', + params: { + id: parameters?.id, + status: parameters?.status, + 'body-format': parameters?.bodyFormat, + cursor: parameters?.cursor, + limit: parameters?.limit, + 'serialize-ids-as-strings': true, + }, + }; + + try { + const blogPosts = await this.client.sendRequest>(config); + const paginatedBlogPosts = this.paginationService.buildPaginatedResult(blogPosts, this.getBlogPosts.bind(this)); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(paginatedBlogPosts as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** + * Creates a new blog post in the space specified by the spaceId. + * + * By default this will create the blog post as a non-draft, unless the status is specified as draft. If creating a + * non-draft, the title must not be empty. + * + * Currently only supports the storage representation specified in the body.representation enums below + */ + async createBlogPost( + parameters: Parameters.CreateBlogPost | undefined, + callback: Callback, + ): Promise; + /** + * Creates a new blog post in the space specified by the spaceId. + * + * By default this will create the blog post as a non-draft, unless the status is specified as draft. If creating a + * non-draft, the title must not be empty. + * + * Currently only supports the storage representation specified in the body.representation enums below + */ + async createBlogPost(parameters?: Parameters.CreateBlogPost, callback?: never): Promise; + async createBlogPost( + parameters?: Parameters.CreateBlogPost, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: '/blogposts', + method: 'POST', + params: { + 'serialize-ids-as-strings': true, + }, + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Returns a specific blog post. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the blog post and its + * corresponding space. + */ + async getBlogPostById( + parameters: Parameters.GetBlogPostById, + callback: Callback, + ): Promise; + /** + * Returns a specific blog post. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the blog post and its + * corresponding space. + */ + async getBlogPostById(parameters: Parameters.GetBlogPostById, callback?: never): Promise; + async getBlogPostById( + parameters: Parameters.GetBlogPostById, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/blogposts/${parameters.id}`, + method: 'GET', + params: { + 'body-format': parameters.bodyFormat, + 'get-draft': parameters.getDraft, + version: parameters.version, + 'serialize-ids-as-strings': true, + }, + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Update a blog post by id. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the blog post and its + * corresponding space. Permission to update blog posts in the space. + */ + async updateBlogPost( + parameters: Parameters.UpdateBlogPost, + callback: Callback, + ): Promise; + /** + * Update a blog post by id. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the blog post and its + * corresponding space. Permission to update blog posts in the space. + */ + async updateBlogPost(parameters: Parameters.UpdateBlogPost, callback?: never): Promise; + async updateBlogPost( + parameters: Parameters.UpdateBlogPost, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/blogposts/${parameters.id}`, + method: 'PUT', + params: { + 'serialize-ids-as-strings': true, + }, + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Delete a blog post by id. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the blog post and its + * corresponding space. Permission to delete blog posts in the space. + */ + async deleteBlogPost(parameters: Parameters.DeleteBlogPost, callback: Callback): Promise; + /** + * Delete a blog post by id. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the blog post and its + * corresponding space. Permission to delete blog posts in the space. + */ + async deleteBlogPost(parameters: Parameters.DeleteBlogPost, callback?: never): Promise; + async deleteBlogPost(parameters: Parameters.DeleteBlogPost, callback?: Callback): Promise { + const config: RequestConfig = { + url: `/blogposts/${parameters.id}`, + method: 'DELETE', + }; + + return this.client.sendRequest(config, callback); + } + + /** Fetches all blog posts of specified label. */ + async getAllLabelBlogPosts( + parameters: Parameters.GetLabelBlogPosts, + callback: Callback, + ): Promise; + /** Fetches all blog posts of specified label. */ + async getAllLabelBlogPosts( + parameters: Parameters.GetLabelBlogPosts, + callback?: never, + ): Promise; + async getAllLabelBlogPosts( + parameters: Parameters.GetLabelBlogPosts, + callback?: Callback, + ): Promise { + try { + const { getAll: getAllBlogPosts } = await this.getLabelBlogPosts(parameters); + + const blogPosts = await getAllBlogPosts(); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(blogPosts as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** + * Returns the blogposts of specified label. The number of results is limited by the `limit` parameter and additional + * results (if available) will be available through the `next` URL present in the `Link` response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the page + * and its corresponding space. + */ + async getLabelBlogPosts>( + parameters: Parameters.GetLabelBlogPosts, + callback: Callback, + ): Promise; + /** + * Returns the blogposts of specified label. The number of results is limited by the `limit` parameter and additional + * results (if available) will be available through the `next` URL present in the `Link` response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the page + * and its corresponding space. + */ + async getLabelBlogPosts>( + parameters: Parameters.GetLabelBlogPosts, + callback?: never, + ): Promise; + async getLabelBlogPosts>( + parameters: Parameters.GetLabelBlogPosts, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/labels/${parameters.id}/blogposts`, + method: 'GET', + params: { + 'body-format': parameters.bodyFormat, + sort: parameters.sort, + cursor: parameters.cursor, + limit: parameters.limit, + 'serialize-ids-as-strings': true, + }, + }; + + try { + const blogPosts = await this.client.sendRequest>(config); + const paginatedBlogPosts = this.paginationService.buildPaginatedResult( + blogPosts, + this.getLabelBlogPosts.bind(this), + ); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(paginatedBlogPosts as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** Fetches all blog posts in a space. */ + async getAllBlogPostsInSpace( + parameters: Parameters.GetLabelBlogPosts, + callback: Callback, + ): Promise; + /** Fetches all blog posts in a space. */ + async getAllBlogPostsInSpace( + parameters: Parameters.GetLabelBlogPosts, + callback?: never, + ): Promise; + async getAllBlogPostsInSpace( + parameters: Parameters.GetLabelBlogPosts, + callback?: Callback, + ): Promise { + try { + const { getAll: getAllBlogPosts } = await this.getBlogPostsInSpace(parameters); + + const blogPosts = await getAllBlogPosts(); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(blogPosts as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** + * Returns all blog posts in a space. The number of results is limited by the `limit` parameter and additional results + * (if available) will be available through the `next` URL present in the `Link` response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to access the Confluence site + * ('Can use' global permission) and view the space. Only blog posts that the user has permission to view will be + * returned. + */ + async getBlogPostsInSpace>( + parameters: Parameters.GetBlogPostsInSpace, + callback: Callback, + ): Promise; + /** + * Returns all blog posts in a space. The number of results is limited by the `limit` parameter and additional results + * (if available) will be available through the `next` URL present in the `Link` response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to access the Confluence site + * ('Can use' global permission) and view the space. Only blog posts that the user has permission to view will be + * returned. + */ + async getBlogPostsInSpace>( + parameters: Parameters.GetBlogPostsInSpace, + callback?: never, + ): Promise; + async getBlogPostsInSpace>( + parameters: Parameters.GetBlogPostsInSpace, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/spaces/${parameters.id}/blogposts`, + method: 'GET', + params: { + status: parameters.status, + 'body-format': parameters.bodyFormat, + cursor: parameters.cursor, + limit: parameters.limit, + 'serialize-ids-as-strings': true, + }, + }; + + try { + const blogPosts = await this.client.sendRequest>(config); + const paginatedBlogPosts = this.paginationService.buildPaginatedResult( + blogPosts, + this.getBlogPostsInSpace.bind(this), + ); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(paginatedBlogPosts as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } +} diff --git a/src/version2/children.ts b/src/version2/children.ts new file mode 100644 index 00000000..6881787b --- /dev/null +++ b/src/version2/children.ts @@ -0,0 +1,177 @@ +import * as Models from './models'; +import * as Parameters from './parameters'; +import { Callback } from '../callback'; +import { Client } from '../clients'; +import { PaginationService } from '../services'; +import { RequestConfig } from '../requestConfig'; + +export class Children { + private paginationService = new PaginationService(); + + constructor(private client: Client) {} + + /** Fetches all child pages. */ + async getAllChildPages( + parameters: Parameters.GetChildPages, + callback: Callback, + ): Promise; + /** Fetches all child pages. */ + async getAllChildPages(parameters: Parameters.GetChildPages, callback?: never): Promise; + async getAllChildPages( + parameters: Parameters.GetChildPages, + callback?: Callback, + ): Promise { + try { + const { getAll: getAllChildPages } = await this.getChildPages(parameters); + + const childPages = await getAllChildPages(); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(childPages as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** + * Returns all child pages for given page id. The number of results is limited by the `limit` parameter and additional + * results (if available) will be available through the `next` URL present in the `Link` response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to access the Confluence site + * ('Can use' global permission). Only pages that the user has permission to view will be returned. + */ + async getChildPages>( + parameters: Parameters.GetChildPages, + callback: Callback, + ): Promise; + /** + * Returns all child pages for given page id. The number of results is limited by the `limit` parameter and additional + * results (if available) will be available through the `next` URL present in the `Link` response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to access the Confluence site + * ('Can use' global permission). Only pages that the user has permission to view will be returned. + */ + async getChildPages>( + parameters: Parameters.GetChildPages, + callback?: never, + ): Promise; + async getChildPages>( + parameters: Parameters.GetChildPages, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/pages/${parameters.id}/children`, + method: 'GET', + params: { + cursor: parameters.cursor, + limit: parameters.limit, + sort: parameters.sort, + 'serialize-ids-as-strings': true, + }, + }; + + try { + const childPages = await this.client.sendRequest>(config); + const paginatedChildPages = this.paginationService.buildPaginatedResult( + childPages, + this.getChildPages.bind(this), + ); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(paginatedChildPages as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** Fetches all child custom content. */ + async getAllChildCustomContent( + parameters: Parameters.GetChildCustomContent, + callback: Callback, + ): Promise; + /** Fetches all child custom content. */ + async getAllChildCustomContent( + parameters: Parameters.GetChildCustomContent, + callback?: never, + ): Promise; + async getAllChildCustomContent( + parameters: Parameters.GetChildCustomContent, + callback?: Callback, + ): Promise { + try { + const { getAll: getAllChildCustomContent } = await this.getChildCustomContent(parameters); + + const childCustomContents = await getAllChildCustomContent(); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(childCustomContents as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** + * Returns all child custom content for given custom content id. The number of results is limited by the `limit` + * parameter and additional results (if available) will be available through the `next` URL present in the `Link` + * response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to access the Confluence site + * ('Can use' global permission). Only custom content that the user has permission to view will be returned. + */ + async getChildCustomContent>( + parameters: Parameters.GetChildCustomContent, + callback: Callback, + ): Promise; + /** + * Returns all child custom content for given custom content id. The number of results is limited by the `limit` + * parameter and additional results (if available) will be available through the `next` URL present in the `Link` + * response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to access the Confluence site + * ('Can use' global permission). Only custom content that the user has permission to view will be returned. + */ + async getChildCustomContent>( + parameters: Parameters.GetChildCustomContent, + callback?: never, + ): Promise; + async getChildCustomContent>( + parameters: Parameters.GetChildCustomContent, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/custom-content/${parameters.id}/children`, + method: 'GET', + params: { + cursor: parameters.cursor, + limit: parameters.limit, + sort: parameters.sort, + 'serialize-ids-as-strings': true, + }, + }; + + try { + const childCustomContents = await this.client.sendRequest>(config); + const paginatedChildCustomContents = this.paginationService.buildPaginatedResult( + childCustomContents, + this.getChildCustomContent.bind(this), + ); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(paginatedChildCustomContents as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } +} diff --git a/src/version2/comment.ts b/src/version2/comment.ts new file mode 100644 index 00000000..86811200 --- /dev/null +++ b/src/version2/comment.ts @@ -0,0 +1,824 @@ +import * as Models from './models'; +import * as Parameters from './parameters'; +import { Callback } from '../callback'; +import { Client } from '../clients'; +import { PaginationService } from '../services'; +import { RequestConfig } from '../requestConfig'; + +export class Comment { + private paginationService = new PaginationService(); + + constructor(private client: Client) {} + + /** Fetches all footer comments of a page. */ + async getAllPageFooterComments( + parameters: Parameters.GetPageFooterComments, + callback: Callback, + ): Promise; + /** Fetches all footer comments of a page. */ + async getAllPageFooterComments( + parameters: Parameters.GetPageFooterComments, + callback?: never, + ): Promise; + async getAllPageFooterComments( + parameters: Parameters.GetPageFooterComments, + callback?: Callback, + ): Promise { + try { + const { getAll: getAllPageFooterComments } = await this.getPageFooterComments(parameters); + + const pageFooterComments = await getAllPageFooterComments(); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(pageFooterComments as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** + * Returns the root footer comments of specific page. The number of results is limited by the `limit` parameter and + * additional results (if available) will be available through the `next` URL present in the `Link` response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the page + * and its corresponding space. + */ + async getPageFooterComments>( + parameters: Parameters.GetPageFooterComments, + callback: Callback, + ): Promise; + /** + * Returns the root footer comments of specific page. The number of results is limited by the `limit` parameter and + * additional results (if available) will be available through the `next` URL present in the `Link` response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the page + * and its corresponding space. + */ + async getPageFooterComments>( + parameters: Parameters.GetPageFooterComments, + callback?: never, + ): Promise; + async getPageFooterComments>( + parameters: Parameters.GetPageFooterComments, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/pages/${parameters.id}/footer-comments`, + method: 'GET', + params: { + 'body-format': parameters.bodyFormat, + sort: parameters.sort, + cursor: parameters.cursor, + limit: parameters.limit, + 'serialize-ids-as-strings': true, + }, + }; + + try { + const pageComments = await this.client.sendRequest>(config); + const paginatedPageComments = this.paginationService.buildPaginatedResult( + pageComments, + this.getPageFooterComments.bind(this), + ); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(paginatedPageComments as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** Fetches all inline comments of a page. */ + async getAllPageInlineComments( + parameters: Parameters.GetPageInlineComments, + callback: Callback, + ): Promise; + /** Fetches all inline comments of a page. */ + async getAllPageInlineComments( + parameters: Parameters.GetPageInlineComments, + callback?: never, + ): Promise; + async getAllPageInlineComments( + parameters: Parameters.GetPageInlineComments, + callback?: Callback, + ): Promise { + try { + const { getAll: getAllPageInlineComments } = await this.getPageInlineComments(parameters); + + const pageInlineComments = await getAllPageInlineComments(); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(pageInlineComments as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** + * Returns the root inline comments of specific page. The number of results is limited by the `limit` parameter and + * additional results (if available) will be available through the `next` URL present in the `Link` response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the page + * and its corresponding space. + */ + async getPageInlineComments>( + parameters: Parameters.GetPageInlineComments, + callback: Callback, + ): Promise; + /** + * Returns the root inline comments of specific page. The number of results is limited by the `limit` parameter and + * additional results (if available) will be available through the `next` URL present in the `Link` response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the page + * and its corresponding space. + */ + async getPageInlineComments>( + parameters: Parameters.GetPageInlineComments, + callback?: never, + ): Promise; + async getPageInlineComments>( + parameters: Parameters.GetPageInlineComments, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/pages/${parameters.id}/inline-comments`, + method: 'GET', + params: { + 'body-format': parameters.bodyFormat, + sort: parameters.sort, + cursor: parameters.cursor, + limit: parameters.limit, + 'serialize-ids-as-strings': true, + }, + }; + + try { + const pageInlineComments = await this.client.sendRequest>(config); + const paginatedPageInlineComments = this.paginationService.buildPaginatedResult( + pageInlineComments, + this.getPageInlineComments.bind(this), + ); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(paginatedPageInlineComments as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** Fetches all footer comments of a blog post. */ + async getAllBlogPostFooterComments( + parameters: Parameters.GetBlogPostFooterComments, + callback: Callback, + ): Promise; + /** Fetches all footer comments of a blog post. */ + async getAllBlogPostFooterComments( + parameters: Parameters.GetBlogPostFooterComments, + callback?: never, + ): Promise; + async getAllBlogPostFooterComments( + parameters: Parameters.GetBlogPostFooterComments, + callback?: Callback, + ): Promise { + try { + const { getAll: getAllBlogPostFooterComments } = await this.getBlogPostFooterComments(parameters); + + const blogPostFooterComments = await getAllBlogPostFooterComments(); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(blogPostFooterComments as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** + * Returns the root footer comments of specific blog post. The number of results is limited by the `limit` parameter + * and additional results (if available) will be available through the `next` URL present in the `Link` response + * header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the blog + * post and its corresponding space. + */ + async getBlogPostFooterComments>( + parameters: Parameters.GetBlogPostFooterComments, + callback: Callback, + ): Promise; + /** + * Returns the root footer comments of specific blog post. The number of results is limited by the `limit` parameter + * and additional results (if available) will be available through the `next` URL present in the `Link` response + * header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the blog + * post and its corresponding space. + */ + async getBlogPostFooterComments>( + parameters: Parameters.GetBlogPostFooterComments, + callback?: never, + ): Promise; + async getBlogPostFooterComments>( + parameters: Parameters.GetBlogPostFooterComments, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/blogposts/${parameters.id}/footer-comments`, + method: 'GET', + params: { + 'body-format': parameters.bodyFormat, + sort: parameters.sort, + cursor: parameters.cursor, + limit: parameters.limit, + 'serialize-ids-as-strings': true, + }, + }; + + try { + const blogPostComments = await this.client.sendRequest>(config); + const paginatedBlogPostComments = this.paginationService.buildPaginatedResult( + blogPostComments, + this.getBlogPostFooterComments.bind(this), + ); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(paginatedBlogPostComments as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** Fetches all inline comments of a blog post. */ + async getAllBlogPostInlineComments( + parameters: Parameters.GetBlogPostInlineComments, + callback: Callback, + ): Promise; + /** Fetches all inline comments of a blog post. */ + async getAllBlogPostInlineComments( + parameters: Parameters.GetBlogPostInlineComments, + callback?: never, + ): Promise; + async getAllBlogPostInlineComments( + parameters: Parameters.GetBlogPostInlineComments, + callback?: Callback, + ): Promise { + try { + const { getAll: getAllBlogPostInlineComments } = await this.getBlogPostInlineComments(parameters); + + const blogPostInlineComments = await getAllBlogPostInlineComments(); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(blogPostInlineComments as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** + * Returns the root inline comments of specific blog post. The number of results is limited by the `limit` parameter + * and additional results (if available) will be available through the `next` URL present in the `Link` response + * header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the blog + * post and its corresponding space. + */ + async getBlogPostInlineComments>( + parameters: Parameters.GetBlogPostInlineComments, + callback: Callback, + ): Promise; + /** + * Returns the root inline comments of specific blog post. The number of results is limited by the `limit` parameter + * and additional results (if available) will be available through the `next` URL present in the `Link` response + * header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the blog + * post and its corresponding space. + */ + async getBlogPostInlineComments>( + parameters: Parameters.GetBlogPostInlineComments, + callback?: never, + ): Promise; + async getBlogPostInlineComments>( + parameters: Parameters.GetBlogPostInlineComments, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/blogposts/${parameters.id}/inline-comments`, + method: 'GET', + params: { + 'body-format': parameters.bodyFormat, + sort: parameters.sort, + cursor: parameters.cursor, + limit: parameters.limit, + 'serialize-ids-as-strings': true, + }, + }; + + try { + const blogPostInlineComments = await this.client.sendRequest>( + config, + ); + const paginatedBlogPostInlineComments = this.paginationService.buildPaginatedResult( + blogPostInlineComments, + this.getBlogPostInlineComments.bind(this), + ); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(paginatedBlogPostInlineComments as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** + * Create a footer comment. This can be at the top level (specifying pageId or blogPostId in the request body) or as a + * reply (specifying parentCommentId in the request body). + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the page + * or blogpost and its corresponding space. Permission to create comments in the space. + */ + async createFooterComment( + parameters: Parameters.CreateFooterComment | undefined, + callback: Callback, + ): Promise; + /** + * Create a footer comment. This can be at the top level (specifying pageId or blogPostId in the request body) or as a + * reply (specifying parentCommentId in the request body). + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the page + * or blogpost and its corresponding space. Permission to create comments in the space. + */ + async createFooterComment( + parameters?: Parameters.CreateFooterComment, + callback?: never, + ): Promise; + async createFooterComment( + parameters?: Parameters.CreateFooterComment, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: '/footer-comments', + method: 'POST', + params: { + 'serialize-ids-as-strings': true, + }, + data: { + blogPostId: parameters?.blogPostId, + pageId: parameters?.pageId, + parentCommentId: parameters?.parentCommentId, + body: parameters?.body, + }, + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Retrieves a footer comment by id + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the page + * or blogpost and its corresponding space. + */ + async getFooterCommentById( + parameters: Parameters.GetFooterCommentById, + callback: Callback, + ): Promise; + /** + * Retrieves a footer comment by id + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the page + * or blogpost and its corresponding space. + */ + async getFooterCommentById( + parameters: Parameters.GetFooterCommentById, + callback?: never, + ): Promise; + async getFooterCommentById( + parameters: Parameters.GetFooterCommentById, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/footer-comments/${parameters.commentId}`, + method: 'GET', + params: { + 'body-format': parameters.bodyFormat, + version: parameters.version, + 'serialize-ids-as-strings': true, + }, + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Update a footer comment. This can be used to update the body text of a comment. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the page + * or blogpost and its corresponding space. Permission to create comments in the space. + */ + async updateFooterComment( + parameters: Parameters.UpdateFooterComment, + callback: Callback, + ): Promise; + /** + * Update a footer comment. This can be used to update the body text of a comment. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the page + * or blogpost and its corresponding space. Permission to create comments in the space. + */ + async updateFooterComment( + parameters: Parameters.UpdateFooterComment, + callback?: never, + ): Promise; + async updateFooterComment( + parameters: Parameters.UpdateFooterComment, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/footer-comments/${parameters.commentId}`, + method: 'PUT', + params: { + 'serialize-ids-as-strings': true, + }, + data: { + version: parameters.version, + body: parameters.body, + }, + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Deletes a footer comment. This is a permanent deletion and cannot be reverted. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the page + * or blogpost and its corresponding space. Permission to delete comments in the space. + */ + async deleteFooterComment(parameters: Parameters.DeleteFooterComment, callback: Callback): Promise; + /** + * Deletes a footer comment. This is a permanent deletion and cannot be reverted. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the page + * or blogpost and its corresponding space. Permission to delete comments in the space. + */ + async deleteFooterComment(parameters: Parameters.DeleteFooterComment, callback?: never): Promise; + async deleteFooterComment( + parameters: Parameters.DeleteFooterComment, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/footer-comments/${parameters.commentId}`, + method: 'DELETE', + }; + + return this.client.sendRequest(config, callback); + } + + /** Fetches all children of a footer comment. */ + async getAllFooterCommentChildren( + parameters: Parameters.GetFooterCommentChildren, + callback: Callback, + ): Promise; + /** Fetches all children of a footer comment. */ + async getAllFooterCommentChildren( + parameters: Parameters.GetFooterCommentChildren, + callback?: never, + ): Promise; + async getAllFooterCommentChildren( + parameters: Parameters.GetFooterCommentChildren, + callback?: Callback, + ): Promise { + try { + const { getAll: getAllFooterCommentChildren } = await this.getFooterCommentChildren(parameters); + + const footerCommentChildren = await getAllFooterCommentChildren(); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(footerCommentChildren as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** + * Returns the children footer comments of specific comment. The number of results is limited by the `limit` parameter + * and additional results (if available) will be available through the `next` URL present in the `Link` response + * header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the page + * and its corresponding space. + */ + async getFooterCommentChildren>( + parameters: Parameters.GetFooterCommentChildren, + callback: Callback, + ): Promise; + /** + * Returns the children footer comments of specific comment. The number of results is limited by the `limit` parameter + * and additional results (if available) will be available through the `next` URL present in the `Link` response + * header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the page + * and its corresponding space. + */ + async getFooterCommentChildren>( + parameters: Parameters.GetFooterCommentChildren, + callback?: never, + ): Promise; + async getFooterCommentChildren>( + parameters: Parameters.GetFooterCommentChildren, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/footer-comments/${parameters.id}/children`, + method: 'GET', + params: { + 'body-format': parameters.bodyFormat, + sort: parameters.sort, + cursor: parameters.cursor, + limit: parameters.limit, + 'serialize-ids-as-strings': true, + }, + }; + + try { + const childrenComments = await this.client.sendRequest>(config); + const paginatedChildrenComments = this.paginationService.buildPaginatedResult( + childrenComments, + this.getFooterCommentChildren.bind(this), + ); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(paginatedChildrenComments as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** + * Create an inline comment. This can be at the top level (specifying pageId or blogPostId in the request body) or as + * a reply (specifying parentCommentId in the request body). Note the inlineCommentProperties object in the request + * body is used to select the text the inline comment should be tied to. This is what determines the text highlighting + * when viewing a page in Confluence. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the page + * or blogpost and its corresponding space. Permission to create comments in the space. + */ + async createInlineComment( + parameters: Parameters.CreateInlineComment | undefined, + callback: Callback, + ): Promise; + /** + * Create an inline comment. This can be at the top level (specifying pageId or blogPostId in the request body) or as + * a reply (specifying parentCommentId in the request body). Note the inlineCommentProperties object in the request + * body is used to select the text the inline comment should be tied to. This is what determines the text highlighting + * when viewing a page in Confluence. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the page + * or blogpost and its corresponding space. Permission to create comments in the space. + */ + async createInlineComment( + parameters?: Parameters.CreateInlineComment, + callback?: never, + ): Promise; + async createInlineComment( + parameters?: Parameters.CreateInlineComment, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: '/inline-comments', + method: 'POST', + params: { + 'serialize-ids-as-strings': true, + }, + data: { + blogPostId: parameters?.blogPostId, + pageId: parameters?.pageId, + parentCommentId: parameters?.parentCommentId, + body: parameters?.body, + inlineCommentProperties: parameters?.inlineCommentProperties, + }, + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Retrieves an inline comment by id + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the page + * or blogpost and its corresponding space. + */ + async getInlineCommentById( + parameters: Parameters.GetInlineCommentById, + callback: Callback, + ): Promise; + /** + * Retrieves an inline comment by id + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the page + * or blogpost and its corresponding space. + */ + async getInlineCommentById( + parameters: Parameters.GetInlineCommentById, + callback?: never, + ): Promise; + async getInlineCommentById( + parameters: Parameters.GetInlineCommentById, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/inline-comments/${parameters.commentId}`, + method: 'GET', + params: { + 'body-format': parameters.bodyFormat, + version: parameters.version, + 'serialize-ids-as-strings': true, + }, + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Update an inline comment. This can be used to update the body text of a comment and/or to resolve the comment + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the page + * or blogpost and its corresponding space. Permission to create comments in the space. + */ + async updateInlineComment( + parameters: Parameters.UpdateInlineComment, + callback: Callback, + ): Promise; + /** + * Update an inline comment. This can be used to update the body text of a comment and/or to resolve the comment + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the page + * or blogpost and its corresponding space. Permission to create comments in the space. + */ + async updateInlineComment( + parameters: Parameters.UpdateInlineComment, + callback?: never, + ): Promise; + async updateInlineComment( + parameters: Parameters.UpdateInlineComment, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/inline-comments/${parameters.commentId}`, + method: 'PUT', + params: { + 'serialize-ids-as-strings': true, + }, + data: { + version: parameters.version, + body: parameters.body, + resolved: parameters.resolved, + }, + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Deletes an inline comment. This is a permanent deletion and cannot be reverted. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the page + * or blogpost and its corresponding space. Permission to delete comments in the space. + */ + async deleteInlineComment(parameters: Parameters.DeleteInlineComment, callback: Callback): Promise; + /** + * Deletes an inline comment. This is a permanent deletion and cannot be reverted. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the page + * or blogpost and its corresponding space. Permission to delete comments in the space. + */ + async deleteInlineComment(parameters: Parameters.DeleteInlineComment, callback?: never): Promise; + async deleteInlineComment( + parameters: Parameters.DeleteInlineComment, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/inline-comments/${parameters.commentId}`, + method: 'DELETE', + }; + + return this.client.sendRequest(config, callback); + } + + /** Fetches all children of an inline comment. */ + async getAllInlineCommentChildren( + parameters: Parameters.GetInlineCommentChildren, + callback: Callback, + ): Promise; + /** Fetches all children of an inline comment. */ + async getAllInlineCommentChildren( + parameters: Parameters.GetInlineCommentChildren, + callback?: never, + ): Promise; + async getAllInlineCommentChildren( + parameters: Parameters.GetInlineCommentChildren, + callback?: Callback, + ): Promise { + try { + const { getAll: getAllInlineCommentChildren } = await this.getInlineCommentChildren(parameters); + + const inlineCommentChildren = await getAllInlineCommentChildren(); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(inlineCommentChildren as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** + * Returns the children inline comments of specific comment. The number of results is limited by the `limit` parameter + * and additional results (if available) will be available through the `next` URL present in the `Link` response + * header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the page + * and its corresponding space. + */ + async getInlineCommentChildren>( + parameters: Parameters.GetInlineCommentChildren, + callback: Callback, + ): Promise; + /** + * Returns the children inline comments of specific comment. The number of results is limited by the `limit` parameter + * and additional results (if available) will be available through the `next` URL present in the `Link` response + * header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the page + * and its corresponding space. + */ + async getInlineCommentChildren>( + parameters: Parameters.GetInlineCommentChildren, + callback?: never, + ): Promise; + async getInlineCommentChildren>( + parameters: Parameters.GetInlineCommentChildren, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/inline-comments/${parameters.id}/children`, + method: 'GET', + params: { + 'serialize-ids-as-strings': true, + 'body-format': parameters.bodyFormat, + sort: parameters.sort, + cursor: parameters.cursor, + limit: parameters.limit, + }, + }; + + try { + const inlineCommentChildren = await this.client.sendRequest>( + config, + ); + const paginatedInlineCommentChildren = this.paginationService.buildPaginatedResult( + inlineCommentChildren, + this.getInlineCommentChildren.bind(this), + ); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(paginatedInlineCommentChildren as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } +} diff --git a/src/version2/content.ts b/src/version2/content.ts new file mode 100644 index 00000000..ef30729e --- /dev/null +++ b/src/version2/content.ts @@ -0,0 +1,41 @@ +import * as Models from './models'; +import { Callback } from '../callback'; +import { Client } from '../clients'; +import { RequestConfig } from '../requestConfig'; + +export class Content { + constructor(private client: Client) {} + + /** + * Converts a list of content ids into their associated content types. This is useful for users migrating from v1 to + * v2 who may have stored just content ids without their associated type. This will return types as they should be + * used in v2. Notably, this will return `inline-comment` for inline comments and `footer-comment` for footer + * comments, which is distinct from them both being represented by `comment` in v1. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the requested content. + * Any content that the user does not have permission to view or does not exist will map to `null` in the response. + */ + async convertContentIdsToContentTypes( + callback: Callback, + ): Promise; + /** + * Converts a list of content ids into their associated content types. This is useful for users migrating from v1 to + * v2 who may have stored just content ids without their associated type. This will return types as they should be + * used in v2. Notably, this will return `inline-comment` for inline comments and `footer-comment` for footer + * comments, which is distinct from them both being represented by `comment` in v1. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the requested content. + * Any content that the user does not have permission to view or does not exist will map to `null` in the response. + */ + async convertContentIdsToContentTypes(callback?: never): Promise; + async convertContentIdsToContentTypes( + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: '/content/convert-ids-to-types', + method: 'POST', + }; + + return this.client.sendRequest(config, callback); + } +} diff --git a/src/version2/contentProperties.ts b/src/version2/contentProperties.ts new file mode 100644 index 00000000..974c53d3 --- /dev/null +++ b/src/version2/contentProperties.ts @@ -0,0 +1,939 @@ +import * as Models from './models'; +import * as Parameters from './parameters'; +import { Callback } from '../callback'; +import { Client } from '../clients'; +import { PaginationService } from '../services'; +import { RequestConfig } from '../requestConfig'; + +export class ContentProperties { + private paginationService = new PaginationService(); + + constructor(private client: Client) {} + + /** + * Retrieves all Content Properties tied to a specified attachment. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the attachment. + */ + async getAttachmentContentProperties>( + parameters: Parameters.GetAttachmentContentProperties, + callback: Callback, + ): Promise; + /** + * Retrieves all Content Properties tied to a specified attachment. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the attachment. + */ + async getAttachmentContentProperties>( + parameters: Parameters.GetAttachmentContentProperties, + callback?: never, + ): Promise; + async getAttachmentContentProperties>( + parameters: Parameters.GetAttachmentContentProperties, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/attachments/${parameters.attachmentId}/properties`, + method: 'GET', + params: { + key: parameters.key, + sort: parameters.sort, + cursor: parameters.cursor, + limit: parameters.limit, + 'serialize-ids-as-strings': true, + }, + }; + + try { + const contentProperties = await this.client.sendRequest>(config); + const paginatedContentProperties = this.paginationService.buildPaginatedResult(contentProperties, this.getAttachmentContentProperties.bind(this)); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(paginatedContentProperties as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** + * Creates a new attachment property. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to update the attachment. + */ + async createAttachmentProperty( + parameters: Parameters.CreateAttachmentProperty, + callback: Callback, + ): Promise; + /** + * Creates a new attachment property. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to update the attachment. + */ + async createAttachmentProperty( + parameters: Parameters.CreateAttachmentProperty, + callback?: never, + ): Promise; + async createAttachmentProperty( + parameters: Parameters.CreateAttachmentProperty, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/attachments/${parameters.attachmentId}/properties`, + method: 'POST', + params: { + 'serialize-ids-as-strings': true, + }, + data: { + key: parameters.key, + value: parameters.value, + }, + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Retrieves a specific Content Property by ID that is attached to a specified attachment. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the attachment. + */ + async getAttachmentContentPropertiesById( + parameters: Parameters.GetAttachmentContentPropertiesById, + callback: Callback, + ): Promise; + /** + * Retrieves a specific Content Property by ID that is attached to a specified attachment. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the attachment. + */ + async getAttachmentContentPropertiesById( + parameters: Parameters.GetAttachmentContentPropertiesById, + callback?: never, + ): Promise; + async getAttachmentContentPropertiesById( + parameters: Parameters.GetAttachmentContentPropertiesById, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/attachments/${parameters.attachmentId}/properties/${parameters.propertyId}`, + method: 'GET', + params: { + 'serialize-ids-as-strings': true, + }, + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Update an attachment property by its id. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to edit the attachment. + */ + async updateAttachmentPropertyById( + parameters: Parameters.UpdateAttachmentPropertyById, + callback: Callback, + ): Promise; + /** + * Update an attachment property by its id. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to edit the attachment. + */ + async updateAttachmentPropertyById( + parameters: Parameters.UpdateAttachmentPropertyById, + callback?: never, + ): Promise; + async updateAttachmentPropertyById( + parameters: Parameters.UpdateAttachmentPropertyById, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/attachments/${parameters.attachmentId}/properties/${parameters.propertyId}`, + method: 'PUT', + params: { + 'serialize-ids-as-strings': true, + }, + data: { + key: parameters.key, + value: parameters.value, + version: parameters.version, + }, + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Deletes an attachment property by its id. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to attachment the page. + */ + async deleteAttachmentPropertyById( + parameters: Parameters.DeleteAttachmentPropertyById, + callback: Callback, + ): Promise; + /** + * Deletes a attachment property by its id. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to attachment the page. + */ + async deleteAttachmentPropertyById( + parameters: Parameters.DeleteAttachmentPropertyById, + callback?: never, + ): Promise; + async deleteAttachmentPropertyById( + parameters: Parameters.DeleteAttachmentPropertyById, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/attachments/${parameters.attachmentId}/properties/${parameters.propertyId}`, + method: 'DELETE', + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Retrieves all Content Properties tied to a specified blog post. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the blog post. + */ + async getBlogpostContentProperties>( + parameters: Parameters.GetBlogpostContentProperties, + callback: Callback, + ): Promise; + /** + * Retrieves all Content Properties tied to a specified blog post. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the blog post. + */ + async getBlogpostContentProperties>( + parameters: Parameters.GetBlogpostContentProperties, + callback?: never, + ): Promise; + async getBlogpostContentProperties>( + parameters: Parameters.GetBlogpostContentProperties, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/blogposts/${parameters.blogpostId}/properties`, + method: 'GET', + params: { + key: parameters.key, + sort: parameters.sort, + cursor: parameters.cursor, + limit: parameters.limit, + 'serialize-ids-as-strings': true, + }, + }; + + try { + const contentProperties = await this.client.sendRequest>(config); + const paginatedContentProperties = this.paginationService.buildPaginatedResult(contentProperties, this.getBlogpostContentProperties.bind(this)); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(paginatedContentProperties as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** + * Creates a new blog post property. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to update the blog post. + */ + async createBlogpostProperty( + parameters: Parameters.CreateBlogpostProperty, + callback: Callback, + ): Promise; + /** + * Creates a new blog post property. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to update the blog post. + */ + async createBlogpostProperty( + parameters: Parameters.CreateBlogpostProperty, + callback?: never, + ): Promise; + async createBlogpostProperty( + parameters: Parameters.CreateBlogpostProperty, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/blogposts/${parameters.blogpostId}/properties`, + method: 'POST', + params: { + 'serialize-ids-as-strings': true, + }, + data: { + key: parameters.key, + value: parameters.value, + }, + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Retrieves a specific Content Property by ID that is attached to a specified blog post. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the blog post. + */ + async getBlogpostContentPropertiesById( + parameters: Parameters.GetBlogpostContentPropertiesById, + callback: Callback, + ): Promise; + /** + * Retrieves a specific Content Property by ID that is attached to a specified blog post. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the blog post. + */ + async getBlogpostContentPropertiesById( + parameters: Parameters.GetBlogpostContentPropertiesById, + callback?: never, + ): Promise; + async getBlogpostContentPropertiesById( + parameters: Parameters.GetBlogpostContentPropertiesById, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/blogposts/${parameters.blogpostId}/properties/${parameters.propertyId}`, + method: 'GET', + params: { + 'serialize-ids-as-strings': true, + }, + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Update a blog post property by its id. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to edit the blog post. + */ + async updateBlogpostPropertyById( + parameters: Parameters.UpdateBlogpostPropertyById, + callback: Callback, + ): Promise; + /** + * Update a blog post property by its id. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to edit the blog post. + */ + async updateBlogpostPropertyById( + parameters: Parameters.UpdateBlogpostPropertyById, + callback?: never, + ): Promise; + async updateBlogpostPropertyById( + parameters: Parameters.UpdateBlogpostPropertyById, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/blogposts/${parameters.blogpostId}/properties/${parameters.propertyId}`, + method: 'PUT', + params: { + 'serialize-ids-as-strings': true, + }, + data: { + key: parameters.key, + value: parameters.value, + version: parameters.version, + }, + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Deletes a blog post property by its id. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to edit the blog post. + */ + async deleteBlogpostPropertyById( + parameters: Parameters.DeleteBlogpostPropertyById, + callback: Callback, + ): Promise; + /** + * Deletes a blog post property by its id. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to edit the blog post. + */ + async deleteBlogpostPropertyById( + parameters: Parameters.DeleteBlogpostPropertyById, + callback?: never, + ): Promise; + async deleteBlogpostPropertyById( + parameters: Parameters.DeleteBlogpostPropertyById, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/blogposts/${parameters.blogpostId}/properties/${parameters.propertyId}`, + method: 'DELETE', + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Retrieves Content Properties tied to a specified custom content. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the custom content. + */ + async getCustomContentContentProperties>( + parameters: Parameters.GetCustomContentContentProperties, + callback: Callback, + ): Promise; + /** + * Retrieves Content Properties tied to a specified custom content. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the custom content. + */ + async getCustomContentContentProperties>( + parameters: Parameters.GetCustomContentContentProperties, + callback?: never, + ): Promise; + async getCustomContentContentProperties>( + parameters: Parameters.GetCustomContentContentProperties, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/custom-content/${parameters.customContentId}/properties`, + method: 'GET', + params: { + key: parameters.key, + sort: parameters.sort, + cursor: parameters.cursor, + limit: parameters.limit, + 'serialize-ids-as-strings': true, + }, + }; + + try { + const contentProperties = await this.client.sendRequest>(config); + const paginatedContentProperties = this.paginationService.buildPaginatedResult(contentProperties, this.getCustomContentContentProperties.bind(this)); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(paginatedContentProperties as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** + * Creates a new custom content property. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to update the custom content. + */ + async createCustomContentProperty( + parameters: Parameters.CreateCustomContentProperty, + callback: Callback, + ): Promise; + /** + * Creates a new custom content property. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to update the custom content. + */ + async createCustomContentProperty( + parameters: Parameters.CreateCustomContentProperty, + callback?: never, + ): Promise; + async createCustomContentProperty( + parameters: Parameters.CreateCustomContentProperty, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/custom-content/${parameters.customContentId}/properties`, + method: 'POST', + params: { + 'serialize-ids-as-strings': true, + }, + data: { + key: parameters.key, + value: parameters.value, + }, + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Retrieves a specific Content Property by ID that is attached to a specified custom content. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the page. + */ + async getCustomContentContentPropertiesById( + parameters: Parameters.GetCustomContentContentPropertiesById, + callback: Callback, + ): Promise; + /** + * Retrieves a specific Content Property by ID that is attached to a specified custom content. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the page. + */ + async getCustomContentContentPropertiesById( + parameters: Parameters.GetCustomContentContentPropertiesById, + callback?: never, + ): Promise; + async getCustomContentContentPropertiesById( + parameters: Parameters.GetCustomContentContentPropertiesById, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/custom-content/${parameters.customContentId}/properties/${parameters.propertyId}`, + method: 'GET', + params: { + 'serialize-ids-as-strings': true, + }, + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Update a custom content property by its id. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to edit the custom content. + */ + async updateCustomContentPropertyById( + parameters: Parameters.UpdateCustomContentPropertyById, + callback: Callback, + ): Promise; + /** + * Update a custom content property by its id. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to edit the custom content. + */ + async updateCustomContentPropertyById( + parameters: Parameters.UpdateCustomContentPropertyById, + callback?: never, + ): Promise; + async updateCustomContentPropertyById( + parameters: Parameters.UpdateCustomContentPropertyById, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/custom-content/${parameters.customContentId}/properties/${parameters.propertyId}`, + method: 'PUT', + params: { + 'serialize-ids-as-strings': true, + }, + data: { + key: parameters.key, + value: parameters.value, + version: parameters.version, + }, + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Deletes a custom content property by its id. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to edit the custom content. + */ + async deleteCustomContentPropertyById( + parameters: Parameters.DeleteCustomContentPropertyById, + callback: Callback, + ): Promise; + /** + * Deletes a custom content property by its id. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to edit the custom content. + */ + async deleteCustomContentPropertyById( + parameters: Parameters.DeleteCustomContentPropertyById, + callback?: never, + ): Promise; + async deleteCustomContentPropertyById( + parameters: Parameters.DeleteCustomContentPropertyById, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/custom-content/${parameters.customContentId}/properties/${parameters.propertyId}`, + method: 'DELETE', + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Retrieves Content Properties tied to a specified page. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the page. + */ + async getPageContentProperties>( + parameters: Parameters.GetPageContentProperties, + callback: Callback, + ): Promise; + /** + * Retrieves Content Properties tied to a specified page. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the page. + */ + async getPageContentProperties>( + parameters: Parameters.GetPageContentProperties, + callback?: never, + ): Promise; + async getPageContentProperties>( + parameters: Parameters.GetPageContentProperties, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/pages/${parameters.pageId}/properties`, + method: 'GET', + params: { + key: parameters.key, + sort: parameters.sort, + cursor: parameters.cursor, + limit: parameters.limit, + 'serialize-ids-as-strings': true, + }, + }; + + try { + const contentProperties = await this.client.sendRequest>(config); + const paginatedContentProperties = this.paginationService.buildPaginatedResult(contentProperties, this.getPageContentProperties.bind(this)); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(paginatedContentProperties as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** + * Creates a new page property. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to update the page. + */ + async createPageProperty( + parameters: Parameters.CreatePageProperty, + callback: Callback, + ): Promise; + /** + * Creates a new page property. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to update the page. + */ + async createPageProperty( + parameters: Parameters.CreatePageProperty, + callback?: never, + ): Promise; + async createPageProperty( + parameters: Parameters.CreatePageProperty, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/pages/${parameters.pageId}/properties`, + method: 'POST', + params: { + 'serialize-ids-as-strings': true, + }, + data: { + key: parameters.key, + value: parameters.value, + }, + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Retrieves a specific Content Property by ID that is attached to a specified page. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the page. + */ + async getPageContentPropertiesById( + parameters: Parameters.GetPageContentPropertiesById, + callback: Callback, + ): Promise; + /** + * Retrieves a specific Content Property by ID that is attached to a specified page. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the page. + */ + async getPageContentPropertiesById( + parameters: Parameters.GetPageContentPropertiesById, + callback?: never, + ): Promise; + async getPageContentPropertiesById( + parameters: Parameters.GetPageContentPropertiesById, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/pages/${parameters.pageId}/properties/${parameters.propertyId}`, + method: 'GET', + params: { + 'serialize-ids-as-strings': true, + }, + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Update a page property by its id. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to edit the page. + */ + async updatePagePropertyById( + parameters: Parameters.UpdatePagePropertyById, + callback: Callback, + ): Promise; + /** + * Update a page property by its id. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to edit the page. + */ + async updatePagePropertyById( + parameters: Parameters.UpdatePagePropertyById, + callback?: never, + ): Promise; + async updatePagePropertyById( + parameters: Parameters.UpdatePagePropertyById, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/pages/${parameters.pageId}/properties/${parameters.propertyId}`, + method: 'PUT', + params: { + 'serialize-ids-as-strings': true, + }, + data: { + key: parameters.key, + value: parameters.value, + version: parameters.version, + }, + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Deletes a page property by its id. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to edit the page. + */ + async deletePagePropertyById( + parameters: Parameters.DeletePagePropertyById, + callback: Callback, + ): Promise; + /** + * Deletes a page property by its id. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to edit the page. + */ + async deletePagePropertyById(parameters: Parameters.DeletePagePropertyById, callback?: never): Promise; + async deletePagePropertyById( + parameters: Parameters.DeletePagePropertyById, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/pages/${parameters.pageId}/properties/${parameters.propertyId}`, + method: 'DELETE', + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Retrieves Content Properties attached to a specified comment. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the comment. + */ + async getCommentContentProperties>( + parameters: Parameters.GetCommentContentProperties, + callback: Callback, + ): Promise; + /** + * Retrieves Content Properties attached to a specified comment. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the comment. + */ + async getCommentContentProperties>( + parameters: Parameters.GetCommentContentProperties, + callback?: never, + ): Promise; + async getCommentContentProperties>( + parameters: Parameters.GetCommentContentProperties, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/comments/${parameters.commentId}/properties`, + method: 'GET', + params: { + key: parameters.key, + sort: parameters.sort, + cursor: parameters.cursor, + limit: parameters.limit, + 'serialize-ids-as-strings': true, + }, + }; + + try { + const contentProperties = await this.client.sendRequest>(config); + const paginatedContentProperties = this.paginationService.buildPaginatedResult(contentProperties, this.getCommentContentProperties.bind(this)); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(paginatedContentProperties as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** + * Creates a new comment property. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to update the comment. + */ + async createCommentProperty( + parameters: Parameters.CreateCommentProperty, + callback: Callback, + ): Promise; + /** + * Creates a new comment property. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to update the comment. + */ + async createCommentProperty( + parameters: Parameters.CreateCommentProperty, + callback?: never, + ): Promise; + async createCommentProperty( + parameters: Parameters.CreateCommentProperty, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/comments/${parameters.commentId}/properties`, + method: 'POST', + params: { + 'serialize-ids-as-strings': true, + }, + data: { + key: parameters.key, + value: parameters.value, + }, + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Retrieves a specific Content Property by ID that is attached to a specified comment. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the comment. + */ + async getCommentContentPropertiesById( + parameters: Parameters.GetCommentContentPropertiesById, + callback: Callback, + ): Promise; + /** + * Retrieves a specific Content Property by ID that is attached to a specified comment. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the comment. + */ + async getCommentContentPropertiesById( + parameters: Parameters.GetCommentContentPropertiesById, + callback?: never, + ): Promise; + async getCommentContentPropertiesById( + parameters: Parameters.GetCommentContentPropertiesById, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/comments/${parameters.commentId}/properties/${parameters.propertyId}`, + method: 'GET', + params: { + 'serialize-ids-as-strings': true, + }, + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Update a comment property by its id. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to edit the comment. + */ + async updateCommentPropertyById( + parameters: Parameters.UpdateCommentPropertyById, + callback: Callback, + ): Promise; + /** + * Update a comment property by its id. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to edit the comment. + */ + async updateCommentPropertyById( + parameters: Parameters.UpdateCommentPropertyById, + callback?: never, + ): Promise; + async updateCommentPropertyById( + parameters: Parameters.UpdateCommentPropertyById, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/comments/${parameters.commentId}/properties/${parameters.propertyId}`, + method: 'PUT', + params: { + 'serialize-ids-as-strings': true, + }, + data: { + key: parameters.key, + value: parameters.value, + version: parameters.version, + }, + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Deletes a comment property by its id. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to edit the comment. + */ + async deleteCommentPropertyById( + parameters: Parameters.DeleteCommentPropertyById, + callback: Callback, + ): Promise; + /** + * Deletes a comment property by its id. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to edit the comment. + */ + async deleteCommentPropertyById( + parameters: Parameters.DeleteCommentPropertyById, + callback?: never, + ): Promise; + async deleteCommentPropertyById( + parameters: Parameters.DeleteCommentPropertyById, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/comments/${parameters.commentId}/properties/${parameters.propertyId}`, + method: 'DELETE', + }; + + return this.client.sendRequest(config, callback); + } +} diff --git a/src/version2/customContent.ts b/src/version2/customContent.ts new file mode 100644 index 00000000..1b2dcbca --- /dev/null +++ b/src/version2/customContent.ts @@ -0,0 +1,364 @@ +import * as Models from './models'; +import * as Parameters from './parameters'; +import { Callback } from '../callback'; +import { Client } from '../clients'; +import { PaginationService } from '../services'; +import { RequestConfig } from '../requestConfig'; + +export class CustomContent { + private paginationService = new PaginationService(); + + constructor(private client: Client) {} + + /** + * Returns all custom content for a given type within a given blogpost. The number of results is limited by the + * `limit` parameter and additional results (if available) will be available through the `next` URL present in the + * `Link` response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the custom content, the + * container of the custom content (blog post), and the corresponding space. + */ + async getCustomContentByTypeInBlogPost>( + parameters: Parameters.GetCustomContentByTypeInBlogPost, + callback: Callback, + ): Promise; + /** + * Returns all custom content for a given type within a given blogpost. The number of results is limited by the + * `limit` parameter and additional results (if available) will be available through the `next` URL present in the + * `Link` response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the custom content, the + * container of the custom content (blog post), and the corresponding space. + */ + async getCustomContentByTypeInBlogPost>( + parameters: Parameters.GetCustomContentByTypeInBlogPost, + callback?: never, + ): Promise; + async getCustomContentByTypeInBlogPost>( + parameters: Parameters.GetCustomContentByTypeInBlogPost, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/blogposts/${parameters.id}/custom-content`, + method: 'GET', + params: { + type: parameters.type, + cursor: parameters.cursor, + limit: parameters.limit, + 'body-format': parameters.bodyFormat, + 'serialize-ids-as-strings': true, + }, + }; + + try { + const customContents = await this.client.sendRequest>(config); + const paginatedCustomContents = this.paginationService.buildPaginatedResult(customContents, this.getCustomContentByTypeInBlogPost.bind(this)); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(paginatedCustomContents as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** + * Returns all custom content for a given type. The number of results is limited by the `limit` parameter and + * additional results (if available) will be available through the `next` URL present in the `Link` response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the custom content, the + * container of the custom content, and the corresponding space (if different from the container). + */ + async getCustomContentByType>( + parameters: Parameters.GetCustomContentByType, + callback: Callback, + ): Promise; + /** + * Returns all custom content for a given type. The number of results is limited by the `limit` parameter and + * additional results (if available) will be available through the `next` URL present in the `Link` response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the custom content, the + * container of the custom content, and the corresponding space (if different from the container). + */ + async getCustomContentByType>( + parameters: Parameters.GetCustomContentByType, + callback?: never, + ): Promise; + async getCustomContentByType>( + parameters: Parameters.GetCustomContentByType, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: '/custom-content', + method: 'GET', + params: { + type: parameters.type, + id: parameters.id, + cursor: parameters.cursor, + limit: parameters.limit, + 'body-format': parameters.bodyFormat, + 'serialize-ids-as-strings': true, + }, + }; + + try { + const customContents = await this.client.sendRequest>(config); + const paginatedCustomContents = this.paginationService.buildPaginatedResult(customContents, this.getCustomContentByType.bind(this)); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(paginatedCustomContents as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** + * Creates a new custom content in the given space, page, blogpost or other custom content. + * + * Only one of `spaceId`, `pageId`, `blogPostId`, or `customContentId` is required in the request body. + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the page + * or blogpost and its corresponding space. Permission to create custom content in the space. + */ + async createCustomContent( + parameters: Parameters.CreateCustomContent | undefined, + callback: Callback, + ): Promise; + /** + * Creates a new custom content in the given space, page, blogpost or other custom content. + * + * Only one of `spaceId`, `pageId`, `blogPostId`, or `customContentId` is required in the request body. + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the page + * or blogpost and its corresponding space. Permission to create custom content in the space. + */ + async createCustomContent( + parameters?: Parameters.CreateCustomContent, + callback?: never, + ): Promise; + async createCustomContent( + parameters?: Parameters.CreateCustomContent, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: '/custom-content', + method: 'POST', + params: { + 'serialize-ids-as-strings': true, + }, + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Returns a specific piece of custom content. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the custom content, the + * container of the custom content, and the corresponding space (if different from the container). + */ + async getCustomContentById( + parameters: Parameters.GetCustomContentById, + callback: Callback, + ): Promise; + /** + * Returns a specific piece of custom content. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the custom content, the + * container of the custom content, and the corresponding space (if different from the container). + */ + async getCustomContentById( + parameters: Parameters.GetCustomContentById, + callback?: never, + ): Promise; + async getCustomContentById( + parameters: Parameters.GetCustomContentById, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/custom-content/${parameters.id}`, + method: 'GET', + params: { + 'body-format': parameters.bodyFormat, + version: parameters.version, + 'serialize-ids-as-strings': true, + }, + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Update a custom content by id. + * + * `spaceId` is always required and maximum one of `pageId`, `blogPostId`, or `customContentId` is allowed in the + * request body. **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content + * of the page or blogpost and its corresponding space. Permission to update custom content in the space. + */ + async updateCustomContent( + parameters: Parameters.UpdateCustomContent, + callback: Callback, + ): Promise; + /** + * Update a custom content by id. + * + * `spaceId` is always required and maximum one of `pageId`, `blogPostId`, or `customContentId` is allowed in the + * request body. **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content + * of the page or blogpost and its corresponding space. Permission to update custom content in the space. + */ + async updateCustomContent( + parameters: Parameters.UpdateCustomContent, + callback?: never, + ): Promise; + async updateCustomContent( + parameters: Parameters.UpdateCustomContent, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/custom-content/${parameters.id}`, + method: 'PUT', + params: { + 'serialize-ids-as-strings': true, + }, + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Delete a custom content by id. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the page + * or blogpost and its corresponding space. Permission to delete custom content in the space. + */ + async deleteCustomContent(parameters: Parameters.DeleteCustomContent, callback: Callback): Promise; + /** + * Delete a custom content by id. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the page + * or blogpost and its corresponding space. Permission to delete custom content in the space. + */ + async deleteCustomContent(parameters: Parameters.DeleteCustomContent, callback?: never): Promise; + async deleteCustomContent( + parameters: Parameters.DeleteCustomContent, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/custom-content/${parameters.id}`, + method: 'DELETE', + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Returns all custom content for a given type within a given page. The number of results is limited by the `limit` + * parameter and additional results (if available) will be available through the `next` URL present in the `Link` + * response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the custom content, the + * container of the custom content (page), and the corresponding space. + */ + async getCustomContentByTypeInPage>( + parameters: Parameters.GetCustomContentByTypeInPage, + callback: Callback, + ): Promise; + /** + * Returns all custom content for a given type within a given page. The number of results is limited by the `limit` + * parameter and additional results (if available) will be available through the `next` URL present in the `Link` + * response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the custom content, the + * container of the custom content (page), and the corresponding space. + */ + async getCustomContentByTypeInPage>( + parameters: Parameters.GetCustomContentByTypeInPage, + callback?: never, + ): Promise; + async getCustomContentByTypeInPage>( + parameters: Parameters.GetCustomContentByTypeInPage, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/pages/${parameters.id}/custom-content`, + method: 'GET', + params: { + type: parameters.type, + cursor: parameters.cursor, + limit: parameters.limit, + 'body-format': parameters.bodyFormat, + 'serialize-ids-as-strings': true, + }, + }; + + try { + const customContents = await this.client.sendRequest>(config); + const paginatedCustomContents = this.paginationService.buildPaginatedResult(customContents, this.getCustomContentByTypeInPage.bind(this)); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(paginatedCustomContents as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** + * Returns all custom content for a given type within a given space. The number of results is limited by the `limit` + * parameter and additional results (if available) will be available through the `next` URL present in the `Link` + * response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the custom content and + * the corresponding space. + */ + async getCustomContentByTypeInSpace>( + parameters: Parameters.GetCustomContentByTypeInSpace, + callback: Callback, + ): Promise; + /** + * Returns all custom content for a given type within a given space. The number of results is limited by the `limit` + * parameter and additional results (if available) will be available through the `next` URL present in the `Link` + * response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the custom content and + * the corresponding space. + */ + async getCustomContentByTypeInSpace>( + parameters: Parameters.GetCustomContentByTypeInSpace, + callback?: never, + ): Promise; + async getCustomContentByTypeInSpace>( + parameters: Parameters.GetCustomContentByTypeInSpace, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/spaces/${parameters.id}/custom-content`, + method: 'GET', + params: { + type: parameters.type, + cursor: parameters.cursor, + limit: parameters.limit, + 'body-format': parameters.bodyFormat, + 'serialize-ids-as-strings': true, + }, + }; + + try { + const customContents = await this.client.sendRequest>(config); + const paginatedCustomContents = this.paginationService.buildPaginatedResult(customContents, this.getCustomContentByTypeInSpace.bind(this)); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(paginatedCustomContents as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } +} diff --git a/src/version2/index.ts b/src/version2/index.ts new file mode 100644 index 00000000..bf51f53c --- /dev/null +++ b/src/version2/index.ts @@ -0,0 +1,14 @@ +export * from './attachment'; +export * from './blogPost'; +export * from './children'; +export * from './comment'; +export * from './content'; +export * from './contentProperties'; +export * from './customContent'; +export * from './label'; +export * from './page'; +export * from './space'; +export * from './spaceProperties'; +export * from './task'; +export * from './user'; +export * from './version'; diff --git a/src/version2/label.ts b/src/version2/label.ts new file mode 100644 index 00000000..3883b24c --- /dev/null +++ b/src/version2/label.ts @@ -0,0 +1,222 @@ +import * as Models from './models'; +import * as Parameters from './parameters'; +import { Callback } from '../callback'; +import { Client } from '../clients'; +import { PaginationService } from '../services'; +import { RequestConfig } from '../requestConfig'; + +export class Label { + private paginationService = new PaginationService(); + + constructor(private client: Client) {} + + /** + * Returns the labels of specific attachment. The number of results is limited by the `limit` parameter and additional + * results (if available) will be available through the `next` URL present in the `Link` response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the parent content of the + * attachment and its corresponding space. + */ + async getAttachmentLabels>( + parameters: Parameters.GetAttachmentLabels, + callback: Callback, + ): Promise; + /** + * Returns the labels of specific attachment. The number of results is limited by the `limit` parameter and additional + * results (if available) will be available through the `next` URL present in the `Link` response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the parent content of the + * attachment and its corresponding space. + */ + async getAttachmentLabels>( + parameters: Parameters.GetAttachmentLabels, + callback?: never, + ): Promise; + async getAttachmentLabels>( + parameters: Parameters.GetAttachmentLabels, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/attachments/${parameters.id}/labels`, + method: 'GET', + params: { + prefix: parameters.prefix, + sort: parameters.sort, + cursor: parameters.cursor, + limit: parameters.limit, + 'serialize-ids-as-strings': true, + }, + }; + + try { + const labels = await this.client.sendRequest>(config); + const paginatedLabels = this.paginationService.buildPaginatedResult(labels, this.getAttachmentLabels.bind(this)); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(paginatedLabels as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** + * Returns the labels of specific blog post. The number of results is limited by the `limit` parameter and additional + * results (if available) will be available through the `next` URL present in the `Link` response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the blog + * post and its corresponding space. + */ + async getBlogPostLabels>( + parameters: Parameters.GetBlogPostLabels, + callback: Callback, + ): Promise; + /** + * Returns the labels of specific blog post. The number of results is limited by the `limit` parameter and additional + * results (if available) will be available through the `next` URL present in the `Link` response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the blog + * post and its corresponding space. + */ + async getBlogPostLabels>( + parameters: Parameters.GetBlogPostLabels, + callback?: never, + ): Promise; + async getBlogPostLabels>( + parameters: Parameters.GetBlogPostLabels, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/blogposts/${parameters.id}/labels`, + method: 'GET', + params: { + prefix: parameters.prefix, + sort: parameters.sort, + cursor: parameters.cursor, + limit: parameters.limit, + 'serialize-ids-as-strings': true, + }, + }; + + try { + const labels = await this.client.sendRequest>(config); + const paginatedLabels = this.paginationService.buildPaginatedResult(labels, this.getBlogPostLabels.bind(this)); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(paginatedLabels as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** + * Returns the labels for a specific piece of custom content. The number of results is limited by the `limit` + * parameter and additional results (if available) will be available through the `next` URL present in the `Link` + * response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the custom content and + * its corresponding space. + */ + async getCustomContentLabels>( + parameters: Parameters.GetCustomContentLabels, + callback: Callback, + ): Promise; + /** + * Returns the labels for a specific piece of custom content. The number of results is limited by the `limit` + * parameter and additional results (if available) will be available through the `next` URL present in the `Link` + * response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the custom content and + * its corresponding space. + */ + async getCustomContentLabels>( + parameters: Parameters.GetCustomContentLabels, + callback?: never, + ): Promise; + async getCustomContentLabels>( + parameters: Parameters.GetCustomContentLabels, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/custom-content/${parameters.id}/labels`, + method: 'GET', + params: { + prefix: parameters.prefix, + sort: parameters.sort, + cursor: parameters.cursor, + limit: parameters.limit, + 'serialize-ids-as-strings': true, + }, + }; + + try { + const labels = await this.client.sendRequest>(config); + const paginatedLabels = this.paginationService.buildPaginatedResult(labels, this.getCustomContentLabels.bind(this)); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(paginatedLabels as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** + * Returns the labels of specific page. The number of results is limited by the `limit` parameter and additional + * results (if available) will be available through the `next` URL present in the `Link` response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the page + * and its corresponding space. + */ + async getPageLabels>( + parameters: Parameters.GetPageLabels, + callback: Callback, + ): Promise; + /** + * Returns the labels of specific page. The number of results is limited by the `limit` parameter and additional + * results (if available) will be available through the `next` URL present in the `Link` response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the page + * and its corresponding space. + */ + async getPageLabels>( + parameters: Parameters.GetPageLabels, + callback?: never, + ): Promise; + async getPageLabels>( + parameters: Parameters.GetPageLabels, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/pages/${parameters.id}/labels`, + method: 'GET', + params: { + prefix: parameters.prefix, + sort: parameters.sort, + cursor: parameters.cursor, + limit: parameters.limit, + 'serialize-ids-as-strings': true, + }, + }; + + try { + const labels = await this.client.sendRequest>(config); + const paginatedLabels = this.paginationService.buildPaginatedResult(labels, this.getPageLabels.bind(this)); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(paginatedLabels as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } +} diff --git a/src/version2/models/attachment.ts b/src/version2/models/attachment.ts new file mode 100644 index 00000000..96bb5b2a --- /dev/null +++ b/src/version2/models/attachment.ts @@ -0,0 +1,41 @@ +import { ContentStatus } from './contentStatus'; +import { Version } from './version'; + +export interface Attachment { + /** ID of the attachment. */ + id?: string; + status?: ContentStatus; + /** Title of the comment. */ + title?: string; + /** + * ID of the containing page. + * + * Note: This is only returned if the attachment has a container that is a page. + */ + pageId?: {}; + /** + * ID of the containing blog post. + * + * Note: This is only returned if the attachment has a container that is a blog post. + */ + blogPostId?: {}; + /** + * ID of the containing custom content. + * + * Note: This is only returned if the attachment has a container that is custom content. + */ + customContentId?: {}; + /** Media Type for the attachment. */ + mediaType?: string; + /** Media Type description for the attachment. */ + mediaTypeDescription?: string; + /** Comment for the attachment. */ + comment?: string; + /** File size of the attachment. */ + fileSize?: number; + /** WebUI link of the attachment. */ + webuiLink?: string; + /** Download link of the attachment. */ + downloadLink?: string; + version?: Version; +} diff --git a/src/version2/models/attachmentSortOrder.ts b/src/version2/models/attachmentSortOrder.ts new file mode 100644 index 00000000..a04079e1 --- /dev/null +++ b/src/version2/models/attachmentSortOrder.ts @@ -0,0 +1,5 @@ +/** + * The sort fields for attachments. The default sort direction is ascending. To sort in descending order, append a `-` + * character before the sort field. For example, `fieldName` or `-fieldName`. + */ +export interface AttachmentSortOrder {} diff --git a/src/version2/models/attachmentVersion.ts b/src/version2/models/attachmentVersion.ts new file mode 100644 index 00000000..ac59a4aa --- /dev/null +++ b/src/version2/models/attachmentVersion.ts @@ -0,0 +1,18 @@ +import { VersionedEntity } from './versionedEntity'; + +export interface AttachmentVersion { + /** Date and time when the version was created. In format "YYYY-MM-DDTHH:mm:ss.sssZ". */ + createdAt: string; + /** Message associated with the current version. */ + message: string; + /** The version number. */ + number: number; + /** + * Describes if this version is a minor version. Email notifications and activity stream updates are not created for + * minor versions. + */ + minorEdit: boolean; + /** The account ID of the user who created this version. */ + authorId: string; + attachment: VersionedEntity; +} diff --git a/src/version2/models/blogPost.ts b/src/version2/models/blogPost.ts new file mode 100644 index 00000000..38200cea --- /dev/null +++ b/src/version2/models/blogPost.ts @@ -0,0 +1,19 @@ +import { Body } from './body'; +import { ContentStatus } from './contentStatus'; +import { Version } from './version'; + +export interface BlogPost { + /** ID of the blog post. */ + id?: {}; + status?: ContentStatus; + /** Title of the blog post. */ + title?: string; + /** ID of the space the blog post is in. */ + spaceId?: {}; + /** The account ID of the user who created this blog post originally. */ + authorId?: string; + /** Date and time when the blog post was created. In format "YYYY-MM-DDTHH:mm:ss.sssZ". */ + createdAt?: string; + version?: Version; + body?: Body; +} diff --git a/src/version2/models/blogPostBodyWrite.ts b/src/version2/models/blogPostBodyWrite.ts new file mode 100644 index 00000000..f016d7ea --- /dev/null +++ b/src/version2/models/blogPostBodyWrite.ts @@ -0,0 +1,6 @@ +export interface BlogPostBodyWrite { + /** Type of content representation used for the value field. */ + representation?: string; + /** Body of the blog post, in the format found in the representation field. */ + value?: string; +} diff --git a/src/version2/models/blogPostComment.ts b/src/version2/models/blogPostComment.ts new file mode 100644 index 00000000..29dfcb6f --- /dev/null +++ b/src/version2/models/blogPostComment.ts @@ -0,0 +1,16 @@ +import { Body } from './body'; +import { ContentStatus } from './contentStatus'; +import { Version } from './version'; + +export interface BlogPostComment { + /** ID of the comment. */ + id?: {}; + status?: ContentStatus; + /** Title of the comment. */ + title?: string; + /** ID of the blog post the comment is in. */ + blogPostId?: {}; + version?: Version; + /** Contains representations of the comment's body in different formats. */ + body?: Body; +} diff --git a/src/version2/models/blogPostInlineComment.ts b/src/version2/models/blogPostInlineComment.ts new file mode 100644 index 00000000..ec9276c3 --- /dev/null +++ b/src/version2/models/blogPostInlineComment.ts @@ -0,0 +1,19 @@ +import { Body } from './body'; +import { ContentStatus } from './contentStatus'; +import { InlineCommentProperties } from './inlineCommentProperties'; +import { InlineCommentResolutionStatus } from './inlineCommentResolutionStatus'; +import { Version } from './version'; + +export interface BlogPostInlineComment { + /** ID of the comment. */ + id?: {}; + status?: ContentStatus; + /** Title of the comment. */ + title?: string; + /** ID of the blog post the comment is in. */ + blogPostId?: {}; + version?: Version; + body?: Body; + resolutionStatus?: InlineCommentResolutionStatus; + properties?: InlineCommentProperties; +} diff --git a/src/version2/models/blogPostNestedBodyWrite.ts b/src/version2/models/blogPostNestedBodyWrite.ts new file mode 100644 index 00000000..dc070bb9 --- /dev/null +++ b/src/version2/models/blogPostNestedBodyWrite.ts @@ -0,0 +1,8 @@ +import { BlogPostBodyWrite } from './blogPostBodyWrite'; + +/** Body of the blog post. Only one body format should be specified as the property* for this object, e.g. `storage`. */ +export interface BlogPostNestedBodyWrite { + storage?: BlogPostBodyWrite; + atlasDocFormat?: BlogPostBodyWrite; + wiki?: BlogPostBodyWrite; +} diff --git a/src/version2/models/blogPostSortOrder.ts b/src/version2/models/blogPostSortOrder.ts new file mode 100644 index 00000000..e21eba68 --- /dev/null +++ b/src/version2/models/blogPostSortOrder.ts @@ -0,0 +1,5 @@ +/** + * The sort fields for blog posts. The default sort direction is ascending. To sort in descending order, append a `-` + * character before the sort field. For example, `fieldName` or `-fieldName`. + */ +export interface BlogPostSortOrder {} diff --git a/src/version2/models/blogPostVersion.ts b/src/version2/models/blogPostVersion.ts new file mode 100644 index 00000000..996c59dc --- /dev/null +++ b/src/version2/models/blogPostVersion.ts @@ -0,0 +1,18 @@ +import { VersionedEntity } from './versionedEntity'; + +export interface BlogPostVersion { + /** Date and time when the version was created. In format "YYYY-MM-DDTHH:mm:ss.sssZ". */ + createdAt?: string; + /** Message associated with the current version. */ + message?: string; + /** The version number. */ + number?: number; + /** + * Describes if this version is a minor version. Email notifications and activity stream updates are not created for + * minor versions. + */ + minorEdit?: boolean; + /** The account ID of the user who created this version. */ + authorId?: string; + blogpost?: VersionedEntity; +} diff --git a/src/version2/models/body.ts b/src/version2/models/body.ts new file mode 100644 index 00000000..4f098b51 --- /dev/null +++ b/src/version2/models/body.ts @@ -0,0 +1,7 @@ +import { BodyType } from './bodyType'; + +/** Contains fields for each representation type requested. */ +export interface Body { + storage?: BodyType; + atlasDocFormat?: BodyType; +} diff --git a/src/version2/models/bodyRepresentation.ts b/src/version2/models/bodyRepresentation.ts new file mode 100644 index 00000000..f00f4316 --- /dev/null +++ b/src/version2/models/bodyRepresentation.ts @@ -0,0 +1,2 @@ +/** The formats a body can be represented as. */ +export interface BodyRepresentation {} diff --git a/src/version2/models/bodyType.ts b/src/version2/models/bodyType.ts new file mode 100644 index 00000000..3f5fc8e2 --- /dev/null +++ b/src/version2/models/bodyType.ts @@ -0,0 +1,6 @@ +export interface BodyType { + /** Type of content representation used for the value field. */ + representation: string; + /** Body of the content, in the format found in the representation field. */ + value: string; +} diff --git a/src/version2/models/checkAccessByEmail.ts b/src/version2/models/checkAccessByEmail.ts new file mode 100644 index 00000000..ade9ed3c --- /dev/null +++ b/src/version2/models/checkAccessByEmail.ts @@ -0,0 +1,6 @@ +export interface CheckAccessByEmail { + /** List of emails that do not have access to site. */ + emailsWithoutAccess?: string[]; + /** List of invalid emails provided in the request. */ + invalidEmails?: string[]; +} diff --git a/src/version2/models/childCustomContent.ts b/src/version2/models/childCustomContent.ts new file mode 100644 index 00000000..0e40fa3d --- /dev/null +++ b/src/version2/models/childCustomContent.ts @@ -0,0 +1,13 @@ +import { OnlyArchivedAndCurrentContentStatus } from './onlyArchivedAndCurrentContentStatus'; + +export interface ChildCustomContent { + /** ID of the child custom content. */ + id?: {}; + status?: OnlyArchivedAndCurrentContentStatus; + /** Title of the custom content. */ + title?: string; + /** Custom content type. */ + type?: string; + /** ID of the space the custom content is in. */ + spaceId?: {}; +} diff --git a/src/version2/models/childCustomContentSortOrder.ts b/src/version2/models/childCustomContentSortOrder.ts new file mode 100644 index 00000000..19b88ed6 --- /dev/null +++ b/src/version2/models/childCustomContentSortOrder.ts @@ -0,0 +1,5 @@ +/** + * The sort fields for child custom content. The default sort direction is ascending by id. To sort in descending order, + * append a `-` character before the sort field. For example, `fieldName` or `-fieldName`. + */ +export interface ChildCustomContentSortOrder {} diff --git a/src/version2/models/childPage.ts b/src/version2/models/childPage.ts new file mode 100644 index 00000000..210a7dd3 --- /dev/null +++ b/src/version2/models/childPage.ts @@ -0,0 +1,13 @@ +import { OnlyArchivedAndCurrentContentStatus } from './onlyArchivedAndCurrentContentStatus'; + +export interface ChildPage { + /** ID of the page. */ + id?: {}; + status?: OnlyArchivedAndCurrentContentStatus; + /** Title of the page. */ + title?: string; + /** ID of the space the page is in. */ + spaceId?: {}; + /** Position of child page within the given parent page tree. */ + childPosition?: number; +} diff --git a/src/version2/models/childPageSortOrder.ts b/src/version2/models/childPageSortOrder.ts new file mode 100644 index 00000000..cc723024 --- /dev/null +++ b/src/version2/models/childPageSortOrder.ts @@ -0,0 +1,5 @@ +/** + * The sort fields for child pages. The default sort direction is ascending by child-position. To sort in descending + * order, append a `-` character before the sort field. For example, `fieldName` or `-fieldName`. + */ +export interface ChildPageSortOrder {} diff --git a/src/version2/models/childrenComment.ts b/src/version2/models/childrenComment.ts new file mode 100644 index 00000000..62568604 --- /dev/null +++ b/src/version2/models/childrenComment.ts @@ -0,0 +1,15 @@ +import { Body } from './body'; +import { ContentStatus } from './contentStatus'; +import { Version } from './version'; + +export interface ChildrenComment { + /** ID of the comment. */ + id?: {}; + status?: ContentStatus; + /** Title of the comment. */ + title?: string; + /** ID of the parent comment the child comment is in. */ + parentCommentId?: {}; + version?: Version; + body?: Body; +} diff --git a/src/version2/models/commentBodyWrite.ts b/src/version2/models/commentBodyWrite.ts new file mode 100644 index 00000000..0e55ece2 --- /dev/null +++ b/src/version2/models/commentBodyWrite.ts @@ -0,0 +1,6 @@ +export interface CommentBodyWrite { + /** Type of content representation used for the value field. */ + representation?: string; + /** Body of the comment, in the format found in the representation field. */ + value?: string; +} diff --git a/src/version2/models/commentNestedBodyWrite.ts b/src/version2/models/commentNestedBodyWrite.ts new file mode 100644 index 00000000..2286b8b2 --- /dev/null +++ b/src/version2/models/commentNestedBodyWrite.ts @@ -0,0 +1,8 @@ +import { CommentBodyWrite } from './commentBodyWrite'; + +/** Body of the comment. Only one body format should be specified as the property* for this object, e.g. `storage`. */ +export interface CommentNestedBodyWrite { + storage?: CommentBodyWrite; + atlasDocFormat?: CommentBodyWrite; + wiki?: CommentBodyWrite; +} diff --git a/src/version2/models/commentSortOrder.ts b/src/version2/models/commentSortOrder.ts new file mode 100644 index 00000000..98ac595d --- /dev/null +++ b/src/version2/models/commentSortOrder.ts @@ -0,0 +1,5 @@ +/** + * The sort fields for comments. The default sort direction is ascending. To sort in descending order, append a `-` + * character before the sort field. For example, `fieldName` or `-fieldName`. + */ +export interface CommentSortOrder {} diff --git a/src/version2/models/commentVersion.ts b/src/version2/models/commentVersion.ts new file mode 100644 index 00000000..f4ddd245 --- /dev/null +++ b/src/version2/models/commentVersion.ts @@ -0,0 +1,18 @@ +import { VersionedEntity } from './versionedEntity'; + +export interface CommentVersion { + /** Date and time when the version was created. In format "YYYY-MM-DDTHH:mm:ss.sssZ". */ + createdAt?: string; + /** Message associated with the current version. */ + message?: string; + /** The version number. */ + number?: number; + /** + * Describes if this version is a minor version. Email notifications and activity stream updates are not created for + * minor versions. + */ + minorEdit?: boolean; + /** The account ID of the user who created this version. */ + authorId?: string; + comment?: VersionedEntity; +} diff --git a/src/version2/models/contentIdToContentTypeResponse.ts b/src/version2/models/contentIdToContentTypeResponse.ts new file mode 100644 index 00000000..c3f07887 --- /dev/null +++ b/src/version2/models/contentIdToContentTypeResponse.ts @@ -0,0 +1,8 @@ +export interface ContentIdToContentTypeResponse { + /** + * JSON object containing all requested content ids as keys and their associated content types as the values. + * Duplicate content ids in the request will be returned under a single key in the response. For built-in content + * types, the enumerations are as specified. Custom content ids will be mapped to their associated type. + */ + results?: {}; +} diff --git a/src/version2/models/contentProperty.ts b/src/version2/models/contentProperty.ts new file mode 100644 index 00000000..b7ddc94e --- /dev/null +++ b/src/version2/models/contentProperty.ts @@ -0,0 +1,11 @@ +import { Version } from './version'; + +export interface ContentProperty { + /** ID of the property */ + id: string; + /** Key of the property */ + key: string; + /** Value of the property. Must be a valid JSON value. */ + value: any; + version: Version; +} diff --git a/src/version2/models/contentPropertyCreateRequest.ts b/src/version2/models/contentPropertyCreateRequest.ts new file mode 100644 index 00000000..70a23c0b --- /dev/null +++ b/src/version2/models/contentPropertyCreateRequest.ts @@ -0,0 +1,7 @@ +export interface ContentPropertyCreateRequest { + attachmentId: string; + /** Key of the content property */ + key: string; + /** Value of the content property. */ + value: any; +} diff --git a/src/version2/models/contentPropertySortOrder.ts b/src/version2/models/contentPropertySortOrder.ts new file mode 100644 index 00000000..9696d842 --- /dev/null +++ b/src/version2/models/contentPropertySortOrder.ts @@ -0,0 +1,5 @@ +/** + * The sort fields for content properties. The default sort direction is ascending. To sort in descending order, append + * a `-` character before the sort field. For example, `fieldName` or `-fieldName`. + */ +export interface ContentPropertySortOrder {} diff --git a/src/version2/models/contentPropertyUpdateRequest.ts b/src/version2/models/contentPropertyUpdateRequest.ts new file mode 100644 index 00000000..3ce59555 --- /dev/null +++ b/src/version2/models/contentPropertyUpdateRequest.ts @@ -0,0 +1,13 @@ +export interface ContentPropertyUpdateRequest { + /** Key of the content property */ + key: string; + /** Value of the content property. */ + value: any; + /** New version number and associated message */ + version?: { + /** Version number of the new version. Should be 1 more than the current version number. */ + number?: number; + /** Message to be associated with the new version. */ + message?: string; + }; +} diff --git a/src/version2/models/contentStatus.ts b/src/version2/models/contentStatus.ts new file mode 100644 index 00000000..ba15d07b --- /dev/null +++ b/src/version2/models/contentStatus.ts @@ -0,0 +1,2 @@ +/** The status of the content. */ +export interface ContentStatus {} diff --git a/src/version2/models/customContent.ts b/src/version2/models/customContent.ts new file mode 100644 index 00000000..ed461180 --- /dev/null +++ b/src/version2/models/customContent.ts @@ -0,0 +1,43 @@ +import { ContentStatus } from './contentStatus'; +import { CustomContentBody } from './customContentBody'; +import { Version } from './version'; + +export interface CustomContent { + /** ID of the custom content. */ + id?: {}; + /** The type of custom content. */ + type?: string; + status?: ContentStatus; + /** Title of the custom content. */ + title?: string; + /** + * ID of the space the custom content is in. + * + * Note: This is always returned, regardless of if the custom content has a container that is a space. + */ + spaceId?: {}; + /** + * ID of the containing page. + * + * Note: This is only returned if the custom content has a container that is a page. + */ + pageId?: {}; + /** + * ID of the containing blog post. + * + * Note: This is only returned if the custom content has a container that is a blog post. + */ + blogPostId?: {}; + /** + * ID of the containing custom content. + * + * Note: This is only returned if the custom content has a container that is custom content. + */ + customContentId?: {}; + /** The account ID of the user who created this custom content originally. */ + authorId?: string; + /** Date and time when the custom content was created. In format "YYYY-MM-DDTHH:mm:ss.sssZ". */ + createdAt?: string; + body?: CustomContentBody; + version?: Version; +} diff --git a/src/version2/models/customContentBody.ts b/src/version2/models/customContentBody.ts new file mode 100644 index 00000000..0b9fd065 --- /dev/null +++ b/src/version2/models/customContentBody.ts @@ -0,0 +1,8 @@ +import { BodyType } from './bodyType'; + +/** Contains fields for each representation type requested. */ +export interface CustomContentBody { + raw?: BodyType; + storage?: BodyType; + atlasDocFormat?: BodyType; +} diff --git a/src/version2/models/customContentBodyRepresentation.ts b/src/version2/models/customContentBodyRepresentation.ts new file mode 100644 index 00000000..aa9c93fd --- /dev/null +++ b/src/version2/models/customContentBodyRepresentation.ts @@ -0,0 +1,2 @@ +/** The formats a custom content body can be represented as. A subset of BodyRepresentation. */ +export interface CustomContentBodyRepresentation {} diff --git a/src/version2/models/customContentBodyWrite.ts b/src/version2/models/customContentBodyWrite.ts new file mode 100644 index 00000000..4a603007 --- /dev/null +++ b/src/version2/models/customContentBodyWrite.ts @@ -0,0 +1,6 @@ +export interface CustomContentBodyWrite { + /** Type of content representation used for the value field. */ + representation?: string; + /** Body of the custom content, in the format found in the representation field. */ + value?: string; +} diff --git a/src/version2/models/customContentNestedBodyWrite.ts b/src/version2/models/customContentNestedBodyWrite.ts new file mode 100644 index 00000000..9c64a9e3 --- /dev/null +++ b/src/version2/models/customContentNestedBodyWrite.ts @@ -0,0 +1,11 @@ +import { CustomContentBodyWrite } from './customContentBodyWrite'; + +/** + * Body of the custom content. Only one body format should be specified as the property* for this object, e.g. + * `storage`. + */ +export interface CustomContentNestedBodyWrite { + storage?: CustomContentBodyWrite; + atlasDocFormat?: CustomContentBodyWrite; + raw?: CustomContentBodyWrite; +} diff --git a/src/version2/models/customContentVersion.ts b/src/version2/models/customContentVersion.ts new file mode 100644 index 00000000..58c105d2 --- /dev/null +++ b/src/version2/models/customContentVersion.ts @@ -0,0 +1,18 @@ +import { VersionedEntity } from './versionedEntity'; + +export interface CustomContentVersion { + /** Date and time when the version was created. In format "YYYY-MM-DDTHH:mm:ss.sssZ". */ + createdAt?: string; + /** Message associated with the current version. */ + message?: string; + /** The version number. */ + number?: number; + /** + * Describes if this version is a minor version. Email notifications and activity stream updates are not created for + * minor versions. + */ + minorEdit?: boolean; + /** The account ID of the user who created this version. */ + authorId?: string; + custom?: VersionedEntity; +} diff --git a/src/version2/models/detailedVersion.ts b/src/version2/models/detailedVersion.ts new file mode 100644 index 00000000..41969372 --- /dev/null +++ b/src/version2/models/detailedVersion.ts @@ -0,0 +1,23 @@ +export interface DetailedVersion { + /** The current version number. */ + number?: number; + /** The account ID of the user who created this version. */ + authorId?: string; + /** Message associated with the current version. */ + message?: string; + /** Date and time when the version was created. In format "YYYY-MM-DDTHH:mm:ss.sssZ". */ + createdAt?: string; + /** + * Describes if this version is a minor version. Email notifications and activity stream updates are not created for + * minor versions. + */ + minorEdit?: boolean; + /** Describes if the content type is modified in this version (e.g. page to blog) */ + contentTypeModified?: boolean; + /** The account IDs of users that collaborated on this version. */ + collaborators?: string[]; + /** The version number of the version prior to this current content update. */ + prevVersion?: number; + /** The version number of the version after this current content update. */ + nextVersion?: number; +} diff --git a/src/version2/models/footerCommentModel.ts b/src/version2/models/footerCommentModel.ts new file mode 100644 index 00000000..d825fbbd --- /dev/null +++ b/src/version2/models/footerCommentModel.ts @@ -0,0 +1,19 @@ +import { Body } from './body'; +import { ContentStatus } from './contentStatus'; +import { Version } from './version'; + +export interface FooterCommentModel { + /** ID of the comment. */ + id?: {}; + status?: ContentStatus; + /** Title of the comment. */ + title?: string; + /** ID of the blog post containing the comment if the comment is on a blog post. */ + blogPostId?: {}; + /** ID of the page containing the comment if the comment is on a page. */ + pageId?: {}; + /** ID of the parent comment if the comment is a reply. */ + parentCommentId?: {}; + version?: Version; + body?: Body; +} diff --git a/src/version2/models/index.ts b/src/version2/models/index.ts new file mode 100644 index 00000000..726a0d61 --- /dev/null +++ b/src/version2/models/index.ts @@ -0,0 +1,66 @@ +export * from './attachment'; +export * from './attachmentSortOrder'; +export * from './attachmentVersion'; +export * from './blogPost'; +export * from './blogPostBodyWrite'; +export * from './blogPostComment'; +export * from './blogPostInlineComment'; +export * from './blogPostNestedBodyWrite'; +export * from './blogPostSortOrder'; +export * from './blogPostVersion'; +export * from './spaceDescriptionFormat'; +export * from './body'; +export * from './bodyRepresentation'; +export * from './bodyType'; +export * from './checkAccessByEmail'; +export * from './childCustomContent'; +export * from './childCustomContentSortOrder'; +export * from './childPage'; +export * from './childPageSortOrder'; +export * from './childrenComment'; +export * from './commentBodyWrite'; +export * from './commentNestedBodyWrite'; +export * from './commentSortOrder'; +export * from './commentVersion'; +export * from './contentIdToContentTypeResponse'; +export * from './contentProperty'; +export * from './contentPropertyCreateRequest'; +export * from './contentPropertySortOrder'; +export * from './contentPropertyUpdateRequest'; +export * from './contentStatus'; +export * from './customContent'; +export * from './customContentBody'; +export * from './customContentBodyRepresentation'; +export * from './customContentBodyWrite'; +export * from './customContentNestedBodyWrite'; +export * from './customContentVersion'; +export * from './detailedVersion'; +export * from './footerCommentModel'; +export * from './inlineCommentChildren'; +export * from './inlineCommentModel'; +export * from './inlineCommentProperties'; +export * from './inlineCommentResolutionStatus'; +export * from './inviteByEmail'; +export * from './label'; +export * from './labelSortOrder'; +export * from './onlyArchivedAndCurrentContentStatus'; +export * from './page'; +export * from './pageBodyWrite'; +export * from './pageComment'; +export * from './pageInlineComment'; +export * from './pageNestedBodyWrite'; +export * from './pageSortOrder'; +export * from './pageVersion'; +export * from './pagination'; +export * from './primaryBodyRepresentation'; +export * from './space'; +export * from './spaceDescription'; +export * from './spaceDescriptionBodyRepresentation'; +export * from './spaceProperty'; +export * from './spaceSortOrder'; +export * from './spaceStatus'; +export * from './spaceType'; +export * from './task'; +export * from './version'; +export * from './versionedEntity'; +export * from './versionSortOrder'; diff --git a/src/version2/models/inlineCommentChildren.ts b/src/version2/models/inlineCommentChildren.ts new file mode 100644 index 00000000..ab07391d --- /dev/null +++ b/src/version2/models/inlineCommentChildren.ts @@ -0,0 +1,18 @@ +import { Body } from './body'; +import { InlineCommentProperties } from './inlineCommentProperties'; +import { InlineCommentResolutionStatus } from './inlineCommentResolutionStatus'; +import { Version } from './version'; + +export interface InlineCommentChildren { + /** ID of the comment. */ + id?: {}; + status: 'current' | 'trashed' | 'historical' | 'deleted' | 'any' | 'draft' | 'archived' | string; + /** Title of the comment. */ + title?: string; + /** ID of the parent comment the child comment is in. */ + parentCommentId?: {}; + version?: Version; + body?: Body; + resolutionStatus?: InlineCommentResolutionStatus; + properties?: InlineCommentProperties; +} diff --git a/src/version2/models/inlineCommentModel.ts b/src/version2/models/inlineCommentModel.ts new file mode 100644 index 00000000..e6a8ea63 --- /dev/null +++ b/src/version2/models/inlineCommentModel.ts @@ -0,0 +1,30 @@ +import { Body } from './body'; +import { ContentStatus } from './contentStatus'; +import { InlineCommentProperties } from './inlineCommentProperties'; +import { InlineCommentResolutionStatus } from './inlineCommentResolutionStatus'; +import { Version } from './version'; + +export interface InlineCommentModel { + /** ID of the comment. */ + id?: {}; + status?: ContentStatus; + /** Title of the comment. */ + title?: string; + /** ID of the blog post containing the comment if the comment is on a blog post. */ + blogPostId?: {}; + /** ID of the page containing the comment if the comment is on a page. */ + pageId?: {}; + /** ID of the parent comment if the comment is a reply. */ + parentCommentId?: {}; + version?: Version; + body?: Body; + /** + * Atlassian Account ID of the last person who modified the resolve state of the comment. Null until comment is + * resolved or reopened. + */ + resolutionLastModifierId?: string; + /** Timestamp of the last modification to the comment's resolution status. Null until comment is resolved or reopened. */ + resolutionLastModifiedAt?: string; + resolutionStatus?: InlineCommentResolutionStatus; + properties?: InlineCommentProperties; +} diff --git a/src/version2/models/inlineCommentProperties.ts b/src/version2/models/inlineCommentProperties.ts new file mode 100644 index 00000000..5baa2132 --- /dev/null +++ b/src/version2/models/inlineCommentProperties.ts @@ -0,0 +1,6 @@ +export interface InlineCommentProperties { + /** Property value used to reference the highlighted element in DOM. */ + 'inline-marker-ref'?: string; + /** Text that is highlighted */ + 'inline-original-selection'?: string; +} diff --git a/src/version2/models/inlineCommentResolutionStatus.ts b/src/version2/models/inlineCommentResolutionStatus.ts new file mode 100644 index 00000000..799fa855 --- /dev/null +++ b/src/version2/models/inlineCommentResolutionStatus.ts @@ -0,0 +1,2 @@ +/** Inline comment resolution status */ +export interface InlineCommentResolutionStatus {} diff --git a/src/version2/models/inviteByEmail.ts b/src/version2/models/inviteByEmail.ts new file mode 100644 index 00000000..ce04206a --- /dev/null +++ b/src/version2/models/inviteByEmail.ts @@ -0,0 +1,11 @@ +export interface InviteByEmail { + /** List of emails invited to the site. */ + emailsInvited?: string[]; + /** List of invalid emails provided in the request. */ + emailsNotInvited?: { + /** Email that was not invited. */ + key?: string; + /** Reason why the email was not invited. */ + value?: string; + }; +} diff --git a/src/version2/models/label.ts b/src/version2/models/label.ts new file mode 100644 index 00000000..15e40830 --- /dev/null +++ b/src/version2/models/label.ts @@ -0,0 +1,8 @@ +export interface Label { + /** ID of the label. */ + id?: {}; + /** Name of the label. */ + name?: string; + /** Prefix of the label. */ + prefix?: string; +} diff --git a/src/version2/models/labelSortOrder.ts b/src/version2/models/labelSortOrder.ts new file mode 100644 index 00000000..64376ca4 --- /dev/null +++ b/src/version2/models/labelSortOrder.ts @@ -0,0 +1,5 @@ +/** + * The sort fields for labels. The default sort direction is ascending. To sort in descending order, append a `-` + * character before the sort field. For example, `fieldName` or `-fieldName`. + */ +export interface LabelSortOrder {} diff --git a/src/version2/models/links.ts b/src/version2/models/links.ts new file mode 100644 index 00000000..0171b668 --- /dev/null +++ b/src/version2/models/links.ts @@ -0,0 +1,7 @@ +export interface Links { + /** + * Used for pagination. Contains the relative URL for the next set of results, using a cursor query parameter. This + * property will not be present if there is no additional data available. + */ + next?: string; +} diff --git a/src/version2/models/onlyArchivedAndCurrentContentStatus.ts b/src/version2/models/onlyArchivedAndCurrentContentStatus.ts new file mode 100644 index 00000000..25bf4d8f --- /dev/null +++ b/src/version2/models/onlyArchivedAndCurrentContentStatus.ts @@ -0,0 +1,2 @@ +/** The status of the content. */ +export interface OnlyArchivedAndCurrentContentStatus {} diff --git a/src/version2/models/page.ts b/src/version2/models/page.ts new file mode 100644 index 00000000..34ec90e2 --- /dev/null +++ b/src/version2/models/page.ts @@ -0,0 +1,21 @@ +import { Body } from './body'; +import { ContentStatus } from './contentStatus'; +import { Version } from './version'; + +export interface Page { + /** ID of the page. */ + id?: {}; + status?: ContentStatus; + /** Title of the page. */ + title?: string; + /** ID of the space the page is in. */ + spaceId?: {}; + /** ID of the parent page, or null if there is no parent page. */ + parentId?: {}; + /** The account ID of the user who created this page originally. */ + authorId?: string; + /** Date and time when the page was created. In format "YYYY-MM-DDTHH:mm:ss.sssZ". */ + createdAt?: string; + version?: Version; + body?: Body; +} diff --git a/src/version2/models/pageBodyWrite.ts b/src/version2/models/pageBodyWrite.ts new file mode 100644 index 00000000..e9e702ca --- /dev/null +++ b/src/version2/models/pageBodyWrite.ts @@ -0,0 +1,6 @@ +export interface PageBodyWrite { + /** Type of content representation used for the value field. */ + representation?: string; + /** Body of the page, in the format found in the representation field. */ + value?: string; +} diff --git a/src/version2/models/pageComment.ts b/src/version2/models/pageComment.ts new file mode 100644 index 00000000..0abde37d --- /dev/null +++ b/src/version2/models/pageComment.ts @@ -0,0 +1,15 @@ +import { Body } from './body'; +import { ContentStatus } from './contentStatus'; +import { Version } from './version'; + +export interface PageComment { + /** ID of the comment. */ + id?: {}; + status?: ContentStatus; + /** Title of the comment. */ + title?: string; + /** ID of the page the comment is in. */ + pageId?: {}; + version?: Version; + body?: Body; +} diff --git a/src/version2/models/pageInlineComment.ts b/src/version2/models/pageInlineComment.ts new file mode 100644 index 00000000..e37997ac --- /dev/null +++ b/src/version2/models/pageInlineComment.ts @@ -0,0 +1,19 @@ +import { Body } from './body'; +import { ContentStatus } from './contentStatus'; +import { InlineCommentProperties } from './inlineCommentProperties'; +import { InlineCommentResolutionStatus } from './inlineCommentResolutionStatus'; +import { Version } from './version'; + +export interface PageInlineComment { + /** ID of the comment. */ + id?: {}; + status?: ContentStatus; + /** Title of the comment. */ + title?: string; + /** ID of the page the comment is in. */ + pageId?: {}; + version?: Version; + body?: Body; + resolutionStatus?: InlineCommentResolutionStatus; + properties?: InlineCommentProperties; +} diff --git a/src/version2/models/pageNestedBodyWrite.ts b/src/version2/models/pageNestedBodyWrite.ts new file mode 100644 index 00000000..72680ba4 --- /dev/null +++ b/src/version2/models/pageNestedBodyWrite.ts @@ -0,0 +1,8 @@ +import { PageBodyWrite } from './pageBodyWrite'; + +/** Body of the page. Only one body format should be specified as the property* for this object, e.g. `storage`. */ +export interface PageNestedBodyWrite { + storage?: PageBodyWrite; + atlasDocFormat?: PageBodyWrite; + wiki?: PageBodyWrite; +} diff --git a/src/version2/models/pageSortOrder.ts b/src/version2/models/pageSortOrder.ts new file mode 100644 index 00000000..db9a0ec0 --- /dev/null +++ b/src/version2/models/pageSortOrder.ts @@ -0,0 +1,5 @@ +/** + * The sort fields for pages. The default sort direction is ascending. To sort in descending order, append a `-` + * character before the sort field. For example, `fieldName` or `-fieldName`. + */ +export interface PageSortOrder {} diff --git a/src/version2/models/pageVersion.ts b/src/version2/models/pageVersion.ts new file mode 100644 index 00000000..ce5b46f4 --- /dev/null +++ b/src/version2/models/pageVersion.ts @@ -0,0 +1,18 @@ +import { VersionedEntity } from './versionedEntity'; + +export interface PageVersion { + /** Date and time when the version was created. In format "YYYY-MM-DDTHH:mm:ss.sssZ". */ + createdAt: string; + /** Message associated with the current version. */ + message: string; + /** The version number. */ + number: number; + /** + * Describes if this version is a minor version. Email notifications and activity stream updates are not created for + * minor versions. + */ + minorEdit: boolean; + /** The account ID of the user who created this version. */ + authorId: string; + page: VersionedEntity; +} diff --git a/src/version2/models/pagination.ts b/src/version2/models/pagination.ts new file mode 100644 index 00000000..8a901557 --- /dev/null +++ b/src/version2/models/pagination.ts @@ -0,0 +1,10 @@ +import { Links } from './links'; + +export interface Pagination { + results: T[]; + parameters: Record; + hasNext: boolean; + next: () => Promise>; + getAll: () => Promise; + _links: Links; +} diff --git a/src/version2/models/primaryBodyRepresentation.ts b/src/version2/models/primaryBodyRepresentation.ts new file mode 100644 index 00000000..6e699989 --- /dev/null +++ b/src/version2/models/primaryBodyRepresentation.ts @@ -0,0 +1,8 @@ +/** + * The primary formats a body can be represented as. A subset of BodyRepresentation. These formats are the only allowed + * formats in certain use cases. + */ +export interface PrimaryBodyRepresentation { + storage?: any; + atlas_doc_format?: any; +} diff --git a/src/version2/models/space.ts b/src/version2/models/space.ts new file mode 100644 index 00000000..06e3f963 --- /dev/null +++ b/src/version2/models/space.ts @@ -0,0 +1,30 @@ +import { SpaceDescription } from './spaceDescription'; +import { SpaceStatus } from './spaceStatus'; +import { SpaceType } from './spaceType'; + +export interface Space { + /** ID of the space. */ + id: string; + /** Key of the space. */ + key: string; + /** Name of the space. */ + name: string; + /** + * The type of the space, which determines its purpose and functionality. For example, it might be `personal` or + * `global`. + */ + type: SpaceType; + /** The current status of the space, for example, `current`, `archived`. */ + status: SpaceStatus; + /** ID of the space's homepage. */ + homepageId: string; + /** The description of the space. Currently set to null, but might be used for additional information in the future. */ + description: SpaceDescription | null; + /** + * The icon associated with the space. Currently set to null, but might be used to set a custom space icon in the + * future. + */ + icon: null; + /** The timestamp indicating when the space was created. */ + createdAt: string; // todo make type a Date +} diff --git a/src/version2/models/spaceDescription.ts b/src/version2/models/spaceDescription.ts new file mode 100644 index 00000000..527925ee --- /dev/null +++ b/src/version2/models/spaceDescription.ts @@ -0,0 +1,7 @@ +import { BodyType } from './bodyType'; + +/** Contains fields for each representation type requested. */ +export interface SpaceDescription { + plain: BodyType; + view: BodyType; +} diff --git a/src/version2/models/spaceDescriptionBodyRepresentation.ts b/src/version2/models/spaceDescriptionBodyRepresentation.ts new file mode 100644 index 00000000..cb3d9b98 --- /dev/null +++ b/src/version2/models/spaceDescriptionBodyRepresentation.ts @@ -0,0 +1,2 @@ +/** The formats a space description can be represented as. A subset of BodyRepresentation. */ +export interface SpaceDescriptionBodyRepresentation {} diff --git a/src/version2/models/spaceDescriptionFormat.ts b/src/version2/models/spaceDescriptionFormat.ts new file mode 100644 index 00000000..461e6d01 --- /dev/null +++ b/src/version2/models/spaceDescriptionFormat.ts @@ -0,0 +1 @@ +export type SpaceDescriptionFormat = 'plain' | 'view'; diff --git a/src/version2/models/spaceProperty.ts b/src/version2/models/spaceProperty.ts new file mode 100644 index 00000000..daaefcf1 --- /dev/null +++ b/src/version2/models/spaceProperty.ts @@ -0,0 +1,22 @@ +export interface SpaceProperty { + /** ID of the space property. */ + id?: {}; + /** Key of the space property. */ + key?: string; + /** Value of the space property. */ + value?: {}; + /** RFC3339 compliant date time at which the property was created. */ + createdAt?: string; + /** Atlassian account ID of the user that created the space property. */ + createdBy?: string; + version?: { + /** RFC3339 compliant date time at which the property's current version was created. */ + createdAt?: string; + /** Atlassian account ID of the user that created the space property's current version. */ + createdBy?: string; + /** Message associated with the current version. */ + message?: string; + /** The space property's current version number. */ + number?: number; + }; +} diff --git a/src/version2/models/spaceSortOrder.ts b/src/version2/models/spaceSortOrder.ts new file mode 100644 index 00000000..4ae0d318 --- /dev/null +++ b/src/version2/models/spaceSortOrder.ts @@ -0,0 +1,5 @@ +/** + * The sort fields for spaces. The default sort direction is ascending. To sort in descending order, append a `-` + * character before the sort field. For example, `fieldName` or `-fieldName`. + */ +export interface SpaceSortOrder {} diff --git a/src/version2/models/spaceStatus.ts b/src/version2/models/spaceStatus.ts new file mode 100644 index 00000000..2cc44b97 --- /dev/null +++ b/src/version2/models/spaceStatus.ts @@ -0,0 +1,2 @@ +/** The status of the space. */ +export type SpaceStatus = 'current' | 'archived'; diff --git a/src/version2/models/spaceType.ts b/src/version2/models/spaceType.ts new file mode 100644 index 00000000..2185a773 --- /dev/null +++ b/src/version2/models/spaceType.ts @@ -0,0 +1,2 @@ +/** The type of space. */ +export type SpaceType = 'global' | 'personal'; diff --git a/src/version2/models/task.ts b/src/version2/models/task.ts new file mode 100644 index 00000000..6b820608 --- /dev/null +++ b/src/version2/models/task.ts @@ -0,0 +1,31 @@ +import { Body } from './body'; + +export interface Task { + /** ID of the task. */ + id?: {}; + /** Local ID of the task. This ID is local to the corresponding page or blog post. */ + localId?: {}; + /** ID of the space the task is in. */ + spaceId?: {}; + /** ID of the page the task is in. */ + pageId?: {}; + /** ID of the blog post the task is in. */ + blogPostId?: {}; + /** Status of the task. */ + status?: string; + body?: Body; + /** Account ID of the user who created this task. */ + createdBy?: string; + /** Account ID of the user to whom this task is assigned. */ + assignedTo?: string; + /** Account ID of the user who completed this task. */ + completedBy?: string; + /** Date and time when the task was created. In format "YYYY-MM-DDTHH:mm:ss.sssZ". */ + createdAt?: string; + /** Date and time when the task was updated. In format "YYYY-MM-DDTHH:mm:ss.sssZ". */ + updatedAt?: string; + /** Date and time when the task is due. In format "YYYY-MM-DDTHH:mm:ss.sssZ". */ + dueAt?: string; + /** Date and time when the task was completed. In format "YYYY-MM-DDTHH:mm:ss.sssZ". */ + completedAt?: string; +} diff --git a/src/version2/models/version.ts b/src/version2/models/version.ts new file mode 100644 index 00000000..293a6043 --- /dev/null +++ b/src/version2/models/version.ts @@ -0,0 +1,15 @@ +export interface Version { + /** Date and time when the version was created. In format "YYYY-MM-DDTHH:mm:ss.sssZ". */ + createdAt?: string; + /** Message associated with the current version. */ + message?: string; + /** The version number. */ + number?: number; + /** + * Describes if this version is a minor version. Email notifications and activity stream updates are not created for + * minor versions. + */ + minorEdit?: boolean; + /** The account ID of the user who created this version. */ + authorId?: string; +} diff --git a/src/version2/models/versionSortOrder.ts b/src/version2/models/versionSortOrder.ts new file mode 100644 index 00000000..ea1695bd --- /dev/null +++ b/src/version2/models/versionSortOrder.ts @@ -0,0 +1,5 @@ +/** + * The sort fields for versions. The default sort direction is ascending. To sort in descending order, append a `-` + * character before the sort field. For example, `fieldName` or `-fieldName`. + */ +export interface VersionSortOrder {} diff --git a/src/version2/models/versionedEntity.ts b/src/version2/models/versionedEntity.ts new file mode 100644 index 00000000..b5f310b5 --- /dev/null +++ b/src/version2/models/versionedEntity.ts @@ -0,0 +1,9 @@ +import { Body } from './body'; + +export interface VersionedEntity { + /** Title of the entity. */ + title: string; + /** ID of the entity. */ + id: string; + body: Body; +} diff --git a/src/version2/page.ts b/src/version2/page.ts new file mode 100644 index 00000000..77858a2a --- /dev/null +++ b/src/version2/page.ts @@ -0,0 +1,281 @@ +import * as Models from './models'; +import * as Parameters from './parameters'; +import { Callback } from '../callback'; +import { Client } from '../clients'; +import { PaginationService } from '../services'; +import { RequestConfig } from '../requestConfig'; + +export class Page { + private paginationService = new PaginationService(); + + constructor(private client: Client) {} + + /** + * Returns the pages of specified label. The number of results is limited by the `limit` parameter and additional + * results (if available) will be available through the `next` URL present in the `Link` response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the page + * and its corresponding space. + */ + async getLabelPages>( + parameters: Parameters.GetLabelPages, + callback: Callback, + ): Promise; + /** + * Returns the pages of specified label. The number of results is limited by the `limit` parameter and additional + * results (if available) will be available through the `next` URL present in the `Link` response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the page + * and its corresponding space. + */ + async getLabelPages>( + parameters: Parameters.GetLabelPages, + callback?: never, + ): Promise; + async getLabelPages>( + parameters: Parameters.GetLabelPages, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/labels/${parameters.id}/pages`, + method: 'GET', + params: { + 'body-format': parameters.bodyFormat, + sort: parameters.sort, + cursor: parameters.cursor, + limit: parameters.limit, + 'serialize-ids-as-strings': true, + }, + }; + + try { + const pages = await this.client.sendRequest>(config); + const paginatedPages = this.paginationService.buildPaginatedResult(pages, this.getLabelPages.bind(this)); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(paginatedPages as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** + * Returns all pages. The number of results is limited by the `limit` parameter and additional results (if available) + * will be available through the `next` URL present in the `Link` response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to access the Confluence site + * ('Can use' global permission). Only pages that the user has permission to view will be returned. + */ + async getPages>( + parameters: Parameters.GetPages | undefined, + callback: Callback, + ): Promise; + /** + * Returns all pages. The number of results is limited by the `limit` parameter and additional results (if available) + * will be available through the `next` URL present in the `Link` response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to access the Confluence site + * ('Can use' global permission). Only pages that the user has permission to view will be returned. + */ + async getPages>(parameters?: Parameters.GetPages, callback?: never): Promise; + async getPages>( + parameters?: Parameters.GetPages, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: '/pages', + method: 'GET', + params: { + id: parameters?.id, + status: parameters?.status, + 'body-format': parameters?.bodyFormat, + cursor: parameters?.cursor, + limit: parameters?.limit, + 'serialize-ids-as-strings': true, + }, + }; + + try { + const pages = await this.client.sendRequest>(config); + const paginatedPages = this.paginationService.buildPaginatedResult(pages, this.getPages.bind(this)); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(paginatedPages as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** + * Creates a page in the space. + * + * Pages are created as published by default unless specified as a draft in the status field. If creating a published + * page, the title must be specified. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the corresponding space. + * Permission to create a page in the space. + */ + async createPage( + parameters: Parameters.CreatePage | undefined, + callback: Callback, + ): Promise; + /** + * Creates a page in the space. + * + * Pages are created as published by default unless specified as a draft in the status field. If creating a published + * page, the title must be specified. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the corresponding space. + * Permission to create a page in the space. + */ + async createPage(parameters?: Parameters.CreatePage, callback?: never): Promise; + async createPage(parameters?: Parameters.CreatePage, callback?: Callback): Promise { + const config: RequestConfig = { + url: '/pages', + method: 'POST', + params: { + 'serialize-ids-as-strings': true, + }, + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Returns a specific page. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the page and its + * corresponding space. + */ + async getPageById(parameters: Parameters.GetPageById, callback: Callback): Promise; + /** + * Returns a specific page. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the page and its + * corresponding space. + */ + async getPageById(parameters: Parameters.GetPageById, callback?: never): Promise; + async getPageById(parameters: Parameters.GetPageById, callback?: Callback): Promise { + const config: RequestConfig = { + url: `/pages/${parameters.id}`, + method: 'GET', + params: { + 'body-format': parameters.bodyFormat, + 'get-draft': parameters.getDraft, + version: parameters.version, + 'serialize-ids-as-strings': true, + }, + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Update a page by id. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the page and its + * corresponding space. Permission to update pages in the space. + */ + async updatePage(parameters: Parameters.UpdatePage, callback: Callback): Promise; + /** + * Update a page by id. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the page and its + * corresponding space. Permission to update pages in the space. + */ + async updatePage(parameters: Parameters.UpdatePage, callback?: never): Promise; + async updatePage(parameters: Parameters.UpdatePage, callback?: Callback): Promise { + const config: RequestConfig = { + url: `/pages/${parameters.id}`, + method: 'PUT', + params: { + 'serialize-ids-as-strings': true, + }, + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Delete a page by id. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the page and its + * corresponding space. Permission to delete pages in the space. + */ + async deletePage(parameters: Parameters.DeletePage, callback: Callback): Promise; + /** + * Delete a page by id. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the page and its + * corresponding space. Permission to delete pages in the space. + */ + async deletePage(parameters: Parameters.DeletePage, callback?: never): Promise; + async deletePage(parameters: Parameters.DeletePage, callback?: Callback): Promise { + const config: RequestConfig = { + url: `/pages/${parameters.id}`, + method: 'DELETE', + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Returns all pages in a space. The number of results is limited by the `limit` parameter and additional results (if + * available) will be available through the `next` URL present in the `Link` response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to access the Confluence site + * ('Can use' global permission) and 'View' permission for the space. Only pages that the user has permission to view + * will be returned. + */ + async getPagesInSpace>( + parameters: Parameters.GetPagesInSpace, + callback: Callback, + ): Promise; + /** + * Returns all pages in a space. The number of results is limited by the `limit` parameter and additional results (if + * available) will be available through the `next` URL present in the `Link` response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to access the Confluence site + * ('Can use' global permission) and 'View' permission for the space. Only pages that the user has permission to view + * will be returned. + */ + async getPagesInSpace>( + parameters: Parameters.GetPagesInSpace, + callback?: never, + ): Promise; + async getPagesInSpace>( + parameters: Parameters.GetPagesInSpace, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/spaces/${parameters.id}/pages`, + method: 'GET', + params: { + status: parameters.status, + 'body-format': parameters.bodyFormat, + cursor: parameters.cursor, + limit: parameters.limit, + 'serialize-ids-as-strings': true, + }, + }; + + try { + const pages = await this.client.sendRequest>(config); + const paginatedPages = this.paginationService.buildPaginatedResult(pages, this.getPagesInSpace.bind(this)); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(paginatedPages as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } +} diff --git a/src/version2/parameters/createAttachmentProperty.ts b/src/version2/parameters/createAttachmentProperty.ts new file mode 100644 index 00000000..61b8c3e2 --- /dev/null +++ b/src/version2/parameters/createAttachmentProperty.ts @@ -0,0 +1,6 @@ +import { ContentPropertyCreateRequest } from '../models'; + +export interface CreateAttachmentProperty extends ContentPropertyCreateRequest { + /** The ID of the attachment to create a property for. */ + attachmentId: string; +} diff --git a/src/version2/parameters/createBlogPost.ts b/src/version2/parameters/createBlogPost.ts new file mode 100644 index 00000000..5ec3d4ea --- /dev/null +++ b/src/version2/parameters/createBlogPost.ts @@ -0,0 +1 @@ +export interface CreateBlogPost {} diff --git a/src/version2/parameters/createBlogpostProperty.ts b/src/version2/parameters/createBlogpostProperty.ts new file mode 100644 index 00000000..fbe8bd06 --- /dev/null +++ b/src/version2/parameters/createBlogpostProperty.ts @@ -0,0 +1,6 @@ +import { ContentPropertyCreateRequest } from '../models'; + +export interface CreateBlogpostProperty extends ContentPropertyCreateRequest { + /** The ID of the blog post to create a property for. */ + blogpostId: number; +} diff --git a/src/version2/parameters/createCommentProperty.ts b/src/version2/parameters/createCommentProperty.ts new file mode 100644 index 00000000..3d26b59f --- /dev/null +++ b/src/version2/parameters/createCommentProperty.ts @@ -0,0 +1,6 @@ +import { ContentPropertyCreateRequest } from '../models'; + +export interface CreateCommentProperty extends ContentPropertyCreateRequest { + /** The ID of the comment to create a property for. */ + commentId: number; +} diff --git a/src/version2/parameters/createCustomContent.ts b/src/version2/parameters/createCustomContent.ts new file mode 100644 index 00000000..8637ca79 --- /dev/null +++ b/src/version2/parameters/createCustomContent.ts @@ -0,0 +1 @@ +export interface CreateCustomContent {} diff --git a/src/version2/parameters/createCustomContentProperty.ts b/src/version2/parameters/createCustomContentProperty.ts new file mode 100644 index 00000000..074f8b63 --- /dev/null +++ b/src/version2/parameters/createCustomContentProperty.ts @@ -0,0 +1,6 @@ +import { ContentPropertyCreateRequest } from '../models'; + +export interface CreateCustomContentProperty extends ContentPropertyCreateRequest { + /** The ID of the custom content to create a property for. */ + customContentId: number; +} diff --git a/src/version2/parameters/createFooterComment.ts b/src/version2/parameters/createFooterComment.ts new file mode 100644 index 00000000..2621501a --- /dev/null +++ b/src/version2/parameters/createFooterComment.ts @@ -0,0 +1,17 @@ +export interface CreateFooterComment { + /** + * ID of the containing blog post, if intending to create a top level footer comment. Do not provide if creating a + * reply. + */ + blogPostId?: string; + /** ID of the containing page, if intending to create a top level footer comment. Do not provide if creating a reply. */ + pageId?: string; + /** ID of the parent comment, if intending to create a reply. Do not provide if creating a top level comment. */ + parentCommentId?: string; + body?: { + /** Body of the comment */ + value?: string; + /** Format of the body's value. */ + representation?: string; + }; +} diff --git a/src/version2/parameters/createInlineComment.ts b/src/version2/parameters/createInlineComment.ts new file mode 100644 index 00000000..c391687b --- /dev/null +++ b/src/version2/parameters/createInlineComment.ts @@ -0,0 +1,28 @@ +export interface CreateInlineComment { + /** + * ID of the containing blog post, if intending to create a top level footer comment. Do not provide if creating a + * reply. + */ + blogPostId?: string; + /** ID of the containing page, if intending to create a top level footer comment. Do not provide if creating a reply. */ + pageId?: string; + /** ID of the parent comment, if intending to create a reply. Do not provide if creating a top level comment. */ + parentCommentId?: string; + body?: {}; + /** + * Object describing the text to highlight on the page/blog post. Only applicable for top level inline comments (not + * replies) and required in that case. + */ + inlineCommentProperties?: { + /** The text to highlight */ + textSelection?: string; + /** The number of matches for the selected text on the page (should be strictly greater than textSelectionMatchIndex) */ + textSelectionMatchCount?: number; + /** + * The match index to highlight. This is zero-based. E.g. if you have 3 occurrences of "hello world" on a page and + * you want to highlight the second occurrence, you should pass 1 for textSelectionMatchIndex and 3 for + * textSelectionMatchCount. + */ + textSelectionMatchIndex?: number; + }; +} diff --git a/src/version2/parameters/createPage.ts b/src/version2/parameters/createPage.ts new file mode 100644 index 00000000..f3c93e3c --- /dev/null +++ b/src/version2/parameters/createPage.ts @@ -0,0 +1 @@ +export interface CreatePage {} diff --git a/src/version2/parameters/createPageProperty.ts b/src/version2/parameters/createPageProperty.ts new file mode 100644 index 00000000..03f6ce2a --- /dev/null +++ b/src/version2/parameters/createPageProperty.ts @@ -0,0 +1,6 @@ +import { ContentPropertyCreateRequest } from '../models'; + +export interface CreatePageProperty extends ContentPropertyCreateRequest { + /** The ID of the page to create a property for. */ + pageId: number; +} diff --git a/src/version2/parameters/createSpaceProperty.ts b/src/version2/parameters/createSpaceProperty.ts new file mode 100644 index 00000000..7e7388ea --- /dev/null +++ b/src/version2/parameters/createSpaceProperty.ts @@ -0,0 +1,8 @@ +export interface CreateSpaceProperty { + /** The ID of the space for which space properties should be returned. */ + spaceId: number; + /** Key of the space property */ + key: string; + /** Value of the space property. */ + value: any; +} diff --git a/src/version2/parameters/deleteAttachmentPropertyById.ts b/src/version2/parameters/deleteAttachmentPropertyById.ts new file mode 100644 index 00000000..6edb144a --- /dev/null +++ b/src/version2/parameters/deleteAttachmentPropertyById.ts @@ -0,0 +1,6 @@ +export interface DeleteAttachmentPropertyById { + /** The ID of the attachment the property belongs to. */ + attachmentId: string; + /** The ID of the property to be deleted. */ + propertyId: number; +} diff --git a/src/version2/parameters/deleteBlogPost.ts b/src/version2/parameters/deleteBlogPost.ts new file mode 100644 index 00000000..7dd2cf69 --- /dev/null +++ b/src/version2/parameters/deleteBlogPost.ts @@ -0,0 +1,4 @@ +export interface DeleteBlogPost { + /** The ID of the blog post to be deleted. */ + id: number; +} diff --git a/src/version2/parameters/deleteBlogpostPropertyById.ts b/src/version2/parameters/deleteBlogpostPropertyById.ts new file mode 100644 index 00000000..c57785be --- /dev/null +++ b/src/version2/parameters/deleteBlogpostPropertyById.ts @@ -0,0 +1,6 @@ +export interface DeleteBlogpostPropertyById { + /** The ID of the blog post the property belongs to. */ + blogpostId: number; + /** The ID of the property to be deleted. */ + propertyId: number; +} diff --git a/src/version2/parameters/deleteCommentPropertyById.ts b/src/version2/parameters/deleteCommentPropertyById.ts new file mode 100644 index 00000000..f9af8265 --- /dev/null +++ b/src/version2/parameters/deleteCommentPropertyById.ts @@ -0,0 +1,6 @@ +export interface DeleteCommentPropertyById { + /** The ID of the comment the property belongs to. */ + commentId: number; + /** The ID of the property to be deleted. */ + propertyId: number; +} diff --git a/src/version2/parameters/deleteCustomContent.ts b/src/version2/parameters/deleteCustomContent.ts new file mode 100644 index 00000000..4ffaf3d6 --- /dev/null +++ b/src/version2/parameters/deleteCustomContent.ts @@ -0,0 +1,4 @@ +export interface DeleteCustomContent { + /** The ID of the custom content to be deleted. */ + id: number; +} diff --git a/src/version2/parameters/deleteCustomContentPropertyById.ts b/src/version2/parameters/deleteCustomContentPropertyById.ts new file mode 100644 index 00000000..cd29c3c2 --- /dev/null +++ b/src/version2/parameters/deleteCustomContentPropertyById.ts @@ -0,0 +1,6 @@ +export interface DeleteCustomContentPropertyById { + /** The ID of the custom content the property belongs to. */ + customContentId: number; + /** The ID of the property to be deleted. */ + propertyId: number; +} diff --git a/src/version2/parameters/deleteFooterComment.ts b/src/version2/parameters/deleteFooterComment.ts new file mode 100644 index 00000000..ff05ab7f --- /dev/null +++ b/src/version2/parameters/deleteFooterComment.ts @@ -0,0 +1,4 @@ +export interface DeleteFooterComment { + /** The ID of the comment to be retrieved. */ + commentId: number; +} diff --git a/src/version2/parameters/deleteInlineComment.ts b/src/version2/parameters/deleteInlineComment.ts new file mode 100644 index 00000000..e15e68a9 --- /dev/null +++ b/src/version2/parameters/deleteInlineComment.ts @@ -0,0 +1,4 @@ +export interface DeleteInlineComment { + /** The ID of the comment to be deleted. */ + commentId: number; +} diff --git a/src/version2/parameters/deletePage.ts b/src/version2/parameters/deletePage.ts new file mode 100644 index 00000000..ba31e7ea --- /dev/null +++ b/src/version2/parameters/deletePage.ts @@ -0,0 +1,4 @@ +export interface DeletePage { + /** The ID of the page to be deleted. */ + id: number; +} diff --git a/src/version2/parameters/deletePagePropertyById.ts b/src/version2/parameters/deletePagePropertyById.ts new file mode 100644 index 00000000..ba6ef1a1 --- /dev/null +++ b/src/version2/parameters/deletePagePropertyById.ts @@ -0,0 +1,6 @@ +export interface DeletePagePropertyById { + /** The ID of the page the property belongs to. */ + pageId: number; + /** The ID of the property to be deleted. */ + propertyId: number; +} diff --git a/src/version2/parameters/deleteSpacePropertyById.ts b/src/version2/parameters/deleteSpacePropertyById.ts new file mode 100644 index 00000000..2aeb76c3 --- /dev/null +++ b/src/version2/parameters/deleteSpacePropertyById.ts @@ -0,0 +1,6 @@ +export interface DeleteSpacePropertyById { + /** The ID of the space the property belongs to. */ + spaceId: number; + /** The ID of the property to be deleted. */ + propertyId: number; +} diff --git a/src/version2/parameters/getAttachmentById.ts b/src/version2/parameters/getAttachmentById.ts new file mode 100644 index 00000000..389ecb03 --- /dev/null +++ b/src/version2/parameters/getAttachmentById.ts @@ -0,0 +1,12 @@ +export interface GetAttachmentById { + /** + * The ID of the attachment to be returned. If you don't know the attachment's ID, use Get attachments for + * page/blogpost/custom content. + */ + id: string; + /** + * Allows you to retrieve a previously published version. Specify the previous version's number to retrieve its + * details. + */ + version?: number; +} diff --git a/src/version2/parameters/getAttachmentContentProperties.ts b/src/version2/parameters/getAttachmentContentProperties.ts new file mode 100644 index 00000000..b3ce5098 --- /dev/null +++ b/src/version2/parameters/getAttachmentContentProperties.ts @@ -0,0 +1,18 @@ +export interface GetAttachmentContentProperties { + /** The ID of the attachment for which content properties should be returned. */ + attachmentId: string; + /** Filters the response to return a specific content property with matching key (case sensitive). */ + key?: string; + /** Used to sort the result by a particular field. */ + sort?: 'key' | '-key'; + /** + * Used for pagination, this opaque cursor will be returned in the `next` URL in the `Link` response header. Use the + * relative URL in the `Link` header to retrieve the `next` set of results. + */ + cursor?: string; + /** + * Maximum number of attachments per result to return. If more results exist, use the `Link` header to retrieve a + * relative URL that will return the next set of results. + */ + limit?: number; +} diff --git a/src/version2/parameters/getAttachmentContentPropertiesById.ts b/src/version2/parameters/getAttachmentContentPropertiesById.ts new file mode 100644 index 00000000..f170105b --- /dev/null +++ b/src/version2/parameters/getAttachmentContentPropertiesById.ts @@ -0,0 +1,6 @@ +export interface GetAttachmentContentPropertiesById { + /** The ID of the attachment for which content properties should be returned. */ + attachmentId: string; + /** The ID of the content property to be returned */ + propertyId: number; +} diff --git a/src/version2/parameters/getAttachmentLabels.ts b/src/version2/parameters/getAttachmentLabels.ts new file mode 100644 index 00000000..49f5ace8 --- /dev/null +++ b/src/version2/parameters/getAttachmentLabels.ts @@ -0,0 +1,18 @@ +export interface GetAttachmentLabels { + /** The ID of the attachment for which labels should be returned. */ + id: number; + /** Filter the results to labels based on their prefix. */ + prefix?: string; + /** Used to sort the result by a particular field. */ + sort?: string; + /** + * Used for pagination, this opaque cursor will be returned in the `next` URL in the `Link` response header. Use the + * relative URL in the `Link` header to retrieve the `next` set of results. + */ + cursor?: string; + /** + * Maximum number of labels per result to return. If more results exist, use the `Link` header to retrieve a relative + * URL that will return the next set of results. + */ + limit?: number; +} diff --git a/src/version2/parameters/getAttachmentVersionDetails.ts b/src/version2/parameters/getAttachmentVersionDetails.ts new file mode 100644 index 00000000..b2388fde --- /dev/null +++ b/src/version2/parameters/getAttachmentVersionDetails.ts @@ -0,0 +1,6 @@ +export interface GetAttachmentVersionDetails { + /** The ID of the attachment for which version details should be returned. */ + attachmentId: string; + /** The version number of the attachment to be returned. */ + versionNumber: number; +} diff --git a/src/version2/parameters/getAttachmentVersions.ts b/src/version2/parameters/getAttachmentVersions.ts new file mode 100644 index 00000000..fe7ad308 --- /dev/null +++ b/src/version2/parameters/getAttachmentVersions.ts @@ -0,0 +1,19 @@ +export interface GetAttachmentVersions { + /** + * The ID of the attachment to be queried for its versions. If you don't know the attachment ID, use Get attachments + * and filter the results. + */ + id: string; + /** + * Used for pagination, this opaque cursor will be returned in the `next` URL in the `Link` response header. Use the + * relative URL in the `Link` header to retrieve the `next` set of results. + */ + cursor?: string; + /** + * Maximum number of versions per result to return. If more results exist, use the `Link` header to retrieve a + * relative URL that will return the next set of results. + */ + limit?: number; + /** Used to sort the result by a particular field. */ + sort?: 'modified-date' | '-modified-date'; +} diff --git a/src/version2/parameters/getBlogPostById.ts b/src/version2/parameters/getBlogPostById.ts new file mode 100644 index 00000000..d5461ab4 --- /dev/null +++ b/src/version2/parameters/getBlogPostById.ts @@ -0,0 +1,19 @@ +export interface GetBlogPostById { + /** + * The ID of the blog post to be returned. If you don't know the blog post ID, use Get blog posts and filter the + * results. + */ + id: number; + /** + * The content format types to be returned in the `body` field of the response. If available, the representation will + * be available under a response field of the same name under the `body` field. + */ + bodyFormat?: {}; + /** Retrieve the draft version of this blog post. */ + getDraft?: boolean; + /** + * Allows you to retrieve a previously published version. Specify the previous version's number to retrieve its + * details. + */ + version?: number; +} diff --git a/src/version2/parameters/getBlogPostFooterComments.ts b/src/version2/parameters/getBlogPostFooterComments.ts new file mode 100644 index 00000000..0f372c1c --- /dev/null +++ b/src/version2/parameters/getBlogPostFooterComments.ts @@ -0,0 +1,21 @@ +export interface GetBlogPostFooterComments { + /** The ID of the blog post for which footer comments should be returned. */ + id: number; + /** + * The content format type to be returned in the `body` field of the response. If available, the representation will + * be available under a response field of the same name under the `body` field. + */ + bodyFormat?: {}; + /** Used to sort the result by a particular field. */ + sort?: 'created-date' | '-created-date' | 'modified-date' | '-modified-date'; + /** + * Used for pagination, this opaque cursor will be returned in the `next` URL in the `Link` response header. Use the + * relative URL in the `Link` header to retrieve the `next` set of results. + */ + cursor?: string; + /** + * Maximum number of footer comments per result to return. If more results exist, use the `Link` header to retrieve a + * relative URL that will return the next set of results. + */ + limit?: number; +} diff --git a/src/version2/parameters/getBlogPostInlineComments.ts b/src/version2/parameters/getBlogPostInlineComments.ts new file mode 100644 index 00000000..25a1543b --- /dev/null +++ b/src/version2/parameters/getBlogPostInlineComments.ts @@ -0,0 +1,21 @@ +export interface GetBlogPostInlineComments { + /** The ID of the blog post for which inline comments should be returned. */ + id: number; + /** + * The content format type to be returned in the `body` field of the response. If available, the representation will + * be available under a response field of the same name under the `body` field. + */ + bodyFormat: {}; + /** Used to sort the result by a particular field. */ + sort?: 'created-date' | '-created-date' | 'modified-date' | '-modified-date'; + /** + * Used for pagination, this opaque cursor will be returned in the `next` URL in the `Link` response header. Use the + * relative URL in the `Link` header to retrieve the `next` set of results. + */ + cursor?: string; + /** + * Maximum number of inline comments per result to return. If more results exist, use the `Link` header to retrieve a + * relative URL that will return the next set of results. + */ + limit?: number; +} diff --git a/src/version2/parameters/getBlogPostLabels.ts b/src/version2/parameters/getBlogPostLabels.ts new file mode 100644 index 00000000..e8eab7b8 --- /dev/null +++ b/src/version2/parameters/getBlogPostLabels.ts @@ -0,0 +1,18 @@ +export interface GetBlogPostLabels { + /** The ID of the blog post for which labels should be returned. */ + id: number; + /** Filter the results to labels based on their prefix. */ + prefix?: string; + /** Used to sort the result by a particular field. */ + sort?: string; + /** + * Used for pagination, this opaque cursor will be returned in the `next` URL in the `Link` response header. Use the + * relative URL in the `Link` header to retrieve the `next` set of results. + */ + cursor?: string; + /** + * Maximum number of labels per result to return. If more results exist, use the `Link` header to retrieve a relative + * URL that will return the next set of results. + */ + limit?: number; +} diff --git a/src/version2/parameters/getBlogPostVersionDetails.ts b/src/version2/parameters/getBlogPostVersionDetails.ts new file mode 100644 index 00000000..25f2a249 --- /dev/null +++ b/src/version2/parameters/getBlogPostVersionDetails.ts @@ -0,0 +1,6 @@ +export interface GetBlogPostVersionDetails { + /** The ID of the blog post for which version details should be returned. */ + blogpostId: number; + /** The version number of the blog post to be returned. */ + versionNumber: number; +} diff --git a/src/version2/parameters/getBlogPostVersions.ts b/src/version2/parameters/getBlogPostVersions.ts new file mode 100644 index 00000000..994c93cc --- /dev/null +++ b/src/version2/parameters/getBlogPostVersions.ts @@ -0,0 +1,24 @@ +export interface GetBlogPostVersions { + /** + * The ID of the blog post to be queried for its versions. If you don't know the blog post ID, use Get blog posts and + * filter the results. + */ + id: number; + /** + * The content format types to be returned in the `body` field of the response. If available, the representation will + * be available under a response field of the same name under the `body` field. + */ + bodyFormat?: {}; + /** + * Used for pagination, this opaque cursor will be returned in the `next` URL in the `Link` response header. Use the + * relative URL in the `Link` header to retrieve the `next` set of results. + */ + cursor?: string; + /** + * Maximum number of versions per result to return. If more results exist, use the `Link` header to retrieve a + * relative URL that will return the next set of results. + */ + limit?: number; + /** Used to sort the result by a particular field. */ + sort?: 'modified-date' | '-modified-date'; +} diff --git a/src/version2/parameters/getBlogPosts.ts b/src/version2/parameters/getBlogPosts.ts new file mode 100644 index 00000000..20d36e9c --- /dev/null +++ b/src/version2/parameters/getBlogPosts.ts @@ -0,0 +1,23 @@ +import { PrimaryBodyRepresentation } from '../models'; + +export interface GetBlogPosts { + /** Filter the results based on blog post ids. Multiple blog post ids can be specified as a comma-separated list. */ + id?: number[]; + /** Filter the results to blog posts based on their status. */ + status?: string; + /** + * The content format types to be returned in the `body` field of the response. If available, the representation will + * be available under a response field of the same name under the `body` field. + */ + bodyFormat?: PrimaryBodyRepresentation; + /** + * Used for pagination, this opaque cursor will be returned in the `next` URL in the `Link` response header. Use the + * relative URL in the `Link` header to retrieve the `next` set of results. + */ + cursor?: string; + /** + * Maximum number of blog posts per result to return. If more results exist, use the `Link` response header to + * retrieve a relative URL that will return the next set of results. + */ + limit?: number; +} diff --git a/src/version2/parameters/getBlogPostsInSpace.ts b/src/version2/parameters/getBlogPostsInSpace.ts new file mode 100644 index 00000000..512f6731 --- /dev/null +++ b/src/version2/parameters/getBlogPostsInSpace.ts @@ -0,0 +1,23 @@ +import { PrimaryBodyRepresentation } from '../models'; + +export interface GetBlogPostsInSpace { + /** The ID of the space for which blog posts should be returned. */ + id: number; + /** Filter the results to blog posts based on their status. */ + status?: string; + /** + * The content format types to be returned in the `body` field of the response. If available, the representation will + * be available under a response field of the same name under the `body` field. + */ + bodyFormat?: PrimaryBodyRepresentation; + /** + * Used for pagination, this opaque cursor will be returned in the `next` URL in the `Link` response header. Use the + * relative URL in the `Link` header to retrieve the `next` set of results. + */ + cursor?: string; + /** + * Maximum number of blog posts per result to return. If more results exist, use the `Link` header to retrieve a + * relative URL that will return the next set of results. + */ + limit?: number; +} diff --git a/src/version2/parameters/getBlogpostAttachments.ts b/src/version2/parameters/getBlogpostAttachments.ts new file mode 100644 index 00000000..6af88a04 --- /dev/null +++ b/src/version2/parameters/getBlogpostAttachments.ts @@ -0,0 +1,20 @@ +export interface GetBlogpostAttachments { + /** The ID of the blog post for which attachments should be returned. */ + id: number; + /** Used to sort the result by a particular field. */ + sort?: 'created-date' | '-created-date' | 'modified-date' | '-modified-date' | string; + /** + * Used for pagination, this opaque cursor will be returned in the `next` URL in the `Link` response header. Use the + * relative URL in the `Link` header to retrieve the `next` set of results. + */ + cursor?: string; + /** Filters on the mediaType of attachments. Only one may be specified. */ + mediaType?: string; + /** Filters on the file-name of attachments. Only one may be specified. */ + filename?: string; + /** + * Maximum number of attachments per result to return. If more results exist, use the `Link` header to retrieve a + * relative URL that will return the next set of results. + */ + limit?: number; +} diff --git a/src/version2/parameters/getBlogpostContentProperties.ts b/src/version2/parameters/getBlogpostContentProperties.ts new file mode 100644 index 00000000..dbf9bf53 --- /dev/null +++ b/src/version2/parameters/getBlogpostContentProperties.ts @@ -0,0 +1,18 @@ +export interface GetBlogpostContentProperties { + /** The ID of the blog post for which content properties should be returned. */ + blogpostId: number; + /** Filters the response to return a specific content property with matching key (case sensitive). */ + key?: string; + /** Used to sort the result by a particular field. */ + sort?: 'key' | '-key'; + /** + * Used for pagination, this opaque cursor will be returned in the `next` URL in the `Link` response header. Use the + * relative URL in the `Link` header to retrieve the `next` set of results. + */ + cursor?: string; + /** + * Maximum number of attachments per result to return. If more results exist, use the `Link` header to retrieve a + * relative URL that will return the next set of results. + */ + limit?: number; +} diff --git a/src/version2/parameters/getBlogpostContentPropertiesById.ts b/src/version2/parameters/getBlogpostContentPropertiesById.ts new file mode 100644 index 00000000..5a3d87cb --- /dev/null +++ b/src/version2/parameters/getBlogpostContentPropertiesById.ts @@ -0,0 +1,6 @@ +export interface GetBlogpostContentPropertiesById { + /** The ID of the blog post for which content properties should be returned. */ + blogpostId: number; + /** The ID of the property being requested */ + propertyId: number; +} diff --git a/src/version2/parameters/getChildCustomContent.ts b/src/version2/parameters/getChildCustomContent.ts new file mode 100644 index 00000000..32652afa --- /dev/null +++ b/src/version2/parameters/getChildCustomContent.ts @@ -0,0 +1,19 @@ +export interface GetChildCustomContent { + /** + * The ID of the parent custom content. If you don't know the custom content ID, use Get custom-content and filter the + * results. + */ + id: number; + /** + * Used for pagination, this opaque cursor will be returned in the `next` URL in the `Link` response header. Use the + * relative URL in the `Link` header to retrieve the `next` set of results. + */ + cursor?: string; + /** + * Maximum number of pages per result to return. If more results exist, use the `Link` header to retrieve a relative + * URL that will return the next set of results. + */ + limit?: number; + /** Used to sort the result by a particular field. */ + sort?: string; +} diff --git a/src/version2/parameters/getChildPages.ts b/src/version2/parameters/getChildPages.ts new file mode 100644 index 00000000..d33c0f52 --- /dev/null +++ b/src/version2/parameters/getChildPages.ts @@ -0,0 +1,16 @@ +export interface GetChildPages { + /** The ID of the parent page. If you don't know the page ID, use Get pages and filter the results. */ + id: number; + /** + * Used for pagination, this opaque cursor will be returned in the `next` URL in the `Link` response header. Use the + * relative URL in the `Link` header to retrieve the `next` set of results. + */ + cursor?: string; + /** + * Maximum number of pages per result to return. If more results exist, use the `Link` header to retrieve a relative + * URL that will return the next set of results. + */ + limit?: number; + /** Used to sort the result by a particular field. */ + sort?: string; +} diff --git a/src/version2/parameters/getCommentContentProperties.ts b/src/version2/parameters/getCommentContentProperties.ts new file mode 100644 index 00000000..3dd4ecee --- /dev/null +++ b/src/version2/parameters/getCommentContentProperties.ts @@ -0,0 +1,18 @@ +export interface GetCommentContentProperties { + /** The ID of the comment for which content properties should be returned. */ + commentId: number; + /** Filters the response to return a specific content property with matching key (case sensitive). */ + key: string; + /** Used to sort the result by a particular field. */ + sort?: 'key' | '-key'; + /** + * Used for pagination, this opaque cursor will be returned in the `next` URL in the `Link` response header. Use the + * relative URL in the `Link` header to retrieve the `next` set of results. + */ + cursor?: string; + /** + * Maximum number of attachments per result to return. If more results exist, use the `Link` header to retrieve a + * relative URL that will return the next set of results. + */ + limit?: number; +} diff --git a/src/version2/parameters/getCommentContentPropertiesById.ts b/src/version2/parameters/getCommentContentPropertiesById.ts new file mode 100644 index 00000000..8edad59a --- /dev/null +++ b/src/version2/parameters/getCommentContentPropertiesById.ts @@ -0,0 +1,6 @@ +export interface GetCommentContentPropertiesById { + /** The ID of the comment for which content properties should be returned. */ + commentId: number; + /** The ID of the content property being requested. */ + propertyId: number; +} diff --git a/src/version2/parameters/getCustomContentAttachments.ts b/src/version2/parameters/getCustomContentAttachments.ts new file mode 100644 index 00000000..007fcd2d --- /dev/null +++ b/src/version2/parameters/getCustomContentAttachments.ts @@ -0,0 +1,20 @@ +export interface GetCustomContentAttachments { + /** The ID of the custom content for which attachments should be returned. */ + id: number; + /** Used to sort the result by a particular field. */ + sort?: 'created-date' | '-created-date' | 'modified-date' | '-modified-date' | string; + /** + * Used for pagination, this opaque cursor will be returned in the `next` URL in the `Link` response header. Use the + * relative URL in the `Link` header to retrieve the `next` set of results. + */ + cursor?: string; + /** Filters on the mediaType of attachments. Only one may be specified. */ + mediaType?: string; + /** Filters on the file-name of attachments. Only one may be specified. */ + filename?: string; + /** + * Maximum number of attachments per result to return. If more results exist, use the `Link` header to retrieve a + * relative URL that will return the next set of results. + */ + limit?: number; +} diff --git a/src/version2/parameters/getCustomContentById.ts b/src/version2/parameters/getCustomContentById.ts new file mode 100644 index 00000000..ac62a4a0 --- /dev/null +++ b/src/version2/parameters/getCustomContentById.ts @@ -0,0 +1,20 @@ +export interface GetCustomContentById { + /** + * The ID of the custom content to be returned. If you don't know the custom content ID, use Get Custom Content by + * Type and filter the results. + */ + id: number; + /** + * The content format types to be returned in the `body` field of the response. If available, the representation will + * be available under a response field of the same name under the `body` field. + * + * Note: If the custom content body type is `storage`, the `storage` and `atlas_doc_format` body formats are able to + * be returned. If the custom content body type is `raw`, only the `raw` body format is able to be returned. + */ + bodyFormat?: {}; + /** + * Allows you to retrieve a previously published version. Specify the previous version's number to retrieve its + * details. + */ + version?: number; +} diff --git a/src/version2/parameters/getCustomContentByType.ts b/src/version2/parameters/getCustomContentByType.ts new file mode 100644 index 00000000..08907d87 --- /dev/null +++ b/src/version2/parameters/getCustomContentByType.ts @@ -0,0 +1,30 @@ +export interface GetCustomContentByType { + /** + * The type of custom content being requested. See: https://developer.atlassian.com/cloud/confluence/custom-content/ + * for additional details on custom content. + */ + type: string; + /** + * Filter the results based on custom content ids. Multiple custom content ids can be specified as a comma-separated + * list. + */ + id?: number[]; + /** + * Used for pagination, this opaque cursor will be returned in the `next` URL in the `Link` response header. Use the + * relative URL in the `Link` header to retrieve the `next` set of results. + */ + cursor?: string; + /** + * Maximum number of pages per result to return. If more results exist, use the `Link` header to retrieve a relative + * URL that will return the next set of results. + */ + limit?: number; + /** + * The content format types to be returned in the `body` field of the response. If available, the representation will + * be available under a response field of the same name under the `body` field. + * + * Note: If the custom content body type is `storage`, the `storage` and `atlas_doc_format` body formats are able to + * be returned. If the custom content body type is `raw`, only the `raw` body format is able to be returned. + */ + bodyFormat?: {}; +} diff --git a/src/version2/parameters/getCustomContentByTypeInBlogPost.ts b/src/version2/parameters/getCustomContentByTypeInBlogPost.ts new file mode 100644 index 00000000..5474095b --- /dev/null +++ b/src/version2/parameters/getCustomContentByTypeInBlogPost.ts @@ -0,0 +1,27 @@ +export interface GetCustomContentByTypeInBlogPost { + /** The ID of the blog post for which custom content should be returned. */ + id: number; + /** + * The type of custom content being requested. See: https://developer.atlassian.com/cloud/confluence/custom-content/ + * for additional details on custom content. + */ + type: string; + /** + * Used for pagination, this opaque cursor will be returned in the `next` URL in the `Link` response header. Use the + * relative URL in the `Link` header to retrieve the `next` set of results. + */ + cursor?: string; + /** + * Maximum number of pages per result to return. If more results exist, use the `Link` header to retrieve a relative + * URL that will return the next set of results. + */ + limit?: number; + /** + * The content format types to be returned in the `body` field of the response. If available, the representation will + * be available under a response field of the same name under the `body` field. + * + * Note: If the custom content body type is `storage`, the `storage` and `atlas_doc_format` body formats are able to + * be returned. If the custom content body type is `raw`, only the `raw` body format is able to be returned. + */ + bodyFormat?: {}; +} diff --git a/src/version2/parameters/getCustomContentByTypeInPage.ts b/src/version2/parameters/getCustomContentByTypeInPage.ts new file mode 100644 index 00000000..7950f77a --- /dev/null +++ b/src/version2/parameters/getCustomContentByTypeInPage.ts @@ -0,0 +1,27 @@ +export interface GetCustomContentByTypeInPage { + /** The ID of the page for which custom content should be returned. */ + id: number; + /** + * The type of custom content being requested. See: https://developer.atlassian.com/cloud/confluence/custom-content/ + * for additional details on custom content. + */ + type: string; + /** + * Used for pagination, this opaque cursor will be returned in the `next` URL in the `Link` response header. Use the + * relative URL in the `Link` header to retrieve the `next` set of results. + */ + cursor?: string; + /** + * Maximum number of pages per result to return. If more results exist, use the `Link` header to retrieve a relative + * URL that will return the next set of results. + */ + limit?: number; + /** + * The content format types to be returned in the `body` field of the response. If available, the representation will + * be available under a response field of the same name under the `body` field. + * + * Note: If the custom content body type is `storage`, the `storage` and `atlas_doc_format` body formats are able to + * be returned. If the custom content body type is `raw`, only the `raw` body format is able to be returned. + */ + bodyFormat?: {}; +} diff --git a/src/version2/parameters/getCustomContentByTypeInSpace.ts b/src/version2/parameters/getCustomContentByTypeInSpace.ts new file mode 100644 index 00000000..6ff8b4e6 --- /dev/null +++ b/src/version2/parameters/getCustomContentByTypeInSpace.ts @@ -0,0 +1,27 @@ +export interface GetCustomContentByTypeInSpace { + /** The ID of the space for which custom content should be returned. */ + id: number; + /** + * The type of custom content being requested. See: https://developer.atlassian.com/cloud/confluence/custom-content/ + * for additional details on custom content. + */ + type: string; + /** + * Used for pagination, this opaque cursor will be returned in the `next` URL in the `Link` response header. Use the + * relative URL in the `Link` header to retrieve the `next` set of results. + */ + cursor?: string; + /** + * Maximum number of pages per result to return. If more results exist, use the `Link` header to retrieve a relative + * URL that will return the next set of results. + */ + limit?: number; + /** + * The content format types to be returned in the `body` field of the response. If available, the representation will + * be available under a response field of the same name under the `body` field. + * + * Note: If the custom content body type is `storage`, the `storage` and `atlas_doc_format` body formats are able to + * be returned. If the custom content body type is `raw`, only the `raw` body format is able to be returned. + */ + bodyFormat?: {}; +} diff --git a/src/version2/parameters/getCustomContentContentProperties.ts b/src/version2/parameters/getCustomContentContentProperties.ts new file mode 100644 index 00000000..6c438597 --- /dev/null +++ b/src/version2/parameters/getCustomContentContentProperties.ts @@ -0,0 +1,18 @@ +export interface GetCustomContentContentProperties { + /** The ID of the custom content for which content properties should be returned. */ + customContentId: number; + /** Filters the response to return a specific content property with matching key (case sensitive). */ + key?: string; + /** Used to sort the result by a particular field. */ + sort?: 'key' | '-key'; + /** + * Used for pagination, this opaque cursor will be returned in the `next` URL in the `Link` response header. Use the + * relative URL in the `Link` header to retrieve the `next` set of results. + */ + cursor?: string; + /** + * Maximum number of attachments per result to return. If more results exist, use the `Link` header to retrieve a + * relative URL that will return the next set of results. + */ + limit?: number; +} diff --git a/src/version2/parameters/getCustomContentContentPropertiesById.ts b/src/version2/parameters/getCustomContentContentPropertiesById.ts new file mode 100644 index 00000000..46dc19ba --- /dev/null +++ b/src/version2/parameters/getCustomContentContentPropertiesById.ts @@ -0,0 +1,6 @@ +export interface GetCustomContentContentPropertiesById { + /** The ID of the custom content for which content properties should be returned. */ + customContentId: number; + /** The ID of the content property being requested. */ + propertyId: number; +} diff --git a/src/version2/parameters/getCustomContentLabels.ts b/src/version2/parameters/getCustomContentLabels.ts new file mode 100644 index 00000000..02afd2cf --- /dev/null +++ b/src/version2/parameters/getCustomContentLabels.ts @@ -0,0 +1,18 @@ +export interface GetCustomContentLabels { + /** The ID of the custom content for which labels should be returned. */ + id: number; + /** Filter the results to labels based on their prefix. */ + prefix?: string; + /** Used to sort the result by a particular field. */ + sort?: string; + /** + * Used for pagination, this opaque cursor will be returned in the `next` URL in the `Link` response header. Use the + * relative URL in the `Link` header to retrieve the `next` set of results. + */ + cursor?: string; + /** + * Maximum number of labels per result to return. If more results exist, use the `Link` header to retrieve a relative + * URL that will return the next set of results. + */ + limit?: number; +} diff --git a/src/version2/parameters/getCustomContentVersionDetails.ts b/src/version2/parameters/getCustomContentVersionDetails.ts new file mode 100644 index 00000000..86828aad --- /dev/null +++ b/src/version2/parameters/getCustomContentVersionDetails.ts @@ -0,0 +1,6 @@ +export interface GetCustomContentVersionDetails { + /** The ID of the custom content for which version details should be returned. */ + customContentId: number; + /** The version number of the custom content to be returned. */ + versionNumber: number; +} diff --git a/src/version2/parameters/getCustomContentVersions.ts b/src/version2/parameters/getCustomContentVersions.ts new file mode 100644 index 00000000..46deb100 --- /dev/null +++ b/src/version2/parameters/getCustomContentVersions.ts @@ -0,0 +1,24 @@ +export interface GetCustomContentVersions { + /** + * The ID of the custom content to be queried for its versions. If you don't know the custom content ID, use Get + * custom-content by type and filter the results. + */ + customContentId: number; + /** + * The content format types to be returned in the `body` field of the response. If available, the representation will + * be available under a response field of the same name under the `body` field. + */ + bodyFormat?: {}; + /** + * Used for pagination, this opaque cursor will be returned in the `next` URL in the `Link` response header. Use the + * relative URL in the `Link` header to retrieve the `next` set of results. + */ + cursor?: string; + /** + * Maximum number of versions per result to return. If more results exist, use the `Link` header to retrieve a + * relative URL that will return the next set of results. + */ + limit?: number; + /** Used to sort the result by a particular field. */ + sort?: 'modified-date' | '-modified-date'; +} diff --git a/src/version2/parameters/getFooterCommentById.ts b/src/version2/parameters/getFooterCommentById.ts new file mode 100644 index 00000000..b0db1b7b --- /dev/null +++ b/src/version2/parameters/getFooterCommentById.ts @@ -0,0 +1,14 @@ +export interface GetFooterCommentById { + /** The ID of the comment to be retrieved. */ + commentId: number; + /** + * The content format type to be returned in the `body` field of the response. If available, the representation will + * be available under a response field of the same name under the `body` field. + */ + bodyFormat?: {}; + /** + * Allows you to retrieve a previously published version. Specify the previous version's number to retrieve its + * details. + */ + version?: number; +} diff --git a/src/version2/parameters/getFooterCommentChildren.ts b/src/version2/parameters/getFooterCommentChildren.ts new file mode 100644 index 00000000..267ddf40 --- /dev/null +++ b/src/version2/parameters/getFooterCommentChildren.ts @@ -0,0 +1,21 @@ +export interface GetFooterCommentChildren { + /** The ID of the parent comment for which footer comment children should be returned. */ + id: number; + /** + * The content format type to be returned in the `body` field of the response. If available, the representation will + * be available under a response field of the same name under the `body` field. + */ + bodyFormat?: {}; + /** Used to sort the result by a particular field. */ + sort?: 'created-date' | '-created-date' | 'modified-date' | '-modified-date'; + /** + * Used for pagination, this opaque cursor will be returned in the `next` URL in the `Link` response header. Use the + * relative URL in the `Link` header to retrieve the `next` set of results. + */ + cursor?: string; + /** + * Maximum number of footer comments per result to return. If more results exist, use the `Link` header to retrieve a + * relative URL that will return the next set of results. + */ + limit?: number; +} diff --git a/src/version2/parameters/getFooterCommentVersionDetails.ts b/src/version2/parameters/getFooterCommentVersionDetails.ts new file mode 100644 index 00000000..20c953f1 --- /dev/null +++ b/src/version2/parameters/getFooterCommentVersionDetails.ts @@ -0,0 +1,6 @@ +export interface GetFooterCommentVersionDetails { + /** The ID of the footer comment for which version details should be returned. */ + id: number; + /** The version number of the footer comment to be returned. */ + versionNumber: number; +} diff --git a/src/version2/parameters/getFooterCommentVersions.ts b/src/version2/parameters/getFooterCommentVersions.ts new file mode 100644 index 00000000..e49bd173 --- /dev/null +++ b/src/version2/parameters/getFooterCommentVersions.ts @@ -0,0 +1,21 @@ +export interface GetFooterCommentVersions { + /** The ID of the footer comment for which versions should be returned */ + id: number; + /** + * The content format types to be returned in the `body` field of the response. If available, the representation will + * be available under a response field of the same name under the `body` field. + */ + bodyFormat?: {}; + /** + * Used for pagination, this opaque cursor will be returned in the `next` URL in the `Link` response header. Use the + * relative URL in the `Link` header to retrieve the `next` set of results. + */ + cursor?: string; + /** + * Maximum number of versions per result to return. If more results exist, use the `Link` header to retrieve a + * relative URL that will return the next set of results. + */ + limit?: number; + /** Used to sort the result by a particular field. */ + sort?: 'modified-date' | '-modified-date'; +} diff --git a/src/version2/parameters/getInlineCommentById.ts b/src/version2/parameters/getInlineCommentById.ts new file mode 100644 index 00000000..cd10c19b --- /dev/null +++ b/src/version2/parameters/getInlineCommentById.ts @@ -0,0 +1,14 @@ +export interface GetInlineCommentById { + /** The ID of the comment to be retrieved. */ + commentId: number; + /** + * The content format type to be returned in the `body` field of the response. If available, the representation will + * be available under a response field of the same name under the `body` field. + */ + bodyFormat?: {}; + /** + * Allows you to retrieve a previously published version. Specify the previous version's number to retrieve its + * details. + */ + version?: number; +} diff --git a/src/version2/parameters/getInlineCommentChildren.ts b/src/version2/parameters/getInlineCommentChildren.ts new file mode 100644 index 00000000..8badb372 --- /dev/null +++ b/src/version2/parameters/getInlineCommentChildren.ts @@ -0,0 +1,22 @@ +export interface GetInlineCommentChildren { + /** The ID of the parent comment for which inline comment children should be returned. */ + id: number; + + /** + * The content format type to be returned in the `body` field of the response. If available, the representation will + * be available under a response field of the same name under the `body` field. + */ + bodyFormat?: {}; + /** Used to sort the result by a particular field. */ + sort?: 'created-date' | '-created-date' | 'modified-date' | '-modified-date'; + /** + * Used for pagination, this opaque cursor will be returned in the `next` URL in the `Link` response header. Use the + * relative URL in the `Link` header to retrieve the `next` set of results. + */ + cursor?: string; + /** + * Maximum number of footer comments per result to return. If more results exist, use the `Link` header to retrieve a + * relative URL that will return the next set of results. + */ + limit?: number; +} diff --git a/src/version2/parameters/getInlineCommentVersionDetails.ts b/src/version2/parameters/getInlineCommentVersionDetails.ts new file mode 100644 index 00000000..11e35f6d --- /dev/null +++ b/src/version2/parameters/getInlineCommentVersionDetails.ts @@ -0,0 +1,6 @@ +export interface GetInlineCommentVersionDetails { + /** The ID of the inline comment for which version details should be returned. */ + id: number; + /** The version number of the inline comment to be returned. */ + versionNumber: number; +} diff --git a/src/version2/parameters/getInlineCommentVersions.ts b/src/version2/parameters/getInlineCommentVersions.ts new file mode 100644 index 00000000..5d1beb7e --- /dev/null +++ b/src/version2/parameters/getInlineCommentVersions.ts @@ -0,0 +1,21 @@ +export interface GetInlineCommentVersions { + /** The ID of the inline comment for which versions should be returned */ + id: number; + /** + * The content format types to be returned in the `body` field of the response. If available, the representation will + * be available under a response field of the same name under the `body` field. + */ + bodyFormat?: {}; + /** + * Used for pagination, this opaque cursor will be returned in the `next` URL in the `Link` response header. Use the + * relative URL in the `Link` header to retrieve the `next` set of results. + */ + cursor?: string; + /** + * Maximum number of versions per result to return. If more results exist, use the `Link` header to retrieve a + * relative URL that will return the next set of results. + */ + limit?: number; + /** Used to sort the result by a particular field. */ + sort?: 'modified-date' | '-modified-date'; +} diff --git a/src/version2/parameters/getLabelAttachments.ts b/src/version2/parameters/getLabelAttachments.ts new file mode 100644 index 00000000..ee31e304 --- /dev/null +++ b/src/version2/parameters/getLabelAttachments.ts @@ -0,0 +1,16 @@ +export interface GetLabelAttachments { + /** The ID of the label for which attachments should be returned. */ + id: number; + /** Used to sort the result by a particular field. */ + sort?: 'created-date' | '-created-date' | 'modified-date' | '-modified-date' | string; + /** + * Used for pagination, this opaque cursor will be returned in the `next` URL in the `Link` response header. Use the + * relative URL in the `Link` header to retrieve the `next` set of results. + */ + cursor?: string; + /** + * Maximum number of pages per result to return. If more results exist, use the `Link` header to retrieve a relative + * URL that will return the next set of results. + */ + limit?: number; +} diff --git a/src/version2/parameters/getLabelBlogPosts.ts b/src/version2/parameters/getLabelBlogPosts.ts new file mode 100644 index 00000000..b8254c48 --- /dev/null +++ b/src/version2/parameters/getLabelBlogPosts.ts @@ -0,0 +1,23 @@ +import { PrimaryBodyRepresentation } from '../models'; + +export interface GetLabelBlogPosts { + /** The ID of the label for which blog posts should be returned. */ + id: number; + /** + * The content format types to be returned in the `body` field of the response. If available, the representation will + * be available under a response field of the same name under the `body` field. + */ + bodyFormat?: PrimaryBodyRepresentation; + /** Used to sort the result by a particular field. */ + sort?: 'id' | '-id' | 'created-date' | '-created-date' | 'modified-date' | '-modified-date' | string; + /** + * Used for pagination, this opaque cursor will be returned in the `next` URL in the `Link` response header. Use the + * relative URL in the `Link` header to retrieve the `next` set of results. + */ + cursor?: string; + /** + * Maximum number of blog posts per result to return. If more results exist, use the `Link` header to retrieve a + * relative URL that will return the next set of results. + */ + limit?: number; +} diff --git a/src/version2/parameters/getLabelPages.ts b/src/version2/parameters/getLabelPages.ts new file mode 100644 index 00000000..940bcf35 --- /dev/null +++ b/src/version2/parameters/getLabelPages.ts @@ -0,0 +1,21 @@ +export interface GetLabelPages { + /** The ID of the label for which pages should be returned. */ + id: number; + /** + * The content format types to be returned in the `body` field of the response. If available, the representation will + * be available under a response field of the same name under the `body` field. + */ + bodyFormat?: {}; + /** Used to sort the result by a particular field. */ + sort?: 'id' | '-id' | 'created-date' | '-created-date' | 'modified-date' | '-modified-date'; + /** + * Used for pagination, this opaque cursor will be returned in the `next` URL in the `Link` response header. Use the + * relative URL in the `Link` header to retrieve the `next` set of results. + */ + cursor?: string; + /** + * Maximum number of pages per result to return. If more results exist, use the `Link` header to retrieve a relative + * URL that will return the next set of results. + */ + limit?: number; +} diff --git a/src/version2/parameters/getPageAttachments.ts b/src/version2/parameters/getPageAttachments.ts new file mode 100644 index 00000000..94d49fe3 --- /dev/null +++ b/src/version2/parameters/getPageAttachments.ts @@ -0,0 +1,20 @@ +export interface GetPageAttachments { + /** The ID of the page for which attachments should be returned. */ + id: number; + /** Used to sort the result by a particular field. */ + sort?: 'created-date' | '-created-date' | 'modified-date' | '-modified-date' | string; + /** + * Used for pagination, this opaque cursor will be returned in the `next` URL in the `Link` response header. Use the + * relative URL in the `Link` header to retrieve the `next` set of results. + */ + cursor?: string; + /** Filters on the mediaType of attachments. Only one may be specified. */ + mediaType?: string; + /** Filters on the file-name of attachments. Only one may be specified. */ + filename?: string; + /** + * Maximum number of attachments per result to return. If more results exist, use the `Link` header to retrieve a + * relative URL that will return the next set of results. + */ + limit?: number; +} diff --git a/src/version2/parameters/getPageById.ts b/src/version2/parameters/getPageById.ts new file mode 100644 index 00000000..1f58a8a4 --- /dev/null +++ b/src/version2/parameters/getPageById.ts @@ -0,0 +1,16 @@ +export interface GetPageById { + /** The ID of the page to be returned. If you don't know the page ID, use Get pages and filter the results. */ + id: number; + /** + * The content format types to be returned in the `body` field of the response. If available, the representation will + * be available under a response field of the same name under the `body` field. + */ + bodyFormat?: {}; + /** Retrieve the draft version of this page. */ + getDraft?: boolean; + /** + * Allows you to retrieve a previously published version. Specify the previous version's number to retrieve its + * details. + */ + version?: number; +} diff --git a/src/version2/parameters/getPageContentProperties.ts b/src/version2/parameters/getPageContentProperties.ts new file mode 100644 index 00000000..4a7599c0 --- /dev/null +++ b/src/version2/parameters/getPageContentProperties.ts @@ -0,0 +1,18 @@ +export interface GetPageContentProperties { + /** The ID of the page for which content properties should be returned. */ + pageId: number; + /** Filters the response to return a specific content property with matching key (case sensitive). */ + key: string; + /** Used to sort the result by a particular field. */ + sort?: 'key' | '-key'; + /** + * Used for pagination, this opaque cursor will be returned in the `next` URL in the `Link` response header. Use the + * relative URL in the `Link` header to retrieve the `next` set of results. + */ + cursor?: string; + /** + * Maximum number of attachments per result to return. If more results exist, use the `Link` header to retrieve a + * relative URL that will return the next set of results. + */ + limit?: number; +} diff --git a/src/version2/parameters/getPageContentPropertiesById.ts b/src/version2/parameters/getPageContentPropertiesById.ts new file mode 100644 index 00000000..72e05c77 --- /dev/null +++ b/src/version2/parameters/getPageContentPropertiesById.ts @@ -0,0 +1,6 @@ +export interface GetPageContentPropertiesById { + /** The ID of the page for which content properties should be returned. */ + pageId: number; + /** The ID of the content property being requested. */ + propertyId: number; +} diff --git a/src/version2/parameters/getPageFooterComments.ts b/src/version2/parameters/getPageFooterComments.ts new file mode 100644 index 00000000..e212c5ab --- /dev/null +++ b/src/version2/parameters/getPageFooterComments.ts @@ -0,0 +1,21 @@ +export interface GetPageFooterComments { + /** The ID of the page for which footer comments should be returned. */ + id: number; + /** + * The content format type to be returned in the `body` field of the response. If available, the representation will + * be available under a response field of the same name under the `body` field. + */ + bodyFormat?: {}; + /** Used to sort the result by a particular field. */ + sort?: 'created-date' | '-created-date' | 'modified-date' | '-modified-date'; + /** + * Used for pagination, this opaque cursor will be returned in the `next` URL in the `Link` response header. Use the + * relative URL in the `Link` header to retrieve the `next` set of results. + */ + cursor?: string; + /** + * Maximum number of footer comments per result to return. If more results exist, use the `Link` header to retrieve a + * relative URL that will return the next set of results. + */ + limit?: number; +} diff --git a/src/version2/parameters/getPageInlineComments.ts b/src/version2/parameters/getPageInlineComments.ts new file mode 100644 index 00000000..975550d7 --- /dev/null +++ b/src/version2/parameters/getPageInlineComments.ts @@ -0,0 +1,21 @@ +export interface GetPageInlineComments { + /** The ID of the page for which inline comments should be returned. */ + id: number; + /** + * The content format type to be returned in the `body` field of the response. If available, the representation will + * be available under a response field of the same name under the `body` field. + */ + bodyFormat?: {}; + /** Used to sort the result by a particular field. */ + sort?: 'created-date' | '-created-date' | 'modified-date' | '-modified-date'; + /** + * Used for pagination, this opaque cursor will be returned in the `next` URL in the `Link` response header. Use the + * relative URL in the `Link` header to retrieve the `next` set of results. + */ + cursor?: string; + /** + * Maximum number of inline comments per result to return. If more results exist, use the `Link` header to retrieve a + * relative URL that will return the next set of results. + */ + limit?: number; +} diff --git a/src/version2/parameters/getPageLabels.ts b/src/version2/parameters/getPageLabels.ts new file mode 100644 index 00000000..b883e437 --- /dev/null +++ b/src/version2/parameters/getPageLabels.ts @@ -0,0 +1,18 @@ +export interface GetPageLabels { + /** The ID of the page for which labels should be returned. */ + id: number; + /** Filter the results to labels based on their prefix. */ + prefix?: string; + /** Used to sort the result by a particular field. */ + sort?: string; + /** + * Used for pagination, this opaque cursor will be returned in the `next` URL in the `Link` response header. Use the + * relative URL in the `Link` header to retrieve the `next` set of results. + */ + cursor?: string; + /** + * Maximum number of labels per result to return. If more results exist, use the `Link` header to retrieve a relative + * URL that will return the next set of results. + */ + limit?: number; +} diff --git a/src/version2/parameters/getPageVersionDetails.ts b/src/version2/parameters/getPageVersionDetails.ts new file mode 100644 index 00000000..c968d455 --- /dev/null +++ b/src/version2/parameters/getPageVersionDetails.ts @@ -0,0 +1,6 @@ +export interface GetPageVersionDetails { + /** The ID of the page for which version details should be returned. */ + pageId: number; + /** The version number of the page to be returned. */ + versionNumber: number; +} diff --git a/src/version2/parameters/getPageVersions.ts b/src/version2/parameters/getPageVersions.ts new file mode 100644 index 00000000..ccbaa2ee --- /dev/null +++ b/src/version2/parameters/getPageVersions.ts @@ -0,0 +1,24 @@ +export interface GetPageVersions { + /** + * The ID of the page to be queried for its versions. If you don't know the page ID, use Get pages and filter the + * results. + */ + id: number; + /** + * The content format types to be returned in the `body` field of the response. If available, the representation will + * be available under a response field of the same name under the `body` field. + */ + bodyFormat?: {}; + /** + * Used for pagination, this opaque cursor will be returned in the `next` URL in the `Link` response header. Use the + * relative URL in the `Link` header to retrieve the `next` set of results. + */ + cursor?: string; + /** + * Maximum number of versions per result to return. If more results exist, use the `Link` header to retrieve a + * relative URL that will return the next set of results. + */ + limit?: number; + /** Used to sort the result by a particular field. */ + sort?: 'modified-date' | '-modified-date'; +} diff --git a/src/version2/parameters/getPages.ts b/src/version2/parameters/getPages.ts new file mode 100644 index 00000000..ab6e0b47 --- /dev/null +++ b/src/version2/parameters/getPages.ts @@ -0,0 +1,21 @@ +export interface GetPages { + /** Filter the results based on page ids. Multiple page ids can be specified as a comma-separated list. */ + id?: number[]; + /** Filter the results to pages based on their status. */ + status?: string; + /** + * The content format types to be returned in the `body` field of the response. If available, the representation will + * be available under a response field of the same name under the `body` field. + */ + bodyFormat?: {}; + /** + * Used for pagination, this opaque cursor will be returned in the `next` URL in the `Link` response header. Use the + * relative URL in the `Link` header to retrieve the `next` set of results. + */ + cursor?: string; + /** + * Maximum number of pages per result to return. If more results exist, use the `Link` header to retrieve a relative + * URL that will return the next set of results. + */ + limit?: number; +} diff --git a/src/version2/parameters/getPagesInSpace.ts b/src/version2/parameters/getPagesInSpace.ts new file mode 100644 index 00000000..130adbd7 --- /dev/null +++ b/src/version2/parameters/getPagesInSpace.ts @@ -0,0 +1,21 @@ +export interface GetPagesInSpace { + /** The ID of the space for which pages should be returned. */ + id: number; + /** Filter the results to pages based on their status. */ + status?: string; + /** + * The content format types to be returned in the `body` field of the response. If available, the representation will + * be available under a response field of the same name under the `body` field. + */ + bodyFormat?: {}; + /** + * Used for pagination, this opaque cursor will be returned in the `next` URL in the `Link` response header. Use the + * relative URL in the `Link` header to retrieve the `next` set of results. + */ + cursor?: string; + /** + * Maximum number of pages per result to return. If more results exist, use the `Link` header to retrieve a relative + * URL that will return the next set of results. + */ + limit?: number; +} diff --git a/src/version2/parameters/getSpaceById.ts b/src/version2/parameters/getSpaceById.ts new file mode 100644 index 00000000..c6a0bbe1 --- /dev/null +++ b/src/version2/parameters/getSpaceById.ts @@ -0,0 +1,11 @@ +import { SpaceDescriptionFormat } from '../models'; + +export interface GetSpaceById { + /** The ID of the space to be returned. */ + id: string; + /** + * The content format type to be returned in the `description` field of the response. If available, the representation + * will be available under a response field of the same name under the `description` field. + */ + descriptionFormat: SpaceDescriptionFormat; +} diff --git a/src/version2/parameters/getSpaceProperties.ts b/src/version2/parameters/getSpaceProperties.ts new file mode 100644 index 00000000..1d14984f --- /dev/null +++ b/src/version2/parameters/getSpaceProperties.ts @@ -0,0 +1,19 @@ +export interface GetSpaceProperties { + /** The ID of the space for which space properties should be returned. */ + spaceId: number; + /** + * The key of the space property to retrieve. This should be used when a user knows the key of their property, but + * needs to retrieve the id for use in other methods. + */ + key?: string; + /** + * Used for pagination, this opaque cursor will be returned in the `next` URL in the `Link` response header. Use the + * relative URL in the `Link` header to retrieve the `next` set of results. + */ + cursor?: string; + /** + * Maximum number of pages per result to return. If more results exist, use the `Link` header to retrieve a relative + * URL that will return the next set of results. + */ + limit?: number; +} diff --git a/src/version2/parameters/getSpacePropertyById.ts b/src/version2/parameters/getSpacePropertyById.ts new file mode 100644 index 00000000..fef871c6 --- /dev/null +++ b/src/version2/parameters/getSpacePropertyById.ts @@ -0,0 +1,6 @@ +export interface GetSpacePropertyById { + /** The ID of the space the property belongs to. */ + spaceId: number; + /** The ID of the property to be retrieved. */ + propertyId: number; +} diff --git a/src/version2/parameters/getSpaces.ts b/src/version2/parameters/getSpaces.ts new file mode 100644 index 00000000..df4d67ab --- /dev/null +++ b/src/version2/parameters/getSpaces.ts @@ -0,0 +1,31 @@ +import { SpaceDescriptionFormat } from '../models'; + +export interface GetSpaces { + /** Filter the results to spaces based on their IDs. Multiple IDs can be specified as a comma-separated list. */ + ids?: number[]; + /** Filter the results to spaces based on their keys. Multiple keys can be specified as a comma-separated list. */ + keys?: string[]; + /** Filter the results to spaces based on their type. */ + type?: string; + /** Filter the results to spaces based on their status. */ + status?: string; + /** Filter the results to spaces based on their labels. Multiple labels can be specified as a comma-separated list. */ + labels?: string[]; + /** Used to sort the result by a particular field. */ + sort?: 'id' | '-id' | 'key' | '-key' | 'name' | '-name'; + /** + * The content format type to be returned in the `description` field of the response. If available, the representation + * will be available under a response field of the same name under the `description` field. + */ + descriptionFormat?: SpaceDescriptionFormat; + /** + * Used for pagination, this opaque cursor will be returned in the `next` URL in the `Link` response header. Use the + * relative URL in the `Link` header to retrieve the `next` set of results. + */ + cursor?: string; + /** + * Maximum number of spaces per result to return. If more results exist, use the `Link` response header to retrieve a + * relative URL that will return the next set of results. + */ + limit?: number; +} diff --git a/src/version2/parameters/getTaskById.ts b/src/version2/parameters/getTaskById.ts new file mode 100644 index 00000000..0432783c --- /dev/null +++ b/src/version2/parameters/getTaskById.ts @@ -0,0 +1,9 @@ +export interface GetTaskById { + /** The ID of the task to be returned. If you don't know the task ID, use Get tasks and filter the results. */ + id: number; + /** + * The content format types to be returned in the `body` field of the response. If available, the representation will + * be available under a response field of the same name under the `body` field. + */ + bodyFormat?: {}; +} diff --git a/src/version2/parameters/getTasks.ts b/src/version2/parameters/getTasks.ts new file mode 100644 index 00000000..b1cedba4 --- /dev/null +++ b/src/version2/parameters/getTasks.ts @@ -0,0 +1,62 @@ +export interface GetTasks { + /** + * The content format types to be returned in the `body` field of the response. If available, the representation will + * be available under a response field of the same name under the `body` field. + */ + bodyFormat?: {}; + /** Specifies whether to include blank tasks in the response. Defaults to `true`. */ + includeBlankTasks?: boolean; + /** Filters on the status of the task. */ + status?: string; + /** Filters on task ID. Multiple IDs can be specified. */ + taskId?: number[]; + /** Filters on the space ID of the task. Multiple IDs can be specified. */ + spaceId?: number[]; + /** + * Filters on the page ID of the task. Multiple IDs can be specified. Note - page and blog post filters can be used in + * conjunction. + */ + pageId?: number[]; + /** + * Filters on the blog post ID of the task. Multiple IDs can be specified. Note - page and blog post filters can be + * used in conjunction. + */ + blogpostId?: number[]; + /** Filters on the Account ID of the user who created this task. Multiple IDs can be specified. */ + createdBy?: string[]; + /** Filters on the Account ID of the user to whom this task is assigned. Multiple IDs can be specified. */ + assignedTo?: string[]; + /** Filters on the Account ID of the user who completed this task. Multiple IDs can be specified. */ + completedBy?: string[]; + /** + * Filters on start of date-time range of task based on creation date (inclusive). Input is epoch time in + * milliseconds. + */ + createdAtFrom?: number; + /** Filters on end of date-time range of task based on creation date (inclusive). Input is epoch time in milliseconds. */ + createdAtTo?: number; + /** Filters on start of date-time range of task based on due date (inclusive). Input is epoch time in milliseconds. */ + dueAtFrom?: number; + /** Filters on end of date-time range of task based on due date (inclusive). Input is epoch time in milliseconds. */ + dueAtTo?: number; + /** + * Filters on start of date-time range of task based on completion date (inclusive). Input is epoch time in + * milliseconds. + */ + completedAtFrom?: number; + /** + * Filters on end of date-time range of task based on completion date (inclusive). Input is epoch time in + * milliseconds. + */ + completedAtTo?: number; + /** + * Used for pagination, this opaque cursor will be returned in the `next` URL in the `Link` response header. Use the + * relative URL in the `Link` header to retrieve the `next` set of results. + */ + cursor?: string; + /** + * Maximum number of tasks per result to return. If more results exist, use the `Link` header to retrieve a relative + * URL that will return the next set of results. + */ + limit?: number; +} diff --git a/src/version2/parameters/index.ts b/src/version2/parameters/index.ts new file mode 100644 index 00000000..99c67fbf --- /dev/null +++ b/src/version2/parameters/index.ts @@ -0,0 +1,94 @@ +export * from './createAttachmentProperty'; +export * from './createBlogPost'; +export * from './createBlogpostProperty'; +export * from './createCommentProperty'; +export * from './createCustomContent'; +export * from './createCustomContentProperty'; +export * from './createFooterComment'; +export * from './createInlineComment'; +export * from './createPage'; +export * from './createPageProperty'; +export * from './createSpaceProperty'; +export * from './deleteAttachmentPropertyById'; +export * from './deleteBlogPost'; +export * from './deleteBlogpostPropertyById'; +export * from './deleteCommentPropertyById'; +export * from './deleteCustomContent'; +export * from './deleteCustomContentPropertyById'; +export * from './deleteFooterComment'; +export * from './deleteInlineComment'; +export * from './deletePage'; +export * from './deletePagePropertyById'; +export * from './deleteSpacePropertyById'; +export * from './getAttachmentById'; +export * from './getAttachmentContentProperties'; +export * from './getAttachmentContentPropertiesById'; +export * from './getAttachmentLabels'; +export * from './getAttachmentVersionDetails'; +export * from './getAttachmentVersions'; +export * from './getBlogpostAttachments'; +export * from './getBlogPostById'; +export * from './getBlogpostContentProperties'; +export * from './getBlogpostContentPropertiesById'; +export * from './getBlogPostFooterComments'; +export * from './getBlogPostInlineComments'; +export * from './getBlogPostLabels'; +export * from './getBlogPosts'; +export * from './getBlogPostsInSpace'; +export * from './getBlogPostVersionDetails'; +export * from './getBlogPostVersions'; +export * from './getChildCustomContent'; +export * from './getChildPages'; +export * from './getCommentContentProperties'; +export * from './getCommentContentPropertiesById'; +export * from './getCustomContentAttachments'; +export * from './getCustomContentById'; +export * from './getCustomContentByType'; +export * from './getCustomContentByTypeInBlogPost'; +export * from './getCustomContentByTypeInPage'; +export * from './getCustomContentByTypeInSpace'; +export * from './getCustomContentContentProperties'; +export * from './getCustomContentContentPropertiesById'; +export * from './getCustomContentLabels'; +export * from './getCustomContentVersionDetails'; +export * from './getCustomContentVersions'; +export * from './getFooterCommentById'; +export * from './getFooterCommentChildren'; +export * from './getFooterCommentVersionDetails'; +export * from './getFooterCommentVersions'; +export * from './getInlineCommentById'; +export * from './getInlineCommentChildren'; +export * from './getInlineCommentVersionDetails'; +export * from './getInlineCommentVersions'; +export * from './getLabelAttachments'; +export * from './getLabelBlogPosts'; +export * from './getLabelPages'; +export * from './getPageAttachments'; +export * from './getPageById'; +export * from './getPageContentProperties'; +export * from './getPageContentPropertiesById'; +export * from './getPageFooterComments'; +export * from './getPageInlineComments'; +export * from './getPageLabels'; +export * from './getPages'; +export * from './getPagesInSpace'; +export * from './getPageVersionDetails'; +export * from './getPageVersions'; +export * from './getSpaceById'; +export * from './getSpaceProperties'; +export * from './getSpacePropertyById'; +export * from './getSpaces'; +export * from './getTaskById'; +export * from './getTasks'; +export * from './updateAttachmentPropertyById'; +export * from './updateBlogPost'; +export * from './updateBlogpostPropertyById'; +export * from './updateCommentPropertyById'; +export * from './updateCustomContent'; +export * from './updateCustomContentPropertyById'; +export * from './updateFooterComment'; +export * from './updateInlineComment'; +export * from './updatePage'; +export * from './updatePagePropertyById'; +export * from './updateSpacePropertyById'; +export * from './updateTask'; diff --git a/src/version2/parameters/updateAttachmentPropertyById.ts b/src/version2/parameters/updateAttachmentPropertyById.ts new file mode 100644 index 00000000..bdcfbd49 --- /dev/null +++ b/src/version2/parameters/updateAttachmentPropertyById.ts @@ -0,0 +1,8 @@ +import { ContentPropertyUpdateRequest } from '../models'; + +export interface UpdateAttachmentPropertyById extends ContentPropertyUpdateRequest { + /** The ID of the attachment the property belongs to. */ + attachmentId: string; + /** The ID of the property to be updated. */ + propertyId: number; +} diff --git a/src/version2/parameters/updateBlogPost.ts b/src/version2/parameters/updateBlogPost.ts new file mode 100644 index 00000000..0164264d --- /dev/null +++ b/src/version2/parameters/updateBlogPost.ts @@ -0,0 +1,7 @@ +export interface UpdateBlogPost { + /** + * The ID of the blog post to be updated. If you don't know the blog post ID, use Get Blog Posts and filter the + * results. + */ + id: number; +} diff --git a/src/version2/parameters/updateBlogpostPropertyById.ts b/src/version2/parameters/updateBlogpostPropertyById.ts new file mode 100644 index 00000000..d10dda04 --- /dev/null +++ b/src/version2/parameters/updateBlogpostPropertyById.ts @@ -0,0 +1,8 @@ +import { ContentPropertyUpdateRequest } from '../models'; + +export interface UpdateBlogpostPropertyById extends ContentPropertyUpdateRequest { + /** The ID of the blog post the property belongs to. */ + blogpostId: number; + /** The ID of the property to be updated. */ + propertyId: number; +} diff --git a/src/version2/parameters/updateCommentPropertyById.ts b/src/version2/parameters/updateCommentPropertyById.ts new file mode 100644 index 00000000..648e7b6e --- /dev/null +++ b/src/version2/parameters/updateCommentPropertyById.ts @@ -0,0 +1,8 @@ +import { ContentPropertyUpdateRequest } from '../models'; + +export interface UpdateCommentPropertyById extends ContentPropertyUpdateRequest { + /** The ID of the comment the property belongs to. */ + commentId: number; + /** The ID of the property to be updated. */ + propertyId: number; +} diff --git a/src/version2/parameters/updateCustomContent.ts b/src/version2/parameters/updateCustomContent.ts new file mode 100644 index 00000000..31dd61b2 --- /dev/null +++ b/src/version2/parameters/updateCustomContent.ts @@ -0,0 +1,7 @@ +export interface UpdateCustomContent { + /** + * The ID of the custom content to be updated. If you don't know the custom content ID, use Get Custom Content by Type + * and filter the results. + */ + id: number; +} diff --git a/src/version2/parameters/updateCustomContentPropertyById.ts b/src/version2/parameters/updateCustomContentPropertyById.ts new file mode 100644 index 00000000..3c98df5f --- /dev/null +++ b/src/version2/parameters/updateCustomContentPropertyById.ts @@ -0,0 +1,8 @@ +import { ContentPropertyUpdateRequest } from '../models'; + +export interface UpdateCustomContentPropertyById extends ContentPropertyUpdateRequest { + /** The ID of the custom content the property belongs to. */ + customContentId: number; + /** The ID of the property to be updated. */ + propertyId: number; +} diff --git a/src/version2/parameters/updateFooterComment.ts b/src/version2/parameters/updateFooterComment.ts new file mode 100644 index 00000000..f4f2295b --- /dev/null +++ b/src/version2/parameters/updateFooterComment.ts @@ -0,0 +1,11 @@ +export interface UpdateFooterComment { + /** The ID of the comment to be retrieved. */ + commentId: number; + version?: { + /** Number of new version. Should be 1 higher than current version of the comment. */ + number?: number; + /** Optional message store for the new version. */ + message?: string; + }; + body?: {}; +} diff --git a/src/version2/parameters/updateInlineComment.ts b/src/version2/parameters/updateInlineComment.ts new file mode 100644 index 00000000..f7b37029 --- /dev/null +++ b/src/version2/parameters/updateInlineComment.ts @@ -0,0 +1,17 @@ +export interface UpdateInlineComment { + /** The ID of the comment to be retrieved. */ + commentId: number; + version?: { + /** Number of new version. Should be 1 higher than current version of the comment. */ + number?: number; + /** Optional message store for the new version. */ + message?: string; + }; + body?: {}; + /** + * Resolved state of the comment. Set to true to resolve the comment, set to false to reopen it. If matching the + * existing state (i.e. true -> resolved or false -> open/reopened) , no change will occur. A dangling comment cannot + * be updated. + */ + resolved?: boolean; +} diff --git a/src/version2/parameters/updatePage.ts b/src/version2/parameters/updatePage.ts new file mode 100644 index 00000000..c389f18a --- /dev/null +++ b/src/version2/parameters/updatePage.ts @@ -0,0 +1,4 @@ +export interface UpdatePage { + /** The ID of the page to be updated. If you don't know the page ID, use Get Pages and filter the results. */ + id: number; +} diff --git a/src/version2/parameters/updatePagePropertyById.ts b/src/version2/parameters/updatePagePropertyById.ts new file mode 100644 index 00000000..3a53f276 --- /dev/null +++ b/src/version2/parameters/updatePagePropertyById.ts @@ -0,0 +1,8 @@ +import { ContentPropertyUpdateRequest } from '../models'; + +export interface UpdatePagePropertyById extends ContentPropertyUpdateRequest { + /** The ID of the page the property belongs to. */ + pageId: number; + /** The ID of the property to be updated. */ + propertyId: number; +} diff --git a/src/version2/parameters/updateSpacePropertyById.ts b/src/version2/parameters/updateSpacePropertyById.ts new file mode 100644 index 00000000..0b114dab --- /dev/null +++ b/src/version2/parameters/updateSpacePropertyById.ts @@ -0,0 +1,17 @@ +export interface UpdateSpacePropertyById { + /** The ID of the space the property belongs to. */ + spaceId: number; + /** The ID of the property to be updated. */ + propertyId: number; + /** Key of the space property */ + key: string; + /** Value of the space property. */ + value: any; + /** New version number and associated message */ + version?: { + /** Version number of the new version. Should be 1 more than the current version number. */ + number?: number; + /** Message to be associated with the new version. */ + message?: string; + }; +} diff --git a/src/version2/parameters/updateTask.ts b/src/version2/parameters/updateTask.ts new file mode 100644 index 00000000..032fe1ee --- /dev/null +++ b/src/version2/parameters/updateTask.ts @@ -0,0 +1,4 @@ +export interface UpdateTask { + /** The ID of the task to be updated. If you don't know the task ID, use Get tasks and filter the results. */ + id: number; +} diff --git a/src/version2/space.ts b/src/version2/space.ts new file mode 100644 index 00000000..3f4c3e28 --- /dev/null +++ b/src/version2/space.ts @@ -0,0 +1,116 @@ +import * as Models from './models'; +import * as Parameters from './parameters'; +import { Callback } from '../callback'; +import { Client } from '../clients'; +import { PaginationService } from '../services'; +import { RequestConfig } from '../requestConfig'; + +export class Space { + private paginationService = new PaginationService(); + + constructor(private client: Client) {} + + /** Fetches all spaces. */ + async getAllSpaces( + parameters: Parameters.GetSpaces | undefined, + callback: Callback, + ): Promise; + /** Fetches all spaces. */ + async getAllSpaces(parameters?: Parameters.GetSpaces, callback?: never): Promise; + async getAllSpaces(parameters?: Parameters.GetSpaces, callback?: Callback): Promise { + try { + const { getAll: getAllSpaces } = await this.getSpaces(parameters); + + const spaces = await getAllSpaces(); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(spaces as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** + * Returns all spaces. The results will be sorted by id ascending. The number of results is limited by the `limit` + * parameter and additional results (if available) will be available through the `next` URL present in the `Link` + * response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to access the Confluence site + * ('Can use' global permission). Only spaces that the user has permission to view will be returned. + */ + async getSpaces>( + parameters: Parameters.GetSpaces | undefined, + callback: Callback, + ): Promise; + /** + * Returns all spaces. The results will be sorted by id ascending. The number of results is limited by the `limit` + * parameter and additional results (if available) will be available through the `next` URL present in the `Link` + * response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to access the Confluence site + * ('Can use' global permission). Only spaces that the user has permission to view will be returned. + */ + async getSpaces>(parameters?: Parameters.GetSpaces, callback?: never): Promise; + async getSpaces>( + parameters?: Parameters.GetSpaces, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: '/spaces', + method: 'GET', + params: { + ids: parameters?.ids, + keys: parameters?.keys, + type: parameters?.type, + status: parameters?.status, + labels: parameters?.labels, + sort: parameters?.sort, + 'description-format': parameters?.descriptionFormat, + cursor: parameters?.cursor, + limit: parameters?.limit, + 'serialize-ids-as-strings': true, + }, + }; + + try { + const spaces = await this.client.sendRequest>(config); + const paginatedSpaces = this.paginationService.buildPaginatedResult(spaces, this.getSpaces.bind(this)); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(paginatedSpaces as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** + * Returns a specific space. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the space. + */ + async getSpaceById(parameters: Parameters.GetSpaceById, callback: Callback): Promise; + /** + * Returns a specific space. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the space. + */ + async getSpaceById(parameters: Parameters.GetSpaceById, callback?: never): Promise; + async getSpaceById(parameters: Parameters.GetSpaceById, callback?: Callback): Promise { + const config: RequestConfig = { + url: `/spaces/${parameters.id}`, + method: 'GET', + params: { + 'description-format': parameters.descriptionFormat, + 'serialize-ids-as-strings': true, + }, + }; + + return this.client.sendRequest(config, callback); + } +} diff --git a/src/version2/spaceProperties.ts b/src/version2/spaceProperties.ts new file mode 100644 index 00000000..d2d35dcd --- /dev/null +++ b/src/version2/spaceProperties.ts @@ -0,0 +1,208 @@ +import * as Models from './models'; +import * as Parameters from './parameters'; +import { Callback } from '../callback'; +import { Client } from '../clients'; +import { PaginationService } from '../services'; +import { RequestConfig } from '../requestConfig'; + +export class SpaceProperties { + private paginationService = new PaginationService(); + + constructor(private client: Client) {} + + /** + * Returns all properties for the given space. Space properties are a key-value storage associated with a space. The + * limit parameter specifies the maximum number of results returned in a single response. Use the `link` response + * header to paginate through additional results. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to access the Confluence site + * ('Can use' global permission) and 'View' permission for the space. + */ + async getSpaceProperties>( + parameters: Parameters.GetSpaceProperties, + callback: Callback, + ): Promise; + /** + * Returns all properties for the given space. Space properties are a key-value storage associated with a space. The + * limit parameter specifies the maximum number of results returned in a single response. Use the `link` response + * header to paginate through additional results. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to access the Confluence site + * ('Can use' global permission) and 'View' permission for the space. + */ + async getSpaceProperties>( + parameters: Parameters.GetSpaceProperties, + callback?: never, + ): Promise; + async getSpaceProperties>( + parameters: Parameters.GetSpaceProperties, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/spaces/${parameters.spaceId}/properties`, + method: 'GET', + params: { + key: parameters.key, + cursor: parameters.cursor, + limit: parameters.limit, + 'serialize-ids-as-strings': true, + }, + }; + + try { + const spaceProperties = await this.client.sendRequest>(config); + const paginatedSpaceProperties = this.paginationService.buildPaginatedResult(spaceProperties, this.getSpaceProperties.bind(this)); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(paginatedSpaceProperties as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** + * Creates a new space property. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to access the Confluence site + * ('Can use' global permission) and 'Admin' permission for the space. + */ + async createSpaceProperty( + parameters: Parameters.CreateSpaceProperty, + callback: Callback, + ): Promise; + /** + * Creates a new space property. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to access the Confluence site + * ('Can use' global permission) and 'Admin' permission for the space. + */ + async createSpaceProperty( + parameters: Parameters.CreateSpaceProperty, + callback?: never, + ): Promise; + async createSpaceProperty( + parameters: Parameters.CreateSpaceProperty, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/spaces/${parameters.spaceId}/properties`, + method: 'POST', + params: { + 'serialize-ids-as-strings': true, + }, + data: { + key: parameters.key, + value: parameters.value, + }, + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Retrieve a space property by its id. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to access the Confluence site + * ('Can use' global permission) and 'View' permission for the space. + */ + async getSpacePropertyById( + parameters: Parameters.GetSpacePropertyById, + callback: Callback, + ): Promise; + /** + * Retrieve a space property by its id. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to access the Confluence site + * ('Can use' global permission) and 'View' permission for the space. + */ + async getSpacePropertyById( + parameters: Parameters.GetSpacePropertyById, + callback?: never, + ): Promise; + async getSpacePropertyById( + parameters: Parameters.GetSpacePropertyById, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/spaces/${parameters.spaceId}/properties/${parameters.propertyId}`, + method: 'GET', + params: { + 'serialize-ids-as-strings': true, + }, + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Update a space property by its id. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to access the Confluence site + * ('Can use' global permission) and 'Admin' permission for the space. + */ + async updateSpacePropertyById( + parameters: Parameters.UpdateSpacePropertyById, + callback: Callback, + ): Promise; + /** + * Update a space property by its id. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to access the Confluence site + * ('Can use' global permission) and 'Admin' permission for the space. + */ + async updateSpacePropertyById( + parameters: Parameters.UpdateSpacePropertyById, + callback?: never, + ): Promise; + async updateSpacePropertyById( + parameters: Parameters.UpdateSpacePropertyById, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/spaces/${parameters.spaceId}/properties/${parameters.propertyId}`, + method: 'PUT', + params: { + 'serialize-ids-as-strings': true, + }, + data: { + key: parameters.key, + value: parameters.value, + version: parameters.version, + }, + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Deletes a space property by its id. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to access the Confluence site + * ('Can use' global permission) and 'Admin' permission for the space. + */ + async deleteSpacePropertyById( + parameters: Parameters.DeleteSpacePropertyById, + callback: Callback, + ): Promise; + /** + * Deletes a space property by its id. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to access the Confluence site + * ('Can use' global permission) and 'Admin' permission for the space. + */ + async deleteSpacePropertyById(parameters: Parameters.DeleteSpacePropertyById, callback?: never): Promise; + async deleteSpacePropertyById( + parameters: Parameters.DeleteSpacePropertyById, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/spaces/${parameters.spaceId}/properties/${parameters.propertyId}`, + method: 'DELETE', + }; + + return this.client.sendRequest(config, callback); + } +} diff --git a/src/version2/task.ts b/src/version2/task.ts new file mode 100644 index 00000000..095d71c9 --- /dev/null +++ b/src/version2/task.ts @@ -0,0 +1,128 @@ +import * as Models from './models'; +import * as Parameters from './parameters'; +import { Callback } from '../callback'; +import { Client } from '../clients'; +import { PaginationService } from '../services'; +import { RequestConfig } from '../requestConfig'; + +export class Task { + private paginationService = new PaginationService(); + + constructor(private client: Client) { } + + /** + * Returns all tasks. The number of results is limited by the `limit` parameter and additional results (if available) + * will be available through the `next` URL present in the `Link` response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to access the Confluence site + * ('Can use' global permission). Only tasks that the user has permission to view will be returned. + */ + async getTasks>( + parameters: Parameters.GetTasks | undefined, + callback: Callback, + ): Promise; + /** + * Returns all tasks. The number of results is limited by the `limit` parameter and additional results (if available) + * will be available through the `next` URL present in the `Link` response header. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to access the Confluence site + * ('Can use' global permission). Only tasks that the user has permission to view will be returned. + */ + async getTasks>(parameters?: Parameters.GetTasks, callback?: never): Promise; + async getTasks>( + parameters?: Parameters.GetTasks, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: '/tasks', + method: 'GET', + params: { + 'body-format': parameters?.bodyFormat, + 'include-blank-tasks': parameters?.includeBlankTasks, + status: parameters?.status, + 'task-id': parameters?.taskId, + 'space-id': parameters?.spaceId, + 'page-id': parameters?.pageId, + 'blogpost-id': parameters?.blogpostId, + 'created-by': parameters?.createdBy, + 'assigned-to': parameters?.assignedTo, + 'completed-by': parameters?.completedBy, + 'created-at-from': parameters?.createdAtFrom, + 'created-at-to': parameters?.createdAtTo, + 'due-at-from': parameters?.dueAtFrom, + 'due-at-to': parameters?.dueAtTo, + 'completed-at-from': parameters?.completedAtFrom, + 'completed-at-to': parameters?.completedAtTo, + cursor: parameters?.cursor, + limit: parameters?.limit, + 'serialize-ids-as-strings': true, + }, + }; + + try { + const tasks = await this.client.sendRequest>(config); + const paginatedTasks = this.paginationService.buildPaginatedResult(tasks, this.getTasks.bind(this)); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(paginatedTasks as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** + * Returns a specific task. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the containing page or + * blog post and its corresponding space. + */ + async getTaskById(parameters: Parameters.GetTaskById, callback: Callback): Promise; + /** + * Returns a specific task. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the containing page or + * blog post and its corresponding space. + */ + async getTaskById(parameters: Parameters.GetTaskById, callback?: never): Promise; + async getTaskById(parameters: Parameters.GetTaskById, callback?: Callback): Promise { + const config: RequestConfig = { + url: `/tasks/${parameters.id}`, + method: 'GET', + params: { + 'body-format': parameters.bodyFormat, + 'serialize-ids-as-strings': true, + }, + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Update a task by id. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to edit the containing page or + * blog post and view its corresponding space. + */ + async updateTask(parameters: Parameters.UpdateTask, callback: Callback): Promise; + /** + * Update a task by id. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to edit the containing page or + * blog post and view its corresponding space. + */ + async updateTask(parameters: Parameters.UpdateTask, callback?: never): Promise; + async updateTask(parameters: Parameters.UpdateTask, callback?: Callback): Promise { + const config: RequestConfig = { + url: `/tasks/${parameters.id}`, + method: 'PUT', + params: { + 'serialize-ids-as-strings': true, + }, + }; + + return this.client.sendRequest(config, callback); + } +} diff --git a/src/version2/user.ts b/src/version2/user.ts new file mode 100644 index 00000000..7959ed3a --- /dev/null +++ b/src/version2/user.ts @@ -0,0 +1,54 @@ +import * as Models from './models'; +import { Callback } from '../callback'; +import { Client } from '../clients'; +import { RequestConfig } from '../requestConfig'; + +export class User { + constructor(private client: Client) {} + + /** + * Returns the list of emails from the input list that do not have access to site. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to access the Confluence site + * ('Can use' global permission). + */ + async checkAccessByEmail(callback: Callback): Promise; + /** + * Returns the list of emails from the input list that do not have access to site. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to access the Confluence site + * ('Can use' global permission). + */ + async checkAccessByEmail(callback?: never): Promise; + async checkAccessByEmail(callback?: Callback): Promise { + const config: RequestConfig = { + url: '/user/access/check-access-by-email', + method: 'POST', + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Invite a list of emails to the site. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to access the Confluence site + * ('Can use' global permission). + */ + async inviteByEmail(callback: Callback): Promise; + /** + * Invite a list of emails to the site. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to access the Confluence site + * ('Can use' global permission). + */ + async inviteByEmail(callback?: never): Promise; + async inviteByEmail(callback?: Callback): Promise { + const config: RequestConfig = { + url: '/user/access/invite-by-email', + method: 'POST', + }; + + return this.client.sendRequest(config, callback); + } +} diff --git a/src/version2/version.ts b/src/version2/version.ts new file mode 100644 index 00000000..6d0a314c --- /dev/null +++ b/src/version2/version.ts @@ -0,0 +1,489 @@ +import * as Models from './models'; +import * as Parameters from './parameters'; +import { Callback } from '../callback'; +import { Client } from '../clients'; +import { PaginationService } from '../services'; +import { RequestConfig } from '../requestConfig'; + +export class Version { + private paginationService = new PaginationService(); + + constructor(private client: Client) {} + + /** + * Returns the versions of specific attachment. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the attachment and its + * corresponding space. + */ + async getAttachmentVersions>( + parameters: Parameters.GetAttachmentVersions, + callback: Callback, + ): Promise; + /** + * Returns the versions of specific attachment. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the attachment and its + * corresponding space. + */ + async getAttachmentVersions>( + parameters: Parameters.GetAttachmentVersions, + callback?: never, + ): Promise; + async getAttachmentVersions>( + parameters: Parameters.GetAttachmentVersions, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/attachments/${parameters.id}/versions`, + method: 'GET', + params: { + cursor: parameters.cursor, + limit: parameters.limit, + sort: parameters.sort, + }, + }; + + try { + const attachmentVersions = await this.client.sendRequest>(config); + const paginatedAttachmentVersions = this.paginationService.buildPaginatedResult(attachmentVersions, this.getAttachmentVersions.bind(this)); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(paginatedAttachmentVersions as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** + * Retrieves version details for the specified attachment and version number. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the attachment. + */ + async getAttachmentVersionDetails( + parameters: Parameters.GetAttachmentVersionDetails, + callback: Callback, + ): Promise; + /** + * Retrieves version details for the specified attachment and version number. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the attachment. + */ + async getAttachmentVersionDetails( + parameters: Parameters.GetAttachmentVersionDetails, + callback?: never, + ): Promise; + async getAttachmentVersionDetails( + parameters: Parameters.GetAttachmentVersionDetails, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/attachments/${parameters.attachmentId}/versions/${parameters.versionNumber}`, + method: 'GET', + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Returns the versions of specific blog post. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the blog post and its + * corresponding space. + */ + async getBlogPostVersions>( + parameters: Parameters.GetBlogPostVersions, + callback: Callback, + ): Promise; + /** + * Returns the versions of specific blog post. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the blog post and its + * corresponding space. + */ + async getBlogPostVersions>( + parameters: Parameters.GetBlogPostVersions, + callback?: never, + ): Promise; + async getBlogPostVersions>( + parameters: Parameters.GetBlogPostVersions, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/blogposts/${parameters.id}/versions`, + method: 'GET', + params: { + 'body-format': parameters.bodyFormat, + cursor: parameters.cursor, + limit: parameters.limit, + sort: parameters.sort, + }, + }; + + try { + const blogPostVersions = await this.client.sendRequest>(config); + const paginatedBlogPostVersions = this.paginationService.buildPaginatedResult(blogPostVersions, this.getBlogPostVersions.bind(this)); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(paginatedBlogPostVersions as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** + * Retrieves version details for the specified blog post and version number. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the blog post. + */ + async getBlogPostVersionDetails( + parameters: Parameters.GetBlogPostVersionDetails, + callback: Callback, + ): Promise; + /** + * Retrieves version details for the specified blog post and version number. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the blog post. + */ + async getBlogPostVersionDetails( + parameters: Parameters.GetBlogPostVersionDetails, + callback?: never, + ): Promise; + async getBlogPostVersionDetails( + parameters: Parameters.GetBlogPostVersionDetails, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/blogposts/${parameters.blogpostId}/versions/${parameters.versionNumber}`, + method: 'GET', + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Returns the versions of specific page. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the page and its + * corresponding space. + */ + async getPageVersions>( + parameters: Parameters.GetPageVersions, + callback: Callback, + ): Promise; + /** + * Returns the versions of specific page. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the page and its + * corresponding space. + */ + async getPageVersions>( + parameters: Parameters.GetPageVersions, + callback?: never, + ): Promise; + async getPageVersions>( + parameters: Parameters.GetPageVersions, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/pages/${parameters.id}/versions`, + method: 'GET', + params: { + 'body-format': parameters.bodyFormat, + cursor: parameters.cursor, + limit: parameters.limit, + sort: parameters.sort, + }, + }; + + try { + const pageVersions = await this.client.sendRequest>(config); + const paginatedPageVersions = this.paginationService.buildPaginatedResult(pageVersions, this.getPageVersions.bind(this)); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(paginatedPageVersions as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** + * Retrieves version details for the specified page and version number. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the page. + */ + async getPageVersionDetails( + parameters: Parameters.GetPageVersionDetails, + callback: Callback, + ): Promise; + /** + * Retrieves version details for the specified page and version number. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the page. + */ + async getPageVersionDetails( + parameters: Parameters.GetPageVersionDetails, + callback?: never, + ): Promise; + async getPageVersionDetails( + parameters: Parameters.GetPageVersionDetails, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/pages/${parameters.pageId}/versions/${parameters.versionNumber}`, + method: 'GET', + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Returns the versions of specific custom content. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the custom content and + * its corresponding page and space. + */ + async getCustomContentVersions>( + parameters: Parameters.GetCustomContentVersions, + callback: Callback, + ): Promise; + /** + * Returns the versions of specific custom content. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the custom content and + * its corresponding page and space. + */ + async getCustomContentVersions>( + parameters: Parameters.GetCustomContentVersions, + callback?: never, + ): Promise; + async getCustomContentVersions>( + parameters: Parameters.GetCustomContentVersions, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/custom-content/${parameters.customContentId}/versions`, + method: 'GET', + params: { + 'body-format': parameters.bodyFormat, + cursor: parameters.cursor, + limit: parameters.limit, + sort: parameters.sort, + }, + }; + + try { + const customContentVersions = await this.client.sendRequest>(config); + const paginatedCustomContentVersions = this.paginationService.buildPaginatedResult(customContentVersions, this.getCustomContentVersions.bind(this)); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(paginatedCustomContentVersions as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** + * Retrieves version details for the specified custom content and version number. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the page. + */ + async getCustomContentVersionDetails( + parameters: Parameters.GetCustomContentVersionDetails, + callback: Callback, + ): Promise; + /** + * Retrieves version details for the specified custom content and version number. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the page. + */ + async getCustomContentVersionDetails( + parameters: Parameters.GetCustomContentVersionDetails, + callback?: never, + ): Promise; + async getCustomContentVersionDetails( + parameters: Parameters.GetCustomContentVersionDetails, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/custom-content/${parameters.customContentId}/versions/${parameters.versionNumber}`, + method: 'GET', + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Retrieves the versions of the specified footer comment. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the page + * or blog post and its corresponding space. + */ + async getFooterCommentVersions>( + parameters: Parameters.GetFooterCommentVersions, + callback: Callback, + ): Promise; + /** + * Retrieves the versions of the specified footer comment. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the page + * or blog post and its corresponding space. + */ + async getFooterCommentVersions>( + parameters: Parameters.GetFooterCommentVersions, + callback?: never, + ): Promise; + async getFooterCommentVersions>( + parameters: Parameters.GetFooterCommentVersions, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/footer-comments/${parameters.id}/versions`, + method: 'GET', + params: { + 'body-format': parameters.bodyFormat, + cursor: parameters.cursor, + limit: parameters.limit, + sort: parameters.sort, + }, + }; + + try { + const commentVersions = await this.client.sendRequest>(config); + const paginatedCommentVersions = this.paginationService.buildPaginatedResult(commentVersions, this.getFooterCommentVersions.bind(this)); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(paginatedCommentVersions as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** + * Retrieves version details for the specified footer comment version. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the page + * or blog post and its corresponding space. + */ + async getFooterCommentVersionDetails( + parameters: Parameters.GetFooterCommentVersionDetails, + callback: Callback, + ): Promise; + /** + * Retrieves version details for the specified footer comment version. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the page + * or blog post and its corresponding space. + */ + async getFooterCommentVersionDetails( + parameters: Parameters.GetFooterCommentVersionDetails, + callback?: never, + ): Promise; + async getFooterCommentVersionDetails( + parameters: Parameters.GetFooterCommentVersionDetails, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/footer-comments/${parameters.id}/versions/${parameters.versionNumber}`, + method: 'GET', + }; + + return this.client.sendRequest(config, callback); + } + + /** + * Retrieves the versions of the specified inline comment. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the page + * or blog post and its corresponding space. + */ + async getInlineCommentVersions>( + parameters: Parameters.GetInlineCommentVersions, + callback: Callback, + ): Promise; + /** + * Retrieves the versions of the specified inline comment. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the page + * or blog post and its corresponding space. + */ + async getInlineCommentVersions>( + parameters: Parameters.GetInlineCommentVersions, + callback?: never, + ): Promise; + async getInlineCommentVersions>( + parameters: Parameters.GetInlineCommentVersions, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/inline-comments/${parameters.id}/versions`, + method: 'GET', + params: { + 'body-format': parameters.bodyFormat, + cursor: parameters.cursor, + limit: parameters.limit, + sort: parameters.sort, + }, + }; + + try { + const commentVersions = await this.client.sendRequest>(config); + const paginatedCommentVersions = this.paginationService.buildPaginatedResult(commentVersions, this.getInlineCommentVersions.bind(this)); + + const responseHandler = this.client.getResponseHandler(callback); + + return responseHandler(paginatedCommentVersions as T); + } catch (e: any) { + const errorHandler = this.client.getErrorHandler(callback); + + return errorHandler(e); + } + } + + /** + * Retrieves version details for the specified inline comment version. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the page + * or blog post and its corresponding space. + */ + async getInlineCommentVersionDetails( + parameters: Parameters.GetInlineCommentVersionDetails, + callback: Callback, + ): Promise; + /** + * Retrieves version details for the specified inline comment version. + * + * **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content of the page + * or blog post and its corresponding space. + */ + async getInlineCommentVersionDetails( + parameters: Parameters.GetInlineCommentVersionDetails, + callback?: never, + ): Promise; + async getInlineCommentVersionDetails( + parameters: Parameters.GetInlineCommentVersionDetails, + callback?: Callback, + ): Promise { + const config: RequestConfig = { + url: `/inline-comments/${parameters.id}/versions/${parameters.versionNumber}`, + method: 'GET', + }; + + return this.client.sendRequest(config, callback); + } +} diff --git a/tests/integration/config.ts b/tests/integration/config.ts new file mode 100644 index 00000000..3d80b0b5 --- /dev/null +++ b/tests/integration/config.ts @@ -0,0 +1,15 @@ +import { Config } from '../../src'; + +const host = process.env.HOST!; +const email = process.env.EMAIL!; +const apiToken = process.env.API_TOKEN!; + +export const config: Config = { + host, + authentication: { + basic: { + email, + apiToken, + }, + }, +}; diff --git a/tests/integration/getSpacesPagination.test.ts b/tests/integration/getSpacesPagination.test.ts new file mode 100644 index 00000000..3283dc1a --- /dev/null +++ b/tests/integration/getSpacesPagination.test.ts @@ -0,0 +1,51 @@ +import { config } from './config'; +import { Space } from '../../src/version2/models'; +import test from 'ava'; +import { Version2Client } from '../../src'; + +const version2Client = new Version2Client(config); + +let spaces: Space[]; + +test.serial('`getSpaces()` should works', async t => { + const spacesPagination = await version2Client.space.getSpaces(); + + spaces = spacesPagination.results; + + t.truthy(spacesPagination.results.length <= 25); +}); + +test.serial('`getSpaceById(id)` should works', async t => { + const space = await version2Client.space.getSpaceById({ + id: spaces[0].id, + descriptionFormat: 'plain', + }); + + t.is(space.id, spaces[0].id); + t.is(space.description.plain.representation, 'plain'); +}); + +test.serial('`getAll()` function should works', async t => { + const batchedSpaces = await version2Client.space.getSpaces({ limit: 1 }); + + const allSpaces = await batchedSpaces.getAll(); + + t.truthy(allSpaces.length > 1); +}); + +test.serial('`next()` function should works', async t => { + const firstSpaceBatch = await version2Client.space.getSpaces({ limit: 1, descriptionFormat: 'view' }); + const secondSpaceBatch = await firstSpaceBatch.next(); + + t.is(firstSpaceBatch.results.length, 1); + t.is(firstSpaceBatch.results[0].description.view.representation, 'view'); + + t.is(secondSpaceBatch.results.length, 1); + t.is(secondSpaceBatch.results[0].description.view.representation, 'view'); +}); + +test.serial('`getAllSpaces()` function should works', async t => { + const allSpaces = await version2Client.space.getAllSpaces({ limit: 1, descriptionFormat: 'plain' }); + + t.truthy(allSpaces.length > 1); +}); diff --git a/tests/e2e/e2e.test.ts b/tests/integration/legacyConflueceClient.test.ts similarity index 100% rename from tests/e2e/e2e.test.ts rename to tests/integration/legacyConflueceClient.test.ts diff --git a/tests/unit/version2/attachment.test.ts b/tests/unit/version2/attachment.test.ts new file mode 100644 index 00000000..924c3239 --- /dev/null +++ b/tests/unit/version2/attachment.test.ts @@ -0,0 +1,20 @@ +import test from 'ava'; +import { Version2Client } from '../../../src'; + +const version2Client = new Version2Client({ host: '' }); + +test('`getAllBlogPostAttachments` should be defined', t => { + t.truthy(!!version2Client.attachment.getAllBlogPostAttachments); +}); + +test('`getAllCustomContentAttachments` should be defined', t => { + t.truthy(!!version2Client.attachment.getAllBlogPostAttachments); +}); + +test('`getAllLabelAttachments` should be defined', t => { + t.truthy(!!version2Client.attachment.getAllLabelAttachments); +}); + +test('`getAllPageAttachments` should be defined', t => { + t.truthy(!!version2Client.attachment.getAllPageAttachments); +}); diff --git a/tests/unit/version2/blogPost.test.ts b/tests/unit/version2/blogPost.test.ts new file mode 100644 index 00000000..b5b0a913 --- /dev/null +++ b/tests/unit/version2/blogPost.test.ts @@ -0,0 +1,16 @@ +import test from 'ava'; +import { Version2Client } from '../../../src'; + +const version2Client = new Version2Client({ host: '' }); + +test('`getAllBlogPosts` should be defined', t => { + t.truthy(!!version2Client.blogPost.getAllBlogPosts); +}); + +test('`getAllLabelBlogPosts` should be defined', t => { + t.truthy(!!version2Client.blogPost.getAllLabelBlogPosts); +}); + +test('`getAllBlogPostsInSpace` should be defined', t => { + t.truthy(!!version2Client.blogPost.getAllBlogPostsInSpace); +}); diff --git a/tests/unit/version2/children.test.ts b/tests/unit/version2/children.test.ts new file mode 100644 index 00000000..c52b9c21 --- /dev/null +++ b/tests/unit/version2/children.test.ts @@ -0,0 +1,12 @@ +import test from 'ava'; +import { Version2Client } from '../../../src'; + +const version2Client = new Version2Client({ host: '' }); + +test('`getAllChildPages` should be defined', t => { + t.truthy(!!version2Client.children.getAllChildPages); +}); + +test('`getAllChildCustomContent` should be defined', t => { + t.truthy(!!version2Client.children.getAllChildCustomContent); +}); diff --git a/tests/unit/version2/comment.test.ts b/tests/unit/version2/comment.test.ts new file mode 100644 index 00000000..44b37a40 --- /dev/null +++ b/tests/unit/version2/comment.test.ts @@ -0,0 +1,28 @@ +import test from 'ava'; +import { Version2Client } from '../../../src'; + +const version2Client = new Version2Client({ host: '' }); + +test('`getAllPageFooterComments` should be defined', t => { + t.truthy(!!version2Client.comment.getAllPageFooterComments); +}); + +test('`getAllPageInlineComments` should be defined', t => { + t.truthy(!!version2Client.comment.getAllPageInlineComments); +}); + +test('`getAllBlogPostFooterComments` should be defined', t => { + t.truthy(!!version2Client.comment.getAllBlogPostFooterComments); +}); + +test('`getAllBlogPostInlineComments` should be defined', t => { + t.truthy(!!version2Client.comment.getAllBlogPostInlineComments); +}); + +test('`getAllFooterCommentChildren` should be defined', t => { + t.truthy(!!version2Client.comment.getAllFooterCommentChildren); +}); + +test('`getAllInlineCommentChildren` should be defined', t => { + t.truthy(!!version2Client.comment.getAllInlineCommentChildren); +}); diff --git a/tests/unit/version2/space.test.ts b/tests/unit/version2/space.test.ts new file mode 100644 index 00000000..2e5a4a8b --- /dev/null +++ b/tests/unit/version2/space.test.ts @@ -0,0 +1,8 @@ +import test from 'ava'; +import { Version2Client } from '../../../src'; + +const version2Client = new Version2Client({ host: '' }); + +test('`getAllSpaces` should be defined', t => { + t.truthy(!!version2Client.space.getAllSpaces); +});