dalux-build-api 2.3.0 → 2.4.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.
Files changed (48) hide show
  1. package/package.json +31 -11
  2. package/src/api/CompaniesApi.js +0 -67
  3. package/src/api/CompanyCatalogApi.js +0 -129
  4. package/src/api/FileAreasApi.js +0 -57
  5. package/src/api/FileRevisionsApi.js +0 -33
  6. package/src/api/FileUploadApi.js +0 -64
  7. package/src/api/FilesApi.js +0 -721
  8. package/src/api/FoldersApi.js +0 -283
  9. package/src/api/FormsApi.js +0 -53
  10. package/src/api/InspectionPlansApi.js +0 -140
  11. package/src/api/ProjectTemplatesApi.js +0 -25
  12. package/src/api/ProjectsApi.js +0 -127
  13. package/src/api/TasksApi.js +0 -193
  14. package/src/api/TestPlansApi.js +0 -137
  15. package/src/api/UsersApi.js +0 -52
  16. package/src/api/VersionSetsApi.js +0 -75
  17. package/src/api/WorkPackagesApi.js +0 -30
  18. package/src/apiClient.js +0 -143
  19. package/src/browser.js +0 -84
  20. package/src/configuration.js +0 -39
  21. package/src/index.js +0 -133
  22. package/src/models/common.js +0 -22
  23. package/src/models/companies/index.js +0 -14
  24. package/src/models/companyCatalog/index.js +0 -19
  25. package/src/models/convert.js +0 -44
  26. package/src/models/fileAreas/index.js +0 -20
  27. package/src/models/fileRevisions/index.js +0 -12
  28. package/src/models/fileUpload/index.js +0 -12
  29. package/src/models/files/index.js +0 -97
  30. package/src/models/folders/index.js +0 -20
  31. package/src/models/forms/index.js +0 -19
  32. package/src/models/helpers.js +0 -62
  33. package/src/models/index.js +0 -178
  34. package/src/models/inspectionPlans/index.js +0 -61
  35. package/src/models/projectTemplates/index.js +0 -11
  36. package/src/models/projects/index.js +0 -57
  37. package/src/models/tasks/index.js +0 -105
  38. package/src/models/testPlans/index.js +0 -61
  39. package/src/models/users/index.js +0 -29
  40. package/src/models/versionSets/index.js +0 -22
  41. package/src/models/workPackages/index.js +0 -19
  42. package/src/next.js +0 -89
  43. package/src/utils/errors.js +0 -45
  44. package/src/utils/index.js +0 -26
  45. package/src/utils/pagination.js +0 -82
  46. package/src/utils/pathResolver.js +0 -124
  47. package/src/utils/search.js +0 -61
  48. package/src/utils/validation.js +0 -36
