dalux-build-api 1.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 -0
- package/README.md +300 -0
- package/package.json +46 -0
- package/src/api/CompaniesApi.js +60 -0
- package/src/api/CompanyCatalogApi.js +108 -0
- package/src/api/FileAreasApi.js +37 -0
- package/src/api/FileRevisionsApi.js +31 -0
- package/src/api/FileUploadApi.js +64 -0
- package/src/api/FilesApi.js +72 -0
- package/src/api/FoldersApi.js +58 -0
- package/src/api/FormsApi.js +48 -0
- package/src/api/InspectionPlansApi.js +62 -0
- package/src/api/ProjectTemplatesApi.js +25 -0
- package/src/api/ProjectsApi.js +106 -0
- package/src/api/TasksApi.js +59 -0
- package/src/api/TestPlansApi.js +59 -0
- package/src/api/UsersApi.js +47 -0
- package/src/api/VersionSetsApi.js +67 -0
- package/src/api/WorkPackagesApi.js +26 -0
- package/src/apiClient.js +75 -0
- package/src/configuration.js +24 -0
- package/src/index.js +92 -0
package/LICENSE
ADDED
|
@@ -0,0 +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.
|
package/README.md
ADDED
|
@@ -0,0 +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
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "dalux-build-api",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Node.js client for the Dalux Build API",
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"src",
|
|
8
|
+
"README.md"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"test": "jest --coverage",
|
|
12
|
+
"build": "npm pack",
|
|
13
|
+
"pack:check": "npm pack --dry-run",
|
|
14
|
+
"release:check": "npm test && npm run pack:check"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"dalux",
|
|
18
|
+
"build",
|
|
19
|
+
"api",
|
|
20
|
+
"client",
|
|
21
|
+
"construction"
|
|
22
|
+
],
|
|
23
|
+
"author": "",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/bruadam/Dalux-Build-API.git"
|
|
28
|
+
},
|
|
29
|
+
"bugs": {
|
|
30
|
+
"url": "https://github.com/bruadam/Dalux-Build-API/issues"
|
|
31
|
+
},
|
|
32
|
+
"homepage": "https://github.com/bruadam/Dalux-Build-API#readme",
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"axios": "^1.7.7"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"axios-mock-adapter": "^2.1.0",
|
|
41
|
+
"jest": "^29.7.0"
|
|
42
|
+
},
|
|
43
|
+
"jest": {
|
|
44
|
+
"testEnvironment": "node"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* API methods for managing companies on a project.
|
|
5
|
+
*/
|
|
6
|
+
class CompaniesApi {
|
|
7
|
+
/**
|
|
8
|
+
* @param {import('../apiClient')} apiClient
|
|
9
|
+
*/
|
|
10
|
+
constructor(apiClient) {
|
|
11
|
+
this._client = apiClient;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Get companies on a project.
|
|
16
|
+
* GET /3.1/projects/{projectId}/companies
|
|
17
|
+
* @param {string} projectId
|
|
18
|
+
* @param {object} [params]
|
|
19
|
+
* @returns {Promise<object>}
|
|
20
|
+
*/
|
|
21
|
+
listProjectCompanies(projectId, params = {}) {
|
|
22
|
+
return this._client.get(`/3.1/projects/${projectId}/companies`, params);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Get a specific company on a project.
|
|
27
|
+
* GET /3.0/projects/{projectId}/companies/{companyId}
|
|
28
|
+
* @param {string} projectId
|
|
29
|
+
* @param {string} companyId
|
|
30
|
+
* @returns {Promise<object>}
|
|
31
|
+
*/
|
|
32
|
+
getProjectCompany(projectId, companyId) {
|
|
33
|
+
return this._client.get(`/3.0/projects/${projectId}/companies/${companyId}`);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Add a company to a project.
|
|
38
|
+
* POST /3.1/projects/{projectId}/companies
|
|
39
|
+
* @param {string} projectId
|
|
40
|
+
* @param {object} body
|
|
41
|
+
* @returns {Promise<object>}
|
|
42
|
+
*/
|
|
43
|
+
createProjectCompany(projectId, body) {
|
|
44
|
+
return this._client.post(`/3.1/projects/${projectId}/companies`, body);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Update a company on a project.
|
|
49
|
+
* PATCH /3.0/projects/{projectId}/companies/{companyId}
|
|
50
|
+
* @param {string} projectId
|
|
51
|
+
* @param {string} companyId
|
|
52
|
+
* @param {object} body
|
|
53
|
+
* @returns {Promise<object>}
|
|
54
|
+
*/
|
|
55
|
+
updateProjectCompany(projectId, companyId, body) {
|
|
56
|
+
return this._client.patch(`/3.0/projects/${projectId}/companies/${companyId}`, body);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
module.exports = CompaniesApi;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* API methods for the company catalog.
|
|
5
|
+
*/
|
|
6
|
+
class CompanyCatalogApi {
|
|
7
|
+
/**
|
|
8
|
+
* @param {import('../apiClient')} apiClient
|
|
9
|
+
*/
|
|
10
|
+
constructor(apiClient) {
|
|
11
|
+
this._client = apiClient;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Get companies registered in the company catalog.
|
|
16
|
+
* GET /2.2/companyCatalog
|
|
17
|
+
* @param {object} [params]
|
|
18
|
+
* @returns {Promise<object>}
|
|
19
|
+
*/
|
|
20
|
+
getCompanies(params = {}) {
|
|
21
|
+
return this._client.get('/2.2/companyCatalog', params);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Get a specific company from the catalog.
|
|
26
|
+
* GET /1.2/companyCatalog/{catalogCompanyId}
|
|
27
|
+
* @param {string} catalogCompanyId
|
|
28
|
+
* @returns {Promise<object>}
|
|
29
|
+
*/
|
|
30
|
+
getCompany(catalogCompanyId) {
|
|
31
|
+
return this._client.get(`/1.2/companyCatalog/${catalogCompanyId}`);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Add a company to the catalog.
|
|
36
|
+
* POST /2.2/companyCatalog
|
|
37
|
+
* @param {object} body
|
|
38
|
+
* @returns {Promise<object>}
|
|
39
|
+
*/
|
|
40
|
+
createCompany(body) {
|
|
41
|
+
return this._client.post('/2.2/companyCatalog', body);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Update a company in the catalog.
|
|
46
|
+
* PATCH /2.1/companyCatalog/{catalogCompanyId}
|
|
47
|
+
* @param {string} catalogCompanyId
|
|
48
|
+
* @param {object} body
|
|
49
|
+
* @returns {Promise<object>}
|
|
50
|
+
*/
|
|
51
|
+
updateCompany(catalogCompanyId, body) {
|
|
52
|
+
return this._client.patch(`/2.1/companyCatalog/${catalogCompanyId}`, body);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Get metadata of a specific company from the catalog.
|
|
57
|
+
* GET /1.0/companyCatalog/{catalogCompanyId}/metadata
|
|
58
|
+
* @param {string} catalogCompanyId
|
|
59
|
+
* @returns {Promise<object>}
|
|
60
|
+
*/
|
|
61
|
+
listCompanyMetadata(catalogCompanyId) {
|
|
62
|
+
return this._client.get(`/1.0/companyCatalog/${catalogCompanyId}/metadata`);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Get all metadata available for a PATCH company-catalog operation.
|
|
67
|
+
* GET /1.0/companyCatalog/{catalogCompanyId}/metadata/1.0/mappings
|
|
68
|
+
* @param {string} catalogCompanyId
|
|
69
|
+
* @returns {Promise<object>}
|
|
70
|
+
*/
|
|
71
|
+
listCompanyMetadataMappings(catalogCompanyId) {
|
|
72
|
+
return this._client.get(`/1.0/companyCatalog/${catalogCompanyId}/metadata/1.0/mappings`);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Get available values for metadata in a PATCH company-catalog operation.
|
|
77
|
+
* GET /1.0/companyCatalog/{catalogCompanyId}/metadata/1.0/mappings/{key}/values
|
|
78
|
+
* @param {string} catalogCompanyId
|
|
79
|
+
* @param {string} key
|
|
80
|
+
* @returns {Promise<object>}
|
|
81
|
+
*/
|
|
82
|
+
listCompanyMetadataValues(catalogCompanyId, key) {
|
|
83
|
+
return this._client.get(
|
|
84
|
+
`/1.0/companyCatalog/${catalogCompanyId}/metadata/1.0/mappings/${key}/values`,
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Get all metadata available for a POST company-catalog operation.
|
|
90
|
+
* GET /1.0/companyCatalog/metadata/1.0/mappings
|
|
91
|
+
* @returns {Promise<object>}
|
|
92
|
+
*/
|
|
93
|
+
listMetadataMappingsForCompanies() {
|
|
94
|
+
return this._client.get('/1.0/companyCatalog/metadata/1.0/mappings');
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Get available values for metadata in a POST company-catalog operation.
|
|
99
|
+
* GET /1.0/companyCatalog/metadata/1.0/mappings/{key}/values
|
|
100
|
+
* @param {string} key
|
|
101
|
+
* @returns {Promise<object>}
|
|
102
|
+
*/
|
|
103
|
+
listMetadataValuesForCompanies(key) {
|
|
104
|
+
return this._client.get(`/1.0/companyCatalog/metadata/1.0/mappings/${key}/values`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
module.exports = CompanyCatalogApi;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* API methods for file areas on a project.
|
|
5
|
+
*/
|
|
6
|
+
class FileAreasApi {
|
|
7
|
+
/**
|
|
8
|
+
* @param {import('../apiClient')} apiClient
|
|
9
|
+
*/
|
|
10
|
+
constructor(apiClient) {
|
|
11
|
+
this._client = apiClient;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Retrieve the file areas on the given project.
|
|
16
|
+
* GET /5.1/projects/{projectId}/file_areas
|
|
17
|
+
* @param {string} projectId
|
|
18
|
+
* @param {object} [params]
|
|
19
|
+
* @returns {Promise<object>}
|
|
20
|
+
*/
|
|
21
|
+
getFileAreas(projectId, params = {}) {
|
|
22
|
+
return this._client.get(`/5.1/projects/${projectId}/file_areas`, params);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Retrieve a specific file area.
|
|
27
|
+
* GET /1.0/projects/{projectId}/file_areas/{fileAreaId}
|
|
28
|
+
* @param {string} projectId
|
|
29
|
+
* @param {string} fileAreaId
|
|
30
|
+
* @returns {Promise<object>}
|
|
31
|
+
*/
|
|
32
|
+
getFileArea(projectId, fileAreaId) {
|
|
33
|
+
return this._client.get(`/1.0/projects/${projectId}/file_areas/${fileAreaId}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
module.exports = FileAreasApi;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* API methods for file revision content.
|
|
5
|
+
*/
|
|
6
|
+
class FileRevisionsApi {
|
|
7
|
+
/**
|
|
8
|
+
* @param {import('../apiClient')} apiClient
|
|
9
|
+
*/
|
|
10
|
+
constructor(apiClient) {
|
|
11
|
+
this._client = apiClient;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Retrieve content of a specific file revision.
|
|
16
|
+
* GET /2.0/projects/{projectId}/file_areas/{fileAreaId}/files/{fileId}/revisions/{fileRevisionId}/content
|
|
17
|
+
* @param {string} projectId
|
|
18
|
+
* @param {string} fileAreaId
|
|
19
|
+
* @param {string} fileId
|
|
20
|
+
* @param {string} fileRevisionId
|
|
21
|
+
* @returns {Promise<Buffer>} Raw binary content
|
|
22
|
+
*/
|
|
23
|
+
getFileRevisionContent(projectId, fileAreaId, fileId, fileRevisionId) {
|
|
24
|
+
return this._client.get(
|
|
25
|
+
`/2.0/projects/${projectId}/file_areas/${fileAreaId}/files/${fileId}/revisions/${fileRevisionId}/content`,
|
|
26
|
+
{},
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
module.exports = FileRevisionsApi;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* API methods for chunked file uploads.
|
|
5
|
+
*/
|
|
6
|
+
class FileUploadApi {
|
|
7
|
+
/**
|
|
8
|
+
* @param {import('../apiClient')} apiClient
|
|
9
|
+
*/
|
|
10
|
+
constructor(apiClient) {
|
|
11
|
+
this._client = apiClient;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Create a new upload slot and return a GUID pointing to that slot.
|
|
16
|
+
* POST /1.0/projects/{projectId}/file_areas/{fileAreaId}/upload
|
|
17
|
+
* @param {string} projectId
|
|
18
|
+
* @param {string} fileAreaId
|
|
19
|
+
* @param {object} body
|
|
20
|
+
* @returns {Promise<object>}
|
|
21
|
+
*/
|
|
22
|
+
createUpload(projectId, fileAreaId, body) {
|
|
23
|
+
return this._client.post(
|
|
24
|
+
`/1.0/projects/${projectId}/file_areas/${fileAreaId}/upload`,
|
|
25
|
+
body,
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Upload a part of a file.
|
|
31
|
+
* POST /1.0/projects/{projectId}/file_areas/{fileAreaId}/upload/{uploadGuid}
|
|
32
|
+
* @param {string} projectId
|
|
33
|
+
* @param {string} fileAreaId
|
|
34
|
+
* @param {string} uploadGuid
|
|
35
|
+
* @param {Buffer|Uint8Array} chunk - Binary file chunk
|
|
36
|
+
* @returns {Promise<object>}
|
|
37
|
+
*/
|
|
38
|
+
uploadFilePart(projectId, fileAreaId, uploadGuid, chunk) {
|
|
39
|
+
return this._client.post(
|
|
40
|
+
`/1.0/projects/${projectId}/file_areas/${fileAreaId}/upload/${uploadGuid}`,
|
|
41
|
+
chunk,
|
|
42
|
+
{},
|
|
43
|
+
{ headers: { 'Content-Type': 'application/octet-stream' } },
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Finish uploading a file (finalize the upload).
|
|
49
|
+
* POST /2.0/projects/{projectId}/file_areas/{fileAreaId}/upload/{uploadGuid}/finalize
|
|
50
|
+
* @param {string} projectId
|
|
51
|
+
* @param {string} fileAreaId
|
|
52
|
+
* @param {string} uploadGuid
|
|
53
|
+
* @param {object} body
|
|
54
|
+
* @returns {Promise<object>}
|
|
55
|
+
*/
|
|
56
|
+
finishUpload(projectId, fileAreaId, uploadGuid, body) {
|
|
57
|
+
return this._client.post(
|
|
58
|
+
`/2.0/projects/${projectId}/file_areas/${fileAreaId}/upload/${uploadGuid}/finalize`,
|
|
59
|
+
body,
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
module.exports = FileUploadApi;
|