@inweb/client 26.9.0 → 26.9.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.
@@ -9,6 +9,7 @@ import { User } from "./User";
9
9
  import { OAuthClient } from "./OAuthClient";
10
10
  import { ISharedLinkPermissions } from "./ISharedLink";
11
11
  import { SharedLink } from "./SharedLink";
12
+ import { Plugin } from "./Plugin";
12
13
  /**
13
14
  * Provides methods for managing Open Cloud Server resources such as users, files, assemblies, jobs,
14
15
  * projects, etc.
@@ -413,8 +414,8 @@ export declare class Client extends EventEmitter2<ClientEventMap> {
413
414
  * - `dwg`, `obj`, `gltf`, `glb`, `vsf`, `pdf`, `3dpdf` - Export file to the specified format.
414
415
  * - Other custom job name. Custom job must be registered in the job templates before running.
415
416
  *
416
- * @param parameters - Parameters for the File Converter jobs or custom job. Can be given as command
417
- * line arguments in form `--arg=value`.
417
+ * @param parameters - Parameters for the File Converter jobs or custom job. Can be given as JSON
418
+ * object or command line arguments in form `--arg=value`.
418
419
  */
419
420
  createJob(fileId: string, outputFormat: string, parameters?: string | object): Promise<Job>;
420
421
  /**
@@ -468,8 +469,8 @@ export declare class Client extends EventEmitter2<ClientEventMap> {
468
469
  * @param name - Assembly name.
469
470
  * @param params - Additional assembly creating parameters.
470
471
  * @param params.jobParameters - Parameters for the File Converter jobs. Use this to specify aditional
471
- * parameters for generating the geometry and properties of the new assembly. Can be given as command
472
- * line arguments in form `--arg=value`.
472
+ * parameters for generating the geometry and properties of the new assembly. Can be given as JSON
473
+ * object or command line arguments in form `--arg=value`.
473
474
  * @param params.waitForDone - Wait for assembly to be created.
474
475
  * @param params.timeout - The time, in milliseconds, that the function should wait for the assembly to
475
476
  * be created. If the assembly is not created within this time, a TimeoutError exception will be
@@ -589,4 +590,71 @@ export declare class Client extends EventEmitter2<ClientEventMap> {
589
590
  * @param password - Password to get access to the file.
590
591
  */
591
592
  getSharedFile(token: string, password?: string): Promise<File>;
593
+ /**
594
+ * Returns the list of installed plugins.
595
+ *
596
+ * Only administrators can get a list of plugins. If the current logged in user is not an
597
+ * administrator, an exception will be thrown.
598
+ */
599
+ getPlugins(): Promise<Plugin[]>;
600
+ /**
601
+ * Returns information about the specified plugin.
602
+ *
603
+ * Only administrators can get plugins. If the current logged in user is not an administrator, they can
604
+ * only get themselves, otherwise an exception will be thrown.
605
+ *
606
+ * @param name - Plugin name.
607
+ * @param version - Plugin version.
608
+ */
609
+ getPlugin(name: string, version: string): Promise<Plugin>;
610
+ /**
611
+ * Uploads and install a plugin package to the server. The package must be a ZIP file and undergoes
612
+ * verification, scanning, and health checks during installation.
613
+ *
614
+ * Only administrators can upload plugins. If the current logged in user is not an administrator, an
615
+ * exception will be thrown.
616
+ *
617
+ * @param file - {@link https://developer.mozilla.org/docs/Web/API/File | Web API File} object are
618
+ * generally retrieved from a {@link https://developer.mozilla.org/docs/Web/API/FileList | FileList}
619
+ * object returned as a result of a user selecting files using the HTML `<input>` element.
620
+ * @param onProgress - Upload progress callback.
621
+ */
622
+ uploadPlugin(file: globalThis.File, onProgress?: (progress: number, file: globalThis.File) => void): Promise<Plugin>;
623
+ /**
624
+ * Uninstalls and deletes the specified plugin from the server.
625
+ *
626
+ * Only administrators can delete plugins. If the current logged in user is not an administrator, an
627
+ * exception will be thrown.
628
+ *
629
+ * @param name - Plugin name.
630
+ * @param version - Plugin version.
631
+ */
632
+ deletePlugin(name: string, version: string): Promise<Plugin>;
633
+ /**
634
+ * Downloads the specified plugin package from the server.
635
+ *
636
+ * Only administrators can download plugins. If the current logged in user is not an administrator, an
637
+ * exception will be thrown.
638
+ *
639
+ * @param name - Plugin name.
640
+ * @param version - Plugin version.
641
+ * @param onProgress - Download progress callback.
642
+ * @param signal - An
643
+ * {@link https://developer.mozilla.org/docs/Web/API/AbortController | AbortController} signal. Allows
644
+ * to communicate with a fetch request and abort it if desired.
645
+ */
646
+ downloadPlugin(name: string, version: string, onProgress?: (progress: number) => void, signal?: AbortSignal): Promise<ArrayBuffer>;
647
+ /**
648
+ * Executes a plugin command.
649
+ *
650
+ * If you have multiple versions of a plugin installed and want to run the command for the latest
651
+ * version of the plugin, specify `undefined` or empty string for the `version` parameter.
652
+ *
653
+ * @param name - Plugin name.
654
+ * @param version - Plugin version. Specify `undefined` or empty string to run the command for the
655
+ * latest version of the plugin.
656
+ * @param command - Command to execute.
657
+ * @param parameters - Command parameters. Command-dependent.
658
+ */
659
+ executePluginCommand(name: string, version: string, command: string, parameters?: BodyInit | object): Promise<any>;
592
660
  }
