@inweb/client 25.9.3 → 25.9.5

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/dist/client.js CHANGED
@@ -511,7 +511,7 @@
511
511
  /**
512
512
  * @param data - Raw test data received from the server.
513
513
  * @param basePath - The clash test API base path of the file/assembly that owns the test.
514
- * @param httpClient - HTTP client instance used to send REST API requests to the server.
514
+ * @param httpClient - HTTP client instance used to send requests to the REST API server.
515
515
  */
516
516
  constructor(data, basePath, httpClient) {
517
517
  this.httpClient = httpClient;
@@ -592,14 +592,6 @@
592
592
  /**
593
593
  * Test owner information.
594
594
  *
595
- * @property {string} userId - User ID.
596
- * @property {string} userName - User name.
597
- * @property {string} name - First name.
598
- * @property {string} lastName - Last name.
599
- * @property {string} fullName - Full name.
600
- * @property {string} initials - Initials.
601
- * @property {string} email - User email.
602
- * @property {string} avatarUrl - User avatar image URL.
603
595
  * @readonly
604
596
  */
605
597
  get owner() {
@@ -751,13 +743,13 @@
751
743
  // acknowledge and accept the above terms.
752
744
  ///////////////////////////////////////////////////////////////////////////////
753
745
  /**
754
- * Provides properties and methods for obtaining information about an assembly on the server
755
- * and managing its data.
746
+ * Provides properties and methods for obtaining information about an assembly on the Open
747
+ * Cloud Server and managing its data.
756
748
  */
757
749
  class Assembly {
758
750
  /**
759
751
  * @param data - Raw assembly data received from the server.
760
- * @param httpClient - HTTP client instance used to send REST API requests to the server.
752
+ * @param httpClient - HTTP client instance used to send requests to the REST API server..
761
753
  */
762
754
  constructor(data, httpClient) {
763
755
  this.path = `/assemblies/${data.id}`;
@@ -868,14 +860,6 @@
868
860
  /**
869
861
  * Assembly owner information.
870
862
  *
871
- * @property {string} userId - User ID.
872
- * @property {string} userName - User name.
873
- * @property {string} name - First name.
874
- * @property {string} lastName - Last name.
875
- * @property {string} fullName - Full name.
876
- * @property {string} initials - Initials.
877
- * @property {string} email - User email.
878
- * @property {string} avatarUrl - User avatar image URL.
879
863
  * @readonly
880
864
  */
881
865
  get owner() {
@@ -1566,7 +1550,7 @@
1566
1550
  },
1567
1551
  }));
1568
1552
  }
