confluence.js 1.2.0 → 1.3.1
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 +19 -0
- package/README.md +0 -57
- package/out/api/audit.js +6 -6
- package/out/api/content.js +11 -10
- package/out/api/contentAttachments.d.ts +2 -2
- package/out/api/contentAttachments.js +7 -6
- package/out/api/contentBody.js +1 -1
- package/out/api/contentChildrenAndDescendants.js +7 -7
- package/out/api/contentComments.js +1 -1
- package/out/api/contentLabels.js +4 -4
- package/out/api/contentMacroBody.js +1 -1
- package/out/api/contentPermissions.js +1 -1
- package/out/api/contentProperties.js +7 -6
- package/out/api/contentRestrictions.js +15 -15
- package/out/api/contentVersions.js +4 -4
- package/out/api/contentWatches.js +12 -12
- package/out/api/dynamicModules.js +3 -3
- package/out/api/experimental.d.ts +36 -0
- package/out/api/experimental.js +38 -2
- package/out/api/group.js +15 -15
- package/out/api/inlineTasks.js +3 -3
- package/out/api/labelInfo.js +1 -1
- package/out/api/longRunningTask.js +2 -2
- package/out/api/parameters/addLabelsToSpace.d.ts +4 -0
- package/out/api/parameters/addLabelsToSpace.js +2 -0
- package/out/api/parameters/deleteLabelFromSpace.d.ts +8 -0
- package/out/api/parameters/deleteLabelFromSpace.js +2 -0
- package/out/api/parameters/getBulkUserLookup.d.ts +0 -6
- package/out/api/parameters/getContentById.d.ts +85 -1
- package/out/api/parameters/getContentById.js +87 -0
- package/out/api/parameters/getContentChildren.d.ts +1 -0
- package/out/api/parameters/getContentProperties.d.ts +1 -1
- package/out/api/parameters/getContentProperty.d.ts +12 -0
- package/out/api/parameters/getContentVersions.d.ts +1 -1
- package/out/api/parameters/getCurrentUser.d.ts +1 -6
- package/out/api/parameters/getHistoryForContent.d.ts +1 -1
- package/out/api/parameters/getLabelsForSpace.d.ts +18 -0
- package/out/api/parameters/getLabelsForSpace.js +2 -0
- package/out/api/parameters/index.d.ts +3 -0
- package/out/api/parameters/index.js +3 -0
- package/out/api/parameters/restoreContentVersion.d.ts +1 -1
- package/out/api/parameters/searchUser.d.ts +7 -0
- package/out/api/relation.js +5 -5
- package/out/api/search.d.ts +2 -2
- package/out/api/search.js +3 -2
- package/out/api/settings.js +6 -6
- package/out/api/space.js +9 -9
- package/out/api/spacePermissions.js +3 -3
- package/out/api/spaceProperties.js +6 -6
- package/out/api/spaceSettings.js +2 -2
- package/out/api/template.d.ts +24 -16
- package/out/api/template.js +6 -6
- package/out/api/themes.js +6 -6
- package/out/api/users.js +8 -8
- package/out/clients/baseClient.d.ts +2 -5
- package/out/clients/baseClient.js +10 -32
- package/out/clients/client.d.ts +2 -3
- package/out/config.d.ts +3 -2
- package/out/index.d.ts +1 -0
- package/out/index.js +2 -1
- package/package.json +24 -24
- package/src/api/audit.ts +6 -6
- package/src/api/content.ts +11 -10
- package/src/api/contentAttachments.ts +10 -9
- package/src/api/contentBody.ts +1 -1
- package/src/api/contentChildrenAndDescendants.ts +7 -7
- package/src/api/contentComments.ts +1 -1
- package/src/api/contentLabels.ts +4 -4
- package/src/api/contentMacroBody.ts +1 -1
- package/src/api/contentPermissions.ts +1 -1
- package/src/api/contentProperties.ts +7 -6
- package/src/api/contentRestrictions.ts +15 -15
- package/src/api/contentVersions.ts +4 -4
- package/src/api/contentWatches.ts +12 -12
- package/src/api/dynamicModules.ts +3 -3
- package/src/api/experimental.ts +95 -2
- package/src/api/group.ts +16 -15
- package/src/api/inlineTasks.ts +3 -3
- package/src/api/labelInfo.ts +1 -1
- package/src/api/longRunningTask.ts +2 -2
- package/src/api/parameters/addLabelsToSpace.ts +4 -0
- package/src/api/parameters/deleteLabelFromSpace.ts +8 -0
- package/src/api/parameters/getBulkUserLookup.ts +0 -6
- package/src/api/parameters/getContentById.ts +86 -1
- package/src/api/parameters/getContentChildren.ts +1 -0
- package/src/api/parameters/getContentProperties.ts +1 -1
- package/src/api/parameters/getContentProperty.ts +12 -0
- package/src/api/parameters/getContentVersions.ts +1 -1
- package/src/api/parameters/getCurrentUser.ts +1 -6
- package/src/api/parameters/getHistoryForContent.ts +1 -1
- package/src/api/parameters/getLabelsForSpace.ts +18 -0
- package/src/api/parameters/index.ts +3 -0
- package/src/api/parameters/restoreContentVersion.ts +1 -1
- package/src/api/parameters/searchUser.ts +7 -0
- package/src/api/relation.ts +5 -5
- package/src/api/search.ts +6 -4
- package/src/api/settings.ts +6 -6
- package/src/api/space.ts +9 -9
- package/src/api/spacePermissions.ts +3 -3
- package/src/api/spaceProperties.ts +6 -6
- package/src/api/spaceSettings.ts +2 -2
- package/src/api/template.ts +30 -22
- package/src/api/themes.ts +6 -6
- package/src/api/users.ts +8 -8
- package/src/clients/baseClient.ts +10 -62
- package/src/clients/client.ts +2 -3
- package/src/config.ts +3 -2
- package/src/index.ts +1 -0
- package/tsconfig.json +2 -1
package/src/api/template.ts
CHANGED
|
@@ -44,14 +44,14 @@ export class Template {
|
|
|
44
44
|
},
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
-
return this.client.sendRequest(config, callback
|
|
47
|
+
return this.client.sendRequest(config, callback);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* Updates a content template. Note, blueprint templates cannot be updated via the REST API.
|
|
52
52
|
*
|
|
53
|
-
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: 'Admin' permission for the space to
|
|
54
|
-
* space template or 'Confluence Administrator' global permission to
|
|
53
|
+
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: 'Admin' permission for the space to update a
|
|
54
|
+
* space template or 'Confluence Administrator' global permission to update a global template.
|
|
55
55
|
*/
|
|
56
56
|
async updateContentTemplate<T = Models.ContentTemplate>(
|
|
57
57
|
parameters: Parameters.UpdateContentTemplate | undefined,
|
|
@@ -60,8 +60,8 @@ export class Template {
|
|
|
60
60
|
/**
|
|
61
61
|
* Updates a content template. Note, blueprint templates cannot be updated via the REST API.
|
|
62
62
|
*
|
|
63
|
-
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: 'Admin' permission for the space to
|
|
64
|
-
* space template or 'Confluence Administrator' global permission to
|
|
63
|
+
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: 'Admin' permission for the space to update a
|
|
64
|
+
* space template or 'Confluence Administrator' global permission to update a global template.
|
|
65
65
|
*/
|
|
66
66
|
async updateContentTemplate<T = Models.ContentTemplate>(
|
|
67
67
|
parameters?: Parameters.UpdateContentTemplate,
|
|
@@ -85,7 +85,7 @@ export class Template {
|
|
|
85
85
|
},
|
|
86
86
|
};
|
|
87
87
|
|
|
88
|
-
return this.client.sendRequest(config, callback
|
|
88
|
+
return this.client.sendRequest(config, callback);
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
/**
|
|
@@ -95,8 +95,9 @@ export class Template {
|
|
|
95
95
|
* Note, all global blueprints are inherited by each space. Space blueprints can be customised without affecting the
|
|
96
96
|
* global blueprints.
|
|
97
97
|
*
|
|
98
|
-
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:
|
|
99
|
-
* ('Can use' global permission)
|
|
98
|
+
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: 'View' permission for the space to view
|
|
99
|
+
* blueprints for the space and permission to access the Confluence site ('Can use' global permission) to view global
|
|
100
|
+
* blueprints.
|
|
100
101
|
*/
|
|
101
102
|
async getBlueprintTemplates<T = Models.BlueprintTemplateArray>(
|
|
102
103
|
parameters: Parameters.GetBlueprintTemplates | undefined,
|
|
@@ -109,8 +110,9 @@ export class Template {
|
|
|
109
110
|
* Note, all global blueprints are inherited by each space. Space blueprints can be customised without affecting the
|
|
110
111
|
* global blueprints.
|
|
111
112
|
*
|
|
112
|
-
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:
|
|
113
|
-
* ('Can use' global permission)
|
|
113
|
+
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: 'View' permission for the space to view
|
|
114
|
+
* blueprints for the space and permission to access the Confluence site ('Can use' global permission) to view global
|
|
115
|
+
* blueprints.
|
|
114
116
|
*/
|
|
115
117
|
async getBlueprintTemplates<T = Models.BlueprintTemplateArray>(
|
|
116
118
|
parameters?: Parameters.GetBlueprintTemplates,
|
|
@@ -131,14 +133,14 @@ export class Template {
|
|
|
131
133
|
},
|
|
132
134
|
};
|
|
133
135
|
|
|
134
|
-
return this.client.sendRequest(config, callback
|
|
136
|
+
return this.client.sendRequest(config, callback);
|
|
135
137
|
}
|
|
136
138
|
|
|
137
139
|
/**
|
|
138
140
|
* Returns all content templates. Use this method to retrieve all global content templates or all content templates in a space.
|
|
139
141
|
*
|
|
140
|
-
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: '
|
|
141
|
-
* space templates and
|
|
142
|
+
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: 'View' permission for the space to view
|
|
143
|
+
* space templates and permission to access the Confluence site ('Can use' global permission) to view global templates.
|
|
142
144
|
*/
|
|
143
145
|
async getContentTemplates<T = Models.ContentTemplateArray>(
|
|
144
146
|
parameters: Parameters.GetContentTemplates | undefined,
|
|
@@ -147,8 +149,8 @@ export class Template {
|
|
|
147
149
|
/**
|
|
148
150
|
* Returns all content templates. Use this method to retrieve all global content templates or all content templates in a space.
|
|
149
151
|
*
|
|
150
|
-
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: '
|
|
151
|
-
* space templates and
|
|
152
|
+
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: 'View' permission for the space to view
|
|
153
|
+
* space templates and permission to access the Confluence site ('Can use' global permission) to view global templates.
|
|
152
154
|
*/
|
|
153
155
|
async getContentTemplates<T = Models.ContentTemplateArray>(
|
|
154
156
|
parameters?: Parameters.GetContentTemplates,
|
|
@@ -169,15 +171,15 @@ export class Template {
|
|
|
169
171
|
},
|
|
170
172
|
};
|
|
171
173
|
|
|
172
|
-
return this.client.sendRequest(config, callback
|
|
174
|
+
return this.client.sendRequest(config, callback);
|
|
173
175
|
}
|
|
174
176
|
|
|
175
177
|
/**
|
|
176
178
|
* Returns a content template. This includes information about template, like the name, the space or blueprint that
|
|
177
179
|
* the template is in, the body of the template, and more.
|
|
178
180
|
*
|
|
179
|
-
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: '
|
|
180
|
-
* space templates and
|
|
181
|
+
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: 'View' permission for the space to view
|
|
182
|
+
* space templates and permission to access the Confluence site ('Can use' global permission) to view global templates.
|
|
181
183
|
*/
|
|
182
184
|
async getContentTemplate<T = Models.ContentTemplate>(
|
|
183
185
|
parameters: Parameters.GetContentTemplate,
|
|
@@ -187,8 +189,8 @@ export class Template {
|
|
|
187
189
|
* Returns a content template. This includes information about template, like the name, the space or blueprint that
|
|
188
190
|
* the template is in, the body of the template, and more.
|
|
189
191
|
*
|
|
190
|
-
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: '
|
|
191
|
-
* space templates and
|
|
192
|
+
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: 'View' permission for the space to view
|
|
193
|
+
* space templates and permission to access the Confluence site ('Can use' global permission) to view global templates.
|
|
192
194
|
*/
|
|
193
195
|
async getContentTemplate<T = Models.ContentTemplate>(
|
|
194
196
|
parameters: Parameters.GetContentTemplate,
|
|
@@ -203,7 +205,7 @@ export class Template {
|
|
|
203
205
|
method: 'GET',
|
|
204
206
|
};
|
|
205
207
|
|
|
206
|
-
return this.client.sendRequest(config, callback
|
|
208
|
+
return this.client.sendRequest(config, callback);
|
|
207
209
|
}
|
|
208
210
|
|
|
209
211
|
/**
|
|
@@ -215,6 +217,9 @@ export class Template {
|
|
|
215
217
|
* - If the template is a modified global-level blueprint template, it reverts to the default global-level blueprint template.
|
|
216
218
|
*
|
|
217
219
|
* Note, unmodified blueprint templates cannot be deleted.
|
|
220
|
+
*
|
|
221
|
+
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: 'Admin' permission for the space to delete a
|
|
222
|
+
* space template or 'Confluence Administrator' global permission to delete a global template.
|
|
218
223
|
*/
|
|
219
224
|
async removeTemplate<T = void>(parameters: Parameters.RemoveTemplate, callback: Callback<T>): Promise<void>;
|
|
220
225
|
/**
|
|
@@ -226,6 +231,9 @@ export class Template {
|
|
|
226
231
|
* - If the template is a modified global-level blueprint template, it reverts to the default global-level blueprint template.
|
|
227
232
|
*
|
|
228
233
|
* Note, unmodified blueprint templates cannot be deleted.
|
|
234
|
+
*
|
|
235
|
+
* **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: 'Admin' permission for the space to delete a
|
|
236
|
+
* space template or 'Confluence Administrator' global permission to delete a global template.
|
|
229
237
|
*/
|
|
230
238
|
async removeTemplate<T = void>(parameters: Parameters.RemoveTemplate, callback?: never): Promise<T>;
|
|
231
239
|
async removeTemplate<T = void>(parameters: Parameters.RemoveTemplate, callback?: Callback<T>): Promise<void | T> {
|
|
@@ -234,6 +242,6 @@ export class Template {
|
|
|
234
242
|
method: 'DELETE',
|
|
235
243
|
};
|
|
236
244
|
|
|
237
|
-
return this.client.sendRequest(config, callback
|
|
245
|
+
return this.client.sendRequest(config, callback);
|
|
238
246
|
}
|
|
239
247
|
}
|
package/src/api/themes.ts
CHANGED
|
@@ -32,7 +32,7 @@ export class Themes {
|
|
|
32
32
|
},
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
return this.client.sendRequest(config, callback
|
|
35
|
+
return this.client.sendRequest(config, callback);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
/**
|
|
@@ -53,7 +53,7 @@ export class Themes {
|
|
|
53
53
|
method: 'GET',
|
|
54
54
|
};
|
|
55
55
|
|
|
56
|
-
return this.client.sendRequest(config, callback
|
|
56
|
+
return this.client.sendRequest(config, callback);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
/**
|
|
@@ -74,7 +74,7 @@ export class Themes {
|
|
|
74
74
|
method: 'GET',
|
|
75
75
|
};
|
|
76
76
|
|
|
77
|
-
return this.client.sendRequest(config, callback
|
|
77
|
+
return this.client.sendRequest(config, callback);
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
/**
|
|
@@ -100,7 +100,7 @@ export class Themes {
|
|
|
100
100
|
method: 'GET',
|
|
101
101
|
};
|
|
102
102
|
|
|
103
|
-
return this.client.sendRequest(config, callback
|
|
103
|
+
return this.client.sendRequest(config, callback);
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
/**
|
|
@@ -129,7 +129,7 @@ export class Themes {
|
|
|
129
129
|
},
|
|
130
130
|
};
|
|
131
131
|
|
|
132
|
-
return this.client.sendRequest(config, callback
|
|
132
|
+
return this.client.sendRequest(config, callback);
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
/**
|
|
@@ -150,6 +150,6 @@ export class Themes {
|
|
|
150
150
|
method: 'DELETE',
|
|
151
151
|
};
|
|
152
152
|
|
|
153
|
-
return this.client.sendRequest(config, callback
|
|
153
|
+
return this.client.sendRequest(config, callback);
|
|
154
154
|
}
|
|
155
155
|
}
|
package/src/api/users.ts
CHANGED
|
@@ -41,7 +41,7 @@ export class Users {
|
|
|
41
41
|
},
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
return this.client.sendRequest(config, callback
|
|
44
|
+
return this.client.sendRequest(config, callback);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
/**
|
|
@@ -76,7 +76,7 @@ export class Users {
|
|
|
76
76
|
},
|
|
77
77
|
};
|
|
78
78
|
|
|
79
|
-
return this.client.sendRequest(config, callback
|
|
79
|
+
return this.client.sendRequest(config, callback);
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
/**
|
|
@@ -110,7 +110,7 @@ export class Users {
|
|
|
110
110
|
},
|
|
111
111
|
};
|
|
112
112
|
|
|
113
|
-
return this.client.sendRequest(config, callback
|
|
113
|
+
return this.client.sendRequest(config, callback);
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
/**
|
|
@@ -149,7 +149,7 @@ export class Users {
|
|
|
149
149
|
},
|
|
150
150
|
};
|
|
151
151
|
|
|
152
|
-
return this.client.sendRequest(config, callback
|
|
152
|
+
return this.client.sendRequest(config, callback);
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
/**
|
|
@@ -186,7 +186,7 @@ export class Users {
|
|
|
186
186
|
},
|
|
187
187
|
};
|
|
188
188
|
|
|
189
|
-
return this.client.sendRequest(config, callback
|
|
189
|
+
return this.client.sendRequest(config, callback);
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
/**
|
|
@@ -223,7 +223,7 @@ export class Users {
|
|
|
223
223
|
},
|
|
224
224
|
};
|
|
225
225
|
|
|
226
|
-
return this.client.sendRequest(config, callback
|
|
226
|
+
return this.client.sendRequest(config, callback);
|
|
227
227
|
}
|
|
228
228
|
|
|
229
229
|
/**
|
|
@@ -266,7 +266,7 @@ export class Users {
|
|
|
266
266
|
},
|
|
267
267
|
};
|
|
268
268
|
|
|
269
|
-
return this.client.sendRequest(config, callback
|
|
269
|
+
return this.client.sendRequest(config, callback);
|
|
270
270
|
}
|
|
271
271
|
|
|
272
272
|
/**
|
|
@@ -306,6 +306,6 @@ export class Users {
|
|
|
306
306
|
},
|
|
307
307
|
};
|
|
308
308
|
|
|
309
|
-
return this.client.sendRequest(config, callback
|
|
309
|
+
return this.client.sendRequest(config, callback);
|
|
310
310
|
}
|
|
311
311
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import axios, { AxiosInstance } from 'axios';
|
|
2
|
-
import { Authentication, Telemetry, TelemetryClient } from 'telemetry.confluence.js';
|
|
3
2
|
import type { Client } from './client';
|
|
4
3
|
import type { Callback } from '../callback';
|
|
5
4
|
import type { Config } from '../config';
|
|
@@ -11,20 +10,17 @@ const ATLASSIAN_TOKEN_CHECK_NOCHECK_VALUE = 'no-check';
|
|
|
11
10
|
|
|
12
11
|
export class BaseClient implements Client {
|
|
13
12
|
#instance: AxiosInstance | undefined;
|
|
14
|
-
private telemetryClient: TelemetryClient;
|
|
15
13
|
|
|
16
14
|
protected urlSuffix = '/wiki/rest/';
|
|
17
15
|
|
|
18
|
-
constructor(protected readonly config: Config) {
|
|
19
|
-
this.telemetryClient = new TelemetryClient(config.telemetry);
|
|
20
|
-
}
|
|
16
|
+
constructor(protected readonly config: Config) {}
|
|
21
17
|
|
|
22
18
|
protected paramSerializer(parameters: Record<string, any>): string {
|
|
23
19
|
const parts: string[] = [];
|
|
24
20
|
|
|
25
21
|
Object.entries(parameters).forEach(([key, value]) => {
|
|
26
22
|
if (value === null || typeof value === 'undefined') {
|
|
27
|
-
return
|
|
23
|
+
return;
|
|
28
24
|
}
|
|
29
25
|
|
|
30
26
|
if (Array.isArray(value)) {
|
|
@@ -38,11 +34,15 @@ export class BaseClient implements Client {
|
|
|
38
34
|
} else if (value !== null && typeof value === 'object') {
|
|
39
35
|
// eslint-disable-next-line no-param-reassign
|
|
40
36
|
value = JSON.stringify(value);
|
|
37
|
+
} else if (value instanceof Function) {
|
|
38
|
+
const part = value();
|
|
39
|
+
|
|
40
|
+
return part && parts.push(part);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
parts.push(`${this.encode(key)}=${this.encode(value)}`);
|
|
44
44
|
|
|
45
|
-
return
|
|
45
|
+
return;
|
|
46
46
|
});
|
|
47
47
|
|
|
48
48
|
return parts.join('&');
|
|
@@ -82,38 +82,16 @@ export class BaseClient implements Client {
|
|
|
82
82
|
return this.#instance;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
async sendRequest<T>(requestConfig: RequestConfig, callback: never, telemetryData?:
|
|
85
|
+
async sendRequest<T>(requestConfig: RequestConfig, callback: never, telemetryData?: any): Promise<T>;
|
|
86
86
|
async sendRequest<T>(
|
|
87
87
|
requestConfig: RequestConfig,
|
|
88
88
|
callback: Callback<T>,
|
|
89
|
-
telemetryData?:
|
|
89
|
+
telemetryData?: any,
|
|
90
90
|
): Promise<void>;
|
|
91
91
|
async sendRequest<T>(
|
|
92
92
|
requestConfig: RequestConfig,
|
|
93
93
|
callback: Callback<T> | never,
|
|
94
|
-
telemetryData?: Partial<Telemetry>,
|
|
95
94
|
): Promise<void | T> {
|
|
96
|
-
const startDateTime = new Date();
|
|
97
|
-
|
|
98
|
-
const telemetry: Telemetry = {
|
|
99
|
-
authentication: this.authenticationType,
|
|
100
|
-
baseRequestConfigUsed: !!this.config.baseRequestConfig,
|
|
101
|
-
bodyExists: !!requestConfig.data,
|
|
102
|
-
callbackUsed: !!callback,
|
|
103
|
-
headersExists: !!requestConfig.headers,
|
|
104
|
-
libVersion: '1.2.0',
|
|
105
|
-
libVersionHash: '0ba4439ee9a46d9d9f14c60f88f45f87',
|
|
106
|
-
methodName: telemetryData?.methodName || 'sendRequest',
|
|
107
|
-
onErrorMiddlewareUsed: !!this.config.middlewares?.onError,
|
|
108
|
-
onResponseMiddlewareUsed: !!this.config.middlewares?.onResponse,
|
|
109
|
-
queryExists: !!requestConfig.params,
|
|
110
|
-
requestEndTime: new Date(),
|
|
111
|
-
requestStartTime: startDateTime,
|
|
112
|
-
requestStatusCode: 0,
|
|
113
|
-
noCheckAtlassianToken: !!this.config.noCheckAtlassianToken,
|
|
114
|
-
...telemetryData,
|
|
115
|
-
};
|
|
116
|
-
|
|
117
95
|
try {
|
|
118
96
|
const modifiedRequestConfig = {
|
|
119
97
|
...requestConfig,
|
|
@@ -127,7 +105,7 @@ export class BaseClient implements Client {
|
|
|
127
105
|
}),
|
|
128
106
|
};
|
|
129
107
|
|
|
130
|
-
const response = await this.instance.request(modifiedRequestConfig);
|
|
108
|
+
const response = await this.instance.request<T>(modifiedRequestConfig);
|
|
131
109
|
|
|
132
110
|
const callbackResponseHandler = callback && ((data: T): void => callback(null, data));
|
|
133
111
|
const defaultResponseHandler = (data: T): T => data;
|
|
@@ -136,8 +114,6 @@ export class BaseClient implements Client {
|
|
|
136
114
|
|
|
137
115
|
this.config.middlewares?.onResponse?.(response.data);
|
|
138
116
|
|
|
139
|
-
telemetry.requestStatusCode = response.status;
|
|
140
|
-
|
|
141
117
|
return responseHandler(response.data);
|
|
142
118
|
} catch (e: any) {
|
|
143
119
|
const callbackErrorHandler = callback && ((error: Config.Error) => callback(error));
|
|
@@ -149,35 +125,7 @@ export class BaseClient implements Client {
|
|
|
149
125
|
|
|
150
126
|
this.config.middlewares?.onError?.(e);
|
|
151
127
|
|
|
152
|
-
telemetry.requestStatusCode = e.isAxiosError ? e.response?.status ?? 0 : 418;
|
|
153
|
-
|
|
154
128
|
return errorHandler(e);
|
|
155
|
-
} finally {
|
|
156
|
-
telemetry.requestEndTime = new Date();
|
|
157
|
-
|
|
158
|
-
this.telemetryClient.sendTelemetry(telemetry);
|
|
159
129
|
}
|
|
160
130
|
}
|
|
161
|
-
|
|
162
|
-
private get authenticationType(): Authentication {
|
|
163
|
-
const { authentication } = this.config;
|
|
164
|
-
|
|
165
|
-
if (!authentication) {
|
|
166
|
-
return Authentication.None;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
if (authentication.basic) {
|
|
170
|
-
return Authentication.Basic;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
if (authentication.oauth2) {
|
|
174
|
-
return Authentication.OAuth2;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
if (authentication.jwt) {
|
|
178
|
-
return Authentication.JWT;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
return Authentication.NA;
|
|
182
|
-
}
|
|
183
131
|
}
|
package/src/clients/client.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import type { Telemetry } from 'telemetry.confluence.js';
|
|
2
1
|
import type { Callback } from '../callback';
|
|
3
2
|
import type { RequestConfig } from '../requestConfig';
|
|
4
3
|
|
|
5
4
|
export interface Client {
|
|
6
|
-
sendRequest<T>(requestConfig: RequestConfig, callback?: never, telemetryData?:
|
|
5
|
+
sendRequest<T>(requestConfig: RequestConfig, callback?: never, telemetryData?: any): Promise<T>;
|
|
7
6
|
sendRequest<T>(
|
|
8
7
|
requestConfig: RequestConfig,
|
|
9
8
|
callback?: Callback<T>,
|
|
10
|
-
telemetryData?:
|
|
9
|
+
telemetryData?: any,
|
|
11
10
|
): Promise<void>;
|
|
12
11
|
}
|
package/src/config.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { AxiosError } from 'axios';
|
|
2
|
-
import type { TelemetryConfig } from 'telemetry.confluence.js';
|
|
3
2
|
import type { RequestConfig } from './requestConfig';
|
|
4
3
|
import type { UtilityTypes } from './utilityTypes';
|
|
5
4
|
|
|
@@ -8,6 +7,7 @@ export interface Config {
|
|
|
8
7
|
baseRequestConfig?: Config.BaseRequestConfig;
|
|
9
8
|
authentication?: Config.Authentication;
|
|
10
9
|
middlewares?: Config.Middlewares;
|
|
10
|
+
/** @deprecated Disabled. Will be removed in the next major version. */
|
|
11
11
|
telemetry?: Config.Telemetry;
|
|
12
12
|
/**
|
|
13
13
|
* Adds `'X-Atlassian-Token': 'no-check'` to each request header
|
|
@@ -18,7 +18,8 @@ export interface Config {
|
|
|
18
18
|
export namespace Config {
|
|
19
19
|
export type BaseRequestConfig = RequestConfig;
|
|
20
20
|
export type Error = AxiosError;
|
|
21
|
-
|
|
21
|
+
/** @deprecated Disabled. Will be removed in the next major version. */
|
|
22
|
+
export type Telemetry = boolean | any;
|
|
22
23
|
|
|
23
24
|
export type Authentication = UtilityTypes.XOR<{
|
|
24
25
|
jwt: Authentication.JWT;
|
package/src/index.ts
CHANGED