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/package.json
CHANGED
|
@@ -1,46 +1,47 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "dalux-build-api",
|
|
3
|
-
"version": "
|
|
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": "Bruno Adam",
|
|
24
|
-
"license": "MIT",
|
|
25
|
-
"repository": {
|
|
26
|
-
"type": "git",
|
|
27
|
-
"url": "git+https://github.com/bruadam/
|
|
28
|
-
},
|
|
29
|
-
"bugs": {
|
|
30
|
-
"url": "https://github.com/bruadam/
|
|
31
|
-
},
|
|
32
|
-
"homepage": "https://github.com/bruadam/
|
|
33
|
-
"publishConfig": {
|
|
34
|
-
"access": "public"
|
|
35
|
-
},
|
|
36
|
-
"dependencies": {
|
|
37
|
-
"axios": "^1.7.7"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "dalux-build-api",
|
|
3
|
+
"version": "2.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": "Bruno Adam",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/bruadam/dalux-build.git"
|
|
28
|
+
},
|
|
29
|
+
"bugs": {
|
|
30
|
+
"url": "https://github.com/bruadam/dalux-build/issues"
|
|
31
|
+
},
|
|
32
|
+
"homepage": "https://github.com/bruadam/dalux-build#readme",
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"axios": "^1.7.7",
|
|
38
|
+
"zod": "^3.23.8"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"axios-mock-adapter": "^2.1.0",
|
|
42
|
+
"jest": "^29.7.0"
|
|
43
|
+
},
|
|
44
|
+
"jest": {
|
|
45
|
+
"testEnvironment": "node"
|
|
46
|
+
}
|
|
47
|
+
}
|
package/src/api/CompaniesApi.js
CHANGED
|
@@ -1,60 +1,67 @@
|
|
|
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
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { convertToModel } = require('../models/convert');
|
|
4
|
+
const { CompaniesListResponseSchema, CompanyResponseSchema } = require('../models/companies');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* API methods for managing companies on a project.
|
|
8
|
+
*/
|
|
9
|
+
class CompaniesApi {
|
|
10
|
+
/**
|
|
11
|
+
* @param {import('../apiClient')} apiClient
|
|
12
|
+
*/
|
|
13
|
+
constructor(apiClient) {
|
|
14
|
+
this._client = apiClient;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Get companies on a project.
|
|
19
|
+
* GET /3.1/projects/{projectId}/companies
|
|
20
|
+
* @param {string} projectId
|
|
21
|
+
* @param {object} [params]
|
|
22
|
+
* @returns {Promise<object>} CompaniesListResponse ({ items: ProjectCompany[], metadata?, links? })
|
|
23
|
+
*/
|
|
24
|
+
async listProjectCompanies(projectId, params = {}) {
|
|
25
|
+
const response = await this._client.get(`/3.1/projects/${projectId}/companies`, params);
|
|
26
|
+
return convertToModel(response, CompaniesListResponseSchema, 'CompaniesListResponse');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Get a specific company on a project.
|
|
31
|
+
* GET /3.0/projects/{projectId}/companies/{companyId}
|
|
32
|
+
* @param {string} projectId
|
|
33
|
+
* @param {string} companyId
|
|
34
|
+
* @returns {Promise<object>} CompanyResponse ({ data: ProjectCompany, links? })
|
|
35
|
+
*/
|
|
36
|
+
async getProjectCompany(projectId, companyId) {
|
|
37
|
+
const response = await this._client.get(`/3.0/projects/${projectId}/companies/${companyId}`);
|
|
38
|
+
return convertToModel(response, CompanyResponseSchema, 'CompanyResponse');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Add a company to a project.
|
|
43
|
+
* POST /3.1/projects/{projectId}/companies
|
|
44
|
+
* @param {string} projectId
|
|
45
|
+
* @param {object} body
|
|
46
|
+
* @returns {Promise<object>} CompanyResponse
|
|
47
|
+
*/
|
|
48
|
+
async createProjectCompany(projectId, body) {
|
|
49
|
+
const response = await this._client.post(`/3.1/projects/${projectId}/companies`, body);
|
|
50
|
+
return convertToModel(response, CompanyResponseSchema, 'CompanyResponse');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Update a company on a project.
|
|
55
|
+
* PATCH /3.0/projects/{projectId}/companies/{companyId}
|
|
56
|
+
* @param {string} projectId
|
|
57
|
+
* @param {string} companyId
|
|
58
|
+
* @param {object} body
|
|
59
|
+
* @returns {Promise<object>} CompanyResponse
|
|
60
|
+
*/
|
|
61
|
+
async updateProjectCompany(projectId, companyId, body) {
|
|
62
|
+
const response = await this._client.patch(`/3.0/projects/${projectId}/companies/${companyId}`, body);
|
|
63
|
+
return convertToModel(response, CompanyResponseSchema, 'CompanyResponse');
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
module.exports = CompaniesApi;
|
|
@@ -1,108 +1,129 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
*
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { findByField } = require('../utils/search');
|
|
4
|
+
const { convertToModel } = require('../models/convert');
|
|
5
|
+
const { CompaniesListResponseSchema, CompanyResponseSchema } = require('../models/companies');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* API methods for the company catalog.
|
|
9
|
+
*/
|
|
10
|
+
class CompanyCatalogApi {
|
|
11
|
+
/**
|
|
12
|
+
* @param {import('../apiClient')} apiClient
|
|
13
|
+
*/
|
|
14
|
+
constructor(apiClient) {
|
|
15
|
+
this._client = apiClient;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Get companies registered in the company catalog.
|
|
20
|
+
* GET /2.2/companyCatalog
|
|
21
|
+
* @param {object} [params]
|
|
22
|
+
* @returns {Promise<object>} CompaniesListResponse ({ items: ProjectCompany[], metadata?, links? })
|
|
23
|
+
*/
|
|
24
|
+
async getCompanies(params = {}) {
|
|
25
|
+
const response = await this._client.get('/2.2/companyCatalog', params);
|
|
26
|
+
return convertToModel(response, CompaniesListResponseSchema, 'CompaniesListResponse');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Get a specific company from the catalog.
|
|
31
|
+
* GET /1.2/companyCatalog/{catalogCompanyId}
|
|
32
|
+
* @param {string} catalogCompanyId
|
|
33
|
+
* @returns {Promise<object>} CompanyResponse ({ data: ProjectCompany, links? })
|
|
34
|
+
*/
|
|
35
|
+
async getCompany(catalogCompanyId) {
|
|
36
|
+
const response = await this._client.get(`/1.2/companyCatalog/${catalogCompanyId}`);
|
|
37
|
+
return convertToModel(response, CompanyResponseSchema, 'CompanyResponse');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Add a company to the catalog.
|
|
42
|
+
* POST /2.2/companyCatalog
|
|
43
|
+
* @param {object} body
|
|
44
|
+
* @returns {Promise<object>} CompanyResponse
|
|
45
|
+
*/
|
|
46
|
+
async createCompany(body) {
|
|
47
|
+
const response = await this._client.post('/2.2/companyCatalog', body);
|
|
48
|
+
return convertToModel(response, CompanyResponseSchema, 'CompanyResponse');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Update a company in the catalog.
|
|
53
|
+
* PATCH /2.1/companyCatalog/{catalogCompanyId}
|
|
54
|
+
* @param {string} catalogCompanyId
|
|
55
|
+
* @param {object} body
|
|
56
|
+
* @returns {Promise<object>} CompanyResponse
|
|
57
|
+
*/
|
|
58
|
+
async updateCompany(catalogCompanyId, body) {
|
|
59
|
+
const response = await this._client.patch(`/2.1/companyCatalog/${catalogCompanyId}`, body);
|
|
60
|
+
return convertToModel(response, CompanyResponseSchema, 'CompanyResponse');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Get metadata of a specific company from the catalog.
|
|
65
|
+
* GET /1.0/companyCatalog/{catalogCompanyId}/metadata
|
|
66
|
+
* @param {string} catalogCompanyId
|
|
67
|
+
* @returns {Promise<object>}
|
|
68
|
+
*/
|
|
69
|
+
listCompanyMetadata(catalogCompanyId) {
|
|
70
|
+
return this._client.get(`/1.0/companyCatalog/${catalogCompanyId}/metadata`);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Get all metadata available for a PATCH company-catalog operation.
|
|
75
|
+
* GET /1.0/companyCatalog/{catalogCompanyId}/metadata/1.0/mappings
|
|
76
|
+
* @param {string} catalogCompanyId
|
|
77
|
+
* @returns {Promise<object>}
|
|
78
|
+
*/
|
|
79
|
+
listCompanyMetadataMappings(catalogCompanyId) {
|
|
80
|
+
return this._client.get(`/1.0/companyCatalog/${catalogCompanyId}/metadata/1.0/mappings`);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Get available values for metadata in a PATCH company-catalog operation.
|
|
85
|
+
* GET /1.0/companyCatalog/{catalogCompanyId}/metadata/1.0/mappings/{key}/values
|
|
86
|
+
* @param {string} catalogCompanyId
|
|
87
|
+
* @param {string} key
|
|
88
|
+
* @returns {Promise<object>}
|
|
89
|
+
*/
|
|
90
|
+
listCompanyMetadataValues(catalogCompanyId, key) {
|
|
91
|
+
return this._client.get(
|
|
92
|
+
`/1.0/companyCatalog/${catalogCompanyId}/metadata/1.0/mappings/${key}/values`,
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Get all metadata available for a POST company-catalog operation.
|
|
98
|
+
* GET /1.0/companyCatalog/metadata/1.0/mappings
|
|
99
|
+
* @returns {Promise<object>}
|
|
100
|
+
*/
|
|
101
|
+
listMetadataMappingsForCompanies() {
|
|
102
|
+
return this._client.get('/1.0/companyCatalog/metadata/1.0/mappings');
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Get available values for metadata in a POST company-catalog operation.
|
|
107
|
+
* GET /1.0/companyCatalog/metadata/1.0/mappings/{key}/values
|
|
108
|
+
* @param {string} key
|
|
109
|
+
* @returns {Promise<object>}
|
|
110
|
+
*/
|
|
111
|
+
listMetadataValuesForCompanies(key) {
|
|
112
|
+
return this._client.get(`/1.0/companyCatalog/metadata/1.0/mappings/${key}/values`);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Get a company ID by its name from the catalog.
|
|
117
|
+
* @param {string} companyName
|
|
118
|
+
* @returns {Promise<string|null>} The catalogCompanyId, or null if not found.
|
|
119
|
+
*/
|
|
120
|
+
async getCompanyByName(companyName) {
|
|
121
|
+
const response = await this.getCompanies();
|
|
122
|
+
const items = (response && response.items) || [];
|
|
123
|
+
const company = findByField(items, 'name', companyName);
|
|
124
|
+
if (!company) return null;
|
|
125
|
+
return company.catalogCompanyId || null;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
module.exports = CompanyCatalogApi;
|
package/src/api/FileAreasApi.js
CHANGED
|
@@ -1,37 +1,57 @@
|
|
|
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
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { findByField } = require('../utils/search');
|
|
4
|
+
const { convertToModel } = require('../models/convert');
|
|
5
|
+
const { FileAreaSchema, FileAreasListResponseSchema } = require('../models/fileAreas');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* API methods for file areas on a project.
|
|
9
|
+
*/
|
|
10
|
+
class FileAreasApi {
|
|
11
|
+
/**
|
|
12
|
+
* @param {import('../apiClient')} apiClient
|
|
13
|
+
*/
|
|
14
|
+
constructor(apiClient) {
|
|
15
|
+
this._client = apiClient;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Retrieve the file areas on the given project.
|
|
20
|
+
* GET /5.1/projects/{projectId}/file_areas
|
|
21
|
+
* @param {string} projectId
|
|
22
|
+
* @param {object} [params]
|
|
23
|
+
* @returns {Promise<object>} FileAreasListResponse ({ items: FileArea[], metadata?, links? })
|
|
24
|
+
*/
|
|
25
|
+
async getFileAreas(projectId, params = {}) {
|
|
26
|
+
const response = await this._client.get(`/5.1/projects/${projectId}/file_areas`, params);
|
|
27
|
+
return convertToModel(response, FileAreasListResponseSchema, 'FileAreasListResponse');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Retrieve a specific file area.
|
|
32
|
+
* GET /1.0/projects/{projectId}/file_areas/{fileAreaId}
|
|
33
|
+
* @param {string} projectId
|
|
34
|
+
* @param {string} fileAreaId
|
|
35
|
+
* @returns {Promise<object>} FileArea (not wrapped in a data envelope, matches Python)
|
|
36
|
+
*/
|
|
37
|
+
async getFileArea(projectId, fileAreaId) {
|
|
38
|
+
const response = await this._client.get(`/1.0/projects/${projectId}/file_areas/${fileAreaId}`);
|
|
39
|
+
return convertToModel(response, FileAreaSchema, 'FileArea');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Get a file area ID by its name for a project.
|
|
44
|
+
* @param {string} projectId
|
|
45
|
+
* @param {string} fileAreaName
|
|
46
|
+
* @returns {Promise<string|null>} The fileAreaId, or null if not found.
|
|
47
|
+
*/
|
|
48
|
+
async getFileAreaByName(projectId, fileAreaName) {
|
|
49
|
+
const response = await this.getFileAreas(projectId);
|
|
50
|
+
const items = (response && response.items) || [];
|
|
51
|
+
const area = findByField(items, 'fileAreaName', fileAreaName);
|
|
52
|
+
if (!area) return null;
|
|
53
|
+
return area.fileAreaId || null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
module.exports = FileAreasApi;
|
|
@@ -1,31 +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;
|
|
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;
|