confluence.js 1.4.1 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/out/api/contentAttachments.d.ts +17 -176
- package/out/api/contentAttachments.js +46 -4
- package/out/api/contentAttachments.js.map +1 -1
- package/out/api/models/attachment.d.ts +30 -0
- package/out/api/models/attachment.js +3 -0
- package/out/api/models/attachment.js.map +1 -0
- package/out/api/models/attachmentContainer.d.ts +27 -0
- package/out/api/models/attachmentContainer.js +3 -0
- package/out/api/models/attachmentContainer.js.map +1 -0
- package/out/api/models/attachmentMetadata.d.ts +20 -0
- package/out/api/models/attachmentMetadata.js +3 -0
- package/out/api/models/attachmentMetadata.js.map +1 -0
- package/out/api/models/attachmentUpdate.d.ts +1 -0
- package/out/api/models/contentArray.d.ts +4 -4
- package/out/api/models/createdAttachment.d.ts +7 -0
- package/out/api/models/createdAttachment.js +3 -0
- package/out/api/models/createdAttachment.js.map +1 -0
- package/out/api/models/genericLinks.d.ts +11 -1
- package/out/api/models/index.d.ts +4 -0
- package/out/api/models/index.js +4 -0
- package/out/api/models/index.js.map +1 -1
- package/out/api/parameters/createAttachments.d.ts +13 -2
- package/out/api/parameters/createOrUpdateAttachments.d.ts +4 -2
- package/out/api/parameters/getAttachments.d.ts +1 -1
- package/out/api/parameters/getAttachments.js.map +1 -1
- package/out/api/parameters/updateAttachmentData.d.ts +4 -2
- package/out/api/parameters/updateAttachmentProperties.d.ts +45 -2
- package/out/clients/baseClient.js +3 -2
- package/out/clients/baseClient.js.map +1 -1
- package/out/config.d.ts +2 -0
- package/out/paramSerializer.js +1 -1
- package/out/paramSerializer.js.map +1 -1
- package/package.json +12 -10
- package/src/api/contentAttachments.ts +85 -197
- package/src/api/models/attachment.ts +31 -0
- package/src/api/models/attachmentContainer.ts +28 -0
- package/src/api/models/attachmentMetadata.ts +21 -0
- package/src/api/models/attachmentUpdate.ts +1 -0
- package/src/api/models/contentArray.ts +4 -4
- package/src/api/models/createdAttachment.ts +8 -0
- package/src/api/models/genericLinks.ts +12 -1
- package/src/api/models/index.ts +4 -0
- package/src/api/parameters/createAttachments.ts +12 -2
- package/src/api/parameters/createOrUpdateAttachments.ts +5 -2
- package/src/api/parameters/getAttachments.ts +71 -1
- package/src/api/parameters/updateAttachmentData.ts +5 -2
- package/src/api/parameters/updateAttachmentProperties.ts +59 -2
- package/src/clients/baseClient.ts +4 -2
- package/src/config.ts +2 -0
- package/src/paramSerializer.ts +1 -1
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { CreateAttachments } from './createAttachments';
|
|
1
2
|
export interface CreateOrUpdateAttachments {
|
|
2
3
|
/** The ID of the content to add the attachment to. */
|
|
3
4
|
id: string;
|
|
4
5
|
/** The status of the content that the attachment is being added to. This should always be set to 'current'. */
|
|
5
|
-
status?: string;
|
|
6
|
-
|
|
6
|
+
status?: 'current' | 'draft' | string;
|
|
7
|
+
/** The attachments to be created or updated. */
|
|
8
|
+
attachments: CreateAttachments.Attachment | CreateAttachments.Attachment[];
|
|
7
9
|
}
|
|
@@ -2,7 +2,7 @@ export interface GetAttachments {
|
|
|
2
2
|
/** The ID of the content to be queried for its attachments. */
|
|
3
3
|
id: string;
|
|
4
4
|
/** A multi-value parameter indicating which properties of the content to expand. */
|
|
5
|
-
expand?: string | string[] | GetAttachments.Expand | GetAttachments.Expand[];
|
|
5
|
+
expand?: 'childTypes.all' | 'childTypes.attachment' | 'childTypes.comment' | 'childTypes.page' | 'container' | 'metadata' | 'metadata.currentuser' | 'metadata.properties' | 'metadata.labels' | 'metadata.frontend' | 'operations' | 'children.page' | 'children.attachment' | 'children.comment' | 'restrictions.read.restrictions.user' | 'restrictions.read.restrictions.group' | 'restrictions.update.restrictions.user' | 'restrictions.update.restrictions.group' | 'history' | 'history.lastUpdated' | 'history.previousVersion' | 'history.contributors' | 'history.nextVersion' | 'ancestors' | 'body' | 'version' | 'descendants.page' | 'descendants.attachment' | 'descendants.comment' | 'space' | 'extensions.inlineProperties' | 'extensions.resolution' | ('childTypes.all' | 'childTypes.attachment' | 'childTypes.comment' | 'childTypes.page' | 'container' | 'metadata' | 'metadata.currentuser' | 'metadata.properties' | 'metadata.labels' | 'metadata.frontend' | 'operations' | 'children.page' | 'children.attachment' | 'children.comment' | 'restrictions.read.restrictions.user' | 'restrictions.read.restrictions.group' | 'restrictions.update.restrictions.user' | 'restrictions.update.restrictions.group' | 'history' | 'history.lastUpdated' | 'history.previousVersion' | 'history.contributors' | 'history.nextVersion' | 'ancestors' | 'body' | 'version' | 'descendants.page' | 'descendants.attachment' | 'descendants.comment' | 'space' | 'extensions.inlineProperties' | 'extensions.resolution')[] | string | string[] | GetAttachments.Expand | GetAttachments.Expand[];
|
|
6
6
|
/** The starting index of the returned attachments. */
|
|
7
7
|
start?: number;
|
|
8
8
|
/** The maximum number of attachments to return per page. Note, this may be restricted by fixed system limits. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getAttachments.js","sourceRoot":"","sources":["../../../src/api/parameters/getAttachments.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"getAttachments.js","sourceRoot":"","sources":["../../../src/api/parameters/getAttachments.ts"],"names":[],"mappings":";;;AAqFA,IAAiB,cAAc,CAmF9B;AAnFD,WAAiB,cAAc;IAC7B,IAAY,MAiFX;IAjFD,WAAY,MAAM;QAChB;;;WAGG;QACH,0CAAgC,CAAA;QAChC,mDAAmD;QACnD,uDAA6C,CAAA;QAC7C,gDAAgD;QAChD,iDAAuC,CAAA;QACvC,mDAAmD;QACnD,2CAAiC,CAAA;QACjC;;;WAGG;QACH,iCAAuB,CAAA;QACvB;;;WAGG;QACH,sDAA4C,CAAA;QAC5C,iFAAiF;QACjF,oDAA0C,CAAA;QAC1C,8DAA8D;QAC9D,4CAAkC,CAAA;QAClC,+CAA+C;QAC/C,gDAAsC,CAAA;QACtC,uFAAuF;QACvF,mCAAyB,CAAA;QACzB,qFAAqF;QACrF,wCAA8B,CAAA;QAC9B,+CAA+C;QAC/C,oDAA0C,CAAA;QAC1C,2CAA2C;QAC3C,8CAAoC,CAAA;QACpC,kEAAkE;QAClE,qEAA2D,CAAA;QAC3D;;;WAGG;QACH,uEAA6D,CAAA;QAC7D,oEAAoE;QACpE,yEAA+D,CAAA;QAC/D;;;WAGG;QACH,2EAAiE,CAAA;QACjE,6EAA6E;QAC7E,6BAAmB,CAAA;QACnB,yHAAyH;QACzH,6CAAmC,CAAA;QACnC,gFAAgF;QAChF,qDAA2C,CAAA;QAC3C,oEAAoE;QACpE,+CAAqC,CAAA;QACrC,gFAAgF;QAChF,6CAAmC,CAAA;QACnC,yDAAyD;QACzD,iCAAuB,CAAA;QACvB,yHAAyH;QACzH,uBAAa,CAAA;QACb,yHAAyH;QACzH,6BAAmB,CAAA;QACnB,yEAAyE;QACzE,6CAAmC,CAAA;QACnC,8EAA8E;QAC9E,yDAA+C,CAAA;QAC/C,uEAAuE;QACvE,mDAAyC,CAAA;QACzC;;;WAGG;QACH,yBAAe,CAAA;QACf,kDAAkD;QAClD,0DAAgD,CAAA;QAChD,qDAAqD;QACrD,8CAAoC,CAAA;IACtC,CAAC,EAjFW,MAAM,GAAN,qBAAM,KAAN,qBAAM,QAiFjB;AACH,CAAC,EAnFgB,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAmF9B"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export interface UpdateAttachmentData
|
|
1
|
+
import { CreateAttachments } from './createAttachments';
|
|
2
|
+
export interface UpdateAttachmentData {
|
|
3
3
|
/** The ID of the content that the attachment is attached to. */
|
|
4
4
|
id: string;
|
|
5
5
|
/** The ID of the attachment to update. */
|
|
6
6
|
attachmentId: string;
|
|
7
|
+
/** Attachment data to update. */
|
|
8
|
+
attachment: CreateAttachments.Attachment;
|
|
7
9
|
}
|
|
@@ -1,8 +1,51 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AttachmentMetadata, Container, Content, ContentChildren, ContentChildType, ContentHistory, GenericLinks, OperationCheckResult, Space, Version } from '../models';
|
|
2
2
|
export interface UpdateAttachmentProperties {
|
|
3
3
|
/** The ID of the content that the attachment is attached to. */
|
|
4
4
|
id: string;
|
|
5
5
|
/** The ID of the attachment to update. */
|
|
6
6
|
attachmentId: string;
|
|
7
|
-
|
|
7
|
+
/** @deprecated Use `update` property instead. */
|
|
8
|
+
body?: UpdateAttachmentProperties.Properties;
|
|
9
|
+
update?: UpdateAttachmentProperties.Properties;
|
|
10
|
+
}
|
|
11
|
+
export declare namespace UpdateAttachmentProperties {
|
|
12
|
+
interface Properties {
|
|
13
|
+
[key: string]: any;
|
|
14
|
+
id: string;
|
|
15
|
+
type: 'page' | 'blogpost' | 'attachment' | 'content' | string;
|
|
16
|
+
status: 'current' | 'draft' | string;
|
|
17
|
+
title?: string;
|
|
18
|
+
space?: Space;
|
|
19
|
+
history?: ContentHistory;
|
|
20
|
+
version: Partial<Version>;
|
|
21
|
+
ancestors?: Content[];
|
|
22
|
+
operations?: OperationCheckResult[];
|
|
23
|
+
children?: ContentChildren;
|
|
24
|
+
childTypes?: ContentChildType;
|
|
25
|
+
descendants?: ContentChildren;
|
|
26
|
+
container?: Container;
|
|
27
|
+
body?: any;
|
|
28
|
+
restrictions?: any;
|
|
29
|
+
metadata?: Partial<AttachmentMetadata>;
|
|
30
|
+
macroRenderedOutput?: any;
|
|
31
|
+
extensions?: any;
|
|
32
|
+
_expandable?: {
|
|
33
|
+
'childTypes': string;
|
|
34
|
+
'container': string;
|
|
35
|
+
'metadata': string;
|
|
36
|
+
'operations': string;
|
|
37
|
+
'children': string;
|
|
38
|
+
'restrictions': string;
|
|
39
|
+
'history': string;
|
|
40
|
+
'ancestors': string;
|
|
41
|
+
'body': string;
|
|
42
|
+
'version': string;
|
|
43
|
+
'descendants': string;
|
|
44
|
+
'space': string;
|
|
45
|
+
'extensions': string;
|
|
46
|
+
'schedulePublishDate': string;
|
|
47
|
+
'macroRenderedOutput': string;
|
|
48
|
+
};
|
|
49
|
+
_links?: GenericLinks;
|
|
50
|
+
}
|
|
8
51
|
}
|
|
@@ -79,13 +79,14 @@ class BaseClient {
|
|
|
79
79
|
return responseHandler(response.data);
|
|
80
80
|
}
|
|
81
81
|
catch (e) {
|
|
82
|
+
const err = this.config.newErrorHandling && e.isAxiosError ? e.response.data : e;
|
|
82
83
|
const callbackErrorHandler = callback && ((error) => callback(error));
|
|
83
84
|
const defaultErrorHandler = (error) => {
|
|
84
85
|
throw error;
|
|
85
86
|
};
|
|
86
87
|
const errorHandler = callbackErrorHandler !== null && callbackErrorHandler !== void 0 ? callbackErrorHandler : defaultErrorHandler;
|
|
87
|
-
(_d = (_c = this.config.middlewares) === null || _c === void 0 ? void 0 : _c.onError) === null || _d === void 0 ? void 0 : _d.call(_c,
|
|
88
|
-
return errorHandler(
|
|
88
|
+
(_d = (_c = this.config.middlewares) === null || _c === void 0 ? void 0 : _c.onError) === null || _d === void 0 ? void 0 : _d.call(_c, err);
|
|
89
|
+
return errorHandler(err);
|
|
89
90
|
}
|
|
90
91
|
});
|
|
91
92
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseClient.js","sourceRoot":"","sources":["../../src/clients/baseClient.ts"],"names":[],"mappings":";;;;;AAAA,6EAA0E;AAK1E,iCAA6C;AAE7C,MAAM,0BAA0B,GAAG,mBAAmB,CAAC;AACvD,MAAM,mCAAmC,GAAG,UAAU,CAAC;AAEvD,MAAa,UAAU;IAKrB,YAA+B,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;QAJ7C,uCAAqC;QAE3B,cAAS,GAAG,aAAa,CAAC;IAEY,CAAC;IAEvC,eAAe,CAAC,UAA+B;QACvD,MAAM,KAAK,GAAa,EAAE,CAAC;QAE3B,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;YAClD,IAAI,KAAK,KA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AAI,CAAC,CAAC,KAAmB,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;gBACpF,MAAM,mBAAmB,GAAG,CAAC,KAAY,EAAE,EAAE;oBAC3C,MAAM,KAAK,CAAC;gBACd,CAAC,CAAC;gBAEF,MAAM,YAAY,GAAG,oBAAoB,aAApB,oBAAoB,cAApB,oBAAoB,GAAI,mBAAmB,CAAC;gBAEjE,MAAA,MAAA,IAAI,CAAC,MAAM,CAAC,WAAW,0CAAE,OAAO,mDAAG,GAAG,CAAC,CAAC;gBAExC,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC;aAC1B;;KACF;CACF;AA1HD,gCA0HC"}
|
package/out/config.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ export interface Config {
|
|
|
12
12
|
* Adds `'X-Atlassian-Token': 'no-check'` to each request header
|
|
13
13
|
*/
|
|
14
14
|
noCheckAtlassianToken?: boolean;
|
|
15
|
+
/** Enable new API error handling. `false` by default. */
|
|
16
|
+
newErrorHandling?: boolean;
|
|
15
17
|
}
|
|
16
18
|
export declare namespace Config {
|
|
17
19
|
type BaseRequestConfig = RequestConfig;
|
package/out/paramSerializer.js
CHANGED
|
@@ -11,7 +11,7 @@ function paramSerializer(key, values) {
|
|
|
11
11
|
if (!values.length) {
|
|
12
12
|
return '';
|
|
13
13
|
}
|
|
14
|
-
return () => values.map(
|
|
14
|
+
return () => values.map(value => `${key}=${value}`).join('&');
|
|
15
15
|
}
|
|
16
16
|
exports.paramSerializer = paramSerializer;
|
|
17
17
|
//# sourceMappingURL=paramSerializer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paramSerializer.js","sourceRoot":"","sources":["../src/paramSerializer.ts"],"names":[],"mappings":";;;AAAA,SAAgB,eAAe,CAAC,GAAW,EAAE,MAA0B;IACrE,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;QAC9B,OAAO,GAAG,EAAE,CAAC,GAAG,GAAG,IAAI,MAAM,EAAE,CAAC;KACjC;IAED,IAAI,CAAC,MAAM,EAAE;QACX,OAAO,SAAS,CAAC;KAClB;IAED,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;QAClB,OAAO,EAAE,CAAC;KACX;IAED,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"paramSerializer.js","sourceRoot":"","sources":["../src/paramSerializer.ts"],"names":[],"mappings":";;;AAAA,SAAgB,eAAe,CAAC,GAAW,EAAE,MAA0B;IACrE,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;QAC9B,OAAO,GAAG,EAAE,CAAC,GAAG,GAAG,IAAI,MAAM,EAAE,CAAC;KACjC;IAED,IAAI,CAAC,MAAM,EAAE;QACX,OAAO,SAAS,CAAC;KAClB;IAED,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;QAClB,OAAO,EAAE,CAAC;KACX;IAED,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAChE,CAAC;AAdD,0CAcC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "confluence.js",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "confluence.js is a powerful Node.JS/Browser module that allows you to interact with the Confluence API very easily",
|
|
5
5
|
"author": "Vladislav Tupikin <mrrefactoring@yandex.ru>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"test": "npm run test:unit && npm run test:e2e",
|
|
15
15
|
"prettier": "prettier --write src/**/*.ts",
|
|
16
16
|
"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",
|
|
17
|
-
"lint": "eslint src --ext .ts",
|
|
17
|
+
"lint": "eslint src tests --ext .ts",
|
|
18
18
|
"lint:fix": "npm run lint -- --fix",
|
|
19
19
|
"test:unit": "ava tests/unit",
|
|
20
20
|
"test:e2e": "ava --timeout=2m --fail-fast --no-worker-threads -c 1 -s tests/e2e/**/*.test.ts"
|
|
@@ -36,34 +36,36 @@
|
|
|
36
36
|
"api",
|
|
37
37
|
"wrapper",
|
|
38
38
|
"client",
|
|
39
|
+
"cloud",
|
|
39
40
|
"rest",
|
|
40
41
|
"wiki",
|
|
41
42
|
"atlassian"
|
|
42
43
|
],
|
|
43
44
|
"devDependencies": {
|
|
44
|
-
"@swc-node/register": "^1.
|
|
45
|
+
"@swc-node/register": "^1.5.1",
|
|
45
46
|
"@types/express": "^4.17.13",
|
|
46
47
|
"@types/oauth": "^0.9.1",
|
|
47
48
|
"@types/sinon": "^10.0.11",
|
|
48
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
49
|
-
"@typescript-eslint/parser": "^5.
|
|
49
|
+
"@typescript-eslint/eslint-plugin": "^5.25.0",
|
|
50
|
+
"@typescript-eslint/parser": "^5.25.0",
|
|
50
51
|
"ava": "^4.2.0",
|
|
51
|
-
"dotenv": "^16.0.
|
|
52
|
-
"eslint": "^8.
|
|
52
|
+
"dotenv": "^16.0.1",
|
|
53
|
+
"eslint": "^8.16.0",
|
|
53
54
|
"eslint-config-airbnb": "^19.0.4",
|
|
54
55
|
"eslint-config-airbnb-typescript": "^17.0.0",
|
|
55
56
|
"eslint-import-resolver-typescript": "^2.7.1",
|
|
56
57
|
"eslint-plugin-import": "^2.26.0",
|
|
57
58
|
"prettier": "^2.6.2",
|
|
58
59
|
"prettier-plugin-jsdoc": "^0.3.38",
|
|
59
|
-
"sinon": "^
|
|
60
|
+
"sinon": "^14.0.0",
|
|
60
61
|
"typedoc": "^0.22.15",
|
|
61
62
|
"typedoc-plugin-extras": "^2.2.3",
|
|
62
|
-
"typescript": "^4.6.
|
|
63
|
+
"typescript": "^4.6.4"
|
|
63
64
|
},
|
|
64
65
|
"dependencies": {
|
|
65
66
|
"atlassian-jwt": "^2.0.2",
|
|
66
|
-
"axios": "^0.27.
|
|
67
|
+
"axios": "^0.27.2",
|
|
68
|
+
"form-data": "^4.0.0",
|
|
67
69
|
"oauth": "^0.9.15",
|
|
68
70
|
"tslib": "^2.4.0"
|
|
69
71
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as FormData from 'form-data';
|
|
1
2
|
import * as Models from './models';
|
|
2
3
|
import * as Parameters from './parameters';
|
|
3
4
|
import { Callback } from '../callback';
|
|
@@ -15,7 +16,7 @@ export class ContentAttachments {
|
|
|
15
16
|
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content. If the
|
|
16
17
|
* content is a blog post, 'View' permission for the space is required.
|
|
17
18
|
*/
|
|
18
|
-
async getAttachments<T = Models.ContentArray
|
|
19
|
+
async getAttachments<T = Models.ContentArray<Models.Attachment>>(
|
|
19
20
|
parameters: Parameters.GetAttachments,
|
|
20
21
|
callback: Callback<T>
|
|
21
22
|
): Promise<void>;
|
|
@@ -27,8 +28,8 @@ export class ContentAttachments {
|
|
|
27
28
|
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to view the content. If the
|
|
28
29
|
* content is a blog post, 'View' permission for the space is required.
|
|
29
30
|
*/
|
|
30
|
-
async getAttachments<T = Models.ContentArray
|
|
31
|
-
async getAttachments<T = Models.ContentArray
|
|
31
|
+
async getAttachments<T = Models.ContentArray<Models.Attachment>>(parameters: Parameters.GetAttachments, callback?: never): Promise<T>;
|
|
32
|
+
async getAttachments<T = Models.ContentArray<Models.Attachment>>(
|
|
32
33
|
parameters: Parameters.GetAttachments,
|
|
33
34
|
callback?: Callback<T>,
|
|
34
35
|
): Promise<void | T> {
|
|
@@ -49,91 +50,55 @@ export class ContentAttachments {
|
|
|
49
50
|
|
|
50
51
|
/**
|
|
51
52
|
* Adds an attachment to a piece of content. This method only adds a new attachment. If you want to update an existing
|
|
52
|
-
* attachment, use [Create or update attachments](
|
|
53
|
-
*
|
|
54
|
-
* Note, you must set a `X-Atlassian-Token: nocheck` header on the request for this method, otherwise it will be
|
|
55
|
-
* blocked. This protects against XSRF attacks, which is necessary as this method accepts multipart/form-data.
|
|
56
|
-
*
|
|
57
|
-
* The media type 'multipart/form-data' is defined in [RFC 7578](https://www.ietf.org/rfc/rfc7578.txt). Most client
|
|
58
|
-
* libraries have classes that make it easier to implement multipart posts, like the
|
|
59
|
-
* [MultipartEntityBuilder](https://hc.apache.org/httpcomponents-client-5.1.x/current/httpclient5/apidocs/) Java class
|
|
60
|
-
* provided by Apache HTTP Components.
|
|
61
|
-
*
|
|
62
|
-
* Note, according to [RFC 7578](https://tools.ietf.org/html/rfc7578#section-4.5), in the case where the form data is
|
|
63
|
-
* text, the charset parameter for the "text/plain" Content-Type may be used to indicate the character encoding used
|
|
64
|
-
* in that part. In the case of this API endpoint, the `comment` body parameter should be sent with `type=text/plain`
|
|
65
|
-
* and `charset=utf-8` values. This will force the charset to be UTF-8.
|
|
66
|
-
*
|
|
67
|
-
* Example: This curl command attaches a file ('example.txt') to a container (id='123') with a comment and `minorEdits`=true.
|
|
68
|
-
*
|
|
69
|
-
* ```bash
|
|
70
|
-
* curl -D- \
|
|
71
|
-
* -u admin:admin \
|
|
72
|
-
* -X POST \
|
|
73
|
-
* -H 'X-Atlassian-Token: nocheck' \
|
|
74
|
-
* -F 'file=@"example.txt"' \
|
|
75
|
-
* -F 'minorEdit="true"' \
|
|
76
|
-
* -F 'comment="Example attachment comment"; type=text/plain; charset=utf-8' \
|
|
77
|
-
* http://myhost/rest/api/content/123/child/attachment
|
|
78
|
-
* ```
|
|
53
|
+
* attachment, use [Create or update attachments](https://developer.atlassian.com/cloud/confluence/rest/api-group-content---attachments/#api-wiki-rest-api-content-id-child-attachment-put).
|
|
79
54
|
*
|
|
80
55
|
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to update the content.
|
|
81
56
|
*/
|
|
82
|
-
async createAttachments<T = Models.ContentArray
|
|
57
|
+
async createAttachments<T = Models.ContentArray<Models.CreatedAttachment>>(
|
|
83
58
|
parameters: Parameters.CreateAttachments,
|
|
84
59
|
callback: Callback<T>
|
|
85
60
|
): Promise<void>;
|
|
86
61
|
/**
|
|
87
62
|
* Adds an attachment to a piece of content. This method only adds a new attachment. If you want to update an existing
|
|
88
|
-
* attachment, use [Create or update attachments](
|
|
89
|
-
*
|
|
90
|
-
* Note, you must set a `X-Atlassian-Token: nocheck` header on the request for this method, otherwise it will be
|
|
91
|
-
* blocked. This protects against XSRF attacks, which is necessary as this method accepts multipart/form-data.
|
|
92
|
-
*
|
|
93
|
-
* The media type 'multipart/form-data' is defined in [RFC 7578](https://www.ietf.org/rfc/rfc7578.txt). Most client
|
|
94
|
-
* libraries have classes that make it easier to implement multipart posts, like the
|
|
95
|
-
* [MultipartEntityBuilder](https://hc.apache.org/httpcomponents-client-5.1.x/current/httpclient5/apidocs/) Java class
|
|
96
|
-
* provided by Apache HTTP Components.
|
|
97
|
-
*
|
|
98
|
-
* Note, according to [RFC 7578](https://tools.ietf.org/html/rfc7578#section-4.5), in the case where the form data is
|
|
99
|
-
* text, the charset parameter for the "text/plain" Content-Type may be used to indicate the character encoding used
|
|
100
|
-
* in that part. In the case of this API endpoint, the `comment` body parameter should be sent with `type=text/plain`
|
|
101
|
-
* and `charset=utf-8` values. This will force the charset to be UTF-8.
|
|
102
|
-
*
|
|
103
|
-
* Example: This curl command attaches a file ('example.txt') to a container (id='123') with a comment and `minorEdits`=true.
|
|
104
|
-
*
|
|
105
|
-
* ```bash
|
|
106
|
-
* curl -D- \
|
|
107
|
-
* -u admin:admin \
|
|
108
|
-
* -X POST \
|
|
109
|
-
* -H 'X-Atlassian-Token: nocheck' \
|
|
110
|
-
* -F 'file=@"example.txt"' \
|
|
111
|
-
* -F 'minorEdit="true"' \
|
|
112
|
-
* -F 'comment="Example attachment comment"; type=text/plain; charset=utf-8' \
|
|
113
|
-
* http://myhost/rest/api/content/123/child/attachment
|
|
114
|
-
* ```
|
|
63
|
+
* attachment, use [Create or update attachments](https://developer.atlassian.com/cloud/confluence/rest/api-group-content---attachments/#api-wiki-rest-api-content-id-child-attachment-put).
|
|
115
64
|
*
|
|
116
65
|
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to update the content.
|
|
117
66
|
*/
|
|
118
|
-
async createAttachments<T = Models.ContentArray
|
|
67
|
+
async createAttachments<T = Models.ContentArray<Models.CreatedAttachment>>(
|
|
119
68
|
parameters: Parameters.CreateAttachments,
|
|
120
69
|
callback?: never
|
|
121
70
|
): Promise<T>;
|
|
122
|
-
async createAttachments<T = Models.ContentArray
|
|
71
|
+
async createAttachments<T = Models.ContentArray<Models.CreatedAttachment>>(
|
|
123
72
|
parameters: Parameters.CreateAttachments,
|
|
124
73
|
callback?: Callback<T>,
|
|
125
74
|
): Promise<void | T> {
|
|
75
|
+
const formData = new FormData();
|
|
76
|
+
const attachments = Array.isArray(parameters.attachments) ? parameters.attachments : [parameters.attachments];
|
|
77
|
+
|
|
78
|
+
attachments.forEach(attachment => {
|
|
79
|
+
formData.append('minorEdit', attachment.minorEdit.toString(), 'minorEdit');
|
|
80
|
+
formData.append('file', attachment.file, {
|
|
81
|
+
filename: attachment.filename,
|
|
82
|
+
contentType: attachment.contentType,
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
if (attachment.comment) {
|
|
86
|
+
formData.append('comment', attachment.comment, 'comment');
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
|
|
126
90
|
const config: RequestConfig = {
|
|
127
91
|
url: `/api/content/${parameters.id}/child/attachment`,
|
|
128
92
|
method: 'POST',
|
|
93
|
+
headers: {
|
|
94
|
+
'X-Atlassian-Token': 'no-check',
|
|
95
|
+
'Content-Type': 'multipart/form-data',
|
|
96
|
+
...formData.getHeaders?.(),
|
|
97
|
+
},
|
|
129
98
|
params: {
|
|
130
99
|
status: parameters.status,
|
|
131
100
|
},
|
|
132
|
-
data:
|
|
133
|
-
...parameters,
|
|
134
|
-
id: undefined,
|
|
135
|
-
status: undefined,
|
|
136
|
-
},
|
|
101
|
+
data: formData,
|
|
137
102
|
};
|
|
138
103
|
|
|
139
104
|
return this.client.sendRequest(config, callback);
|
|
@@ -143,36 +108,9 @@ export class ContentAttachments {
|
|
|
143
108
|
* Adds an attachment to a piece of content. If the attachment already exists for the content, then the attachment is
|
|
144
109
|
* updated (i.e. a new version of the attachment is created).
|
|
145
110
|
*
|
|
146
|
-
* Note, you must set a `X-Atlassian-Token: nocheck` header on the request for this method, otherwise it will be
|
|
147
|
-
* blocked. This protects against XSRF attacks, which is necessary as this method accepts multipart/form-data.
|
|
148
|
-
*
|
|
149
|
-
* The media type 'multipart/form-data' is defined in [RFC 7578](https://www.ietf.org/rfc/rfc7578.txt). Most client
|
|
150
|
-
* libraries have classes that make it easier to implement multipart posts, like the
|
|
151
|
-
* [MultipartEntityBuilder](https://hc.apache.org/httpcomponents-client-5.1.x/current/httpclient5/apidocs/) Java class
|
|
152
|
-
* provided by Apache HTTP Components.
|
|
153
|
-
*
|
|
154
|
-
* Note, according to [RFC 7578](https://tools.ietf.org/html/rfc7578#section-4.5), in the case where the form data is
|
|
155
|
-
* text, the charset parameter for the "text/plain" Content-Type may be used to indicate the character encoding used
|
|
156
|
-
* in that part. In the case of this API endpoint, the `comment` body parameter should be sent with `type=text/plain`
|
|
157
|
-
* and `charset=utf-8` values. This will force the charset to be UTF-8.
|
|
158
|
-
*
|
|
159
|
-
* Example: This curl command attaches a file ('example.txt') to a piece of content (id='123') with a comment and
|
|
160
|
-
* `minorEdits`=true. If the 'example.txt' file already exists, it will update it with a new version of the attachment.
|
|
161
|
-
*
|
|
162
|
-
* ```bash
|
|
163
|
-
* curl -D- \
|
|
164
|
-
* -u admin:admin \
|
|
165
|
-
* -X PUT \
|
|
166
|
-
* -H 'X-Atlassian-Token: nocheck' \
|
|
167
|
-
* -F 'file=@"example.txt"' \
|
|
168
|
-
* -F 'minorEdit="true"' \
|
|
169
|
-
* -F 'comment="Example attachment comment"; type=text/plain; charset=utf-8' \
|
|
170
|
-
* http://myhost/rest/api/content/123/child/attachment
|
|
171
|
-
* ```
|
|
172
|
-
*
|
|
173
111
|
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to update the content.
|
|
174
112
|
*/
|
|
175
|
-
async createOrUpdateAttachments<T = Models.ContentArray
|
|
113
|
+
async createOrUpdateAttachments<T = Models.ContentArray<Models.CreatedAttachment>>(
|
|
176
114
|
parameters: Parameters.CreateOrUpdateAttachments,
|
|
177
115
|
callback: Callback<T>
|
|
178
116
|
): Promise<void>;
|
|
@@ -180,54 +118,43 @@ export class ContentAttachments {
|
|
|
180
118
|
* Adds an attachment to a piece of content. If the attachment already exists for the content, then the attachment is
|
|
181
119
|
* updated (i.e. a new version of the attachment is created).
|
|
182
120
|
*
|
|
183
|
-
* Note, you must set a `X-Atlassian-Token: nocheck` header on the request for this method, otherwise it will be
|
|
184
|
-
* blocked. This protects against XSRF attacks, which is necessary as this method accepts multipart/form-data.
|
|
185
|
-
*
|
|
186
|
-
* The media type 'multipart/form-data' is defined in [RFC 7578](https://www.ietf.org/rfc/rfc7578.txt). Most client
|
|
187
|
-
* libraries have classes that make it easier to implement multipart posts, like the
|
|
188
|
-
* [MultipartEntityBuilder](https://hc.apache.org/httpcomponents-client-5.1.x/current/httpclient5/apidocs/) Java class
|
|
189
|
-
* provided by Apache HTTP Components.
|
|
190
|
-
*
|
|
191
|
-
* Note, according to [RFC 7578](https://tools.ietf.org/html/rfc7578#section-4.5), in the case where the form data is
|
|
192
|
-
* text, the charset parameter for the "text/plain" Content-Type may be used to indicate the character encoding used
|
|
193
|
-
* in that part. In the case of this API endpoint, the `comment` body parameter should be sent with `type=text/plain`
|
|
194
|
-
* and `charset=utf-8` values. This will force the charset to be UTF-8.
|
|
195
|
-
*
|
|
196
|
-
* Example: This curl command attaches a file ('example.txt') to a piece of content (id='123') with a comment and
|
|
197
|
-
* `minorEdits`=true. If the 'example.txt' file already exists, it will update it with a new version of the attachment.
|
|
198
|
-
*
|
|
199
|
-
* ```bash
|
|
200
|
-
* curl -D- \
|
|
201
|
-
* -u admin:admin \
|
|
202
|
-
* -X PUT \
|
|
203
|
-
* -H 'X-Atlassian-Token: nocheck' \
|
|
204
|
-
* -F 'file=@"example.txt"' \
|
|
205
|
-
* -F 'minorEdit="true"' \
|
|
206
|
-
* -F 'comment="Example attachment comment"; type=text/plain; charset=utf-8' \
|
|
207
|
-
* http://myhost/rest/api/content/123/child/attachment
|
|
208
|
-
* ```
|
|
209
|
-
*
|
|
210
121
|
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to update the content.
|
|
211
122
|
*/
|
|
212
|
-
async createOrUpdateAttachments<T = Models.ContentArray
|
|
123
|
+
async createOrUpdateAttachments<T = Models.ContentArray<Models.CreatedAttachment>>(
|
|
213
124
|
parameters: Parameters.CreateOrUpdateAttachments,
|
|
214
125
|
callback?: never
|
|
215
126
|
): Promise<T>;
|
|
216
|
-
async createOrUpdateAttachments<T = Models.ContentArray
|
|
127
|
+
async createOrUpdateAttachments<T = Models.ContentArray<Models.CreatedAttachment>>(
|
|
217
128
|
parameters: Parameters.CreateOrUpdateAttachments,
|
|
218
129
|
callback?: Callback<T>,
|
|
219
130
|
): Promise<void | T> {
|
|
131
|
+
const formData = new FormData();
|
|
132
|
+
const attachments = Array.isArray(parameters.attachments) ? parameters.attachments : [parameters.attachments];
|
|
133
|
+
|
|
134
|
+
attachments.forEach(attachment => {
|
|
135
|
+
formData.append('minorEdit', attachment.minorEdit.toString(), 'minorEdit');
|
|
136
|
+
formData.append('file', attachment.file, {
|
|
137
|
+
filename: attachment.filename,
|
|
138
|
+
contentType: attachment.contentType,
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
if (attachment.comment) {
|
|
142
|
+
formData.append('comment', attachment.comment, 'comment');
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
|
|
220
146
|
const config: RequestConfig = {
|
|
221
147
|
url: `/api/content/${parameters.id}/child/attachment`,
|
|
222
148
|
method: 'PUT',
|
|
149
|
+
headers: {
|
|
150
|
+
'X-Atlassian-Token': 'no-check',
|
|
151
|
+
'Content-Type': 'multipart/form-data',
|
|
152
|
+
...formData.getHeaders?.(),
|
|
153
|
+
},
|
|
223
154
|
params: {
|
|
224
155
|
status: parameters.status,
|
|
225
156
|
},
|
|
226
|
-
data:
|
|
227
|
-
...parameters,
|
|
228
|
-
id: undefined,
|
|
229
|
-
status: undefined,
|
|
230
|
-
},
|
|
157
|
+
data: formData,
|
|
231
158
|
};
|
|
232
159
|
|
|
233
160
|
return this.client.sendRequest(config, callback);
|
|
@@ -239,7 +166,7 @@ export class ContentAttachments {
|
|
|
239
166
|
*
|
|
240
167
|
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to update the content.
|
|
241
168
|
*/
|
|
242
|
-
async updateAttachmentProperties<T = Models.
|
|
169
|
+
async updateAttachmentProperties<T = Models.CreatedAttachment>(
|
|
243
170
|
parameters: Parameters.UpdateAttachmentProperties,
|
|
244
171
|
callback: Callback<T>
|
|
245
172
|
): Promise<void>;
|
|
@@ -249,18 +176,18 @@ export class ContentAttachments {
|
|
|
249
176
|
*
|
|
250
177
|
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to update the content.
|
|
251
178
|
*/
|
|
252
|
-
async updateAttachmentProperties<T = Models.
|
|
179
|
+
async updateAttachmentProperties<T = Models.CreatedAttachment>(
|
|
253
180
|
parameters: Parameters.UpdateAttachmentProperties,
|
|
254
181
|
callback?: never
|
|
255
182
|
): Promise<T>;
|
|
256
|
-
async updateAttachmentProperties<T = Models.
|
|
183
|
+
async updateAttachmentProperties<T = Models.CreatedAttachment>(
|
|
257
184
|
parameters: Parameters.UpdateAttachmentProperties,
|
|
258
185
|
callback?: Callback<T>,
|
|
259
186
|
): Promise<void | T> {
|
|
260
187
|
const config: RequestConfig = {
|
|
261
188
|
url: `/api/content/${parameters.id}/child/attachment/${parameters.attachmentId}`,
|
|
262
189
|
method: 'PUT',
|
|
263
|
-
data: parameters.body,
|
|
190
|
+
data: parameters.update ?? parameters.body,
|
|
264
191
|
};
|
|
265
192
|
|
|
266
193
|
return this.client.sendRequest(config, callback);
|
|
@@ -269,106 +196,67 @@ export class ContentAttachments {
|
|
|
269
196
|
/**
|
|
270
197
|
* Updates the binary data of an attachment, given the attachment ID, and optionally the comment and the minor edit field.
|
|
271
198
|
*
|
|
272
|
-
* This method is essentially the same as [Create or update attachments](
|
|
199
|
+
* This method is essentially the same as [Create or update attachments](https://developer.atlassian.com/cloud/confluence/rest/api-group-content---attachments/#api-wiki-rest-api-content-id-child-attachment-put), except
|
|
273
200
|
* that it matches the attachment ID rather than the name.
|
|
274
201
|
*
|
|
275
|
-
* Note, you must set a `X-Atlassian-Token: nocheck` header on the request for this method, otherwise it will be
|
|
276
|
-
* blocked. This protects against XSRF attacks, which is necessary as this method accepts multipart/form-data.
|
|
277
|
-
*
|
|
278
|
-
* The media type 'multipart/form-data' is defined in [RFC 7578](https://www.ietf.org/rfc/rfc7578.txt). Most client
|
|
279
|
-
* libraries have classes that make it easier to implement multipart posts, like the
|
|
280
|
-
* [MultipartEntityBuilder](https://hc.apache.org/httpcomponents-client-5.1.x/current/httpclient5/apidocs/) Java class
|
|
281
|
-
* provided by Apache HTTP Components.
|
|
282
|
-
*
|
|
283
|
-
* Note, according to [RFC 7578](https://tools.ietf.org/html/rfc7578#section-4.5), in the case where the form data is
|
|
284
|
-
* text, the charset parameter for the "text/plain" Content-Type may be used to indicate the character encoding used
|
|
285
|
-
* in that part. In the case of this API endpoint, the `comment` body parameter should be sent with `type=text/plain`
|
|
286
|
-
* and `charset=utf-8` values. This will force the charset to be UTF-8.
|
|
287
|
-
*
|
|
288
|
-
* Example: This curl command updates an attachment (id='att456') that is attached to a piece of content (id='123')
|
|
289
|
-
* with a comment and `minorEdits`=true.
|
|
290
|
-
*
|
|
291
|
-
* ```bash
|
|
292
|
-
* curl -D- \
|
|
293
|
-
* -u admin:admin \
|
|
294
|
-
* -X POST \
|
|
295
|
-
* -H 'X-Atlassian-Token: nocheck' \
|
|
296
|
-
* -F 'file=@"example.txt"' \
|
|
297
|
-
* -F 'minorEdit="true"' \
|
|
298
|
-
* -F 'comment="Example attachment comment"; type=text/plain; charset=utf-8' \
|
|
299
|
-
* http://myhost/rest/api/content/123/child/attachment/att456/data
|
|
300
|
-
* ```
|
|
301
|
-
*
|
|
302
202
|
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to update the content.
|
|
303
203
|
*/
|
|
304
|
-
async updateAttachmentData<T = Models.
|
|
204
|
+
async updateAttachmentData<T = Models.CreatedAttachment>(
|
|
305
205
|
parameters: Parameters.UpdateAttachmentData,
|
|
306
206
|
callback: Callback<T>
|
|
307
207
|
): Promise<void>;
|
|
308
208
|
/**
|
|
309
209
|
* Updates the binary data of an attachment, given the attachment ID, and optionally the comment and the minor edit field.
|
|
310
210
|
*
|
|
311
|
-
* This method is essentially the same as [Create or update attachments](
|
|
211
|
+
* This method is essentially the same as [Create or update attachments](https://developer.atlassian.com/cloud/confluence/rest/api-group-content---attachments/#api-wiki-rest-api-content-id-child-attachment-put), except
|
|
312
212
|
* that it matches the attachment ID rather than the name.
|
|
313
213
|
*
|
|
314
|
-
* Note, you must set a `X-Atlassian-Token: nocheck` header on the request for this method, otherwise it will be
|
|
315
|
-
* blocked. This protects against XSRF attacks, which is necessary as this method accepts multipart/form-data.
|
|
316
|
-
*
|
|
317
|
-
* The media type 'multipart/form-data' is defined in [RFC 7578](https://www.ietf.org/rfc/rfc7578.txt). Most client
|
|
318
|
-
* libraries have classes that make it easier to implement multipart posts, like the
|
|
319
|
-
* [MultipartEntityBuilder](https://hc.apache.org/httpcomponents-client-5.1.x/current/httpclient5/apidocs/) Java class
|
|
320
|
-
* provided by Apache HTTP Components.
|
|
321
|
-
*
|
|
322
|
-
* Note, according to [RFC 7578](https://tools.ietf.org/html/rfc7578#section-4.5), in the case where the form data is
|
|
323
|
-
* text, the charset parameter for the "text/plain" Content-Type may be used to indicate the character encoding used
|
|
324
|
-
* in that part. In the case of this API endpoint, the `comment` body parameter should be sent with `type=text/plain`
|
|
325
|
-
* and `charset=utf-8` values. This will force the charset to be UTF-8.
|
|
326
|
-
*
|
|
327
|
-
* Example: This curl command updates an attachment (id='att456') that is attached to a piece of content (id='123')
|
|
328
|
-
* with a comment and `minorEdits`=true.
|
|
329
|
-
*
|
|
330
|
-
* ```bash
|
|
331
|
-
* curl -D- \
|
|
332
|
-
* -u admin:admin \
|
|
333
|
-
* -X POST \
|
|
334
|
-
* -H 'X-Atlassian-Token: nocheck' \
|
|
335
|
-
* -F 'file=@"example.txt"' \
|
|
336
|
-
* -F 'minorEdit="true"' \
|
|
337
|
-
* -F 'comment="Example attachment comment"; type=text/plain; charset=utf-8' \
|
|
338
|
-
* http://myhost/rest/api/content/123/child/attachment/att456/data
|
|
339
|
-
* ```
|
|
340
|
-
*
|
|
341
214
|
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to update the content.
|
|
342
215
|
*/
|
|
343
|
-
async updateAttachmentData<T = Models.
|
|
216
|
+
async updateAttachmentData<T = Models.CreatedAttachment>(
|
|
344
217
|
parameters: Parameters.UpdateAttachmentData,
|
|
345
218
|
callback?: never
|
|
346
219
|
): Promise<T>;
|
|
347
|
-
async updateAttachmentData<T = Models.
|
|
220
|
+
async updateAttachmentData<T = Models.CreatedAttachment>(
|
|
348
221
|
parameters: Parameters.UpdateAttachmentData,
|
|
349
222
|
callback?: Callback<T>,
|
|
350
223
|
): Promise<void | T> {
|
|
224
|
+
const { attachment } = parameters;
|
|
225
|
+
|
|
226
|
+
const formData = new FormData();
|
|
227
|
+
|
|
228
|
+
formData.append('minorEdit', attachment.minorEdit.toString(), 'minorEdit');
|
|
229
|
+
formData.append('file', attachment.file, {
|
|
230
|
+
filename: attachment.filename,
|
|
231
|
+
contentType: attachment.contentType,
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
if (attachment.comment) {
|
|
235
|
+
formData.append('comment', attachment.comment, 'comment');
|
|
236
|
+
}
|
|
237
|
+
|
|
351
238
|
const config: RequestConfig = {
|
|
352
239
|
url: `/api/content/${parameters.id}/child/attachment/${parameters.attachmentId}/data`,
|
|
353
240
|
method: 'POST',
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
241
|
+
headers: {
|
|
242
|
+
'X-Atlassian-Token': 'no-check',
|
|
243
|
+
'Content-Type': 'multipart/form-data',
|
|
244
|
+
...formData.getHeaders?.(),
|
|
358
245
|
},
|
|
246
|
+
data: formData,
|
|
359
247
|
};
|
|
360
248
|
|
|
361
249
|
return this.client.sendRequest(config, callback);
|
|
362
250
|
}
|
|
363
251
|
|
|
364
252
|
/** Redirects the client to a URL that serves an attachment's binary data. */
|
|
365
|
-
async downloadAttachment<T =
|
|
253
|
+
async downloadAttachment<T = Buffer>(
|
|
366
254
|
parameters: Parameters.DownloadAttachment,
|
|
367
255
|
callback: Callback<T>
|
|
368
256
|
): Promise<void>;
|
|
369
257
|
/** Redirects the client to a URL that serves an attachment's binary data. */
|
|
370
|
-
async downloadAttachment<T =
|
|
371
|
-
async downloadAttachment<T =
|
|
258
|
+
async downloadAttachment<T = Buffer>(parameters: Parameters.DownloadAttachment, callback?: never): Promise<T>;
|
|
259
|
+
async downloadAttachment<T = Buffer>(
|
|
372
260
|
parameters: Parameters.DownloadAttachment,
|
|
373
261
|
callback?: Callback<T>,
|
|
374
262
|
): Promise<void | T> {
|