package/lib/Api/File.d.ts CHANGED
@@ -435,8 +435,8 @@ export declare class File extends Endpoint {
435
435
  * {@link downloadResource | downloadResource()} to download the exported file.
436
436
  * - Other custom job name. Custom job must be registered in the job templates before running.
437
437
  *
438
- * @param parameters - Parameters for the File Converter jobs or custom job. Can be given as command
439
- * line arguments in form `--arg=value`.
438
+ * @param parameters - Parameters for the File Converter jobs or custom job. Can be given as JSON
439
+ * object or command line arguments in form `--arg=value`.
440
440
  */
441
441
  createJob(outputFormat: string, parameters?: string | object): Promise<Job>;
442
442
  /**
@@ -0,0 +1,141 @@
1
+ import { IHttpClient } from "./IHttpClient";
2
+ import { Endpoint } from "./Endpoint";
3
+ /**
4
+ * Provides properties and methods for obtaining information about a server plugin on the Open Cloud
5
+ * Server and managing its data.
6
+ */
7
+ export declare class Plugin extends Endpoint {
8
+ private _data;
9
+ /**
10
+ * @param data - Raw plugin data received from the server. For more information, see
11
+ * {@link https://cloud.opendesign.com/docs//pages/server/api.html#Plugin | Open Cloud Plugins API}.
12
+ * @param httpClient - HTTP client instance used to send requests to the REST API server.
13
+ */
14
+ constructor(data: any, httpClient: IHttpClient);
15
+ /**
16
+ * Plugin author information. The `author` is an object with a `name` field and optionally `url` and
17
+ * `email`. Or it can be shorten that all into a single string.
18
+ *
19
+ * @readonly
20
+ */
21
+ get author(): any;
22
+ /**
23
+ * Raw plugin data received from the server. For more information, see
24
+ * {@link https://cloud.opendesign.com/docs//pages/server/api.html#Plugin | Open Cloud Plugins API}.
25
+ */
26
+ get data(): any;
27
+ set data(value: any);
28
+ /**
29
+ * Short description of the plugin.
30
+ *
31
+ * @readonly
32
+ */
33
+ get description(): string;
34
+ /**
35
+ * Plugin state.
36
+ *
37
+ * @readonly
38
+ */
39
+ get enabled(): boolean;
40
+ /**
41
+ * The URL to the plugin homepage.
42
+ *
43
+ * @readonly
44
+ */
45
+ get homepage(): string;
46
+ /**
47
+ * Unique plugin ID.
48
+ *
49
+ * @readonly
50
+ */
51
+ get id(): string;
52
+ /**
53
+ * A license for the plugin.
54
+ *
55
+ * @readonly
56
+ */
57
+ get license(): string;
58
+ /**
59
+ * Plugin name.
60
+ *
61
+ * @readonly
62
+ */
63
+ get name(): string;
64
+ /**
65
+ * API permissions required.
66
+ *
67
+ * @readonly
68
+ */
69
+ get permissions(): string[];
70
+ /**
71
+ * Plugin type. Can be set of:
72
+ *
73
+ * - `app` - Viewer plugin, the client‑side web app that the server hosts and serves as static content.
74
+ * - `server` - Binary dll that extends server functionality.
75
+ * - `jobrunner` - Binary dll that adds a new Job Runner on the server.
76
+ *
77
+ * @readonly
78
+ */
79
+ get pluginType(): string[];
80
+ /**
81
+ * {@link https://semver.org/ | SemVer} compatible version of the plugin.
82
+ *
83
+ * @readonly
84
+ */
85
+ get version(): number;
86
+ /**
87
+ * Reloads plugin data from the server.
88
+ */
89
+ checkout(): Promise<this>;
90
+ /**
91
+ * Uninstalls and deletes a plugin from the server.
92
+ *
93
+ * @returns Returns the raw data of a deleted plugin. For more information, see
94
+ * {@link https://cloud.opendesign.com/docs//pages/server/api.html#Plugin | Open Cloud Plugins API}.
95
+ */
96
+ delete(): Promise<any>;
97
+ /**
98
+ * Enables a plugin.
99
+ */
100
+ enable(): Promise<this>;
101
+ /**
102
+ * Disables a plugin.
103
+ */
104
+ disable(): Promise<this>;
105
+ /**
106
+ * Downloads the plugins package from the server.
107
+ *
108
+ * @param onProgress - Download progress callback.
109
+ * @param signal - An
110
+ * {@link https://developer.mozilla.org/docs/Web/API/AbortController | AbortController} signal. Allows
111
+ * to communicate with a fetch request and abort it if desired.
112
+ */
113
+ download(onProgress?: (progress: number) => void, signal?: AbortSignal): Promise<ArrayBuffer>;
114
+ /**
115
+ * Returns a plugin manfest.
116
+ */
117
+ getManifest(): Promise<any>;
118
+ /**
119
+ * Returns the plugin settings.
120
+ *
121
+ * @returns Returns an object with plugin settings.
122
+ */
123
+ getSettings(): Promise<any>;
124
+ /**
125
+ * Changes the plugin settings.
126
+ *
127
+ * @param settings - An object with the new plugin settings or part of the settings.
128
+ * @returns Returns an object with updated plugin settings.
129
+ */
130
+ updateSettings(settings: any): Promise<any>;
131
+ /**
132
+ * Executes a plugin command.
133
+ *
134
+ * This method executes the command for the current version of the plugin. To execute a command for the
135
+ * latest installed version of the plugin, use the {@link Client.executePluginCommand}.
136
+ *
137
+ * @param command - Command to execute.
138
+ * @param parameters - Command parameters. Command-dependent.
139
+ */
140
+ executeCommand(command: string, parameters?: BodyInit | object): Promise<any>;
141
+ }
package/lib/index.d.ts CHANGED
@@ -18,6 +18,7 @@ export { Permission } from "./Api/Permission";
18
18
  export { Project } from "./Api/Project";
19
19
  export * from "./Api/Endpoint";
20
20
  export { Role } from "./Api/Role";
21
+ export * from "./Api/Plugin";
21
22
  export * from "./Api/SharedLink";
22
23
  export * from "./Api/SharedFile";
23
24
  export { User } from "./Api/User";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inweb/client",
3
- "version": "26.9.0",
3
+ "version": "26.9.2",
4
4
  "description": "JavaScript REST API client for the Open Cloud Server",
5
5
  "homepage": "https://cloud.opendesign.com/docs/index.html",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -26,6 +26,9 @@
26
26
  "docs": "typedoc"
27
27
  },
