@classcad/client 0.0.0-stage → 3.0.0-beta.20261119090857
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/README.md +20 -2
- package/bin/buerli-classcad.cjs +23 -0
- package/build/cjs/BuerliCadFacade.js +718 -0
- package/build/cjs/cclass/utils/assembly.js +687 -0
- package/build/cjs/cclass/utils/base.js +136 -0
- package/build/cjs/cclass/utils/index.js +99 -0
- package/build/cjs/cclass/utils/part.js +153 -0
- package/build/cjs/classcadEngine.js +33 -0
- package/build/cjs/createApi.js +71 -0
- package/build/cjs/createUnwrappedApi.js +43 -0
- package/build/cjs/facade.js +103 -0
- package/build/cjs/globals.js +157 -0
- package/build/cjs/index.js +102 -0
- package/build/cjs/io/AwvNodeClient.js +290 -0
- package/build/cjs/io/SocketIOClient.js +339 -0
- package/build/cjs/io/Transaction.js +134 -0
- package/build/cjs/io/WASMClient.js +433 -0
- package/build/cjs/io/WSClient.js +646 -0
- package/build/cjs/io/engineKey.js +202 -0
- package/build/cjs/re-export.js +35 -0
- package/build/cjs/session/host.js +479 -0
- package/build/cjs/session/identity.js +38 -0
- package/build/cjs/session/selection.js +283 -0
- package/build/cjs/session/share.js +229 -0
- package/build/cjs/session/types.js +23 -0
- package/build/cjs/test/SocketIOClient.spec.js +178 -0
- package/build/cjs/types/ComClient.js +10 -0
- package/build/cjs/utils/createRecursiveBufferGeometry.js +55 -0
- package/build/cjs/utils/createRecursiveScene.js +140 -0
- package/build/cjs/utils/getDifferentColoredMeshesFromEntity.js +24 -0
- package/build/cjs/utils/index.js +20 -0
- package/build/cjs/utils/polyline.js +65 -0
- package/build/cjs/utils/waitForSelect.js +29 -0
- package/build/esm/BuerliCadFacade.js +714 -0
- package/build/esm/cclass/utils/assembly.js +665 -0
- package/build/esm/cclass/utils/base.js +127 -0
- package/build/esm/cclass/utils/index.js +62 -0
- package/build/esm/cclass/utils/part.js +144 -0
- package/build/esm/classcadEngine.js +30 -0
- package/build/esm/createApi.js +66 -0
- package/build/esm/createUnwrappedApi.js +39 -0
- package/build/esm/facade.js +98 -0
- package/build/esm/globals.js +150 -0
- package/build/esm/index.js +80 -0
- package/build/esm/io/AwvNodeClient.js +286 -0
- package/build/esm/io/SocketIOClient.js +332 -0
- package/build/esm/io/Transaction.js +130 -0
- package/build/esm/io/WASMClient.js +429 -0
- package/build/esm/io/WSClient.js +642 -0
- package/build/esm/io/engineKey.js +196 -0
- package/build/esm/re-export.js +3 -0
- package/build/esm/session/host.js +474 -0
- package/build/esm/session/identity.js +34 -0
- package/build/esm/session/selection.js +277 -0
- package/build/esm/session/share.js +221 -0
- package/build/esm/session/types.js +20 -0
- package/build/esm/test/SocketIOClient.spec.js +178 -0
- package/build/esm/types/ComClient.js +7 -0
- package/build/esm/utils/createRecursiveBufferGeometry.js +51 -0
- package/build/esm/utils/createRecursiveScene.js +136 -0
- package/build/esm/utils/getDifferentColoredMeshesFromEntity.js +20 -0
- package/build/esm/utils/index.js +4 -0
- package/build/esm/utils/polyline.js +60 -0
- package/build/esm/utils/waitForSelect.js +23 -0
- package/build/types/BuerliCadFacade.d.ts +410 -0
- package/build/types/cclass/utils/assembly.d.ts +180 -0
- package/build/types/cclass/utils/base.d.ts +55 -0
- package/build/types/cclass/utils/index.d.ts +46 -0
- package/build/types/cclass/utils/part.d.ts +46 -0
- package/build/types/classcadEngine.d.ts +40 -0
- package/build/types/createApi.d.ts +65 -0
- package/build/types/createUnwrappedApi.d.ts +36 -0
- package/build/types/facade.d.ts +9 -0
- package/build/types/globals.d.ts +79 -0
- package/build/types/index.d.ts +82 -0
- package/build/types/io/AwvNodeClient.d.ts +182 -0
- package/build/types/io/SocketIOClient.d.ts +84 -0
- package/build/types/io/Transaction.d.ts +56 -0
- package/build/types/io/WASMClient.d.ts +239 -0
- package/build/types/io/WSClient.d.ts +242 -0
- package/build/types/io/engineKey.d.ts +137 -0
- package/build/types/re-export.d.ts +6 -0
- package/build/types/session/host.d.ts +108 -0
- package/build/types/session/identity.d.ts +46 -0
- package/build/types/session/selection.d.ts +164 -0
- package/build/types/session/share.d.ts +131 -0
- package/build/types/session/types.d.ts +113 -0
- package/build/types/test/SocketIOClient.spec.d.ts +0 -0
- package/build/types/types/ComClient.d.ts +307 -0
- package/build/types/utils/createRecursiveBufferGeometry.d.ts +8 -0
- package/build/types/utils/createRecursiveScene.d.ts +24 -0
- package/build/types/utils/getDifferentColoredMeshesFromEntity.d.ts +14 -0
- package/build/types/utils/index.d.ts +4 -0
- package/build/types/utils/polyline.d.ts +43 -0
- package/build/types/utils/waitForSelect.d.ts +4 -0
- package/doc/api/advanced/connection.md +488 -0
- package/doc/api/clients.md +2045 -0
- package/doc/api/engine-keys.md +230 -0
- package/doc/api/index.md +58 -0
- package/doc/api/modeling.md +682 -0
- package/doc/api/other.md +33 -0
- package/doc/api/session-sharing.md +706 -0
- package/package.json +59 -4
- package/test/classcadEngine.test.cjs +44 -0
- package/test/connect.test.cjs +81 -0
- package/test/engineKey.test.cjs +80 -0
- package/test/onClient.test.cjs +82 -0
- package/typedoc.json +8 -0
|
@@ -0,0 +1,488 @@
|
|
|
1
|
+
# Connection
|
|
2
|
+
|
|
3
|
+
The protocol between a client and its engine: requests, replies, and what the engine sends back after a command
|
|
4
|
+
(`EmissionConfig`). For apps that talk to the engine directly.
|
|
5
|
+
|
|
6
|
+
## Types
|
|
7
|
+
|
|
8
|
+
### EmissionConfig {#emissionconfig}
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
type EmissionConfig = {
|
|
12
|
+
safeApi?: boolean;
|
|
13
|
+
sendGraphic_AdvancedNotifications: boolean;
|
|
14
|
+
sendGraphic_Compressed: boolean;
|
|
15
|
+
sendGraphic_Immediately: boolean;
|
|
16
|
+
sendGraphic_ImmediatelyBinary: boolean;
|
|
17
|
+
sendGraphic_Invisible: boolean;
|
|
18
|
+
sendGraphic_Kernel: boolean;
|
|
19
|
+
sendGraphic_Multipackage: boolean;
|
|
20
|
+
sendGraphic_Sketch: boolean;
|
|
21
|
+
sendGraphic_StructureObj: boolean;
|
|
22
|
+
sendGraphic_UseDraco: boolean;
|
|
23
|
+
sendGraphic_UseDracoHybrid: boolean;
|
|
24
|
+
sendMessages: boolean;
|
|
25
|
+
sendMessages_Immediately: boolean;
|
|
26
|
+
sendMessages_MinLevel: number;
|
|
27
|
+
sendStructure: boolean;
|
|
28
|
+
sendStructure_Compressed: boolean;
|
|
29
|
+
sendStructure_Immediately: boolean;
|
|
30
|
+
sendStructure_ImmediatelyBinary: boolean;
|
|
31
|
+
sendStructure_Patch: boolean;
|
|
32
|
+
storeState: boolean;
|
|
33
|
+
};
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
The engine's per-connection emission flags: what it sends back after a command, and in which form.
|
|
37
|
+
|
|
38
|
+
Content flags decide WHAT comes back after a command (structure tree, the
|
|
39
|
+
four graphic categories, messages); delivery flags decide HOW (patches vs
|
|
40
|
+
snapshot, streamed immediately vs bundled on the Result, binary/compressed,
|
|
41
|
+
multipackage). Two commands ignore the content flags on purpose:
|
|
42
|
+
GetTree/Sync always deliver the structure, v1.common.requestVisualisation
|
|
43
|
+
always delivers its graphic - they are explicit requests.
|
|
44
|
+
|
|
45
|
+
Read and change them with `getEmissionConfig`/`setEmissionConfig` of a client, or for a stretch of commands
|
|
46
|
+
with `BuerliCadFacade.utils.withEmissionConfig`. Not to be confused with `v1.common.setDatabaseSettings`, which
|
|
47
|
+
decides what the engine tessellates.
|
|
48
|
+
|
|
49
|
+
#### Example
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
import { BuerliCadFacade } from '@classcad/client'
|
|
53
|
+
import type { EmissionConfig } from '@classcad/client'
|
|
54
|
+
|
|
55
|
+
// A study of twenty variants: no graphic after each change, only the volume
|
|
56
|
+
const noGraphic: Partial<EmissionConfig> = { sendGraphic_Kernel: false, sendGraphic_Sketch: false }
|
|
57
|
+
const volumes = await BuerliCadFacade.utils.withEmissionConfig(facade.drawingId, noGraphic, async () => {
|
|
58
|
+
const result: number[] = []
|
|
59
|
+
for (let length = 50; length < 250; length += 10) {
|
|
60
|
+
await facade.api.v1.part.updateExpression({ id: part, toUpdate: [{ name: 'length', value: length }] })
|
|
61
|
+
const mass = await facade.api.v1.part.calculateMassProperties({ id: part })
|
|
62
|
+
if (mass) result.push(mass.volume)
|
|
63
|
+
}
|
|
64
|
+
return result
|
|
65
|
+
})
|
|
66
|
+
// The flags are back: the tree, and with it the graphic, once
|
|
67
|
+
await BuerliCadFacade.utils.fetchTree(facade.drawingId)
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
#### Properties
|
|
71
|
+
|
|
72
|
+
| Property | Type | Description |
|
|
73
|
+
| :------ | :------ | :------ |
|
|
74
|
+
| <a id="property-safeapi"></a> `safeApi?` | `boolean` | Read-only instance property, echoed for completeness. |
|
|
75
|
+
| <a id="property-sendgraphic_advancednotifications"></a> `sendGraphic_AdvancedNotifications` | `boolean` | Also send graphic when objects were only moved or changed their material. |
|
|
76
|
+
| <a id="property-sendgraphic_compressed"></a> `sendGraphic_Compressed` | `boolean` | Send graphic as a base64 string of deflated JSON. |
|
|
77
|
+
| <a id="property-sendgraphic_immediately"></a> `sendGraphic_Immediately` | `boolean` | Send graphic in frames of its own while the command runs, instead of on its Result. |
|
|
78
|
+
| <a id="property-sendgraphic_immediatelybinary"></a> `sendGraphic_ImmediatelyBinary` | `boolean` | Send the frames of `sendGraphic_Immediately` as binary (deflated) WebSocket frames. |
|
|
79
|
+
| <a id="property-sendgraphic_invisible"></a> `sendGraphic_Invisible` | `boolean` | Send the graphic of hidden objects as well. |
|
|
80
|
+
| <a id="property-sendgraphic_kernel"></a> `sendGraphic_Kernel` | `boolean` | Send the graphic of bodies: their faces, edges and vertices. |
|
|
81
|
+
| <a id="property-sendgraphic_multipackage"></a> `sendGraphic_Multipackage` | `boolean` | Send one graphic package per changed object instead of one for all of them. |
|
|
82
|
+
| <a id="property-sendgraphic_sketch"></a> `sendGraphic_Sketch` | `boolean` | Send the graphic of sketches. |
|
|
83
|
+
| <a id="property-sendgraphic_structureobj"></a> `sendGraphic_StructureObj` | `boolean` | Send the graphic of model objects that are not bodies, such as work geometry. |
|
|
84
|
+
| <a id="property-sendgraphic_usedraco"></a> `sendGraphic_UseDraco` | `boolean` | Compress meshes with Draco. buerli's clients do not decode it. |
|
|
85
|
+
| <a id="property-sendgraphic_usedracohybrid"></a> `sendGraphic_UseDracoHybrid` | `boolean` | Compress meshes with Draco in its hybrid form. buerli's clients do not decode it. |
|
|
86
|
+
| <a id="property-sendmessages"></a> `sendMessages` | `boolean` | Send the messages (warnings, errors) of a command. |
|
|
87
|
+
| <a id="property-sendmessages_immediately"></a> `sendMessages_Immediately` | `boolean` | Send messages in frames of their own while the command runs, instead of on its Result. |
|
|
88
|
+
| <a id="property-sendmessages_minlevel"></a> `sendMessages_MinLevel` | `number` | The lowest level of message that is sent (a `MessageLevel`, 31 = info). |
|
|
89
|
+
| <a id="property-sendstructure"></a> `sendStructure` | `boolean` | Send the structure tree after a command that changed it. |
|
|
90
|
+
| <a id="property-sendstructure_compressed"></a> `sendStructure_Compressed` | `boolean` | Send the structure as a base64 string of deflated JSON. |
|
|
91
|
+
| <a id="property-sendstructure_immediately"></a> `sendStructure_Immediately` | `boolean` | Send the structure in frames of its own while the command runs, instead of on its Result. |
|
|
92
|
+
| <a id="property-sendstructure_immediatelybinary"></a> `sendStructure_ImmediatelyBinary` | `boolean` | Send the frames of `sendStructure_Immediately` as binary (deflated) WebSocket frames. |
|
|
93
|
+
| <a id="property-sendstructure_patch"></a> `sendStructure_Patch` | `boolean` | Send structure changes as JSON patches instead of the whole tree. |
|
|
94
|
+
| <a id="property-storestate"></a> `storeState` | `boolean` | Taken and echoed by the engine; it does not act on it. |
|
|
95
|
+
|
|
96
|
+
***
|
|
97
|
+
|
|
98
|
+
### IComClient {#icomclient}
|
|
99
|
+
|
|
100
|
+
What a client does for buerli: connect a drawing to an engine, run commands on it and load its structure.
|
|
101
|
+
|
|
102
|
+
[AwvNodeClient](../clients.md#abstract-awvnodeclient) implements it; the clients ([WASMClient](../clients.md#wasmclient), [WSClient](../clients.md#wsclient), [SocketIOClient](../clients.md#socketioclient))
|
|
103
|
+
extend that.
|
|
104
|
+
|
|
105
|
+
#### Methods
|
|
106
|
+
|
|
107
|
+
##### connect() {#connect}
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
connect(): Promise<IComClient>;
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Connects to the engine; resolves once the drawing's structure tree is loaded and API calls can be made.
|
|
114
|
+
|
|
115
|
+
###### Returns
|
|
116
|
+
|
|
117
|
+
`Promise`<[`IComClient`](#icomclient)>
|
|
118
|
+
|
|
119
|
+
##### disconnect() {#disconnect}
|
|
120
|
+
|
|
121
|
+
```ts
|
|
122
|
+
disconnect(): Promise<IComClient>;
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Closes the connection to the engine.
|
|
126
|
+
|
|
127
|
+
###### Returns
|
|
128
|
+
|
|
129
|
+
`Promise`<[`IComClient`](#icomclient)>
|
|
130
|
+
|
|
131
|
+
##### executeMiddleware() {#executemiddleware}
|
|
132
|
+
|
|
133
|
+
```ts
|
|
134
|
+
executeMiddleware(command, data): {
|
|
135
|
+
};
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Sends a command of the server's own (a middleware command) with `data`.
|
|
139
|
+
|
|
140
|
+
###### Parameters
|
|
141
|
+
|
|
142
|
+
| Parameter | Type | Description |
|
|
143
|
+
| :------ | :------ | :------ |
|
|
144
|
+
| `command` | `string` | The command's name. |
|
|
145
|
+
| `data` | `any` | Fields sent with the command. |
|
|
146
|
+
|
|
147
|
+
###### Returns
|
|
148
|
+
|
|
149
|
+
```ts
|
|
150
|
+
{
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
##### executeRequest() {#executerequest}
|
|
155
|
+
|
|
156
|
+
```ts
|
|
157
|
+
executeRequest(
|
|
158
|
+
task,
|
|
159
|
+
streamMap?,
|
|
160
|
+
options?
|
|
161
|
+
): {
|
|
162
|
+
};
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Runs `task` (API calls) on the engine. Rejects with the reply when it carries an error.
|
|
166
|
+
|
|
167
|
+
###### Parameters
|
|
168
|
+
|
|
169
|
+
| Parameter | Type | Description |
|
|
170
|
+
| :------ | :------ | :------ |
|
|
171
|
+
| `task` | [`Task`](#task) | The API calls to run, e.g. `[{ 'v1.part.create': [{ name: 'Part' }] }]`. |
|
|
172
|
+
| `streamMap?` | [`StreamMap`](#streammap) | Data the calls read, by stream key (a file to import, for example). |
|
|
173
|
+
| `options?` | [`RequestOptions`](#requestoptions) | Options of the request, such as `undoable`. |
|
|
174
|
+
|
|
175
|
+
###### Returns
|
|
176
|
+
|
|
177
|
+
```ts
|
|
178
|
+
{
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
##### getEmissionConfig() {#getemissionconfig}
|
|
183
|
+
|
|
184
|
+
```ts
|
|
185
|
+
getEmissionConfig(): Promise<EmissionConfig>;
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
Per-connection emission config (what the engine pushes back: structure,
|
|
189
|
+
graphic categories, messages, delivery form). `getEmissionConfig` returns the
|
|
190
|
+
effective flags, `setEmissionConfig` merges a partial set and returns the result.
|
|
191
|
+
Rejects with an Error named EMISSION_CONFIG_UNSUPPORTED on engines that
|
|
192
|
+
predate the GetEmissionConfig/SetEmissionConfig commands (old WASM builds, old servers).
|
|
193
|
+
|
|
194
|
+
###### Returns
|
|
195
|
+
|
|
196
|
+
`Promise`<[`EmissionConfig`](#emissionconfig)>
|
|
197
|
+
|
|
198
|
+
##### redo() {#redo}
|
|
199
|
+
|
|
200
|
+
```ts
|
|
201
|
+
redo(options?): {
|
|
202
|
+
};
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Steps forward in the drawing's undo history.
|
|
206
|
+
|
|
207
|
+
###### Parameters
|
|
208
|
+
|
|
209
|
+
| Parameter | Type |
|
|
210
|
+
| :------ | :------ |
|
|
211
|
+
| `options?` | [`RedoOptions`](#redooptions) |
|
|
212
|
+
|
|
213
|
+
###### Returns
|
|
214
|
+
|
|
215
|
+
```ts
|
|
216
|
+
{
|
|
217
|
+
}
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
##### requestTree() {#requesttree}
|
|
221
|
+
|
|
222
|
+
```ts
|
|
223
|
+
requestTree(): {
|
|
224
|
+
};
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
Loads the drawing's structure tree from the engine into the buerli store.
|
|
228
|
+
|
|
229
|
+
###### Returns
|
|
230
|
+
|
|
231
|
+
```ts
|
|
232
|
+
{
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
##### setEmissionConfig() {#setemissionconfig}
|
|
237
|
+
|
|
238
|
+
```ts
|
|
239
|
+
setEmissionConfig(partial): Promise<EmissionConfig>;
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
Merges `partial` into the connection's emission config and resolves to the effective flags. Rejects with an
|
|
243
|
+
Error named [EMISSION\_CONFIG\_UNSUPPORTED](#emission_config_unsupported) on engines that predate the command.
|
|
244
|
+
|
|
245
|
+
###### Parameters
|
|
246
|
+
|
|
247
|
+
| Parameter | Type | Description |
|
|
248
|
+
| :------ | :------ | :------ |
|
|
249
|
+
| `partial` | `Partial`<[`EmissionConfig`](#emissionconfig)> | The flags to change; the others stay as they are. |
|
|
250
|
+
|
|
251
|
+
###### Returns
|
|
252
|
+
|
|
253
|
+
`Promise`<[`EmissionConfig`](#emissionconfig)>
|
|
254
|
+
|
|
255
|
+
##### undo() {#undo}
|
|
256
|
+
|
|
257
|
+
```ts
|
|
258
|
+
undo(options?): {
|
|
259
|
+
};
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
Steps back in the drawing's undo history.
|
|
263
|
+
|
|
264
|
+
###### Parameters
|
|
265
|
+
|
|
266
|
+
| Parameter | Type |
|
|
267
|
+
| :------ | :------ |
|
|
268
|
+
| `options?` | [`UndoOptions`](#undooptions) |
|
|
269
|
+
|
|
270
|
+
###### Returns
|
|
271
|
+
|
|
272
|
+
```ts
|
|
273
|
+
{
|
|
274
|
+
}
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
***
|
|
278
|
+
|
|
279
|
+
### RedoOptions {#redooptions}
|
|
280
|
+
|
|
281
|
+
```ts
|
|
282
|
+
type RedoOptions = {
|
|
283
|
+
[key: string]: any;
|
|
284
|
+
state?: string;
|
|
285
|
+
};
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
Options of a redo; keys other than `state` travel with it to the engine.
|
|
289
|
+
|
|
290
|
+
#### Indexable
|
|
291
|
+
|
|
292
|
+
```ts
|
|
293
|
+
[key: string]: any
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
#### Properties
|
|
297
|
+
|
|
298
|
+
| Property | Type | Description |
|
|
299
|
+
| :------ | :------ | :------ |
|
|
300
|
+
| <a id="property-state"></a> `state?` | `string` | The state of the undo history to go forward to, a name from the drawing's `cad.states.stack`. |
|
|
301
|
+
|
|
302
|
+
***
|
|
303
|
+
|
|
304
|
+
### RequestOptions {#requestoptions}
|
|
305
|
+
|
|
306
|
+
```ts
|
|
307
|
+
type RequestOptions = {
|
|
308
|
+
[key: string]: any;
|
|
309
|
+
undoable?: boolean;
|
|
310
|
+
};
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
Options of a request; keys other than `undoable` travel with it to the engine.
|
|
314
|
+
|
|
315
|
+
#### Indexable
|
|
316
|
+
|
|
317
|
+
```ts
|
|
318
|
+
[key: string]: any
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
#### Properties
|
|
322
|
+
|
|
323
|
+
| Property | Type | Description |
|
|
324
|
+
| :------ | :------ | :------ |
|
|
325
|
+
| <a id="property-undoable"></a> `undoable?` | `boolean` | Makes the request a step of the drawing's undo history, named after its first API call. |
|
|
326
|
+
|
|
327
|
+
***
|
|
328
|
+
|
|
329
|
+
### ServerError {#servererror}
|
|
330
|
+
|
|
331
|
+
```ts
|
|
332
|
+
type ServerError = {
|
|
333
|
+
errorCode: number;
|
|
334
|
+
errorMessage: string;
|
|
335
|
+
errorState: number;
|
|
336
|
+
};
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
An error in the form older engines report it, before `messages`; clients turn it into a [ServerMessage](#servermessage).
|
|
340
|
+
|
|
341
|
+
#### Properties
|
|
342
|
+
|
|
343
|
+
| Property | Type | Description |
|
|
344
|
+
| :------ | :------ | :------ |
|
|
345
|
+
| <a id="property-errorcode"></a> `errorCode` | `number` | The error's code. |
|
|
346
|
+
| <a id="property-errormessage"></a> `errorMessage` | `string` | The error's text. |
|
|
347
|
+
| <a id="property-errorstate"></a> `errorState` | `number` | How bad it is: 0 no error, 1 warning, 2 error (the command went on), 3 error (the command stopped). |
|
|
348
|
+
|
|
349
|
+
***
|
|
350
|
+
|
|
351
|
+
### ServerMessage {#servermessage}
|
|
352
|
+
|
|
353
|
+
```ts
|
|
354
|
+
type ServerMessage = Message;
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
A message of the engine about a command: its text, `code` and `level` (a `MessageLevel`).
|
|
358
|
+
|
|
359
|
+
***
|
|
360
|
+
|
|
361
|
+
### ServerRequest {#serverrequest}
|
|
362
|
+
|
|
363
|
+
```ts
|
|
364
|
+
type ServerRequest = {
|
|
365
|
+
command: | "Execute"
|
|
366
|
+
| "GetTree"
|
|
367
|
+
| "GetEmissionConfig"
|
|
368
|
+
| "SetEmissionConfig"
|
|
369
|
+
| string;
|
|
370
|
+
config?: Partial<EmissionConfig>;
|
|
371
|
+
options?: RequestOptions;
|
|
372
|
+
state?: string;
|
|
373
|
+
streamData?: StreamMap;
|
|
374
|
+
task?: Task;
|
|
375
|
+
};
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
A request to the engine: a command, and what it needs.
|
|
379
|
+
|
|
380
|
+
#### Properties
|
|
381
|
+
|
|
382
|
+
| Property | Type | Description |
|
|
383
|
+
| :------ | :------ | :------ |
|
|
384
|
+
| <a id="property-command"></a> `command` | \| `"Execute"` \| `"GetTree"` \| `"GetEmissionConfig"` \| `"SetEmissionConfig"` \| `string` | The command: `Execute` runs `task`, `GetTree` returns the structure tree; the engine knows more. |
|
|
385
|
+
| <a id="property-config"></a> `config?` | `Partial`<[`EmissionConfig`](#emissionconfig)> | Only for the SetEmissionConfig command: the partial EmissionConfig to merge. The engine ignores this field on every other command - emission flags are a per-CONNECTION setting (see [IComClient.setEmissionConfig](#setemissionconfig)), not per request. |
|
|
386
|
+
| <a id="property-options"></a> `options?` | [`RequestOptions`](#requestoptions) | Options of the request. |
|
|
387
|
+
| <a id="property-state-1"></a> `state?` | `string` | Only for the Undo / Redo commands: the state of the undo history to go to (see UndoStackFrame). |
|
|
388
|
+
| <a id="property-streamdata"></a> `streamData?` | [`StreamMap`](#streammap) | For `Execute`: the data the calls read, by stream key. |
|
|
389
|
+
| <a id="property-task"></a> `task?` | [`Task`](#task) | For `Execute`: the API calls to run. |
|
|
390
|
+
|
|
391
|
+
***
|
|
392
|
+
|
|
393
|
+
### ServerResponse {#serverresponse}
|
|
394
|
+
|
|
395
|
+
```ts
|
|
396
|
+
type ServerResponse = {
|
|
397
|
+
maxLevel?: number;
|
|
398
|
+
messages?: Message[];
|
|
399
|
+
result?: any;
|
|
400
|
+
streamData?: {
|
|
401
|
+
[key: string]: string;
|
|
402
|
+
};
|
|
403
|
+
};
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
The engine's reply to a request: the result, and the messages that came with it.
|
|
407
|
+
|
|
408
|
+
A client rejects with the reply when `maxLevel` is an error or worse.
|
|
409
|
+
|
|
410
|
+
#### Properties
|
|
411
|
+
|
|
412
|
+
| Property | Type | Description |
|
|
413
|
+
| :------ | :------ | :------ |
|
|
414
|
+
| <a id="property-maxlevel"></a> `maxLevel?` | `number` | The highest level among `messages` (a `MessageLevel`); undefined without messages. |
|
|
415
|
+
| <a id="property-messages"></a> `messages?` | `Message`[] | The warnings and errors of the command. |
|
|
416
|
+
| <a id="property-result"></a> `result?` | `any` | The command's result, e.g. the id of a new object. |
|
|
417
|
+
| <a id="property-streamdata-1"></a> `streamData?` | \{ \[`key`: `string`\]: `string`; \} | Data the command returned by stream key, such as the content of an export. |
|
|
418
|
+
|
|
419
|
+
***
|
|
420
|
+
|
|
421
|
+
### StreamData {#streamdata}
|
|
422
|
+
|
|
423
|
+
```ts
|
|
424
|
+
type StreamData = any;
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
The data of one stream: the content of a file, for example.
|
|
428
|
+
|
|
429
|
+
***
|
|
430
|
+
|
|
431
|
+
### StreamMap {#streammap}
|
|
432
|
+
|
|
433
|
+
```ts
|
|
434
|
+
type StreamMap = Record<string, StreamData>;
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
Data sent with a request or returned by it, by stream key; API calls refer to it by that key.
|
|
438
|
+
|
|
439
|
+
***
|
|
440
|
+
|
|
441
|
+
### Task {#task}
|
|
442
|
+
|
|
443
|
+
```ts
|
|
444
|
+
type Task =
|
|
445
|
+
| {
|
|
446
|
+
[apiCommand: string]: (string | number)[];
|
|
447
|
+
}[]
|
|
448
|
+
| string;
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
What an `Execute` request runs: a list of API calls, or a command as a string.
|
|
452
|
+
|
|
453
|
+
Each API call is `{ '<version>.<namespace>.<function>': [args] }`.
|
|
454
|
+
|
|
455
|
+
***
|
|
456
|
+
|
|
457
|
+
### UndoOptions {#undooptions}
|
|
458
|
+
|
|
459
|
+
```ts
|
|
460
|
+
type UndoOptions = {
|
|
461
|
+
[key: string]: any;
|
|
462
|
+
state?: string;
|
|
463
|
+
};
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
Options of an undo; keys other than `state` travel with it to the engine.
|
|
467
|
+
|
|
468
|
+
#### Indexable
|
|
469
|
+
|
|
470
|
+
```ts
|
|
471
|
+
[key: string]: any
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
#### Properties
|
|
475
|
+
|
|
476
|
+
| Property | Type | Description |
|
|
477
|
+
| :------ | :------ | :------ |
|
|
478
|
+
| <a id="property-state-2"></a> `state?` | `string` | The state of the undo history to go back to, a name from the drawing's `cad.states.stack`. |
|
|
479
|
+
|
|
480
|
+
## Constants
|
|
481
|
+
|
|
482
|
+
### EMISSION\_CONFIG\_UNSUPPORTED {#emission_config_unsupported}
|
|
483
|
+
|
|
484
|
+
```ts
|
|
485
|
+
const EMISSION_CONFIG_UNSUPPORTED: "EmissionConfigUnsupported" = 'EmissionConfigUnsupported';
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
`Error.name` of the rejection when the engine does not support GetEmissionConfig/SetEmissionConfig.
|