@inweb/client 25.10.1 → 25.11.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.
package/dist/client.js CHANGED
@@ -4018,6 +4018,188 @@
4018
4018
  }
4019
4019
  }
4020
4020
 
4021
+ ///////////////////////////////////////////////////////////////////////////////
4022
+ // Copyright (C) 2002-2024, Open Design Alliance (the "Alliance").
4023
+ // All rights reserved.
4024
+ //
4025
+ // This software and its documentation and related materials are owned by
4026
+ // the Alliance. The software may only be incorporated into application
4027
+ // programs owned by members of the Alliance, subject to a signed
4028
+ // Membership Agreement and Supplemental Software License Agreement with the
4029
+ // Alliance. The structure and organization of this software are the valuable
4030
+ // trade secrets of the Alliance and its suppliers. The software is also
4031
+ // protected by copyright law and international treaty provisions. Application
4032
+ // programs incorporating this software must include the following statement
4033
+ // with their copyright notices:
4034
+ //
4035
+ // This application incorporates Open Design Alliance software pursuant to a
4036
+ // license agreement with Open Design Alliance.
4037
+ // Open Design Alliance Copyright (C) 2002-2024 by Open Design Alliance.
4038
+ // All rights reserved.
4039
+ //
4040
+ // By use of this software, its documentation or related materials, you
4041
+ // acknowledge and accept the above terms.
4042
+ ///////////////////////////////////////////////////////////////////////////////
4043
+ /**
4044
+ * Provides properties and methods for obtaining information about a OAuth 2.0 client that have
4045
+ * access the Open Cloud Server API.
4046
+ */
4047
+ class OAuthClient {
4048
+ /**
4049
+ * @param data - Raw client data received from the server. For more information, see
4050
+ * {@link https://cloud.opendesign.com/docs//pages/server/api.html#OAuthClient | Open Cloud OAuth Clients API}.
4051
+ * @param httpClient - HTTP client instance used to send requests to the REST API server.
4052
+ */
4053
+ constructor(data, httpClient) {
4054
+ this.httpClient = httpClient;
4055
+ this.data = data;
4056
+ }
4057
+ internalGet() {
4058
+ return this.httpClient.get(`/oauth/clients/${this.clientId}`);
4059
+ }
4060
+ internalPost(relativePath, body) {
4061
+ return this.httpClient.post(`/oauth/clients/${this.clientId}${relativePath}`, body);
4062
+ }
4063
+ internalPut(body) {
4064
+ return this.httpClient.put(`/oauth/clients/${this.clientId}`, body);
4065
+ }
4066
+ internalDelete() {
4067
+ return this.httpClient.delete(`/oauth/clients/${this.clientId}`);
4068
+ }
4069
+ /**
4070
+ * OAuth 2.0 server authorization endpoint.
4071
+ */
4072
+ get authUrl() {
4073
+ return this.data.authUrl;
4074
+ }
4075
+ /**
4076
+ * OAuth 2.0 server token endpoint.
4077
+ */
4078
+ get accessTokenUrl() {
4079
+ return this.data.accessTokenUrl;
4080
+ }
4081
+ /**
4082
+ * Unique client ID.
4083
+ *
4084
+ * @readonly
4085
+ */
4086
+ get clientId() {
4087
+ return this.data.clientId;
4088
+ }
4089
+ /**
4090
+ * Client creation time (UTC) in the format specified in
4091
+ * {@link https://www.wikipedia.org/wiki/ISO_8601 | ISO 8601}.
4092
+ */
4093
+ get createdAt() {
4094
+ return this.data.createdAt;
4095
+ }
4096
+ /**
4097
+ * Client application description.
4098
+ */
4099
+ get description() {
4100
+ return this.data.description;
4101
+ }
4102
+ set description(value) {
4103
+ this._data.description = value;
4104
+ }
4105
+ /**
4106
+ * Client data received from the server. For more information, see
4107
+ * {@link https://cloud.opendesign.com/docs//pages/server/api.html#OAuthClient | Open Cloud OAuth Clients API}.
4108
+ *
4109
+ * @readonly
4110
+ */
4111
+ get data() {
4112
+ return this._data;
4113
+ }
4114
+ set data(value) {
4115
+ this._data = value;
4116
+ }
4117
+ /**
4118
+ * Client application name.
4119
+ */
4120
+ get name() {
4121
+ return this.data.name;
4122
+ }
4123
+ set name(value) {
4124
+ this._data.name = value;
4125
+ }
4126
+ /**
4127
+ * The endpoint to which the OAuth 2.0 server sends the response.
4128
+ */
4129
+ get redirectUrl() {
4130
+ return this.data.redirectUrl;
4131
+ }
4132
+ set redirectUrl(value) {
4133
+ this.data.redirectUrl = value;
4134
+ }
4135
+ /**
4136
+ * Client secret.
4137
+ *
4138
+ * @readonly
4139
+ */
4140
+ get secret() {
4141
+ return this.data.secret;
4142
+ }
4143
+ /**
4144
+ * Client last update time (UTC) in the format specified in
4145
+ * {@link https://www.wikipedia.org/wiki/ISO_8601 | ISO 8601}.
4146
+ */
4147
+ get updatedAt() {
4148
+ return this.data.updatedAt;
4149
+ }
4150
+ /**
4151
+ * Reloads clien data from the server.
4152
+ */
4153
+ async checkout() {
4154
+ const response = await this.internalGet();
4155
+ this.data = await response.json();
4156
+ return this;
4157
+ }
4158
+ /**
4159
+ * Updates client data on the server.
4160
+ *
4161
+ * Only administrators can update OAuth clients. If the current logged in user is not an
4162
+ * administrator, an exception will be thrown.
4163
+ *
4164
+ * @param data - Raw client data. For more information, see
4165
+ * {@link https://cloud.opendesign.com/docs//pages/server/api.html#OAuthClient | Open Cloud OAuth Clients API}.
4166
+ */
4167
+ async update(data) {
4168
+ const response = await this.internalPut(data);
4169
+ this.data = await response.json();
4170
+ return this;
4171
+ }
4172
+ /**
4173
+ * Deletes a client from the server.
4174
+ *
4175
+ * Only administrators can delete OAuth clients. If the current logged in user is not an
4176
+ * administrator, an exception will be thrown.
4177
+ *
4178
+ * @returns Returns the raw data of a deleted client. For more information, see
4179
+ * {@link https://cloud.opendesign.com/docs//pages/server/api.html#OAuthClient | Open Cloud OAuth Clients API}.
4180
+ */
4181
+ delete() {
4182
+ return this.internalDelete().then((response) => response.json());
4183
+ }
4184
+ /**
4185
+ * Saves client properties changes to the server. Call this method to update client data on
4186
+ * the server after any property changes.
4187
+ *
4188
+ * Only administrators can update OAuth clients. If the current logged in user is not an
4189
+ * administrator, an exception will be thrown.
4190
+ */
4191
+ save() {
4192
+ return this.update(this.data);
4193
+ }
4194
+ /**
4195
+ * Revokes the access tokens for all users of the client application.
4196
+ */
4197
+ async revoke() {
4198
+ await this.internalPost("/revoke");
4199
+ return this;
4200
+ }
4201
+ }
4202
+
4021
4203
  ///////////////////////////////////////////////////////////////////////////////