28
28
  "dependencies": {
29
- "@inweb/eventemitter2": "~26.9.0"
29
+ "@inweb/eventemitter2": "~26.9.2"
30
+ },
31
+ "devDependencies": {
32
+ "fflate": "^0.8.2"
30
33
  }
31
34
  }
package/src/Api/Client.ts CHANGED
@@ -36,6 +36,7 @@ import { OAuthClient } from "./OAuthClient";
36
36
  import { ISharedLinkPermissions } from "./ISharedLink";
37
37
  import { SharedLink } from "./SharedLink";
38
38
  import { SharedFile } from "./SharedFile";
39
+ import { Plugin } from "./Plugin";
39
40
  import { parseArgs } from "./Utils";
40
41
 
41
42
  /**
@@ -778,8 +779,8 @@ export class Client extends EventEmitter2<ClientEventMap> {
778
779
  * - `dwg`, `obj`, `gltf`, `glb`, `vsf`, `pdf`, `3dpdf` - Export file to the specified format.
779
780
  * - Other custom job name. Custom job must be registered in the job templates before running.
780
781
  *
781
- * @param parameters - Parameters for the File Converter jobs or custom job. Can be given as command
782
- * line arguments in form `--arg=value`.
782
+ * @param parameters - Parameters for the File Converter jobs or custom job. Can be given as JSON
783
+ * object or command line arguments in form `--arg=value`.
783
784
  */