1569
- async downloadFileRange(relativePath, requestId, ranges, onProgress, signal) {
1553
+ async downloadFileRange(relativePath, reserved, ranges, onProgress, signal) {
1570
1554
  const headers = { ...this.headers };
1571
1555
  headers["Range"] = "bytes=" + ranges.map((x) => `${x.begin}-${x.end}`).join(",");
1572
1556
  const response = await $fetch(`${this.serverUrl}${relativePath}`, { method: "GET", headers, signal });
@@ -1643,7 +1627,7 @@
1643
1627
  /**
1644
1628
  * @param data - Raw permission data received from the server.
1645
1629
  * @param fileId - Owner file ID.
1646
- * @param httpClient - HTTP client instance used to send REST API requests to the server.
1630
+ * @param httpClient - HTTP client instance used to send requests to the REST API server.
1647
1631
  */
1648
1632
  constructor(data, fileId, httpClient) {
1649
1633
  this.httpClient = httpClient;
@@ -1694,19 +1678,7 @@
1694
1678
  return this.data.id;
1695
1679
  }
1696
1680
  /**
1697
- * Principials are any entity that can be authenticated by the server, such as a any user or
1698
- * project that will get access to the file.
1699
- *
1700
- * @typedef {any} Principial
1701
- * @property {any} user - The user entry that get access to the file.
1702
- * @property {string} user.id - User ID.
1703
- * @property {string} user.name - User name.
1704
- * @property {any} project - The project entry that get access to the file.
1705
- * @property {string} project.id - Project ID.
1706
- * @property {string} project.name - Project name.
1707
- */
1708
- /**
1709
- * A list of principials that will get access to the file.
1681
+ * A list of entities that will get access to the file.
1710
1682
  */
1711
1683
  get grantedTo() {
1712
1684
  return this.data.grantedTo;
@@ -1734,6 +1706,17 @@
1734
1706
  /**
1735
1707
  * Updates permission data on the server.
1736
1708
  *
1709
+ * @example <caption>Update file permissions for the the specified project.</caption>
1710
+ * const myFile = client.getFile(myFileId);
1711
+ * const permissions = await myFile.getPermissions();
1712
+ * const projectPermissions = permissions.filter((permission) =>
1713
+ * permission.grantedTo.some((x) => x.project?.id === myProjectId)
1714
+ * );
1715
+ * const newActions = ["read", "readSourceFile", "update"];
1716
+ * await Promise.allSettled(
1717
+ * projectPermissions.map((permission) => permission.update({ newActions }))
1718
+ * );
1719
+ *
1737
1720
  * @param data - Raw permission data.
1738
1721
  */
1739
1722
  async update(data) {
@@ -1781,12 +1764,12 @@
1781
1764
  // acknowledge and accept the above terms.
1782
1765
  ///////////////////////////////////////////////////////////////////////////////
1783
1766
  /**
1784
- * Provides properties and methods for obtaining information about a job on the server.
1767
+ * Provides properties and methods for obtaining information about a job on the Open Cloud Server.
1785
1768
  */
1786
1769
  class Job {
1787
1770
  /**
1788
1771
  * @param data - Raw job data received from the server.
1789
- * @param httpClient - HTTP client instance used to send REST API requests to the server.
1772
+ * @param httpClient - HTTP client instance used to send requests to the REST API server.
1790
1773
  */
1791
1774
  constructor(data, httpClient) {
1792
1775
  this.httpClient = httpClient;
@@ -1996,13 +1979,13 @@
1996
1979
  // acknowledge and accept the above terms.
1997
1980
  ///////////////////////////////////////////////////////////////////////////////
1998
1981
  /**
1999
- * Provides properties and methods for obtaining information about a file on the server and
2000
- * managing its data and versions.
1982
+ * Provides properties and methods for obtaining information about a file on the Open Cloud
1983
+ * Server and managing its data and versions.
2001
1984
  */
2002
1985
  class File {
2003
1986
  /**
2004
1987
  * @param data - Raw file data received from the server.
2005
- * @param httpClient - HTTP client instance used to send REST API requests to the server.
1988
+ * @param httpClient - HTTP client instance used to send requests to the REST API server.
2006
1989
  */
2007
1990
  constructor(data, httpClient) {
2008
1991
  this.path = `/files/${data.id}`;
@@ -2166,14 +2149,6 @@
2166
2149
  /**
2167
2150
  * File owner information.
2168
2151
  *
2169
- * @property {string} userId - User ID.
2170
- * @property {string} userName - User name.
2171
- * @property {string} name - First name.
2172
- * @property {string} lastName - Last name.
2173
- * @property {string} fullName - Full name.
2174
- * @property {string} initials - Initials.
2175
- * @property {string} email - User email.
2176
- * @property {string} avatarUrl - User avatar image URL.
2177
2152
  * @readonly
2178
2153
  */
2179
2154
  get owner() {
@@ -2242,14 +2217,6 @@
2242
2217
  /**
2243
2218
  * Information about the user who made the last update.
2244
2219
  *
2245
- * @property {string} userId - User ID.
2246
- * @property {string} userName - User name.
2247
- * @property {string} name - First name.
2248
- * @property {string} lastName - Last name.
2249
- * @property {string} fullName - Full name.
2250
- * @property {string} initials - Initials.
2251
- * @property {string} email - User email.
2252
- * @property {string} avatarUrl - User avatar image URL.
2253
2220
  * @readonly
2254
2221
  */
2255
2222
  get updatedBy() {
@@ -2677,7 +2644,17 @@
2677
2644
  .then((data) => new Permission(data, this.id, this.httpClient));
2678
2645
  }
2679
2646
  /**
2680
- * Creates a new file permission.
2647
+ * Creates a new file permission for a user, project, or group.
2648
+ *
2649
+ * @example <caption>Grant the specified user permission to "update" the file.</caption>
2650
+ * const action = "update";
2651
+ * const grantedTo = [{ user: { id: myUser.id, email: myUser.email } }];
2652
+ * await file.createPermission(action, grantedTo);
2653
+ *
2654
+ * @example <caption>Add a file to the specified project in `read-only` mode.</caption>
2655
+ * const actions = ["read", "readSourceFile"];
2656
+ * const grantedTo = [{ project: { id: myProject.id, name: myProject.name } }];
2657
+ * await file.createPermission(actions, grantedTo);
2681
2658
  *
2682
2659
  * @param actions - Actions are allowed to be performed on a file with this permission:
2683
2660
  *
@@ -2687,7 +2664,7 @@
2687
2664
  * - `readViewpoint` - The ability to read file viewpoints.
2688
2665
  * - `createViewpoint` - The ability to create file viewpoints.
2689
2666
  *
2690
- * @param grantedTo - A list of principials that will get access to the file.
2667
+ * @param grantedTo - A list of entities that will get access to the file.
2691
2668
  * @param _public - Specifies whether all users have access to the file or not.
2692
2669
  */
2693
2670
  createPermission(actions, grantedTo, _public) {
@@ -2868,7 +2845,7 @@
2868
2845
  /**
2869
2846
  * @param data - Raw role data received from the server.
2870
2847
  * @param projectId - Owner project ID.
2871
- * @param httpClient - HTTP client instance used to send REST API requests to the server.
2848
+ * @param httpClient - HTTP client instance used to send requests to the REST API server.
2872
2849
  */
2873
2850
  constructor(data, projectId, httpClient) {
2874
2851
  this.httpClient = httpClient;
@@ -2915,20 +2892,6 @@
2915
2892
  }
2916
2893
  /**
2917
2894
  * Role actions are allowed to be performed.
2918
- *
2919
- * @property {string[]} projectActions - Actions are allowed to be performed at the project
2920
- * level: `update`, `createTopic`, `createDocument`.
2921
- * @property {string[]} topicActions - Actions are allowed to be performed at the topic
2922
- * level: `update`, `updateBimSnippet`, `updateRelatedTopics`, `updateDocumentReferences`,
2923
- * `updateFiles`, `createComment`, `createViewpoint`, `delete`.
2924
- * @property {string[]} commentActions - Actions are allowed to be performed at the comment
2925
- * level: `update`, `delete`.
2926
- * @property {string[]} viewpointActions - Actions are allowed to be performed at the
2927
- * viewpoint level: `delete`.
2928
- * @property {string[]} odaGroupActions - Actions are allowed to be performed at the members
2929
- * level: `update`, `delete`.
2930
- * @property {string[]} odaRoleActions - Actions are allowed to be performed at the roles
2931
- * level: `update`, `delete`.
2932
2895
  */
2933
2896
  get permissions() {
2934
2897
  return this.data.permissions;
@@ -3001,7 +2964,7 @@
3001
2964
  /**
3002
2965
  * @param data - Raw member data received from the server.
3003
2966
  * @param projectId - Owner project ID.
3004
- * @param httpClient - HTTP client instance used to send REST API requests to the server.
2967
+ * @param httpClient - HTTP client instance used to send requests to the REST API server.
3005
2968
  */
3006
2969
  constructor(data, projectId, httpClient) {
3007
2970
  this.httpClient = httpClient;
@@ -3040,7 +3003,8 @@
3040
3003
  return this.data.id;
3041
3004
  }
3042
3005
  /**
3043
- * Member role. See {@link Project.getRoles | Project.getRoles()} for more details.
3006
+ * Member role name in the project. See {@link Project.getRoles | Project.getRoles()} for list
3007
+ * of project roles.
3044
3008
  */
3045
3009
  get role() {
3046
3010
  return this.data.role;
@@ -3059,14 +3023,6 @@
3059
3023
  /**
3060
3024
  * User information.
3061
3025
  *
3062
- * @property {string} userId - User ID.
3063
- * @property {string} userName - User name.
3064
- * @property {string} name - First name.
3065
- * @property {string} lastName - Last name.
3066
- * @property {string} fullName - Full name.
3067
- * @property {string} initials - Initials.
3068
- * @property {string} email - User email.
3069
- * @property {string} avatarUrl - User avatar image URL.
3070
3026
  * @readonly
3071
3027
  */
3072
3028
  get user() {
@@ -3130,13 +3086,13 @@
3130
3086
  // acknowledge and accept the above terms.
3131
3087
  ///////////////////////////////////////////////////////////////////////////////
3132
3088
  /**
3133
- * Provides properties and methods for obtaining information about a project on the server and
3134
- * managing its {@link Role | roles}, {@link Member | members} and models.
3089
+ * Provides properties and methods for obtaining information about a project on the Open Cloud
3090
+ * Server and managing its {@link Role | roles}, {@link Member | members} and models.
3135
3091
  */
3136
3092
  class Project {
3137
3093
  /**
3138
3094
  * @param data - Raw project data received from the server.
3139
- * @param httpClient - HTTP client instance used to send REST API requests to the server.
3095
+ * @param httpClient - HTTP client instance used to send requests to the REST API server.
3140
3096
  */
3141
3097
  constructor(data, httpClient) {
3142
3098
  this.httpClient = httpClient;
@@ -3252,14 +3208,6 @@
3252
3208
  /**
3253
3209
  * Project owner information.
3254
3210
  *
3255
- * @property {string} userId - User ID.
3256
- * @property {string} userName - User name.
3257
- * @property {string} name - First name.
3258
- * @property {string} lastName - Last name.
3259
- * @property {string} fullName - Full name.
3260
- * @property {string} initials - Initials.
3261
- * @property {string} email - User email.
3262
- * @property {string} avatarUrl - User avatar image URL.
3263
3211
  * @readonly
3264
3212
  */
3265
3213
  get owner() {
@@ -3406,8 +3354,7 @@
3406
3354
  *
3407
3355
  * @param name - Role name.
3408
3356
  * @param description - Role description.
3409
- * @param permissions - Actions are allowed to be performed. See {@link Role.permissions} for
3410
- * more details.
3357
+ * @param permissions - Actions are allowed to be performed for the role.
3411
3358
  */
3412
3359
  createRole(name, description, permissions) {
3413
3360
  return this.internalPost("/roles", {
@@ -3446,10 +3393,10 @@
3446
3393
  .then((data) => new Member(data, this.id, this.httpClient));
3447
3394
  }
3448
3395
  /**
3449
- * Add a user to the project to become a member and have permission to perform actions.
3396
+ * Adds a user to the project to become a member and have permission to perform actions.
3450
3397
  *
3451
3398
  * @param userId - User ID.
3452
- * @param role - Role name from the list of project roles.
3399
+ * @param role - Role name from the list of project {@link getRoles | roles}.
3453
3400
  */
3454
3401
  addMember(userId, role) {
3455
3402
  return this.internalPost("/members", { userId, role })
@@ -3457,7 +3404,7 @@
3457
3404
  .then((data) => new Member(data, this.id, this.httpClient));
3458
3405
  }
3459
3406
  /**
3460
- * Remove the specified member from a project.
3407
+ * Removes the specified member from a project.
3461
3408
  *
3462
3409
  * @param memberId - Member ID.
3463
3410
  * @returns Returns the raw data of a deleted member.
@@ -3478,8 +3425,11 @@
3478
3425
  * @property {string} file.reference - File ID.
3479
3426
  */
3480
3427
  /**
3481
- * Returns a list of project files. To add a file to this list, create a `project` permission
3482
- * on the file using {@link File.createPermission | File.createPermission()}.
3428
+ * Returns a list of project files.
3429
+ *
3430
+ * This list contains all files that the project has access to. To add a file to this list,
3431
+ * create a {@link IGrantedTo.project | project} permission on the file using
3432
+ * {@link File.createPermission | File.createPermission()}.
3483
3433
  */
3484
3434
  getFilesInformation() {
3485
3435
  return this.httpClient
@@ -3523,6 +3473,63 @@
3523
3473
  return items;
3524
3474
  });
3525
3475
  }
3476
+ /**
3477
+ * Returns a list of project models.
3478
+ */
3479
+ getModels() {
3480
+ return this.getFilesInformation()
3481
+ .then((filesInformation) => filesInformation.map((item) => item.file.reference))
3482
+ .then((ids) => {
3483
+ const searchParams = new URLSearchParams();
3484
+ searchParams.set("id", ids.join("|"));
3485
+ return this.httpClient.get(`/files?${searchParams.toString()}`);
3486
+ })
3487
+ .then((response) => response.json())
3488
+ .then((files) => files.result.map((data) => new File(data, this.httpClient)));
3489
+ }
3490
+ /**
3491
+ * Adds a file to the project with specified permissions.
3492
+ *
3493
+ * To change file permissions for the project use {@link Permission.update | Permissions.update()}.
3494
+ *
3495
+ * @param fileId - File ID.
3496
+ * @param actions - Actions are allowed to be performed on a file:
3497
+ *
3498
+ * - `read` - The ability to read file description, geometry data and properties.
3499
+ * - `readSourceFile` - The ability to read source file.
3500
+ * - `write` - The ability to modify file name, description and references.
3501
+ * - `readViewpoint` - The ability to read file viewpoints.
3502
+ * - `createViewpoint` - The ability to create file viewpoints.
3503
+ *
3504
+ * @param _public - Specifies whether all users have access to the file or not.
3505
+ * @returns Returns a file instance added to the project.
3506
+ */
3507
+ async addModel(fileId, actions, _public) {
3508
+ const file = await this.httpClient
3509
+ .get(`/files/${fileId}`)
3510
+ .then((response) => response.json())
3511
+ .then((data) => new File(data, this.httpClient));
3512
+ const grantedTo = [{ project: { id: this.id, name: this.name } }];
3513
+ await file.createPermission(actions, grantedTo, _public);
3514
+ return file;
3515
+ }
3516
+ /**
3517
+ * Removes the specified file from a project.
3518
+ *
3519
+ * @param fileId - File ID.
3520
+ * @returns Returns a file instance removed from the project.
3521
+ */
3522
+ async removeModel(fileId) {
3523
+ const file = await this.httpClient
3524
+ .get(`/files/${fileId}`)
3525
+ .then((response) => response.json())
3526
+ .then((data) => new File(data, this.httpClient));
3527
+ const permissions = await file.getPermissions();
3528
+ await Promise.allSettled(permissions
3529
+ .filter((permission) => permission.grantedTo.some((x) => { var _a; return ((_a = x.project) === null || _a === void 0 ? void 0 : _a.id) === this.id; }))
3530
+ .map((permission) => permission.delete()));
3531
+ return file;
3532
+ }
3526
3533
  }
3527
3534
 
3528
3535
  ///////////////////////////////////////////////////////////////////////////////
@@ -3548,12 +3555,13 @@
3548
3555
  // acknowledge and accept the above terms.
3549
3556
  ///////////////////////////////////////////////////////////////////////////////
3550
3557
  /**
3551
- * Provides properties and methods for obtaining information about a server user and manage its data.
3558
+ * Provides properties and methods for obtaining information about a Open Cloud Server user and
3559
+ * manage its data.
3552
3560
  */
3553
3561
  class User {
3554
3562
  /**
3555
3563
  * @param data - Raw user data received from the server.
3556
- * @param httpClient - HTTP client instance used to send REST API requests to the server.
3564
+ * @param httpClient - HTTP client instance used to send requests to the REST API server.
3557
3565
  */
3558
3566
  constructor(data, httpClient) {
3559
3567
  this.httpClient = httpClient;
@@ -3957,7 +3965,8 @@
3957
3965
  // acknowledge and accept the above terms.
3958
3966
  ///////////////////////////////////////////////////////////////////////////////
3959
3967
  /**
3960
- * Provides methods for managing server resources such as users, files, assemblies, jobs, projects, etc.
3968
+ * Provides methods for managing Open Cloud Server resources such as users, files, assemblies,
3969
+ * jobs, projects, etc.
3961
3970
  */
3962
3971
  class Client extends EventEmitter2 {
3963
3972
  /**
@@ -3974,7 +3983,7 @@
3974
3983
  this.configure(params);
3975
3984
  }
3976
3985
  /**
3977
- * Open Cloud Server REST API base URL. Use {@link configure | configure()} to change server URL.
3986
+ * Open Cloud REST API server base URL. Use {@link configure | configure()} to change server URL.
3978
3987
  *
3979
3988
  * @readonly
3980
3989
  */
@@ -3982,7 +3991,7 @@
3982
3991
  return this._serverUrl;
3983
3992
  }
3984
3993
  /**
3985
- * HTTP client instance used to send REST API requests and receive responses from the server.
3994
+ * HTTP client instance used to send requests to the REST API server.
3986
3995
  *
3987
3996
  * @readonly
3988
3997
  */
@@ -4062,7 +4071,7 @@
4062
4071
  .then((data) => ({
4063
4072
  ...data,
4064
4073
  server: data.version,
4065
- client: "25.9.3",
4074
+ client: "25.9.5",
4066
4075
  }));
4067
4076
  }
4068
4077
  /**
@@ -4777,7 +4786,7 @@
4777
4786
  // By use of this software, its documentation or related materials, you
4778
4787
  // acknowledge and accept the above terms.
4779
4788
  ///////////////////////////////////////////////////////////////////////////////
4780
- const version = "25.9.3";
4789
+ const version = "25.9.5";
4781
4790
 
4782
4791
  exports.Assembly = Assembly;
4783
4792
  exports.ClashTest = ClashTest;