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/FoldersApi.js
CHANGED
|
@@ -1,58 +1,283 @@
|
|
|
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
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { paginate } = require('../utils/pagination');
|
|
4
|
+
const { findByField } = require('../utils/search');
|
|
5
|
+
const { validateProjectId, validateFileAreaId } = require('../utils/validation');
|
|
6
|
+
const { resolveFolderIdFromNamedPath } = require('../utils/pathResolver');
|
|
7
|
+
const { convertToModel, convertToModelList } = require('../models/convert');
|
|
8
|
+
const { FolderSchema, FolderResponseSchema, FoldersListResponseSchema } = require('../models/folders');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* API methods for folders within a file area.
|
|
12
|
+
*/
|
|
13
|
+
class FoldersApi {
|
|
14
|
+
/**
|
|
15
|
+
* @param {import('../apiClient')} apiClient
|
|
16
|
+
*/
|
|
17
|
+
constructor(apiClient) {
|
|
18
|
+
this._client = apiClient;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Browse all folders on the given project and file area (single page).
|
|
23
|
+
* GET /5.1/projects/{projectId}/file_areas/{fileAreaId}/folders
|
|
24
|
+
* @param {string} projectId
|
|
25
|
+
* @param {string} fileAreaId
|
|
26
|
+
* @param {object} [params]
|
|
27
|
+
* @returns {Promise<object>}
|
|
28
|
+
*/
|
|
29
|
+
async listFolders(projectId, fileAreaId, params = {}) {
|
|
30
|
+
const response = await this._client.get(
|
|
31
|
+
`/5.1/projects/${projectId}/file_areas/${fileAreaId}/folders`,
|
|
32
|
+
params,
|
|
33
|
+
);
|
|
34
|
+
return convertToModel(response, FoldersListResponseSchema, 'FoldersListResponse');
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Retrieve all folders by following bookmark pagination automatically.
|
|
39
|
+
* @param {string} projectId
|
|
40
|
+
* @param {string} fileAreaId
|
|
41
|
+
* @param {object} [params]
|
|
42
|
+
* @param {boolean} [verbose=false]
|
|
43
|
+
* @returns {Promise<object[]>} All folder items across all pages.
|
|
44
|
+
*/
|
|
45
|
+
async getAllFolders(projectId, fileAreaId, params = {}, verbose = false) {
|
|
46
|
+
validateProjectId(projectId);
|
|
47
|
+
validateFileAreaId(fileAreaId);
|
|
48
|
+
const endpoint = `/5.1/projects/${projectId}/file_areas/${fileAreaId}/folders`;
|
|
49
|
+
const raw = await paginate(endpoint, this._client, params, verbose);
|
|
50
|
+
return convertToModelList(raw, FolderSchema, 'Folder');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Retrieve a specific folder.
|
|
55
|
+
* GET /5.0/projects/{projectId}/file_areas/{fileAreaId}/folders/{folderId}
|
|
56
|
+
* @param {string} projectId
|
|
57
|
+
* @param {string} fileAreaId
|
|
58
|
+
* @param {string} folderId
|
|
59
|
+
* @returns {Promise<object>}
|
|
60
|
+
*/
|
|
61
|
+
async getFolder(projectId, fileAreaId, folderId) {
|
|
62
|
+
const response = await this._client.get(
|
|
63
|
+
`/5.0/projects/${projectId}/file_areas/${fileAreaId}/folders/${folderId}`,
|
|
64
|
+
);
|
|
65
|
+
return convertToModel(response, FolderResponseSchema, 'FolderResponse');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Get a folder using a full path starting with the file area name.
|
|
70
|
+
* e.g. "Files/4_Design/C07_Geometry"
|
|
71
|
+
* @param {string} projectId
|
|
72
|
+
* @param {string} path - Full path starting with file area name.
|
|
73
|
+
* @param {boolean} [verbose=false]
|
|
74
|
+
* @returns {Promise<object|null>} Folder response or null if not found.
|
|
75
|
+
*/
|
|
76
|
+
async getFolderByPath(projectId, path, verbose = false) {
|
|
77
|
+
validateProjectId(projectId);
|
|
78
|
+
const { fileAreaId, folderId } = await resolveFolderIdFromNamedPath(
|
|
79
|
+
this._client, projectId, path, { verbose },
|
|
80
|
+
);
|
|
81
|
+
if (!fileAreaId || !folderId) return null;
|
|
82
|
+
return this.getFolder(projectId, fileAreaId, folderId);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Retrieve all properties for each file type in a specific folder.
|
|
87
|
+
* GET /1.0/projects/{projectId}/file_areas/{fileAreaId}/folders/{folderId}/files/properties/1.0/mappings
|
|
88
|
+
* @param {string} projectId
|
|
89
|
+
* @param {string} fileAreaId
|
|
90
|
+
* @param {string} folderId
|
|
91
|
+
* @returns {Promise<object>}
|
|
92
|
+
*/
|
|
93
|
+
getFolderFilesProperties(projectId, fileAreaId, folderId) {
|
|
94
|
+
return this._client.get(
|
|
95
|
+
`/1.0/projects/${projectId}/file_areas/${fileAreaId}/folders/${folderId}/files/properties/1.0/mappings`,
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Get a folder by name within a file area, optionally filtered by parent folder.
|
|
101
|
+
* @param {string} projectId
|
|
102
|
+
* @param {string} fileAreaId
|
|
103
|
+
* @param {string} folderName
|
|
104
|
+
* @param {string|null} [parentFolderId=null]
|
|
105
|
+
* @returns {Promise<object|null>} Folder item or null if not found.
|
|
106
|
+
*/
|
|
107
|
+
async getFolderByName(projectId, fileAreaId, folderName, parentFolderId = null) {
|
|
108
|
+
validateProjectId(projectId);
|
|
109
|
+
validateFileAreaId(fileAreaId);
|
|
110
|
+
const allFolders = await this.getAllFolders(projectId, fileAreaId);
|
|
111
|
+
const folder = findByField(allFolders, 'folderName', folderName);
|
|
112
|
+
if (!folder) return null;
|
|
113
|
+
if (parentFolderId != null && folder.parentFolderId !== parentFolderId) {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
return convertToModel({ data: folder }, FolderResponseSchema, 'FolderResponse');
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Resolve a folder path (e.g. "Folder1/Folder2") to a folder ID.
|
|
121
|
+
* Supports wildcard matching with * in path segments.
|
|
122
|
+
* @param {string} projectId
|
|
123
|
+
* @param {string} fileAreaId
|
|
124
|
+
* @param {string} folderPath - e.g. "Folder1/SubFolder" or a wildcard path ("*" matches any single segment)
|
|
125
|
+
* @param {boolean} [verbose=false]
|
|
126
|
+
* @returns {Promise<string|null>} Folder ID or null if not found.
|
|
127
|
+
*/
|
|
128
|
+
async getFileAreaTreeByPath(projectId, fileAreaId, folderPath, verbose = false) {
|
|
129
|
+
const allFolders = await this.getAllFolders(projectId, fileAreaId);
|
|
130
|
+
|
|
131
|
+
const cleanPath = folderPath.replace(/^\/|\/$/g, '');
|
|
132
|
+
const pathParts = cleanPath.split('/').map((p) => p.trim()).filter(Boolean);
|
|
133
|
+
if (!pathParts.length) return null;
|
|
134
|
+
|
|
135
|
+
function getData(item) {
|
|
136
|
+
return item.data || item;
|
|
137
|
+
}
|
|
138
|
+
function getFid(item) {
|
|
139
|
+
const d = getData(item);
|
|
140
|
+
return d.folderId || d.id || null;
|
|
141
|
+
}
|
|
142
|
+
function getPid(item) {
|
|
143
|
+
const d = getData(item);
|
|
144
|
+
return d.parentFolderId || d.parentId || '';
|
|
145
|
+
}
|
|
146
|
+
function getName(item) {
|
|
147
|
+
const d = getData(item);
|
|
148
|
+
return d.folderName || d.name || '';
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Collect valid folder IDs
|
|
152
|
+
const validFolderIds = new Set(allFolders.map(getFid).filter(Boolean));
|
|
153
|
+
const fileAreaRootId = fileAreaId;
|
|
154
|
+
|
|
155
|
+
let candidateParentIds = new Set([fileAreaRootId, null, '']);
|
|
156
|
+
|
|
157
|
+
for (const segment of pathParts) {
|
|
158
|
+
const pattern = segment.toLowerCase();
|
|
159
|
+
const nextCandidates = new Set();
|
|
160
|
+
for (const item of allFolders) {
|
|
161
|
+
const fid = getFid(item);
|
|
162
|
+
const pid = getPid(item);
|
|
163
|
+
const name = getName(item).toLowerCase();
|
|
164
|
+
// The folder's effective parent: if pid is not in validFolderIds, treat as root
|
|
165
|
+
const effectivePid = validFolderIds.has(pid) ? pid : fileAreaRootId;
|
|
166
|
+
if (candidateParentIds.has(effectivePid) && _fnmatch(name, pattern)) {
|
|
167
|
+
if (fid) nextCandidates.add(fid);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (!nextCandidates.size) {
|
|
171
|
+
if (verbose) console.log(`Folder segment '${segment}' not found`);
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
candidateParentIds = nextCandidates;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const result = [...candidateParentIds];
|
|
178
|
+
if (result.length === 1) return result[0];
|
|
179
|
+
if (result.length > 1) {
|
|
180
|
+
if (verbose) console.log(`Multiple folders match path '${folderPath}'`);
|
|
181
|
+
return result[0];
|
|
182
|
+
}
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Build the complete folder+file tree for a file area.
|
|
188
|
+
* Fetches all folders (and optionally all files) and assembles them into a nested tree.
|
|
189
|
+
* When *filesApi* is provided, folders and files are fetched concurrently.
|
|
190
|
+
*
|
|
191
|
+
* Each node has the shape:
|
|
192
|
+
* ```
|
|
193
|
+
* { id, name, path, raw, children: [...], files: [...] }
|
|
194
|
+
* ```
|
|
195
|
+
* The returned root node represents the file-area root (id=null).
|
|
196
|
+
*
|
|
197
|
+
* @param {string} projectId
|
|
198
|
+
* @param {string} fileAreaId
|
|
199
|
+
* @param {object|null} [filesApi] - Optional FilesApi instance; when provided files are
|
|
200
|
+
* fetched in parallel and attached to their folder nodes.
|
|
201
|
+
* @param {boolean} [verbose=false]
|
|
202
|
+
* @returns {Promise<object>} Root tree node.
|
|
203
|
+
*/
|
|
204
|
+
async getFileAreaTree(projectId, fileAreaId, filesApi = null, verbose = false) {
|
|
205
|
+
let allFolders, allFiles;
|
|
206
|
+
|
|
207
|
+
if (filesApi) {
|
|
208
|
+
[allFolders, allFiles] = await Promise.all([
|
|
209
|
+
this.getAllFolders(projectId, fileAreaId, {}, verbose),
|
|
210
|
+
filesApi.getAllFiles(projectId, fileAreaId, {}, verbose),
|
|
211
|
+
]);
|
|
212
|
+
} else {
|
|
213
|
+
allFolders = await this.getAllFolders(projectId, fileAreaId, {}, verbose);
|
|
214
|
+
allFiles = [];
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (verbose) {
|
|
218
|
+
console.log(`Building tree: ${allFolders.length} folder(s), ${allFiles.length} file(s)`);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function fid(item) {
|
|
222
|
+
const d = item.data || item;
|
|
223
|
+
return d.folderId || d.id || null;
|
|
224
|
+
}
|
|
225
|
+
function pid(item) {
|
|
226
|
+
const d = item.data || item;
|
|
227
|
+
return d.parentFolderId || d.parentId || null;
|
|
228
|
+
}
|
|
229
|
+
function name(item) {
|
|
230
|
+
const d = item.data || item;
|
|
231
|
+
return d.folderName || d.name || fid(item) || '?';
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// Build node map
|
|
235
|
+
const nodes = {};
|
|
236
|
+
for (const folder of allFolders) {
|
|
237
|
+
const id = fid(folder);
|
|
238
|
+
if (!id) continue;
|
|
239
|
+
nodes[id] = { id, name: name(folder), path: '', raw: folder, children: [], files: [] };
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// Wire parent→child
|
|
243
|
+
const root = { id: null, name: fileAreaId, path: '', raw: null, children: [], files: [] };
|
|
244
|
+
const validIds = new Set(Object.keys(nodes));
|
|
245
|
+
for (const folder of allFolders) {
|
|
246
|
+
const id = fid(folder);
|
|
247
|
+
if (!id) continue;
|
|
248
|
+
const parentId = pid(folder);
|
|
249
|
+
const parent = (parentId && validIds.has(parentId)) ? nodes[parentId] : root;
|
|
250
|
+
parent.children.push(nodes[id]);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// Compute paths
|
|
254
|
+
function setPaths(node, parentPath) {
|
|
255
|
+
node.path = parentPath ? `${parentPath}/${node.name}` : node.name;
|
|
256
|
+
for (const child of node.children) setPaths(child, node.path);
|
|
257
|
+
}
|
|
258
|
+
for (const child of root.children) setPaths(child, '');
|
|
259
|
+
|
|
260
|
+
// Attach files to their folder nodes
|
|
261
|
+
for (const f of allFiles) {
|
|
262
|
+
const folderIdVal = (f.data || {}).folderId || f.folderId || null;
|
|
263
|
+
const target = (folderIdVal && nodes[folderIdVal]) ? nodes[folderIdVal] : root;
|
|
264
|
+
target.files.push(f);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
return root;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Simple fnmatch-style wildcard matching (only * is supported).
|
|
273
|
+
* @param {string} str
|
|
274
|
+
* @param {string} pattern
|
|
275
|
+
* @returns {boolean}
|
|
276
|
+
*/
|
|
277
|
+
function _fnmatch(str, pattern) {
|
|
278
|
+
if (!pattern.includes('*')) return str === pattern;
|
|
279
|
+
const re = new RegExp('^' + pattern.replace(/[.+^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '.*') + '$');
|
|
280
|
+
return re.test(str);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
module.exports = FoldersApi;
|
package/src/api/FormsApi.js
CHANGED
|
@@ -1,48 +1,53 @@
|
|
|
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
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { convertToModel } = require('../models/convert');
|
|
4
|
+
const { FormsListResponseSchema, FormResponseSchema } = require('../models/forms');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* API methods for forms on a project.
|
|
8
|
+
*/
|
|
9
|
+
class FormsApi {
|
|
10
|
+
/**
|
|
11
|
+
* @param {import('../apiClient')} apiClient
|
|
12
|
+
*/
|
|
13
|
+
constructor(apiClient) {
|
|
14
|
+
this._client = apiClient;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Retrieve forms on a project.
|
|
19
|
+
* GET /2.1/projects/{projectId}/forms
|
|
20
|
+
* @param {string} projectId
|
|
21
|
+
* @param {object} [params] - Optional filters (e.g. updatedAfter)
|
|
22
|
+
* @returns {Promise<object>} FormsListResponse ({ items, metadata?, links? })
|
|
23
|
+
*/
|
|
24
|
+
async getProjectForms(projectId, params = {}) {
|
|
25
|
+
const response = await this._client.get(`/2.1/projects/${projectId}/forms`, params);
|
|
26
|
+
return convertToModel(response, FormsListResponseSchema, 'FormsListResponse');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Retrieve a specific form.
|
|
31
|
+
* GET /1.2/projects/{projectId}/forms/{formId}
|
|
32
|
+
* @param {string} projectId
|
|
33
|
+
* @param {string} formId
|
|
34
|
+
* @returns {Promise<object>} FormResponse ({ data, links? })
|
|
35
|
+
*/
|
|
36
|
+
async getForm(projectId, formId) {
|
|
37
|
+
const response = await this._client.get(`/1.2/projects/${projectId}/forms/${formId}`);
|
|
38
|
+
return convertToModel(response, FormResponseSchema, 'FormResponse');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Retrieve attachments on forms on a project in incremental updates.
|
|
43
|
+
* GET /2.1/projects/{projectId}/forms/attachments
|
|
44
|
+
* @param {string} projectId
|
|
45
|
+
* @param {object} [params] - Optional filters (e.g. updatedAfter)
|
|
46
|
+
* @returns {Promise<object>}
|
|
47
|
+
*/
|
|
48
|
+
getProjectFormAttachments(projectId, params = {}) {
|
|
49
|
+
return this._client.get(`/2.1/projects/${projectId}/forms/attachments`, params);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
module.exports = FormsApi;
|
|
@@ -1,62 +1,66 @@
|
|
|
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
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { convertToModel } = require('../models/convert');
|
|
4
|
+
const { InspectionPlansListResponseSchema } = require('../models/inspectionPlans');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* API methods for inspection plans.
|
|
8
|
+
*/
|
|
9
|
+
class InspectionPlansApi {
|
|
10
|
+
/**
|
|
11
|
+
* @param {import('../apiClient')} apiClient
|
|
12
|
+
*/
|
|
13
|
+
constructor(apiClient) {
|
|
14
|
+
this._client = apiClient;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Browse all inspection plans on the given project.
|
|
19
|
+
* GET /1.2/projects/{projectId}/inspectionPlans
|
|
20
|
+
* @param {string} projectId
|
|
21
|
+
* @param {object} [params]
|
|
22
|
+
* @returns {Promise<object>} InspectionPlansListResponse ({ items, metadata?, links? })
|
|
23
|
+
*/
|
|
24
|
+
async listInspectionPlans(projectId, params = {}) {
|
|
25
|
+
const response = await this._client.get(`/1.2/projects/${projectId}/inspectionPlans`, params);
|
|
26
|
+
return convertToModel(response, InspectionPlansListResponseSchema, 'InspectionPlansListResponse');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Browse all inspection plan items on the given project.
|
|
31
|
+
* GET /1.1/projects/{projectId}/inspectionPlanItems
|
|
32
|
+
* @param {string} projectId
|
|
33
|
+
* @param {object} [params]
|
|
34
|
+
* @returns {Promise<object>}
|
|
35
|
+
*/
|
|
36
|
+
listInspectionPlanItems(projectId, params = {}) {
|
|
37
|
+
return this._client.get(`/1.1/projects/${projectId}/inspectionPlanItems`, params);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Browse all inspection plan item zones on the given project.
|
|
42
|
+
* GET /1.1/projects/{projectId}/inspectionPlanItemZones
|
|
43
|
+
* @param {string} projectId
|
|
44
|
+
* @param {object} [params]
|
|
45
|
+
* @returns {Promise<object>}
|
|
46
|
+
*/
|
|
47
|
+
listInspectionPlanItemZones(projectId, params = {}) {
|
|
48
|
+
return this._client.get(`/1.1/projects/${projectId}/inspectionPlanItemZones`, params);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Browse all inspection plan registrations on the given project.
|
|
53
|
+
* GET /2.1/projects/{projectId}/inspectionPlanRegistrations
|
|
54
|
+
* @param {string} projectId
|
|
55
|
+
* @param {object} [params]
|
|
56
|
+
* @returns {Promise<object>}
|
|
57
|
+
*/
|
|
58
|
+
listInspectionPlanRegistrations(projectId, params = {}) {
|
|
59
|
+
return this._client.get(
|
|
60
|
+
`/2.1/projects/${projectId}/inspectionPlanRegistrations`,
|
|
61
|
+
params,
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
module.exports = InspectionPlansApi;
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* API methods for project templates.
|
|
5
|
-
*/
|
|
6
|
-
class ProjectTemplatesApi {
|
|
7
|
-
/**
|
|
8
|
-
* @param {import('../apiClient')} apiClient
|
|
9
|
-
*/
|
|
10
|
-
constructor(apiClient) {
|
|
11
|
-
this._client = apiClient;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Get all available project templates on the company profile.
|
|
16
|
-
* GET /1.1/projectTemplates
|
|
17
|
-
* @param {object} [params]
|
|
18
|
-
* @returns {Promise<object>}
|
|
19
|
-
*/
|
|
20
|
-
listProjectTemplates(params = {}) {
|
|
21
|
-
return this._client.get('/1.1/projectTemplates', params);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
module.exports = ProjectTemplatesApi;
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* API methods for project templates.
|
|
5
|
+
*/
|
|
6
|
+
class ProjectTemplatesApi {
|
|
7
|
+
/**
|
|
8
|
+
* @param {import('../apiClient')} apiClient
|
|
9
|
+
*/
|
|
10
|
+
constructor(apiClient) {
|
|
11
|
+
this._client = apiClient;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Get all available project templates on the company profile.
|
|
16
|
+
* GET /1.1/projectTemplates
|
|
17
|
+
* @param {object} [params]
|
|
18
|
+
* @returns {Promise<object>}
|
|
19
|
+
*/
|
|
20
|
+
listProjectTemplates(params = {}) {
|
|
21
|
+
return this._client.get('/1.1/projectTemplates', params);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
module.exports = ProjectTemplatesApi;
|