@@ -1,283 +0,0 @@
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;
@@ -1,53 +0,0 @@
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,140 +0,0 @@
1
- 'use strict';
2
-
3
- const { convertToModel, convertToModelList } = require('../models/convert');
4
- const { paginate } = require('../utils/pagination');
5
- const {
6
- InspectionPlanSchema,
7
- InspectionPlanItemSchema,
8
- InspectionPlanItemZoneSchema,
9
- InspectionPlanRegistrationSchema,
10
- InspectionPlansListResponseSchema,
11
- InspectionPlanItemsListResponseSchema,
12
- InspectionPlanItemZonesListResponseSchema,
13
- InspectionPlanRegistrationsListResponseSchema,
14
- } = require('../models/inspectionPlans');
15
-
16
- /**
17
- * API methods for inspection plans.
18
- */
19
- class InspectionPlansApi {
20
- /**
21
- * @param {import('../apiClient')} apiClient
22
- */
23
- constructor(apiClient) {
24
- this._client = apiClient;
25
- }
26
-
27
- /**
28
- * Browse all inspection plans on the given project.
29
- * GET /1.2/projects/{projectId}/inspectionPlans
30
- * @param {string} projectId
31
- * @param {object} [params]
32
- * @param {boolean} [fullResponse=false]
33
- * @returns {Promise<object[]|object>}
34
- */
35
- async listInspectionPlans(projectId, params = {}, fullResponse = false) {
36
- const response = await this._client.get(`/1.2/projects/${projectId}/inspectionPlans`, params);
37
- const result = convertToModel(
38
- response,
39
- InspectionPlansListResponseSchema,
40
- 'InspectionPlansListResponse',
41
- );
42
- return fullResponse ? result : (result?.items || []);
43
- }
44
-
45
- async getAllInspectionPlans(projectId, params = {}, verbose = false) {
46
- const items = await paginate(
47
- `/1.2/projects/${projectId}/inspectionPlans`,
48
- this._client,
49
- params,
50
- verbose,
51
- );
52
- return convertToModelList(items, InspectionPlanSchema, 'InspectionPlan');
53
- }
54
-
55
- /**
56
- * Browse all inspection plan items on the given project.
57
- * GET /1.1/projects/{projectId}/inspectionPlanItems
58
- * @param {string} projectId
59
- * @param {object} [params]
60
- * @returns {Promise<object>}
61
- */
62
- async listInspectionPlanItems(projectId, params = {}, fullResponse = false) {
63
- const response = await this._client.get(`/1.1/projects/${projectId}/inspectionPlanItems`, params);
64
- const result = convertToModel(
65
- response,
66
- InspectionPlanItemsListResponseSchema,
67
- 'InspectionPlanItemsListResponse',
68
- );
69
- return fullResponse ? result : (result?.items || []);
70
- }
71
-
72
- async getAllInspectionPlanItems(projectId, params = {}, verbose = false) {
73
- const items = await paginate(
74
- `/1.1/projects/${projectId}/inspectionPlanItems`,
75
- this._client,
76
- params,
77
- verbose,
78
- );
79
- return convertToModelList(items, InspectionPlanItemSchema, 'InspectionPlanItem');
80
- }
81
-
82
- /**
83
- * Browse all inspection plan item zones on the given project.
84
- * GET /1.1/projects/{projectId}/inspectionPlanItemZones
85
- * @param {string} projectId
86
- * @param {object} [params]
87
- * @returns {Promise<object>}
88
- */
89
- async listInspectionPlanItemZones(projectId, params = {}, fullResponse = false) {
90
- const response = await this._client.get(`/1.1/projects/${projectId}/inspectionPlanItemZones`, params);
91
- const result = convertToModel(
92
- response,
93
- InspectionPlanItemZonesListResponseSchema,
94
- 'InspectionPlanItemZonesListResponse',
95
- );
96
- return fullResponse ? result : (result?.items || []);
97
- }
98
-
99
- async getAllInspectionPlanItemZones(projectId, params = {}, verbose = false) {
100
- const items = await paginate(
101
- `/1.1/projects/${projectId}/inspectionPlanItemZones`,
102
- this._client,
103
- params,
104
- verbose,
105
- );
106
- return convertToModelList(items, InspectionPlanItemZoneSchema, 'InspectionPlanItemZone');
107
- }
108
-
109
- /**
110
- * Browse all inspection plan registrations on the given project.
111
- * GET /2.1/projects/{projectId}/inspectionPlanRegistrations
112
- * @param {string} projectId
113
- * @param {object} [params]
114
- * @returns {Promise<object>}
115
- */
116
- async listInspectionPlanRegistrations(projectId, params = {}, fullResponse = false) {
117
- const response = await this._client.get(
118
- `/2.1/projects/${projectId}/inspectionPlanRegistrations`,
119
- params,
120
- );
121
- const result = convertToModel(
122
- response,
123
- InspectionPlanRegistrationsListResponseSchema,
124
- 'InspectionPlanRegistrationsListResponse',
125
- );
126
- return fullResponse ? result : (result?.items || []);
127
- }
128
-
129
- async getAllInspectionPlanRegistrations(projectId, params = {}, verbose = false) {
130
- const items = await paginate(
131
- `/2.1/projects/${projectId}/inspectionPlanRegistrations`,
132
- this._client,
133
- params,
134
- verbose,
135
- );
136
- return convertToModelList(items, InspectionPlanRegistrationSchema, 'InspectionPlanRegistration');
137
- }
138
- }
139
-
140
- module.exports = InspectionPlansApi;
@@ -1,25 +0,0 @@
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,127 +0,0 @@
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;