dalux-build-api 1.0.0 → 1.0.1

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.
@@ -1,67 +1,67 @@
1
- 'use strict';
2
-
3
- /**
4
- * API methods for version sets.
5
- */
6
- class VersionSetsApi {
7
- /**
8
- * @param {import('../apiClient')} apiClient
9
- */
10
- constructor(apiClient) {
11
- this._client = apiClient;
12
- }
13
-
14
- /**
15
- * Retrieve the version sets on the given project.
16
- * GET /2.1/projects/{projectId}/version_sets
17
- * @param {string} projectId
18
- * @param {object} [params]
19
- * @returns {Promise<object>}
20
- */
21
- getVersionSets(projectId, params = {}) {
22
- return this._client.get(`/2.1/projects/${projectId}/version_sets`, params);
23
- }
24
-
25
- /**
26
- * Retrieve a specific version set.
27
- * GET /2.0/projects/{projectId}/version_sets/{versionSetId}
28
- * @param {string} projectId
29
- * @param {string} versionSetId
30
- * @returns {Promise<object>}
31
- */
32
- getVersionSet(projectId, versionSetId) {
33
- return this._client.get(`/2.0/projects/${projectId}/version_sets/${versionSetId}`);
34
- }
35
-
36
- /**
37
- * Browse all version sets on the given file area and project.
38
- * GET /2.1/projects/{projectId}/file_areas/{fileAreaId}/version_sets
39
- * @param {string} projectId
40
- * @param {string} fileAreaId
41
- * @param {object} [params]
42
- * @returns {Promise<object>}
43
- */
44
- listFileAreaVersionSets(projectId, fileAreaId, params = {}) {
45
- return this._client.get(
46
- `/2.1/projects/${projectId}/file_areas/${fileAreaId}/version_sets`,
47
- params,
48
- );
49
- }
50
-
51
- /**
52
- * Browse all files on the given project and given version set.
53
- * GET /3.0/projects/{projectId}/version_sets/{versionSetId}/files
54
- * @param {string} projectId
55
- * @param {string} versionSetId
56
- * @param {object} [params]
57
- * @returns {Promise<object>}
58
- */
59
- listVersionSetFiles(projectId, versionSetId, params = {}) {
60
- return this._client.get(
61
- `/3.0/projects/${projectId}/version_sets/${versionSetId}/files`,
62
- params,
63
- );
64
- }
65
- }
66
-
67
- module.exports = VersionSetsApi;
1
+ 'use strict';
2
+
3
+ /**
4
+ * API methods for version sets.
5
+ */
6
+ class VersionSetsApi {
7
+ /**
8
+ * @param {import('../apiClient')} apiClient
9
+ */
10
+ constructor(apiClient) {
11
+ this._client = apiClient;
12
+ }
13
+
14
+ /**
15
+ * Retrieve the version sets on the given project.
16
+ * GET /2.1/projects/{projectId}/version_sets
17
+ * @param {string} projectId
18
+ * @param {object} [params]
19
+ * @returns {Promise<object>}
20
+ */
21
+ getVersionSets(projectId, params = {}) {
22
+ return this._client.get(`/2.1/projects/${projectId}/version_sets`, params);
23
+ }
24
+
25
+ /**
26
+ * Retrieve a specific version set.
27
+ * GET /2.0/projects/{projectId}/version_sets/{versionSetId}
28
+ * @param {string} projectId
29
+ * @param {string} versionSetId
30
+ * @returns {Promise<object>}
31
+ */
32
+ getVersionSet(projectId, versionSetId) {
33
+ return this._client.get(`/2.0/projects/${projectId}/version_sets/${versionSetId}`);
34
+ }
35
+
36
+ /**
37
+ * Browse all version sets on the given file area and project.
38
+ * GET /2.1/projects/{projectId}/file_areas/{fileAreaId}/version_sets
39
+ * @param {string} projectId
40
+ * @param {string} fileAreaId
41
+ * @param {object} [params]
42
+ * @returns {Promise<object>}
43
+ */
44
+ listFileAreaVersionSets(projectId, fileAreaId, params = {}) {
45
+ return this._client.get(
46
+ `/2.1/projects/${projectId}/file_areas/${fileAreaId}/version_sets`,
47
+ params,
48
+ );
49
+ }
50
+
51
+ /**
52
+ * Browse all files on the given project and given version set.
53
+ * GET /3.0/projects/{projectId}/version_sets/{versionSetId}/files
54
+ * @param {string} projectId
55
+ * @param {string} versionSetId
56
+ * @param {object} [params]
57
+ * @returns {Promise<object>}
58
+ */
59
+ listVersionSetFiles(projectId, versionSetId, params = {}) {
60
+ return this._client.get(
61
+ `/3.0/projects/${projectId}/version_sets/${versionSetId}/files`,
62
+ params,
63
+ );
64
+ }
65
+ }
66
+
67
+ module.exports = VersionSetsApi;
@@ -1,26 +1,26 @@
1
- 'use strict';
2
-
3
- /**
4
- * API methods for work packages on a project.
5
- */
6
- class WorkPackagesApi {
7
- /**
8
- * @param {import('../apiClient')} apiClient
9
- */
10
- constructor(apiClient) {
11
- this._client = apiClient;
12
- }
13
-
14
- /**
15
- * Browse all work packages on the given project.
16
- * GET /1.0/projects/{projectId}/workpackages
17
- * @param {string} projectId
18
- * @param {object} [params]
19
- * @returns {Promise<object>}
20
- */
21
- listWorkPackages(projectId, params = {}) {
22
- return this._client.get(`/1.0/projects/${projectId}/workpackages`, params);
23
- }
24
- }
25
-
26
- module.exports = WorkPackagesApi;
1
+ 'use strict';
2
+
3
+ /**
4
+ * API methods for work packages on a project.
5
+ */
6
+ class WorkPackagesApi {
7
+ /**
8
+ * @param {import('../apiClient')} apiClient
9
+ */
10
+ constructor(apiClient) {
11
+ this._client = apiClient;
12
+ }
13
+
14
+ /**
15
+ * Browse all work packages on the given project.
16
+ * GET /1.0/projects/{projectId}/workpackages
17
+ * @param {string} projectId
18
+ * @param {object} [params]
19
+ * @returns {Promise<object>}
20
+ */
21
+ listWorkPackages(projectId, params = {}) {
22
+ return this._client.get(`/1.0/projects/${projectId}/workpackages`, params);
23
+ }
24
+ }
25
+
26
+ module.exports = WorkPackagesApi;
package/src/apiClient.js CHANGED
@@ -1,75 +1,75 @@
1
- 'use strict';
2
-
3
- const axios = require('axios');
4
-
5
- /**
6
- * Base HTTP client that attaches the X-API-KEY header to every request.
7
- */
8
- class ApiClient {
9
- /**
10
- * @param {import('./configuration')} configuration
11
- */
12
- constructor(configuration) {
13
- if (!configuration) {
14
- throw new Error('configuration is required');
15
- }
16
- this.configuration = configuration;
17
-
18
- this._axios = axios.create({
19
- baseURL: configuration.baseUrl,
20
- headers: {
21
- 'X-API-KEY': configuration.apiKey,
22
- 'Content-Type': 'application/json',
23
- },
24
- });
25
- }
26
-
27
- /**
28
- * Perform a GET request.
29
- * @param {string} path - URL path (e.g. '/5.1/projects')
30
- * @param {object} [params] - Query string parameters
31
- * @returns {Promise<any>} Parsed response body
32
- */
33
- async get(path, params = {}) {
34
- const response = await this._axios.get(path, { params });
35
- return response.data;
36
- }
37
-
38
- /**
39
- * Perform a POST request.
40
- * @param {string} path
41
- * @param {object} [body]
42
- * @param {object} [params]
43
- * @param {object} [config] - Extra axios config (e.g. custom headers or responseType)
44
- * @returns {Promise<any>}
45
- */
46
- async post(path, body = {}, params = {}, config = {}) {
47
- const response = await this._axios.post(path, body, { params, ...config });
48
- return response.data;
49
- }
50
-
51
- /**
52
- * Perform a PATCH request.
53
- * @param {string} path
54
- * @param {object} [body]
55
- * @param {object} [params]
56
- * @returns {Promise<any>}
57
- */
58
- async patch(path, body = {}, params = {}) {
59
- const response = await this._axios.patch(path, body, { params });
60
- return response.data;
61
- }
62
-
63
- /**
64
- * Perform a DELETE request.
65
- * @param {string} path
66
- * @param {object} [params]
67
- * @returns {Promise<any>}
68
- */
69
- async delete(path, params = {}) {
70
- const response = await this._axios.delete(path, { params });
71
- return response.data;
72
- }
73
- }
74
-
75
- module.exports = ApiClient;
1
+ 'use strict';
2
+
3
+ const axios = require('axios');
4
+
5
+ /**
6
+ * Base HTTP client that attaches the X-API-KEY header to every request.
7
+ */
8
+ class ApiClient {
9
+ /**
10
+ * @param {import('./configuration')} configuration
11
+ */
12
+ constructor(configuration) {
13
+ if (!configuration) {
14
+ throw new Error('configuration is required');
15
+ }
16
+ this.configuration = configuration;
17
+
18
+ this._axios = axios.create({
19
+ baseURL: configuration.baseUrl,
20
+ headers: {
21
+ 'X-API-KEY': configuration.apiKey,
22
+ 'Content-Type': 'application/json',
23
+ },
24
+ });
25
+ }
26
+
27
+ /**
28
+ * Perform a GET request.
29
+ * @param {string} path - URL path (e.g. '/5.1/projects')
30
+ * @param {object} [params] - Query string parameters
31
+ * @returns {Promise<any>} Parsed response body
32
+ */
33
+ async get(path, params = {}) {
34
+ const response = await this._axios.get(path, { params });
35
+ return response.data;
36
+ }
37
+
38
+ /**
39
+ * Perform a POST request.
40
+ * @param {string} path
41
+ * @param {object} [body]
42
+ * @param {object} [params]
43
+ * @param {object} [config] - Extra axios config (e.g. custom headers or responseType)
44
+ * @returns {Promise<any>}
45
+ */
46
+ async post(path, body = {}, params = {}, config = {}) {
47
+ const response = await this._axios.post(path, body, { params, ...config });
48
+ return response.data;
49
+ }
50
+
51
+ /**
52
+ * Perform a PATCH request.
53
+ * @param {string} path
54
+ * @param {object} [body]
55
+ * @param {object} [params]
56
+ * @returns {Promise<any>}
57
+ */
58
+ async patch(path, body = {}, params = {}) {
59
+ const response = await this._axios.patch(path, body, { params });
60
+ return response.data;
61
+ }
62
+
63
+ /**
64
+ * Perform a DELETE request.
65
+ * @param {string} path
66
+ * @param {object} [params]
67
+ * @returns {Promise<any>}
68
+ */
69
+ async delete(path, params = {}) {
70
+ const response = await this._axios.delete(path, { params });
71
+ return response.data;
72
+ }
73
+ }
74
+
75
+ module.exports = ApiClient;
@@ -1,24 +1,24 @@
1
- 'use strict';
2
-
3
- /**
4
- * Configuration for the Dalux Build API client.
5
- */
6
- class Configuration {
7
- /**
8
- * @param {object} options
9
- * @param {string} options.baseUrl - The API base URL provided by Dalux (e.g. https://api.dalux.com/build)
10
- * @param {string} options.apiKey - Your company-specific X-API-KEY
11
- */
12
- constructor({ baseUrl, apiKey } = {}) {
13
- if (!baseUrl) {
14
- throw new Error('baseUrl is required');
15
- }
16
- if (!apiKey) {
17
- throw new Error('apiKey is required');
18
- }
19
- this.baseUrl = baseUrl.replace(/\/$/, '');
20
- this.apiKey = apiKey;
21
- }
22
- }
23
-
24
- module.exports = Configuration;
1
+ 'use strict';
2
+
3
+ /**
4
+ * Configuration for the Dalux Build API client.
5
+ */
6
+ class Configuration {
7
+ /**
8
+ * @param {object} options
9
+ * @param {string} options.baseUrl - The API base URL provided by Dalux (e.g. https://api.dalux.com/build)
10
+ * @param {string} options.apiKey - Your company-specific X-API-KEY
11
+ */
12
+ constructor({ baseUrl, apiKey } = {}) {
13
+ if (!baseUrl) {
14
+ throw new Error('baseUrl is required');
15
+ }
16
+ if (!apiKey) {
17
+ throw new Error('apiKey is required');
18
+ }
19
+ this.baseUrl = baseUrl.replace(/\/$/, '');
20
+ this.apiKey = apiKey;
21
+ }
22
+ }
23
+
24
+ module.exports = Configuration;
package/src/index.js CHANGED
@@ -1,92 +1,92 @@
1
- 'use strict';
2
-
3
- const Configuration = require('./configuration');
4
- const ApiClient = require('./apiClient');
5
-
6
- const CompaniesApi = require('./api/CompaniesApi');
7
- const CompanyCatalogApi = require('./api/CompanyCatalogApi');
8
- const FileAreasApi = require('./api/FileAreasApi');
9
- const FileRevisionsApi = require('./api/FileRevisionsApi');
10
- const FileUploadApi = require('./api/FileUploadApi');
11
- const FilesApi = require('./api/FilesApi');
12
- const FoldersApi = require('./api/FoldersApi');
13
- const FormsApi = require('./api/FormsApi');
14
- const InspectionPlansApi = require('./api/InspectionPlansApi');
15
- const ProjectTemplatesApi = require('./api/ProjectTemplatesApi');
16
- const ProjectsApi = require('./api/ProjectsApi');
17
- const TasksApi = require('./api/TasksApi');
18
- const TestPlansApi = require('./api/TestPlansApi');
19
- const UsersApi = require('./api/UsersApi');
20
- const VersionSetsApi = require('./api/VersionSetsApi');
21
- const WorkPackagesApi = require('./api/WorkPackagesApi');
22
-
23
- /**
24
- * Create a fully configured Dalux Build API client.
25
- *
26
- * @param {object} options
27
- * @param {string} options.baseUrl - The API base URL (obtain from Dalux support)
28
- * @param {string} options.apiKey - Your X-API-KEY (manage via Dalux Settings › Integrations › API Identities)
29
- * @returns {{
30
- * projects: ProjectsApi,
31
- * companies: CompaniesApi,
32
- * companyCatalog: CompanyCatalogApi,
33
- * fileAreas: FileAreasApi,
34
- * fileRevisions: FileRevisionsApi,
35
- * fileUpload: FileUploadApi,
36
- * files: FilesApi,
37
- * folders: FoldersApi,
38
- * forms: FormsApi,
39
- * inspectionPlans: InspectionPlansApi,
40
- * projectTemplates: ProjectTemplatesApi,
41
- * tasks: TasksApi,
42
- * testPlans: TestPlansApi,
43
- * users: UsersApi,
44
- * versionSets: VersionSetsApi,
45
- * workPackages: WorkPackagesApi
46
- * }}
47
- */
48
- function createClient({ baseUrl, apiKey } = {}) {
49
- const configuration = new Configuration({ baseUrl, apiKey });
50
- const apiClient = new ApiClient(configuration);
51
-
52
- return {
53
- projects: new ProjectsApi(apiClient),
54
- companies: new CompaniesApi(apiClient),
55
- companyCatalog: new CompanyCatalogApi(apiClient),
56
- fileAreas: new FileAreasApi(apiClient),
57
- fileRevisions: new FileRevisionsApi(apiClient),
58
- fileUpload: new FileUploadApi(apiClient),
59
- files: new FilesApi(apiClient),
60
- folders: new FoldersApi(apiClient),
61
- forms: new FormsApi(apiClient),
62
- inspectionPlans: new InspectionPlansApi(apiClient),
63
- projectTemplates: new ProjectTemplatesApi(apiClient),
64
- tasks: new TasksApi(apiClient),
65
- testPlans: new TestPlansApi(apiClient),
66
- users: new UsersApi(apiClient),
67
- versionSets: new VersionSetsApi(apiClient),
68
- workPackages: new WorkPackagesApi(apiClient),
69
- };
70
- }
71
-
72
- module.exports = {
73
- createClient,
74
- Configuration,
75
- ApiClient,
76
- CompaniesApi,
77
- CompanyCatalogApi,
78
- FileAreasApi,
79
- FileRevisionsApi,
80
- FileUploadApi,
81
- FilesApi,
82
- FoldersApi,
83
- FormsApi,
84
- InspectionPlansApi,
85
- ProjectTemplatesApi,
86
- ProjectsApi,
87
- TasksApi,
88
- TestPlansApi,
89
- UsersApi,
90
- VersionSetsApi,
91
- WorkPackagesApi,
92
- };
1
+ 'use strict';
2
+
3
+ const Configuration = require('./configuration');
4
+ const ApiClient = require('./apiClient');
5
+
6
+ const CompaniesApi = require('./api/CompaniesApi');
7
+ const CompanyCatalogApi = require('./api/CompanyCatalogApi');
8
+ const FileAreasApi = require('./api/FileAreasApi');
9
+ const FileRevisionsApi = require('./api/FileRevisionsApi');
10
+ const FileUploadApi = require('./api/FileUploadApi');
11
+ const FilesApi = require('./api/FilesApi');
12
+ const FoldersApi = require('./api/FoldersApi');
13
+ const FormsApi = require('./api/FormsApi');
14
+ const InspectionPlansApi = require('./api/InspectionPlansApi');
15
+ const ProjectTemplatesApi = require('./api/ProjectTemplatesApi');
16
+ const ProjectsApi = require('./api/ProjectsApi');
17
+ const TasksApi = require('./api/TasksApi');
18
+ const TestPlansApi = require('./api/TestPlansApi');
19
+ const UsersApi = require('./api/UsersApi');
20
+ const VersionSetsApi = require('./api/VersionSetsApi');
21
+ const WorkPackagesApi = require('./api/WorkPackagesApi');
22
+
23
+ /**
24
+ * Create a fully configured Dalux Build API client.
25
+ *
26
+ * @param {object} options
27
+ * @param {string} options.baseUrl - The API base URL (obtain from Dalux support)
28
+ * @param {string} options.apiKey - Your X-API-KEY (manage via Dalux Settings › Integrations › API Identities)
29
+ * @returns {{
30
+ * projects: ProjectsApi,
31
+ * companies: CompaniesApi,
32
+ * companyCatalog: CompanyCatalogApi,
33
+ * fileAreas: FileAreasApi,
34
+ * fileRevisions: FileRevisionsApi,
35
+ * fileUpload: FileUploadApi,
36
+ * files: FilesApi,
37
+ * folders: FoldersApi,
38
+ * forms: FormsApi,
39
+ * inspectionPlans: InspectionPlansApi,
40
+ * projectTemplates: ProjectTemplatesApi,
41
+ * tasks: TasksApi,
42
+ * testPlans: TestPlansApi,
43
+ * users: UsersApi,
44
+ * versionSets: VersionSetsApi,
45
+ * workPackages: WorkPackagesApi
46
+ * }}
47
+ */
48
+ function createClient({ baseUrl, apiKey } = {}) {
49
+ const configuration = new Configuration({ baseUrl, apiKey });
50
+ const apiClient = new ApiClient(configuration);
51
+
52
+ return {
53
+ projects: new ProjectsApi(apiClient),
54
+ companies: new CompaniesApi(apiClient),
55
+ companyCatalog: new CompanyCatalogApi(apiClient),
56
+ fileAreas: new FileAreasApi(apiClient),
57
+ fileRevisions: new FileRevisionsApi(apiClient),
58
+ fileUpload: new FileUploadApi(apiClient),
59
+ files: new FilesApi(apiClient),
60
+ folders: new FoldersApi(apiClient),
61
+ forms: new FormsApi(apiClient),
62
+ inspectionPlans: new InspectionPlansApi(apiClient),
63
+ projectTemplates: new ProjectTemplatesApi(apiClient),
64
+ tasks: new TasksApi(apiClient),
65
+ testPlans: new TestPlansApi(apiClient),
66
+ users: new UsersApi(apiClient),
67
+ versionSets: new VersionSetsApi(apiClient),
68
+ workPackages: new WorkPackagesApi(apiClient),
69
+ };
70
+ }
71
+
72
+ module.exports = {
73
+ createClient,
74
+ Configuration,
75
+ ApiClient,
76
+ CompaniesApi,
77
+ CompanyCatalogApi,
78
+ FileAreasApi,
79
+ FileRevisionsApi,
80
+ FileUploadApi,
81
+ FilesApi,
82
+ FoldersApi,
83
+ FormsApi,
84
+ InspectionPlansApi,
85
+ ProjectTemplatesApi,
86
+ ProjectsApi,
87
+ TasksApi,
88
+ TestPlansApi,
89
+ UsersApi,
90
+ VersionSetsApi,
91
+ WorkPackagesApi,
92
+ };