dalux-build-api 1.0.0 → 1.0.4
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 +300 -300
- package/package.json +46 -46
- package/src/api/CompaniesApi.js +60 -60
- package/src/api/CompanyCatalogApi.js +108 -108
- package/src/api/FileAreasApi.js +37 -37
- package/src/api/FileRevisionsApi.js +31 -31
- package/src/api/FileUploadApi.js +64 -64
- package/src/api/FilesApi.js +72 -72
- package/src/api/FoldersApi.js +58 -58
- package/src/api/FormsApi.js +48 -48
- package/src/api/InspectionPlansApi.js +62 -62
- package/src/api/ProjectTemplatesApi.js +25 -25
- package/src/api/ProjectsApi.js +106 -106
- package/src/api/TasksApi.js +87 -59
- package/src/api/TestPlansApi.js +59 -59
- package/src/api/UsersApi.js +47 -47
- package/src/api/VersionSetsApi.js +67 -67
- package/src/api/WorkPackagesApi.js +26 -26
- package/src/apiClient.js +75 -75
- package/src/configuration.js +24 -24
- package/src/index.js +92 -92
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Bruno Adam
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Bruno Adam
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,300 +1,300 @@
|
|
|
1
|
-
# Dalux Build API
|
|
2
|
-
|
|
3
|
-
API clients for the [Dalux Build REST API](https://app.swaggerhub.com/apis-docs/Dalux/DaluxBuild-api/4.14), available in two languages:
|
|
4
|
-
|
|
5
|
-
| Language | Location | Documentation |
|
|
6
|
-
|---|---|---|
|
|
7
|
-
| Node.js | [`/`](.) | See below |
|
|
8
|
-
| Python | [`/python`](python/) | [python/README.md](python/README.md) |
|
|
9
|
-
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
# Node.js Client
|
|
13
|
-
|
|
14
|
-
A lightweight Node.js client for the Dalux Build REST API.
|
|
15
|
-
|
|
16
|
-
## Requirements
|
|
17
|
-
|
|
18
|
-
- Node.js 14 or later
|
|
19
|
-
|
|
20
|
-
## Installation
|
|
21
|
-
|
|
22
|
-
```bash
|
|
23
|
-
npm install dalux-build-api
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## Getting Started
|
|
27
|
-
|
|
28
|
-
To access the API you need:
|
|
29
|
-
|
|
30
|
-
1. A company-specific **base URL** (obtain from Dalux support at <support@dalux.com>).
|
|
31
|
-
2. An **API key** — managed via _Settings › Integrations › API Identities_ inside the Dalux Build UI.
|
|
32
|
-
|
|
33
|
-
```js
|
|
34
|
-
const { createClient } = require('dalux-build-api');
|
|
35
|
-
|
|
36
|
-
const dalux = createClient({
|
|
37
|
-
baseUrl: 'https://<your-company>.dalux.com/api',
|
|
38
|
-
apiKey: 'YOUR_API_KEY',
|
|
39
|
-
});
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
The returned object exposes one namespace per API group (see [API Reference](#api-reference) below).
|
|
43
|
-
|
|
44
|
-
### Examples
|
|
45
|
-
|
|
46
|
-
**List all projects**
|
|
47
|
-
```js
|
|
48
|
-
const projects = await dalux.projects.listProjects();
|
|
49
|
-
console.log(projects);
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
**Get a specific project**
|
|
53
|
-
```js
|
|
54
|
-
const project = await dalux.projects.getProject('my-project-id');
|
|
55
|
-
console.log(project);
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
**List tasks on a project**
|
|
59
|
-
```js
|
|
60
|
-
const tasks = await dalux.tasks.getProjectTasks('my-project-id', {
|
|
61
|
-
updatedAfter: '2024-01-01',
|
|
62
|
-
});
|
|
63
|
-
console.log(tasks);
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
**Upload a file (chunked)**
|
|
67
|
-
```js
|
|
68
|
-
const fs = require('fs');
|
|
69
|
-
|
|
70
|
-
// 1. Create an upload slot
|
|
71
|
-
const { uploadGuid } = await dalux.fileUpload.createUpload(
|
|
72
|
-
'my-project-id',
|
|
73
|
-
'my-file-area-id',
|
|
74
|
-
{ fileName: 'drawing.pdf', mimeType: 'application/pdf' },
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
// 2. Upload the file in one chunk
|
|
78
|
-
const content = fs.readFileSync('./drawing.pdf');
|
|
79
|
-
await dalux.fileUpload.uploadFilePart('my-project-id', 'my-file-area-id', uploadGuid, content);
|
|
80
|
-
|
|
81
|
-
// 3. Finalize the upload
|
|
82
|
-
const result = await dalux.fileUpload.finishUpload(
|
|
83
|
-
'my-project-id',
|
|
84
|
-
'my-file-area-id',
|
|
85
|
-
uploadGuid,
|
|
86
|
-
{ folderId: 'target-folder-id' },
|
|
87
|
-
);
|
|
88
|
-
console.log('New file ID:', result.fileId);
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
## Authentication
|
|
92
|
-
|
|
93
|
-
Every request automatically includes the `X-API-KEY` header with the API key supplied to `createClient`. No additional configuration is required.
|
|
94
|
-
|
|
95
|
-
## Error Handling
|
|
96
|
-
|
|
97
|
-
All methods return Promises. Network or HTTP errors (4xx / 5xx) are thrown as Axios errors, so wrap calls with `try/catch` or `.catch()`:
|
|
98
|
-
|
|
99
|
-
```js
|
|
100
|
-
try {
|
|
101
|
-
const project = await dalux.projects.getProject('unknown-id');
|
|
102
|
-
} catch (err) {
|
|
103
|
-
console.error(err.response?.status, err.response?.data);
|
|
104
|
-
}
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
## API Reference
|
|
108
|
-
|
|
109
|
-
All API namespaces are accessible on the object returned by `createClient`:
|
|
110
|
-
|
|
111
|
-
| Namespace | Class | Description |
|
|
112
|
-
|---|---|---|
|
|
113
|
-
| `projects` | `ProjectsApi` | List, get, create and update projects; manage project metadata |
|
|
114
|
-
| `companies` | `CompaniesApi` | Project companies (CRUD) |
|
|
115
|
-
| `companyCatalog` | `CompanyCatalogApi` | Company catalog (CRUD + metadata) |
|
|
116
|
-
| `tasks` | `TasksApi` | Tasks, approvals, safety issues, observations & good practices |
|
|
117
|
-
| `fileAreas` | `FileAreasApi` | File areas on a project |
|
|
118
|
-
| `files` | `FilesApi` | Files within a file area |
|
|
119
|
-
| `folders` | `FoldersApi` | Folders within a file area |
|
|
120
|
-
| `fileUpload` | `FileUploadApi` | Chunked file upload (create slot → upload parts → finalize) |
|
|
121
|
-
| `fileRevisions` | `FileRevisionsApi` | Download file revision content |
|
|
122
|
-
| `forms` | `FormsApi` | Forms and form attachments |
|
|
123
|
-
| `users` | `UsersApi` | Company and project users |
|
|
124
|
-
| `projectTemplates` | `ProjectTemplatesApi` | Available project templates |
|
|
125
|
-
| `inspectionPlans` | `InspectionPlansApi` | Inspection plans, items, zones and registrations |
|
|
126
|
-
| `testPlans` | `TestPlansApi` | Test plans, items, zones and registrations |
|
|
127
|
-
| `versionSets` | `VersionSetsApi` | Version sets and version set files |
|
|
128
|
-
| `workPackages` | `WorkPackagesApi` | Work packages on a project |
|
|
129
|
-
|
|
130
|
-
### ProjectsApi
|
|
131
|
-
|
|
132
|
-
| Method | HTTP | Path |
|
|
133
|
-
|---|---|---|
|
|
134
|
-
| `listProjects(params?)` | GET | `/5.1/projects` |
|
|
135
|
-
| `getProject(projectId)` | GET | `/5.0/projects/{projectId}` |
|
|
136
|
-
| `createProject(body)` | POST | `/5.0/projects` |
|
|
137
|
-
| `updateProject(projectId, body)` | PATCH | `/5.0/projects/{projectId}` |
|
|
138
|
-
| `listMetadataMappingsForProjects()` | GET | `/1.0/projects/metadata/1.0/mappings` |
|
|
139
|
-
| `listMetadataValuesForProjects(key)` | GET | `/1.0/projects/metadata/1.0/mappings/{key}/values` |
|
|
140
|
-
| `listProjectMetadata(projectId)` | GET | `/1.0/projects/{projectId}/metadata` |
|
|
141
|
-
| `listProjectMetadataMappings(projectId)` | GET | `/1.0/projects/{projectId}/metadata/1.0/mappings` |
|
|
142
|
-
| `listProjectMetadataValues(projectId, key)` | GET | `/1.0/projects/{projectId}/metadata/1.0/mappings/{key}/values` |
|
|
143
|
-
|
|
144
|
-
### CompaniesApi
|
|
145
|
-
|
|
146
|
-
| Method | HTTP | Path |
|
|
147
|
-
|---|---|---|
|
|
148
|
-
| `listProjectCompanies(projectId, params?)` | GET | `/3.1/projects/{projectId}/companies` |
|
|
149
|
-
| `getProjectCompany(projectId, companyId)` | GET | `/3.0/projects/{projectId}/companies/{companyId}` |
|
|
150
|
-
| `createProjectCompany(projectId, body)` | POST | `/3.1/projects/{projectId}/companies` |
|
|
151
|
-
| `updateProjectCompany(projectId, companyId, body)` | PATCH | `/3.0/projects/{projectId}/companies/{companyId}` |
|
|
152
|
-
|
|
153
|
-
### CompanyCatalogApi
|
|
154
|
-
|
|
155
|
-
| Method | HTTP | Path |
|
|
156
|
-
|---|---|---|
|
|
157
|
-
| `getCompanies(params?)` | GET | `/2.2/companyCatalog` |
|
|
158
|
-
| `getCompany(catalogCompanyId)` | GET | `/1.2/companyCatalog/{catalogCompanyId}` |
|
|
159
|
-
| `createCompany(body)` | POST | `/2.2/companyCatalog` |
|
|
160
|
-
| `updateCompany(catalogCompanyId, body)` | PATCH | `/2.1/companyCatalog/{catalogCompanyId}` |
|
|
161
|
-
| `listCompanyMetadata(catalogCompanyId)` | GET | `/1.0/companyCatalog/{catalogCompanyId}/metadata` |
|
|
162
|
-
| `listCompanyMetadataMappings(catalogCompanyId)` | GET | `/1.0/companyCatalog/{catalogCompanyId}/metadata/1.0/mappings` |
|
|
163
|
-
| `listCompanyMetadataValues(catalogCompanyId, key)` | GET | `/1.0/companyCatalog/{catalogCompanyId}/metadata/1.0/mappings/{key}/values` |
|
|
164
|
-
| `listMetadataMappingsForCompanies()` | GET | `/1.0/companyCatalog/metadata/1.0/mappings` |
|
|
165
|
-
| `listMetadataValuesForCompanies(key)` | GET | `/1.0/companyCatalog/metadata/1.0/mappings/{key}/values` |
|
|
166
|
-
|
|
167
|
-
### TasksApi
|
|
168
|
-
|
|
169
|
-
| Method | HTTP | Path |
|
|
170
|
-
|---|---|---|
|
|
171
|
-
| `getProjectTasks(projectId, params?)` | GET | `/5.1/projects/{projectId}/tasks` |
|
|
172
|
-
| `getTask(projectId, taskId)` | GET | `/3.3/projects/{projectId}/tasks/{taskId}` |
|
|
173
|
-
| `getProjectTaskChanges(projectId, params?)` | GET | `/2.2/projects/{projectId}/tasks/changes` |
|
|
174
|
-
| `getProjectTaskAttachments(projectId, params?)` | GET | `/1.1/projects/{projectId}/tasks/attachments` |
|
|
175
|
-
|
|
176
|
-
### FileAreasApi
|
|
177
|
-
|
|
178
|
-
| Method | HTTP | Path |
|
|
179
|
-
|---|---|---|
|
|
180
|
-
| `getFileAreas(projectId, params?)` | GET | `/5.1/projects/{projectId}/file_areas` |
|
|
181
|
-
| `getFileArea(projectId, fileAreaId)` | GET | `/1.0/projects/{projectId}/file_areas/{fileAreaId}` |
|
|
182
|
-
|
|
183
|
-
### FilesApi
|
|
184
|
-
|
|
185
|
-
| Method | HTTP | Path |
|
|
186
|
-
|---|---|---|
|
|
187
|
-
| `listFiles(projectId, fileAreaId, params?)` | GET | `/6.0/projects/{projectId}/file_areas/{fileAreaId}/files` |
|
|
188
|
-
| `getFile(projectId, fileAreaId, fileId)` | GET | `/5.0/projects/{projectId}/file_areas/{fileAreaId}/files/{fileId}` |
|
|
189
|
-
| `getFilePropertiesMapping(projectId, fileAreaId, fileId)` | GET | `/1.0/.../files/{fileId}/properties/1.0/mappings` |
|
|
190
|
-
| `getFilePropertyMappingValues(projectId, fileAreaId, filePropertyId)` | GET | `/1.0/.../files/properties/1.0/mappings/{filePropertyId}/values` |
|
|
191
|
-
|
|
192
|
-
### FoldersApi
|
|
193
|
-
|
|
194
|
-
| Method | HTTP | Path |
|
|
195
|
-
|---|---|---|
|
|
196
|
-
| `listFolders(projectId, fileAreaId, params?)` | GET | `/5.1/projects/{projectId}/file_areas/{fileAreaId}/folders` |
|
|
197
|
-
| `getFolder(projectId, fileAreaId, folderId)` | GET | `/5.0/projects/{projectId}/file_areas/{fileAreaId}/folders/{folderId}` |
|
|
198
|
-
| `getFolderFilesProperties(projectId, fileAreaId, folderId)` | GET | `/1.0/.../folders/{folderId}/files/properties/1.0/mappings` |
|
|
199
|
-
|
|
200
|
-
### FileUploadApi
|
|
201
|
-
|
|
202
|
-
| Method | HTTP | Path |
|
|
203
|
-
|---|---|---|
|
|
204
|
-
| `createUpload(projectId, fileAreaId, body)` | POST | `/1.0/projects/{projectId}/file_areas/{fileAreaId}/upload` |
|
|
205
|
-
| `uploadFilePart(projectId, fileAreaId, uploadGuid, chunk)` | POST | `/1.0/.../upload/{uploadGuid}` |
|
|
206
|
-
| `finishUpload(projectId, fileAreaId, uploadGuid, body)` | POST | `/2.0/.../upload/{uploadGuid}/finalize` |
|
|
207
|
-
|
|
208
|
-
### FileRevisionsApi
|
|
209
|
-
|
|
210
|
-
| Method | HTTP | Path |
|
|
211
|
-
|---|---|---|
|
|
212
|
-
| `getFileRevisionContent(projectId, fileAreaId, fileId, fileRevisionId)` | GET | `/2.0/.../files/{fileId}/revisions/{fileRevisionId}/content` |
|
|
213
|
-
|
|
214
|
-
### FormsApi
|
|
215
|
-
|
|
216
|
-
| Method | HTTP | Path |
|
|
217
|
-
|---|---|---|
|
|
218
|
-
| `getProjectForms(projectId, params?)` | GET | `/2.1/projects/{projectId}/forms` |
|
|
219
|
-
| `getForm(projectId, formId)` | GET | `/1.2/projects/{projectId}/forms/{formId}` |
|
|
220
|
-
| `getProjectFormAttachments(projectId, params?)` | GET | `/2.1/projects/{projectId}/forms/attachments` |
|
|
221
|
-
|
|
222
|
-
### UsersApi
|
|
223
|
-
|
|
224
|
-
| Method | HTTP | Path |
|
|
225
|
-
|---|---|---|
|
|
226
|
-
| `getUser(userId)` | GET | `/1.1/users/{userId}` |
|
|
227
|
-
| `listProjectUsers(projectId, params?)` | GET | `/1.2/projects/{projectId}/users` |
|
|
228
|
-
| `getProjectUser(projectId, userId)` | GET | `/1.1/projects/{projectId}/users/{userId}` |
|
|
229
|
-
|
|
230
|
-
### ProjectTemplatesApi
|
|
231
|
-
|
|
232
|
-
| Method | HTTP | Path |
|
|
233
|
-
|---|---|---|
|
|
234
|
-
| `listProjectTemplates(params?)` | GET | `/1.1/projectTemplates` |
|
|
235
|
-
|
|
236
|
-
### InspectionPlansApi
|
|
237
|
-
|
|
238
|
-
| Method | HTTP | Path |
|
|
239
|
-
|---|---|---|
|
|
240
|
-
| `listInspectionPlans(projectId, params?)` | GET | `/1.2/projects/{projectId}/inspectionPlans` |
|
|
241
|
-
| `listInspectionPlanItems(projectId, params?)` | GET | `/1.1/projects/{projectId}/inspectionPlanItems` |
|
|
242
|
-
| `listInspectionPlanItemZones(projectId, params?)` | GET | `/1.1/projects/{projectId}/inspectionPlanItemZones` |
|
|
243
|
-
| `listInspectionPlanRegistrations(projectId, params?)` | GET | `/2.1/projects/{projectId}/inspectionPlanRegistrations` |
|
|
244
|
-
|
|
245
|
-
### TestPlansApi
|
|
246
|
-
|
|
247
|
-
| Method | HTTP | Path |
|
|
248
|
-
|---|---|---|
|
|
249
|
-
| `listTestPlans(projectId, params?)` | GET | `/1.2/projects/{projectId}/testPlans` |
|
|
250
|
-
| `listTestPlanItems(projectId, params?)` | GET | `/1.1/projects/{projectId}/testPlanItems` |
|
|
251
|
-
| `listTestPlanItemZones(projectId, params?)` | GET | `/1.1/projects/{projectId}/testPlanItemZones` |
|
|
252
|
-
| `listTestPlanRegistrations(projectId, params?)` | GET | `/1.1/projects/{projectId}/testPlanRegistrations` |
|
|
253
|
-
|
|
254
|
-
### VersionSetsApi
|
|
255
|
-
|
|
256
|
-
| Method | HTTP | Path |
|
|
257
|
-
|---|---|---|
|
|
258
|
-
| `getVersionSets(projectId, params?)` | GET | `/2.1/projects/{projectId}/version_sets` |
|
|
259
|
-
| `getVersionSet(projectId, versionSetId)` | GET | `/2.0/projects/{projectId}/version_sets/{versionSetId}` |
|
|
260
|
-
| `listFileAreaVersionSets(projectId, fileAreaId, params?)` | GET | `/2.1/projects/{projectId}/file_areas/{fileAreaId}/version_sets` |
|
|
261
|
-
| `listVersionSetFiles(projectId, versionSetId, params?)` | GET | `/3.0/projects/{projectId}/version_sets/{versionSetId}/files` |
|
|
262
|
-
|
|
263
|
-
### WorkPackagesApi
|
|
264
|
-
|
|
265
|
-
| Method | HTTP | Path |
|
|
266
|
-
|---|---|---|
|
|
267
|
-
| `listWorkPackages(projectId, params?)` | GET | `/1.0/projects/{projectId}/workpackages` |
|
|
268
|
-
|
|
269
|
-
## Advanced Usage
|
|
270
|
-
|
|
271
|
-
### Using individual API classes
|
|
272
|
-
|
|
273
|
-
You can also instantiate API classes directly with a shared `ApiClient`:
|
|
274
|
-
|
|
275
|
-
```js
|
|
276
|
-
const { Configuration, ApiClient, ProjectsApi, TasksApi } = require('dalux-build-api');
|
|
277
|
-
|
|
278
|
-
const config = new Configuration({
|
|
279
|
-
baseUrl: 'https://<your-company>.dalux.com/api',
|
|
280
|
-
apiKey: 'YOUR_API_KEY',
|
|
281
|
-
});
|
|
282
|
-
const apiClient = new ApiClient(config);
|
|
283
|
-
|
|
284
|
-
const projects = new ProjectsApi(apiClient);
|
|
285
|
-
const tasks = new TasksApi(apiClient);
|
|
286
|
-
```
|
|
287
|
-
|
|
288
|
-
## Development
|
|
289
|
-
|
|
290
|
-
```bash
|
|
291
|
-
# Install dependencies
|
|
292
|
-
npm install
|
|
293
|
-
|
|
294
|
-
# Run tests with coverage
|
|
295
|
-
npm test
|
|
296
|
-
```
|
|
297
|
-
|
|
298
|
-
## License
|
|
299
|
-
|
|
300
|
-
MIT
|
|
1
|
+
# Dalux Build API
|
|
2
|
+
|
|
3
|
+
API clients for the [Dalux Build REST API](https://app.swaggerhub.com/apis-docs/Dalux/DaluxBuild-api/4.14), available in two languages:
|
|
4
|
+
|
|
5
|
+
| Language | Location | Documentation |
|
|
6
|
+
|---|---|---|
|
|
7
|
+
| Node.js | [`/`](.) | See below |
|
|
8
|
+
| Python | [`/python`](python/) | [python/README.md](python/README.md) |
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Node.js Client
|
|
13
|
+
|
|
14
|
+
A lightweight Node.js client for the Dalux Build REST API.
|
|
15
|
+
|
|
16
|
+
## Requirements
|
|
17
|
+
|
|
18
|
+
- Node.js 14 or later
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install dalux-build-api
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Getting Started
|
|
27
|
+
|
|
28
|
+
To access the API you need:
|
|
29
|
+
|
|
30
|
+
1. A company-specific **base URL** (obtain from Dalux support at <support@dalux.com>).
|
|
31
|
+
2. An **API key** — managed via _Settings › Integrations › API Identities_ inside the Dalux Build UI.
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
const { createClient } = require('dalux-build-api');
|
|
35
|
+
|
|
36
|
+
const dalux = createClient({
|
|
37
|
+
baseUrl: 'https://<your-company>.dalux.com/api',
|
|
38
|
+
apiKey: 'YOUR_API_KEY',
|
|
39
|
+
});
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
The returned object exposes one namespace per API group (see [API Reference](#api-reference) below).
|
|
43
|
+
|
|
44
|
+
### Examples
|
|
45
|
+
|
|
46
|
+
**List all projects**
|
|
47
|
+
```js
|
|
48
|
+
const projects = await dalux.projects.listProjects();
|
|
49
|
+
console.log(projects);
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**Get a specific project**
|
|
53
|
+
```js
|
|
54
|
+
const project = await dalux.projects.getProject('my-project-id');
|
|
55
|
+
console.log(project);
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**List tasks on a project**
|
|
59
|
+
```js
|
|
60
|
+
const tasks = await dalux.tasks.getProjectTasks('my-project-id', {
|
|
61
|
+
updatedAfter: '2024-01-01',
|
|
62
|
+
});
|
|
63
|
+
console.log(tasks);
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**Upload a file (chunked)**
|
|
67
|
+
```js
|
|
68
|
+
const fs = require('fs');
|
|
69
|
+
|
|
70
|
+
// 1. Create an upload slot
|
|
71
|
+
const { uploadGuid } = await dalux.fileUpload.createUpload(
|
|
72
|
+
'my-project-id',
|
|
73
|
+
'my-file-area-id',
|
|
74
|
+
{ fileName: 'drawing.pdf', mimeType: 'application/pdf' },
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
// 2. Upload the file in one chunk
|
|
78
|
+
const content = fs.readFileSync('./drawing.pdf');
|
|
79
|
+
await dalux.fileUpload.uploadFilePart('my-project-id', 'my-file-area-id', uploadGuid, content);
|
|
80
|
+
|
|
81
|
+
// 3. Finalize the upload
|
|
82
|
+
const result = await dalux.fileUpload.finishUpload(
|
|
83
|
+
'my-project-id',
|
|
84
|
+
'my-file-area-id',
|
|
85
|
+
uploadGuid,
|
|
86
|
+
{ folderId: 'target-folder-id' },
|
|
87
|
+
);
|
|
88
|
+
console.log('New file ID:', result.fileId);
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Authentication
|
|
92
|
+
|
|
93
|
+
Every request automatically includes the `X-API-KEY` header with the API key supplied to `createClient`. No additional configuration is required.
|
|
94
|
+
|
|
95
|
+
## Error Handling
|
|
96
|
+
|
|
97
|
+
All methods return Promises. Network or HTTP errors (4xx / 5xx) are thrown as Axios errors, so wrap calls with `try/catch` or `.catch()`:
|
|
98
|
+
|
|
99
|
+
```js
|
|
100
|
+
try {
|
|
101
|
+
const project = await dalux.projects.getProject('unknown-id');
|
|
102
|
+
} catch (err) {
|
|
103
|
+
console.error(err.response?.status, err.response?.data);
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## API Reference
|
|
108
|
+
|
|
109
|
+
All API namespaces are accessible on the object returned by `createClient`:
|
|
110
|
+
|
|
111
|
+
| Namespace | Class | Description |
|
|
112
|
+
|---|---|---|
|
|
113
|
+
| `projects` | `ProjectsApi` | List, get, create and update projects; manage project metadata |
|
|
114
|
+
| `companies` | `CompaniesApi` | Project companies (CRUD) |
|
|
115
|
+
| `companyCatalog` | `CompanyCatalogApi` | Company catalog (CRUD + metadata) |
|
|
116
|
+
| `tasks` | `TasksApi` | Tasks, approvals, safety issues, observations & good practices |
|
|
117
|
+
| `fileAreas` | `FileAreasApi` | File areas on a project |
|
|
118
|
+
| `files` | `FilesApi` | Files within a file area |
|
|
119
|
+
| `folders` | `FoldersApi` | Folders within a file area |
|
|
120
|
+
| `fileUpload` | `FileUploadApi` | Chunked file upload (create slot → upload parts → finalize) |
|
|
121
|
+
| `fileRevisions` | `FileRevisionsApi` | Download file revision content |
|
|
122
|
+
| `forms` | `FormsApi` | Forms and form attachments |
|
|
123
|
+
| `users` | `UsersApi` | Company and project users |
|
|
124
|
+
| `projectTemplates` | `ProjectTemplatesApi` | Available project templates |
|
|
125
|
+
| `inspectionPlans` | `InspectionPlansApi` | Inspection plans, items, zones and registrations |
|
|
126
|
+
| `testPlans` | `TestPlansApi` | Test plans, items, zones and registrations |
|
|
127
|
+
| `versionSets` | `VersionSetsApi` | Version sets and version set files |
|
|
128
|
+
| `workPackages` | `WorkPackagesApi` | Work packages on a project |
|
|
129
|
+
|
|
130
|
+
### ProjectsApi
|
|
131
|
+
|
|
132
|
+
| Method | HTTP | Path |
|
|
133
|
+
|---|---|---|
|
|
134
|
+
| `listProjects(params?)` | GET | `/5.1/projects` |
|
|
135
|
+
| `getProject(projectId)` | GET | `/5.0/projects/{projectId}` |
|
|
136
|
+
| `createProject(body)` | POST | `/5.0/projects` |
|
|
137
|
+
| `updateProject(projectId, body)` | PATCH | `/5.0/projects/{projectId}` |
|
|
138
|
+
| `listMetadataMappingsForProjects()` | GET | `/1.0/projects/metadata/1.0/mappings` |
|
|
139
|
+
| `listMetadataValuesForProjects(key)` | GET | `/1.0/projects/metadata/1.0/mappings/{key}/values` |
|
|
140
|
+
| `listProjectMetadata(projectId)` | GET | `/1.0/projects/{projectId}/metadata` |
|
|
141
|
+
| `listProjectMetadataMappings(projectId)` | GET | `/1.0/projects/{projectId}/metadata/1.0/mappings` |
|
|
142
|
+
| `listProjectMetadataValues(projectId, key)` | GET | `/1.0/projects/{projectId}/metadata/1.0/mappings/{key}/values` |
|
|
143
|
+
|
|
144
|
+
### CompaniesApi
|
|
145
|
+
|
|
146
|
+
| Method | HTTP | Path |
|
|
147
|
+
|---|---|---|
|
|
148
|
+
| `listProjectCompanies(projectId, params?)` | GET | `/3.1/projects/{projectId}/companies` |
|
|
149
|
+
| `getProjectCompany(projectId, companyId)` | GET | `/3.0/projects/{projectId}/companies/{companyId}` |
|
|
150
|
+
| `createProjectCompany(projectId, body)` | POST | `/3.1/projects/{projectId}/companies` |
|
|
151
|
+
| `updateProjectCompany(projectId, companyId, body)` | PATCH | `/3.0/projects/{projectId}/companies/{companyId}` |
|
|
152
|
+
|
|
153
|
+
### CompanyCatalogApi
|
|
154
|
+
|
|
155
|
+
| Method | HTTP | Path |
|
|
156
|
+
|---|---|---|
|
|
157
|
+
| `getCompanies(params?)` | GET | `/2.2/companyCatalog` |
|
|
158
|
+
| `getCompany(catalogCompanyId)` | GET | `/1.2/companyCatalog/{catalogCompanyId}` |
|
|
159
|
+
| `createCompany(body)` | POST | `/2.2/companyCatalog` |
|
|
160
|
+
| `updateCompany(catalogCompanyId, body)` | PATCH | `/2.1/companyCatalog/{catalogCompanyId}` |
|
|
161
|
+
| `listCompanyMetadata(catalogCompanyId)` | GET | `/1.0/companyCatalog/{catalogCompanyId}/metadata` |
|
|
162
|
+
| `listCompanyMetadataMappings(catalogCompanyId)` | GET | `/1.0/companyCatalog/{catalogCompanyId}/metadata/1.0/mappings` |
|
|
163
|
+
| `listCompanyMetadataValues(catalogCompanyId, key)` | GET | `/1.0/companyCatalog/{catalogCompanyId}/metadata/1.0/mappings/{key}/values` |
|
|
164
|
+
| `listMetadataMappingsForCompanies()` | GET | `/1.0/companyCatalog/metadata/1.0/mappings` |
|
|
165
|
+
| `listMetadataValuesForCompanies(key)` | GET | `/1.0/companyCatalog/metadata/1.0/mappings/{key}/values` |
|
|
166
|
+
|
|
167
|
+
### TasksApi
|
|
168
|
+
|
|
169
|
+
| Method | HTTP | Path |
|
|
170
|
+
|---|---|---|
|
|
171
|
+
| `getProjectTasks(projectId, params?)` | GET | `/5.1/projects/{projectId}/tasks` |
|
|
172
|
+
| `getTask(projectId, taskId)` | GET | `/3.3/projects/{projectId}/tasks/{taskId}` |
|
|
173
|
+
| `getProjectTaskChanges(projectId, params?)` | GET | `/2.2/projects/{projectId}/tasks/changes` |
|
|
174
|
+
| `getProjectTaskAttachments(projectId, params?)` | GET | `/1.1/projects/{projectId}/tasks/attachments` |
|
|
175
|
+
|
|
176
|
+
### FileAreasApi
|
|
177
|
+
|
|
178
|
+
| Method | HTTP | Path |
|
|
179
|
+
|---|---|---|
|
|
180
|
+
| `getFileAreas(projectId, params?)` | GET | `/5.1/projects/{projectId}/file_areas` |
|
|
181
|
+
| `getFileArea(projectId, fileAreaId)` | GET | `/1.0/projects/{projectId}/file_areas/{fileAreaId}` |
|
|
182
|
+
|
|
183
|
+
### FilesApi
|
|
184
|
+
|
|
185
|
+
| Method | HTTP | Path |
|
|
186
|
+
|---|---|---|
|
|
187
|
+
| `listFiles(projectId, fileAreaId, params?)` | GET | `/6.0/projects/{projectId}/file_areas/{fileAreaId}/files` |
|
|
188
|
+
| `getFile(projectId, fileAreaId, fileId)` | GET | `/5.0/projects/{projectId}/file_areas/{fileAreaId}/files/{fileId}` |
|
|
189
|
+
| `getFilePropertiesMapping(projectId, fileAreaId, fileId)` | GET | `/1.0/.../files/{fileId}/properties/1.0/mappings` |
|
|
190
|
+
| `getFilePropertyMappingValues(projectId, fileAreaId, filePropertyId)` | GET | `/1.0/.../files/properties/1.0/mappings/{filePropertyId}/values` |
|
|
191
|
+
|
|
192
|
+
### FoldersApi
|
|
193
|
+
|
|
194
|
+
| Method | HTTP | Path |
|
|
195
|
+
|---|---|---|
|
|
196
|
+
| `listFolders(projectId, fileAreaId, params?)` | GET | `/5.1/projects/{projectId}/file_areas/{fileAreaId}/folders` |
|
|
197
|
+
| `getFolder(projectId, fileAreaId, folderId)` | GET | `/5.0/projects/{projectId}/file_areas/{fileAreaId}/folders/{folderId}` |
|
|
198
|
+
| `getFolderFilesProperties(projectId, fileAreaId, folderId)` | GET | `/1.0/.../folders/{folderId}/files/properties/1.0/mappings` |
|
|
199
|
+
|
|
200
|
+
### FileUploadApi
|
|
201
|
+
|
|
202
|
+
| Method | HTTP | Path |
|
|
203
|
+
|---|---|---|
|
|
204
|
+
| `createUpload(projectId, fileAreaId, body)` | POST | `/1.0/projects/{projectId}/file_areas/{fileAreaId}/upload` |
|
|
205
|
+
| `uploadFilePart(projectId, fileAreaId, uploadGuid, chunk)` | POST | `/1.0/.../upload/{uploadGuid}` |
|
|
206
|
+
| `finishUpload(projectId, fileAreaId, uploadGuid, body)` | POST | `/2.0/.../upload/{uploadGuid}/finalize` |
|
|
207
|
+
|
|
208
|
+
### FileRevisionsApi
|
|
209
|
+
|
|
210
|
+
| Method | HTTP | Path |
|
|
211
|
+
|---|---|---|
|
|
212
|
+
| `getFileRevisionContent(projectId, fileAreaId, fileId, fileRevisionId)` | GET | `/2.0/.../files/{fileId}/revisions/{fileRevisionId}/content` |
|
|
213
|
+
|
|
214
|
+
### FormsApi
|
|
215
|
+
|
|
216
|
+
| Method | HTTP | Path |
|
|
217
|
+
|---|---|---|
|
|
218
|
+
| `getProjectForms(projectId, params?)` | GET | `/2.1/projects/{projectId}/forms` |
|
|
219
|
+
| `getForm(projectId, formId)` | GET | `/1.2/projects/{projectId}/forms/{formId}` |
|
|
220
|
+
| `getProjectFormAttachments(projectId, params?)` | GET | `/2.1/projects/{projectId}/forms/attachments` |
|
|
221
|
+
|
|
222
|
+
### UsersApi
|
|
223
|
+
|
|
224
|
+
| Method | HTTP | Path |
|
|
225
|
+
|---|---|---|
|
|
226
|
+
| `getUser(userId)` | GET | `/1.1/users/{userId}` |
|
|
227
|
+
| `listProjectUsers(projectId, params?)` | GET | `/1.2/projects/{projectId}/users` |
|
|
228
|
+
| `getProjectUser(projectId, userId)` | GET | `/1.1/projects/{projectId}/users/{userId}` |
|
|
229
|
+
|
|
230
|
+
### ProjectTemplatesApi
|
|
231
|
+
|
|
232
|
+
| Method | HTTP | Path |
|
|
233
|
+
|---|---|---|
|
|
234
|
+
| `listProjectTemplates(params?)` | GET | `/1.1/projectTemplates` |
|
|
235
|
+
|
|
236
|
+
### InspectionPlansApi
|
|
237
|
+
|
|
238
|
+
| Method | HTTP | Path |
|
|
239
|
+
|---|---|---|
|
|
240
|
+
| `listInspectionPlans(projectId, params?)` | GET | `/1.2/projects/{projectId}/inspectionPlans` |
|
|
241
|
+
| `listInspectionPlanItems(projectId, params?)` | GET | `/1.1/projects/{projectId}/inspectionPlanItems` |
|
|
242
|
+
| `listInspectionPlanItemZones(projectId, params?)` | GET | `/1.1/projects/{projectId}/inspectionPlanItemZones` |
|
|
243
|
+
| `listInspectionPlanRegistrations(projectId, params?)` | GET | `/2.1/projects/{projectId}/inspectionPlanRegistrations` |
|
|
244
|
+
|
|
245
|
+
### TestPlansApi
|
|
246
|
+
|
|
247
|
+
| Method | HTTP | Path |
|
|
248
|
+
|---|---|---|
|
|
249
|
+
| `listTestPlans(projectId, params?)` | GET | `/1.2/projects/{projectId}/testPlans` |
|
|
250
|
+
| `listTestPlanItems(projectId, params?)` | GET | `/1.1/projects/{projectId}/testPlanItems` |
|
|
251
|
+
| `listTestPlanItemZones(projectId, params?)` | GET | `/1.1/projects/{projectId}/testPlanItemZones` |
|
|
252
|
+
| `listTestPlanRegistrations(projectId, params?)` | GET | `/1.1/projects/{projectId}/testPlanRegistrations` |
|
|
253
|
+
|
|
254
|
+
### VersionSetsApi
|
|
255
|
+
|
|
256
|
+
| Method | HTTP | Path |
|
|
257
|
+
|---|---|---|
|
|
258
|
+
| `getVersionSets(projectId, params?)` | GET | `/2.1/projects/{projectId}/version_sets` |
|
|
259
|
+
| `getVersionSet(projectId, versionSetId)` | GET | `/2.0/projects/{projectId}/version_sets/{versionSetId}` |
|
|
260
|
+
| `listFileAreaVersionSets(projectId, fileAreaId, params?)` | GET | `/2.1/projects/{projectId}/file_areas/{fileAreaId}/version_sets` |
|
|
261
|
+
| `listVersionSetFiles(projectId, versionSetId, params?)` | GET | `/3.0/projects/{projectId}/version_sets/{versionSetId}/files` |
|
|
262
|
+
|
|
263
|
+
### WorkPackagesApi
|
|
264
|
+
|
|
265
|
+
| Method | HTTP | Path |
|
|
266
|
+
|---|---|---|
|
|
267
|
+
| `listWorkPackages(projectId, params?)` | GET | `/1.0/projects/{projectId}/workpackages` |
|
|
268
|
+
|
|
269
|
+
## Advanced Usage
|
|
270
|
+
|
|
271
|
+
### Using individual API classes
|
|
272
|
+
|
|
273
|
+
You can also instantiate API classes directly with a shared `ApiClient`:
|
|
274
|
+
|
|
275
|
+
```js
|
|
276
|
+
const { Configuration, ApiClient, ProjectsApi, TasksApi } = require('dalux-build-api');
|
|
277
|
+
|
|
278
|
+
const config = new Configuration({
|
|
279
|
+
baseUrl: 'https://<your-company>.dalux.com/api',
|
|
280
|
+
apiKey: 'YOUR_API_KEY',
|
|
281
|
+
});
|
|
282
|
+
const apiClient = new ApiClient(config);
|
|
283
|
+
|
|
284
|
+
const projects = new ProjectsApi(apiClient);
|
|
285
|
+
const tasks = new TasksApi(apiClient);
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
## Development
|
|
289
|
+
|
|
290
|
+
```bash
|
|
291
|
+
# Install dependencies
|
|
292
|
+
npm install
|
|
293
|
+
|
|
294
|
+
# Run tests with coverage
|
|
295
|
+
npm test
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
## License
|
|
299
|
+
|
|
300
|
+
MIT
|