dalux-build-api 1.1.3 → 2.0.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/LICENSE +21 -21
- package/README.md +404 -365
- package/package.json +47 -46
- package/src/api/CompaniesApi.js +67 -60
- package/src/api/CompanyCatalogApi.js +129 -108
- package/src/api/FileAreasApi.js +57 -37
- package/src/api/FileRevisionsApi.js +31 -31
- package/src/api/FileUploadApi.js +64 -64
- package/src/api/FilesApi.js +701 -297
- package/src/api/FoldersApi.js +283 -58
- package/src/api/FormsApi.js +53 -48
- package/src/api/InspectionPlansApi.js +66 -62
- package/src/api/ProjectTemplatesApi.js +25 -25
- package/src/api/ProjectsApi.js +127 -106
- package/src/api/TasksApi.js +193 -161
- package/src/api/TestPlansApi.js +63 -59
- package/src/api/UsersApi.js +52 -47
- package/src/api/VersionSetsApi.js +75 -67
- package/src/api/WorkPackagesApi.js +30 -26
- package/src/apiClient.js +139 -75
- package/src/configuration.js +39 -24
- package/src/index.js +133 -92
- package/src/models/common.js +22 -0
- package/src/models/companies/index.js +14 -0
- package/src/models/companyCatalog/index.js +19 -0
- package/src/models/convert.js +44 -0
- package/src/models/fileAreas/index.js +20 -0
- package/src/models/fileRevisions/index.js +12 -0
- package/src/models/fileUpload/index.js +12 -0
- package/src/models/files/index.js +97 -0
- package/src/models/folders/index.js +20 -0
- package/src/models/forms/index.js +19 -0
- package/src/models/helpers.js +62 -0
- package/src/models/index.js +148 -0
- package/src/models/inspectionPlans/index.js +18 -0
- package/src/models/projectTemplates/index.js +11 -0
- package/src/models/projects/index.js +57 -0
- package/src/models/tasks/index.js +105 -0
- package/src/models/testPlans/index.js +17 -0
- package/src/models/users/index.js +29 -0
- package/src/models/versionSets/index.js +22 -0
- package/src/models/workPackages/index.js +19 -0
- package/src/utils/errors.js +45 -0
- package/src/utils/index.js +26 -0
- package/src/utils/pagination.js +82 -0
- package/src/utils/pathResolver.js +124 -0
- package/src/utils/search.js +61 -0
- package/src/utils/validation.js +36 -0
package/src/api/ProjectsApi.js
CHANGED
|
@@ -1,106 +1,127 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
*
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { findByField } = require('../utils/search');
|
|
4
|
+
const { convertToModel } = require('../models/convert');
|
|
5
|
+
const { ProjectsListResponseSchema, ProjectResponseSchema } = require('../models/projects');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* API methods for project management.
|
|
9
|
+
*/
|
|
10
|
+
class ProjectsApi {
|
|
11
|
+
/**
|
|
12
|
+
* @param {import('../apiClient')} apiClient
|
|
13
|
+
*/
|
|
14
|
+
constructor(apiClient) {
|
|
15
|
+
this._client = apiClient;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Get all available projects.
|
|
20
|
+
* GET /5.1/projects
|
|
21
|
+
* @param {object} [params] - Optional query parameters (e.g. updatedAfter)
|
|
22
|
+
* @returns {Promise<object>} ProjectsListResponse ({ items: Project[], metadata?, links? })
|
|
23
|
+
*/
|
|
24
|
+
async listProjects(params = {}) {
|
|
25
|
+
const response = await this._client.get('/5.1/projects', params);
|
|
26
|
+
return convertToModel(response, ProjectsListResponseSchema, 'ProjectsListResponse');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Get a specific project.
|
|
31
|
+
* GET /5.0/projects/{projectId}
|
|
32
|
+
* @param {string} projectId
|
|
33
|
+
* @returns {Promise<object>} ProjectResponse ({ data: Project, links? })
|
|
34
|
+
*/
|
|
35
|
+
async getProject(projectId) {
|
|
36
|
+
const response = await this._client.get(`/5.0/projects/${projectId}`);
|
|
37
|
+
return convertToModel(response, ProjectResponseSchema, 'ProjectResponse');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Create a new project.
|
|
42
|
+
* POST /5.0/projects
|
|
43
|
+
* @param {object} body
|
|
44
|
+
* @returns {Promise<object>} ProjectResponse
|
|
45
|
+
*/
|
|
46
|
+
async createProject(body) {
|
|
47
|
+
const response = await this._client.post('/5.0/projects', body);
|
|
48
|
+
return convertToModel(response, ProjectResponseSchema, 'ProjectResponse');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Update a project.
|
|
53
|
+
* PATCH /5.0/projects/{projectId}
|
|
54
|
+
* @param {string} projectId
|
|
55
|
+
* @param {object} body
|
|
56
|
+
* @returns {Promise<object>} ProjectResponse
|
|
57
|
+
*/
|
|
58
|
+
async updateProject(projectId, body) {
|
|
59
|
+
const response = await this._client.patch(`/5.0/projects/${projectId}`, body);
|
|
60
|
+
return convertToModel(response, ProjectResponseSchema, 'ProjectResponse');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Get all metadata available for POST project operations.
|
|
65
|
+
* GET /1.0/projects/metadata/1.0/mappings
|
|
66
|
+
* @returns {Promise<object>}
|
|
67
|
+
*/
|
|
68
|
+
listMetadataMappingsForProjects() {
|
|
69
|
+
return this._client.get('/1.0/projects/metadata/1.0/mappings');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Get available values for a metadata key in POST project operations.
|
|
74
|
+
* GET /1.0/projects/metadata/1.0/mappings/{key}/values
|
|
75
|
+
* @param {string} key
|
|
76
|
+
* @returns {Promise<object>}
|
|
77
|
+
*/
|
|
78
|
+
listMetadataValuesForProjects(key) {
|
|
79
|
+
return this._client.get(`/1.0/projects/metadata/1.0/mappings/${key}/values`);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Get metadata of a specific project.
|
|
84
|
+
* GET /1.0/projects/{projectId}/metadata
|
|
85
|
+
* @param {string} projectId
|
|
86
|
+
* @returns {Promise<object>}
|
|
87
|
+
*/
|
|
88
|
+
listProjectMetadata(projectId) {
|
|
89
|
+
return this._client.get(`/1.0/projects/${projectId}/metadata`);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Get all metadata available for PATCH project operations.
|
|
94
|
+
* GET /1.0/projects/{projectId}/metadata/1.0/mappings
|
|
95
|
+
* @param {string} projectId
|
|
96
|
+
* @returns {Promise<object>}
|
|
97
|
+
*/
|
|
98
|
+
listProjectMetadataMappings(projectId) {
|
|
99
|
+
return this._client.get(`/1.0/projects/${projectId}/metadata/1.0/mappings`);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Get available values for metadata in a PATCH project operation.
|
|
104
|
+
* GET /1.0/projects/{projectId}/metadata/1.0/mappings/{key}/values
|
|
105
|
+
* @param {string} projectId
|
|
106
|
+
* @param {string} key
|
|
107
|
+
* @returns {Promise<object>}
|
|
108
|
+
*/
|
|
109
|
+
listProjectMetadataValues(projectId, key) {
|
|
110
|
+
return this._client.get(`/1.0/projects/${projectId}/metadata/1.0/mappings/${key}/values`);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Get a project ID by its name.
|
|
115
|
+
* @param {string} projectName
|
|
116
|
+
* @returns {Promise<string|null>} The projectId, or null if not found.
|
|
117
|
+
*/
|
|
118
|
+
async getProjectByName(projectName) {
|
|
119
|
+
const response = await this.listProjects();
|
|
120
|
+
const items = (response && response.items) || [];
|
|
121
|
+
const project = findByField(items, 'projectName', projectName);
|
|
122
|
+
if (!project) return null;
|
|
123
|
+
return project.projectId || null;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
module.exports = ProjectsApi;
|
package/src/api/TasksApi.js
CHANGED
|
@@ -1,161 +1,193 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
* @param {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* @
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
} else {
|
|
115
|
-
hasNextPage = false;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
return
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Retrieve
|
|
138
|
-
* GET /
|
|
139
|
-
* @param {string} projectId
|
|
140
|
-
* @param {
|
|
141
|
-
* @returns {Promise<object>}
|
|
142
|
-
*/
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
* @param {
|
|
152
|
-
* @
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { convertToModel, convertToModelList } = require('../models/convert');
|
|
4
|
+
const {
|
|
5
|
+
TaskSchema,
|
|
6
|
+
TaskChangeSchema,
|
|
7
|
+
TasksListResponseSchema,
|
|
8
|
+
TaskResponseSchema,
|
|
9
|
+
TaskChangesSchema,
|
|
10
|
+
TaskAttachmentsListResponseSchema,
|
|
11
|
+
} = require('../models/tasks');
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Build query params for GET /5.2/projects/.../tasks (OData).
|
|
15
|
+
* If params contains typeId and no $filter, expands to
|
|
16
|
+
* $filter=data/type/typeId eq '<typeId>'
|
|
17
|
+
* Single quotes in typeId are escaped as '' per OData. If $filter is set,
|
|
18
|
+
* typeId is still omitted from the outgoing query (not merged).
|
|
19
|
+
* @param {object} [params]
|
|
20
|
+
* @returns {object}
|
|
21
|
+
*/
|
|
22
|
+
function normalizeTaskParams(params = {}) {
|
|
23
|
+
const normalized = { ...params };
|
|
24
|
+
const typeId = normalized.typeId;
|
|
25
|
+
delete normalized.typeId;
|
|
26
|
+
if (typeId != null && normalized.$filter === undefined) {
|
|
27
|
+
const escaped = String(typeId).replace(/'/g, "''");
|
|
28
|
+
normalized.$filter = `data/type/typeId eq '${escaped}'`;
|
|
29
|
+
}
|
|
30
|
+
return normalized;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* API methods for tasks, approvals, safety issues, observations and good practices.
|
|
35
|
+
*/
|
|
36
|
+
class TasksApi {
|
|
37
|
+
/**
|
|
38
|
+
* @param {import('../apiClient')} apiClient
|
|
39
|
+
*/
|
|
40
|
+
constructor(apiClient) {
|
|
41
|
+
this._client = apiClient;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Retrieve tasks, approvals, safety issues, safety observations and good practices on a project.
|
|
46
|
+
* GET /5.2/projects/{projectId}/tasks
|
|
47
|
+
* @param {string} projectId
|
|
48
|
+
* @param {object} [params] - Optional filters (e.g. updatedAfter). Pass typeId as shorthand for
|
|
49
|
+
* OData $filter on task type, or pass $filter (and other OData options) directly.
|
|
50
|
+
* @returns {Promise<object>}
|
|
51
|
+
*/
|
|
52
|
+
async getProjectTasks(projectId, params = {}) {
|
|
53
|
+
const response = await this._client.get(`/5.2/projects/${projectId}/tasks`, normalizeTaskParams(params));
|
|
54
|
+
return convertToModel(response, TasksListResponseSchema, 'TasksListResponse');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Retrieve all tasks on a project by following bookmark pagination automatically.
|
|
59
|
+
* Matches Python client behaviour: uses metadata.totalRemainingItems when present;
|
|
60
|
+
* otherwise uses metadata.totalItems across pages as a ceiling so pagination cannot run forever.
|
|
61
|
+
* @param {string} projectId
|
|
62
|
+
* @param {object} [params] - Optional filters / OData (typeId shorthand supported).
|
|
63
|
+
* @param {boolean} [verbose=false] - Log progress to console.
|
|
64
|
+
* @returns {Promise<object[]>} All task items across all pages
|
|
65
|
+
*/
|
|
66
|
+
async getAllProjectTasks(projectId, params = {}, verbose = false) {
|
|
67
|
+
const allItems = [];
|
|
68
|
+
const baseParams = normalizeTaskParams(params);
|
|
69
|
+
let currentParams = { ...baseParams };
|
|
70
|
+
let hasNextPage = true;
|
|
71
|
+
/** @type {number|null} */
|
|
72
|
+
let tasksItemsCeiling = null;
|
|
73
|
+
|
|
74
|
+
while (hasNextPage) {
|
|
75
|
+
const response = await this._client.get(`/5.2/projects/${projectId}/tasks`, currentParams);
|
|
76
|
+
const items = Array.isArray(response.items) ? response.items : [];
|
|
77
|
+
if (items.length) {
|
|
78
|
+
allItems.push(...items);
|
|
79
|
+
}
|
|
80
|
+
const meta = (response && response.metadata) || {};
|
|
81
|
+
let remaining;
|
|
82
|
+
let useFilesRemainingStop;
|
|
83
|
+
|
|
84
|
+
if (Object.prototype.hasOwnProperty.call(meta, 'totalRemainingItems')) {
|
|
85
|
+
remaining = Number(meta.totalRemainingItems);
|
|
86
|
+
useFilesRemainingStop = true;
|
|
87
|
+
} else if (Object.prototype.hasOwnProperty.call(meta, 'totalItems')) {
|
|
88
|
+
const ti = Number(meta.totalItems);
|
|
89
|
+
tasksItemsCeiling = Math.max(tasksItemsCeiling || 0, ti);
|
|
90
|
+
remaining = ti;
|
|
91
|
+
useFilesRemainingStop = false;
|
|
92
|
+
} else {
|
|
93
|
+
remaining = 0;
|
|
94
|
+
useFilesRemainingStop = true;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const nextLink = (response.links || []).find((l) => l.rel === 'nextPage');
|
|
98
|
+
const nextHref = nextLink ? nextLink.href : null;
|
|
99
|
+
|
|
100
|
+
if (verbose) {
|
|
101
|
+
const nextPart = nextHref ? ` next: ${nextHref}` : ' next: (none)';
|
|
102
|
+
if (useFilesRemainingStop) {
|
|
103
|
+
console.log(`Retrieved ${allItems.length} tasks so far, ${remaining} remaining...${nextPart}`);
|
|
104
|
+
} else if (tasksItemsCeiling != null) {
|
|
105
|
+
const remV = Math.max(0, tasksItemsCeiling - allItems.length);
|
|
106
|
+
console.log(`Retrieved ${allItems.length} tasks so far, ${remV} remaining...${nextPart}`);
|
|
107
|
+
} else {
|
|
108
|
+
console.log(`Retrieved ${allItems.length} tasks so far, ${remaining} remaining...${nextPart}`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (!items.length) {
|
|
113
|
+
hasNextPage = false;
|
|
114
|
+
} else if (useFilesRemainingStop && remaining === 0) {
|
|
115
|
+
hasNextPage = false;
|
|
116
|
+
} else if (
|
|
117
|
+
!useFilesRemainingStop &&
|
|
118
|
+
tasksItemsCeiling != null &&
|
|
119
|
+
allItems.length >= tasksItemsCeiling
|
|
120
|
+
) {
|
|
121
|
+
hasNextPage = false;
|
|
122
|
+
} else if (nextLink) {
|
|
123
|
+
const bookmark = new URL(nextLink.href).searchParams.get('bookmark');
|
|
124
|
+
currentParams = { ...baseParams, bookmark };
|
|
125
|
+
} else {
|
|
126
|
+
hasNextPage = false;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (verbose) {
|
|
131
|
+
console.log(`Done. Total tasks retrieved: ${allItems.length}`);
|
|
132
|
+
}
|
|
133
|
+
return convertToModelList(allItems, TaskSchema, 'Task');
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Retrieve a specific task/approval/safety issue/safety observation/good practice.
|
|
138
|
+
* GET /3.3/projects/{projectId}/tasks/{taskId}
|
|
139
|
+
* @param {string} projectId
|
|
140
|
+
* @param {string} taskId
|
|
141
|
+
* @returns {Promise<object>}
|
|
142
|
+
*/
|
|
143
|
+
async getTask(projectId, taskId) {
|
|
144
|
+
const response = await this._client.get(`/3.3/projects/${projectId}/tasks/${taskId}`);
|
|
145
|
+
return convertToModel(response, TaskResponseSchema, 'TaskResponse');
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Retrieve task changes on a project in incremental updates.
|
|
150
|
+
* GET /2.2/projects/{projectId}/tasks/changes
|
|
151
|
+
* @param {string} projectId
|
|
152
|
+
* @param {object} [params] - Optional filters (e.g. updatedAfter)
|
|
153
|
+
* @returns {Promise<object>}
|
|
154
|
+
*/
|
|
155
|
+
async getProjectTaskChanges(projectId, params = {}) {
|
|
156
|
+
const response = await this._client.get(`/2.2/projects/${projectId}/tasks/changes`, params);
|
|
157
|
+
return convertToModel(response, TaskChangesSchema, 'TaskChanges');
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Retrieve attachments on tasks on a project.
|
|
162
|
+
* GET /1.1/projects/{projectId}/tasks/attachments
|
|
163
|
+
* @param {string} projectId
|
|
164
|
+
* @param {object} [params] - Optional filters (e.g. updatedAfter)
|
|
165
|
+
* @returns {Promise<object>}
|
|
166
|
+
*/
|
|
167
|
+
async getProjectTaskAttachments(projectId, params = {}) {
|
|
168
|
+
const response = await this._client.get(`/1.1/projects/${projectId}/tasks/attachments`, params);
|
|
169
|
+
return convertToModel(response, TaskAttachmentsListResponseSchema, 'TaskAttachmentsListResponse');
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Retrieve all task changes by following bookmark pagination automatically.
|
|
174
|
+
* @param {string} projectId
|
|
175
|
+
* @param {object} [params] - Optional query parameters (e.g. updatedAfter).
|
|
176
|
+
* @param {boolean} [verbose=false]
|
|
177
|
+
* @returns {Promise<object[]>} All task change items across all pages.
|
|
178
|
+
*/
|
|
179
|
+
async getAllProjectTaskChanges(projectId, params = {}, verbose = false) {
|
|
180
|
+
const { paginate } = require('../utils/pagination');
|
|
181
|
+
const raw = await paginate(
|
|
182
|
+
`/2.2/projects/${projectId}/tasks/changes`,
|
|
183
|
+
this._client,
|
|
184
|
+
params,
|
|
185
|
+
verbose,
|
|
186
|
+
);
|
|
187
|
+
return convertToModelList(raw, TaskChangeSchema, 'TaskChange');
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
TasksApi.normalizeTaskParams = normalizeTaskParams;
|
|
192
|
+
|
|
193
|
+
module.exports = TasksApi;
|