@bimdata/bcf-components 6.0.2-rc.5 → 6.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/service.js +29 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bimdata/bcf-components",
3
- "version": "6.0.2-rc.5",
3
+ "version": "6.0.2",
4
4
  "files": [
5
5
  "src",
6
6
  "vue3-plugin.js"
package/src/service.js CHANGED
@@ -5,16 +5,30 @@ import { getPriorityColor } from "./utils/topic.js";
5
5
  import { downloadBlobAs } from "./utils/download.js";
6
6
 
7
7
  class Service {
8
+ /**
9
+ * Define service `apiClient` instance and `fetchUsers` promise.
10
+ *
11
+ * @param {Object} param setup options
12
+ */
8
13
  setup({ apiClient, fetchUsers }) {
9
14
  this.apiClient = apiClient;
10
15
  this.fetchUsers = fetchUsers;
11
16
  }
12
17
 
18
+ // --- Users API ---
19
+
20
+ /**
21
+ * Internal user list getter
22
+ * This is a "private" method that is not intended to be used outside of Service class.
23
+ * Use `fetchUsers` promise if defined, fallback to BIMData API otherwise.
24
+ *
25
+ * @param {Object} project
26
+ * @returns {Promise<Object[]>}
27
+ */
13
28
  _getUsers(project) {
14
- return (
15
- this.fetchUsers?.(project) ??
16
- this.apiClient.collaborationApi.getProjectUsers(project.cloud.id, project.id)
17
- );
29
+ return this.fetchUsers
30
+ ? this.fetchUsers(project)
31
+ : this.apiClient.collaborationApi.getProjectUsers(project.cloud.id, project.id);
18
32
  }
19
33
 
20
34
  fetchCurrentUser() {
@@ -23,6 +37,16 @@ class Service {
23
37
 
24
38
  // --- BCF Topics API ---
25
39
 
40
+ /**
41
+ * Fetch project topics.
42
+ * You can provide a prefetched list of extensions/users as options.
43
+ * If not provided `fetchUsers` promise and BIMData API are used to
44
+ * fetch the project extensions/users.
45
+ *
46
+ * @param {Object} project
47
+ * @param {Object} options
48
+ * @returns
49
+ */
26
50
  async fetchTopics(project, { extensions, users } = {}) {
27
51
  const _extensions = extensions ?? (await this.apiClient.bcfApi.getDetailedExtensions(project.id));
28
52
  const _users = users ?? (await this._getUsers(project));
@@ -93,7 +117,7 @@ class Service {
93
117
 
94
118
  async loadTopicsViewpoints(project, topics) {
95
119
  await eachLimit(topics, 10, (topic, done) => {
96
- fetchTopicViewpoints(project, topic).then(viewpoints => {
120
+ this.fetchTopicViewpoints(project, topic).then(viewpoints => {
97
121
  topic.viewpoints = viewpoints;
98
122
  done();
99
123
  }, done);