4022
4204
  // Copyright (C) 2002-2024, Open Design Alliance (the "Alliance").
4023
4205
  // All rights reserved.
@@ -4142,7 +4324,7 @@
4142
4324
  .then((data) => ({
4143
4325
  ...data,
4144
4326
  server: data.version,
4145
- client: "25.10.1",
4327
+ client: "25.11.1",
4146
4328
  }));
4147
4329
  }
4148
4330
  /**
@@ -4264,6 +4446,91 @@
4264
4446
  updateServerSettings(settings) {
4265
4447
  return this.httpClient.put("/settings", settings).then((response) => response.json());
4266
4448
  }
4449
+ /**
4450
+ * Result for OAuth client list.
4451
+ *
4452
+ * @typedef {any} OAuthClientsResult
4453
+ * @property {OAuthClient[]} result - Result client list.
4454
+ * @property {number} start - The starting index in the client list in the request.
4455
+ * @property {number} limit - The maximum number of requested clients.
4456
+ * @property {number} allSize - Total number of OAuth clients on the server.
4457
+ * @property {number} size - The number of clients in the result list.
4458
+ */
4459
+ /**
4460
+ * Returns a list of OAuth clients of the server.
4461
+ *
4462
+ * Only administrators can get a list of OAuth clients. If the current logged in user is not
4463
+ * an administrator, an exception will be thrown.
4464
+ *
4465
+ * @param start - The starting index in the client list. Used for paging.
4466
+ * @param limit - The maximum number of clients that should be returned per request. Used for paging.
4467
+ */
4468
+ getOAuthClients(start, limit) {
4469
+ const searchParams = new URLSearchParams();
4470
+ if (start > 0)
4471
+ searchParams.set("start", start.toString());
4472
+ if (limit > 0)
4473
+ searchParams.set("limit", limit.toString());
4474
+ let queryString = searchParams.toString();
4475
+ if (queryString)
4476
+ queryString = "?" + queryString;
4477
+ return this.httpClient
4478
+ .get(`/oauth/clients${queryString}`)
4479
+ .then((response) => response.json())
4480
+ .then((clients) => {
4481
+ return {
4482
+ ...clients,
4483
+ result: clients.result.map((data) => new OAuthClient(data, this.httpClient)),
4484
+ };
4485
+ });
4486
+ }
4487
+ /**
4488
+ * Returns information about the specified OAuth client.
4489
+ *
4490
+ * Only administrators can get OAuth clients. If the current logged in user is not an
4491
+ * administrator, an exception will be thrown.
4492
+ *
4493
+ * @param clientId - Client ID.
4494
+ */
4495
+ getOAuthClient(clientId) {
4496
+ return this.httpClient
4497
+ .get(`/oauth/clients/${clientId}`)
4498
+ .then((response) => response.json())
4499
+ .then((data) => new OAuthClient(data, this.httpClient));
4500
+ }
4501
+ /**
4502
+ * Creates a new OAuth client on the server.
4503
+ *
4504
+ * Only administrators can create OAuth clients. If the current logged in user is not an
4505
+ * administrator, an exception will be thrown.
4506
+ *
4507
+ * @param name - Client name.
4508
+ * @param redirectUrl - Endpoint to which the OAuth 2.0 server sends the response.
4509
+ * @param description - Client description.
4510
+ */
4511
+ createOAuthClient(name, redirectUrl, description) {
4512
+ return this.httpClient
4513
+ .post("/oauth/clients", {
4514
+ name,
4515
+ redirectUrl,
4516
+ description,
4517
+ })
4518
+ .then((response) => response.json())
4519
+ .then((data) => new OAuthClient(data, this.httpClient));
4520
+ }
4521
+ /**
4522
+ * Deletes the specified OAuth client from the server.
4523
+ *
4524
+ * Only administrators can delete OAuth clients. If the current logged in user is not an
4525
+ * administrator, an exception will be thrown.
4526
+ *
4527
+ * @param clientId - Client ID.
4528
+ * @returns Returns the raw data of a deleted client. For more information, see
4529
+ * {@link https://cloud.opendesign.com/docs//pages/server/api.html#OAuthClient | Open Cloud OAuth Clients API}.
4530
+ */
4531
+ deleteOAuthClient(clientId) {
4532
+ return this.httpClient.delete(`/oauth/clients/${clientId}`).then((response) => response.json());
4533
+ }
4267
4534
  /**
4268
4535
  * Returns the list of server users.
4269
4536
  *
@@ -4374,10 +4641,10 @@
4374
4641
  * Result for file list.
4375
4642
  *
4376
4643
  * @typedef {any} FilesResult
4377
- * @property {number} allSize - Total number of files the user has access to.
4644
+ * @property {File[]} result - Result file list.
4378
4645
  * @property {number} start - The starting index in the file list in the request.
4379
4646
  * @property {number} limit - The maximum number of requested files.
4380
- * @property {File[]} result - Result file list.
4647
+ * @property {number} allSize - Total number of files the user has access to.
4381
4648
  * @property {number} size - The number of files in the result list.
4382
4649
  */