784
785
  createJob(fileId: string, outputFormat: string, parameters?: string | object): Promise<Job> {
785
786
  return this.httpClient
@@ -886,8 +887,8 @@ export class Client extends EventEmitter2<ClientEventMap> {
886
887
  * @param name - Assembly name.
887
888
  * @param params - Additional assembly creating parameters.
888
889
  * @param params.jobParameters - Parameters for the File Converter jobs. Use this to specify aditional
889
- * parameters for generating the geometry and properties of the new assembly. Can be given as command
890
- * line arguments in form `--arg=value`.
890
+ * parameters for generating the geometry and properties of the new assembly. Can be given as JSON
891
+ * object or command line arguments in form `--arg=value`.
891
892
  * @param params.waitForDone - Wait for assembly to be created.
892
893
  * @param params.timeout - The time, in milliseconds, that the function should wait for the assembly to
893
894
  * be created. If the assembly is not created within this time, a TimeoutError exception will be
@@ -1138,4 +1139,118 @@ export class Client extends EventEmitter2<ClientEventMap> {
1138
1139
  .then((response) => response.json())
1139
1140
  .then((data) => new SharedFile(data, password, this.httpClient));
1140
1141
  }
1142
+
1143
+ /**
1144
+ * Returns the list of installed plugins.
1145
+ *
1146
+ * Only administrators can get a list of plugins. If the current logged in user is not an
1147
+ * administrator, an exception will be thrown.
1148
+ */
1149
+ getPlugins(): Promise<Plugin[]> {
1150
+ return this.httpClient
1151
+ .get("/plugins")
1152
+ .then((response) => response.json())
1153
+ .then((array) => array.map((data) => new Plugin(data, this.httpClient)));
1154
+ }
1155
+
1156
+ /**
1157
+ * Returns information about the specified plugin.
1158
+ *
1159
+ * Only administrators can get plugins. If the current logged in user is not an administrator, they can
1160
+ * only get themselves, otherwise an exception will be thrown.
1161
+ *
1162
+ * @param name - Plugin name.
1163
+ * @param version - Plugin version.
1164
+ */
1165
+ getPlugin(name: string, version: string): Promise<Plugin> {
1166
+ return this.httpClient
1167
+ .get(`/plugins/${name}/${version}`)
1168
+ .then((response) => response.json())
1169
+ .then((data) => new Plugin(data, this.httpClient));
1170
+ }
1171
+
1172
+ /**
1173
+ * Uploads and install a plugin package to the server. The package must be a ZIP file and undergoes
1174
+ * verification, scanning, and health checks during installation.
1175
+ *
1176
+ * Only administrators can upload plugins. If the current logged in user is not an administrator, an
1177
+ * exception will be thrown.
1178
+ *
1179
+ * @param file - {@link https://developer.mozilla.org/docs/Web/API/File | Web API File} object are
1180
+ * generally retrieved from a {@link https://developer.mozilla.org/docs/Web/API/FileList | FileList}
1181
+ * object returned as a result of a user selecting files using the HTML `<input>` element.
1182
+ * @param onProgress - Upload progress callback.
1183
+ */
1184
+ async uploadPlugin(
1185
+ file: globalThis.File,
1186
+ onProgress?: (progress: number, file: globalThis.File) => void
1187
+ ): Promise<Plugin> {
1188
+ return await this.httpClient
1189
+ .uploadFile("/plugins", file, (progress) => {
1190
+ this.emitEvent({ type: "uploadprogress", data: progress, file });
1191
+ if (onProgress) onProgress(progress, file);
1192
+ })
1193
+ .then((xhr: XMLHttpRequest) => JSON.parse(xhr.responseText))
1194
+ .then((data) => new Plugin(data, this.httpClient));
1195
+ }
1196
+
1197
+ /**
1198
+ * Uninstalls and deletes the specified plugin from the server.
1199
+ *
1200
+ * Only administrators can delete plugins. If the current logged in user is not an administrator, an
1201
+ * exception will be thrown.
1202
+ *
1203
+ * @param name - Plugin name.
1204
+ * @param version - Plugin version.
1205
+ */
1206
+ deletePlugin(name: string, version: string): Promise<Plugin> {
1207
+ return this.httpClient.delete(`/plugins/${name}/${version}`).then((response) => response.json());
1208
+ }
1209
+
1210
+ /**
1211
+ * Downloads the specified plugin package from the server.
1212
+ *
1213
+ * Only administrators can download plugins. If the current logged in user is not an administrator, an
1214
+ * exception will be thrown.
1215
+ *
1216
+ * @param name - Plugin name.
1217
+ * @param version - Plugin version.
1218
+ * @param onProgress - Download progress callback.
1219
+ * @param signal - An
1220
+ * {@link https://developer.mozilla.org/docs/Web/API/AbortController | AbortController} signal. Allows
1221
+ * to communicate with a fetch request and abort it if desired.
1222
+ */
1223
+ downloadPlugin(
1224
+ name: string,
1225
+ version: string,
1226
+ onProgress?: (progress: number) => void,
1227
+ signal?: AbortSignal
1228
+ ): Promise<ArrayBuffer> {
1229
+ return this.httpClient
1230
+ .downloadFile(`/plugins/${name}/${version}/download`, onProgress, { signal })
1231
+ .then((response) => response.arrayBuffer());
1232
+ }
1233
+
1234
+ /**
1235
+ * Executes a plugin command.
1236
+ *
1237
+ * If you have multiple versions of a plugin installed and want to run the command for the latest
1238
+ * version of the plugin, specify `undefined` or empty string for the `version` parameter.
1239
+ *
1240
+ * @param name - Plugin name.
1241
+ * @param version - Plugin version. Specify `undefined` or empty string to run the command for the
1242
+ * latest version of the plugin.
1243
+ * @param command - Command to execute.
1244
+ * @param parameters - Command parameters. Command-dependent.
1245
+ */
1246
+ executePluginCommand(name: string, version: string, command: string, parameters?: BodyInit | object): Promise<any> {
1247
+ const searchParams = new URLSearchParams();
1248
+ if (version) searchParams.set("version", version);
1249
+
1250
+ let queryString = searchParams.toString();
1251
+ if (queryString) queryString = "?" + queryString;
1252
+ return this.httpClient
1253
+ .post(`/plugins/${name}/commands/${command}${queryString}`, parameters)
1254
+ .then((response) => response.json());
1255
+ }
1141
1256
  }
package/src/Api/File.ts CHANGED
@@ -704,8 +704,8 @@ export class File extends Endpoint {
704
704
  * {@link downloadResource | downloadResource()} to download the exported file.
705
705
  * - Other custom job name. Custom job must be registered in the job templates before running.
706
706
  *
707
- * @param parameters - Parameters for the File Converter jobs or custom job. Can be given as command
708
- * line arguments in form `--arg=value`.
707
+ * @param parameters - Parameters for the File Converter jobs or custom job. Can be given as JSON
708
+ * object or command line arguments in form `--arg=value`.
709
709
  */
710
710
  createJob(outputFormat: string, parameters?: string | object): Promise<Job> {
711
711
  const jobs = new Endpoint("/jobs", this.httpClient, this.headers);
@@ -0,0 +1,241 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance").
3
+ // All rights reserved.
4
+ //
5
+ // This software and its documentation and related materials are owned by
6
+ // the Alliance. The software may only be incorporated into application
7
+ // programs owned by members of the Alliance, subject to a signed
8
+ // Membership Agreement and Supplemental Software License Agreement with the
9
+ // Alliance. The structure and organization of this software are the valuable
10
+ // trade secrets of the Alliance and its suppliers. The software is also
11
+ // protected by copyright law and international treaty provisions. Application
12
+ // programs incorporating this software must include the following statement
13
+ // with their copyright notices:
14
+ //
15
+ // This application incorporates Open Design Alliance software pursuant to a
16
+ // license agreement with Open Design Alliance.
17
+ // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance.
18
+ // All rights reserved.
19
+ //
20
+ // By use of this software, its documentation or related materials, you
21
+ // acknowledge and accept the above terms.
22
+ ///////////////////////////////////////////////////////////////////////////////
23
+
24
+ import { IHttpClient } from "./IHttpClient";
25
+ import { Endpoint } from "./Endpoint";
26
+
27
+ /**
28
+ * Provides properties and methods for obtaining information about a server plugin on the Open Cloud
29
+ * Server and managing its data.
30
+ */
31
+ export class Plugin extends Endpoint {
32
+ private _data: any;
33
+
34
+ /**
35
+ * @param data - Raw plugin data received from the server. For more information, see
36
+ * {@link https://cloud.opendesign.com/docs//pages/server/api.html#Plugin | Open Cloud Plugins API}.
37
+ * @param httpClient - HTTP client instance used to send requests to the REST API server.
38
+ */
39
+ constructor(data: any, httpClient: IHttpClient) {
40
+ super(`/plugins/${data.name}/${data.version}`, httpClient);
41
+ this.data = data;
42
+ }
43
+
44
+ /**
45
+ * Plugin author information. The `author` is an object with a `name` field and optionally `url` and
46
+ * `email`. Or it can be shorten that all into a single string.
47
+ *
48
+ * @readonly
49
+ */
50
+ get author(): any {
51
+ return this.data.author;
52
+ }
53
+
54
+ /**
55
+ * Raw plugin data received from the server. For more information, see
56
+ * {@link https://cloud.opendesign.com/docs//pages/server/api.html#Plugin | Open Cloud Plugins API}.
57
+ */
58
+ get data(): any {
59
+ return this._data;
60
+ }
61
+
62
+ set data(value: any) {
63
+ this._data = value;
64
+ }
65
+
66
+ /**
67
+ * Short description of the plugin.
68
+ *
69
+ * @readonly
70
+ */
71
+ get description(): string {
72
+ return this.data.description;
73
+ }
74
+
75
+ /**
76
+ * Plugin state.
77
+ *
78
+ * @readonly
79
+ */
80
+ get enabled(): boolean {
81
+ return this.data.enabled;
82
+ }
83
+
84
+ /**
85
+ * The URL to the plugin homepage.
86
+ *
87
+ * @readonly
88
+ */
89
+ get homepage(): string {
90
+ return this.data.homepage;
91
+ }
92
+
93
+ /**
94
+ * Unique plugin ID.
95
+ *
96
+ * @readonly
97
+ */
98
+ get id(): string {
99
+ return this.data.id;
100
+ }
101
+
102
+ /**
103
+ * A license for the plugin.
104
+ *
105
+ * @readonly
106
+ */
107
+ get license(): string {
108
+ return this.data.license;
109
+ }
110
+
111
+ /**
112
+ * Plugin name.
113
+ *
114
+ * @readonly
115
+ */
116
+ get name(): string {
117
+ return this.data.name;
118
+ }
119
+
120
+ /**
121
+ * API permissions required.
122
+ *
123
+ * @readonly
124
+ */
125
+ get permissions(): string[] {
126
+ return this.data.permissions;
127
+ }
128
+
129
+ /**
130
+ * Plugin type. Can be set of:
131
+ *
132
+ * - `app` - Viewer plugin, the client‑side web app that the server hosts and serves as static content.
133
+ * - `server` - Binary dll that extends server functionality.
134
+ * - `jobrunner` - Binary dll that adds a new Job Runner on the server.
135
+ *
136
+ * @readonly
137
+ */
138
+ get pluginType(): string[] {
139
+ return this.data.pluginType;
140
+ }
141
+
142
+ /**
143
+ * {@link https://semver.org/ | SemVer} compatible version of the plugin.
144
+ *
145
+ * @readonly
146
+ */
147
+ get version(): number {
148
+ return this.data.version;
149
+ }
150
+
151
+ /**
152
+ * Reloads plugin data from the server.
153
+ */
154
+ async checkout(): Promise<this> {
155
+ const response = await this.get("");
156
+ this.data = await response.json();
157
+ return this;
158
+ }
159
+
160
+ /**
161
+ * Uninstalls and deletes a plugin from the server.
162
+ *
163
+ * @returns Returns the raw data of a deleted plugin. For more information, see
164
+ * {@link https://cloud.opendesign.com/docs//pages/server/api.html#Plugin | Open Cloud Plugins API}.
165
+ */
166
+ override delete(): Promise<any> {
167
+ return super.delete("").then((response) => response.json());
168
+ }
169
+
170
+ /**
171
+ * Enables a plugin.
172
+ */
173
+ async enable(): Promise<this> {
174
+ const response = await this.put("/enable");
175
+ this.data = await response.json();
176
+ return this;
177
+ }
178
+
179
+ /**
180
+ * Disables a plugin.
181
+ */
182
+ async disable(): Promise<this> {
183
+ const response = await this.put("/disable");
184
+ this.data = await response.json();
185
+ return this;
186
+ }
187
+
188
+ /**
189
+ * Downloads the plugins package from the server.
190
+ *
191
+ * @param onProgress - Download progress callback.
192
+ * @param signal - An
193
+ * {@link https://developer.mozilla.org/docs/Web/API/AbortController | AbortController} signal. Allows
194
+ * to communicate with a fetch request and abort it if desired.
195
+ */
196
+ download(onProgress?: (progress: number) => void, signal?: AbortSignal): Promise<ArrayBuffer> {
197
+ return this.httpClient
198
+ .downloadFile(this.getEndpointPath("/download"), onProgress, { signal, headers: this.headers })
199
+ .then((response) => response.arrayBuffer());
200
+ }
201
+
202
+ /**
203
+ * Returns a plugin manfest.
204
+ */
205
+ getManifest(): Promise<any> {
206
+ return this.get("/manifest").then((response) => response.json());
207
+ }
208
+
209
+ /**
210
+ * Returns the plugin settings.
211
+ *
212
+ * @returns Returns an object with plugin settings.
213
+ */
214
+ getSettings(): Promise<any> {
215
+ return this.get("/settings").then((response) => response.json());
216
+ }
217
+
218
+ /**
219
+ * Changes the plugin settings.
220
+ *
221
+ * @param settings - An object with the new plugin settings or part of the settings.
222
+ * @returns Returns an object with updated plugin settings.
223
+ */
224
+ updateSettings(settings: any): Promise<any> {
225
+ return this.post("/settings", settings).then((response) => response.json());
226
+ }
227
+
228
+ /**
229
+ * Executes a plugin command.
230
+ *
231
+ * This method executes the command for the current version of the plugin. To execute a command for the
232
+ * latest installed version of the plugin, use the {@link Client.executePluginCommand}.
233
+ *
234
+ * @param command - Command to execute.
235
+ * @param parameters - Command parameters. Command-dependent.
236
+ */
237
+ executeCommand(command: string, parameters?: BodyInit | object): Promise<any> {
238
+ const commands = new Endpoint(`/plugins/${this.name}/commands`, this.httpClient, this.headers);
239
+ return commands.post(`/${command}?version=${this.version}`, parameters).then((response) => response.json());
240
+ }
241
+ }