4383
4650
  /**
@@ -4529,10 +4796,10 @@
4529
4796
  * Result for job list.
4530
4797
  *
4531
4798
  * @typedef {any} JobsResult
4532
- * @property {number} allSize - Total number of jobs created by the user.
4799
+ * @property {Job[]} result - Result job list.
4533
4800
  * @property {number} start - The starting index in the job list in the request.
4534
4801
  * @property {number} limit - The maximum number of requested jobs.
4535
- * @property {Job[]} result - Result job list.
4802
+ * @property {number} allSize - Total number of jobs created by the user.
4536
4803
  * @property {number} size - The number of jobs in the result list.
4537
4804
  */
4538
4805
  /**
@@ -4627,10 +4894,10 @@
4627
4894
  * Result for assembly list.
4628
4895
  *
4629
4896
  * @typedef {any} AssembliesResult
4630
- * @property {number} allSize - Total number of assemblies the user has access to.
4897
+ * @property {Assembly[]} result - Result assembly list.
4631
4898
  * @property {number} start - The starting index in the assembly list in the request.
4632
4899
  * @property {number} limit - The maximum number of requested assemblies.
4633
- * @property {Assembly[]} result - Result assembly list.
4900
+ * @property {number} allSize - Total number of assemblies the user has access to.
4634
4901
  * @property {number} size - The number of assemblies in the result list.
4635
4902
  */
4636
4903
  /**
@@ -4728,10 +4995,10 @@
4728
4995
  * Result for project list.
4729
4996
  *
4730
4997
  * @typedef {any} ProjectsResult
4731
- * @property {number} allSize - Total number of projects the user has access to.
4998
+ * @property {Project[]} result - Result project list.
4732
4999
  * @property {number} start - The starting index in the project list in the request.
4733
5000
  * @property {number} limit - The maximum number of requested projects.
4734
- * @property {Project[]} result - Result project list.
5001
+ * @property {number} allSize - Total number of projects the user has access to.
4735
5002
  * @property {number} size - The number of projects in the result list.
4736
5003
  */
4737
5004
  /**
@@ -4872,7 +5139,7 @@
4872
5139
  // By use of this software, its documentation or related materials, you
4873
5140
  // acknowledge and accept the above terms.
4874
5141
  ///////////////////////////////////////////////////////////////////////////////
4875
- const version = "25.10.1";
5142
+ const version = "25.11.1";
4876
5143
 
4877
5144
  exports.Assembly = Assembly;
4878
5145
  exports.ClashTest = ClashTest;
@@ -4882,6 +5149,7 @@
4882
5149
  exports.Job = Job;
4883
5150
  exports.Member = Member;
4884
5151
  exports.Model = Model;
5152
+ exports.OAuthClient = OAuthClient;
4885
5153
  exports.Permission = Permission;
4886
5154
  exports.Project = Project;
4887
5155
  exports.Role = Role;