@selvajs/compute 1.5.2-beta.0 → 1.5.2-beta.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/README.md +12 -8
- package/dist/chunk-2D74PNQU.cjs +2 -0
- package/dist/chunk-2D74PNQU.cjs.map +1 -0
- package/dist/chunk-5465MDT4.cjs +2 -0
- package/dist/chunk-5465MDT4.cjs.map +1 -0
- package/dist/chunk-DADFXYBV.js +2 -0
- package/dist/chunk-DADFXYBV.js.map +1 -0
- package/dist/chunk-MZGKJZVP.cjs +2 -0
- package/dist/chunk-MZGKJZVP.cjs.map +1 -0
- package/dist/chunk-RHULSS7S.js +3 -0
- package/dist/chunk-RHULSS7S.js.map +1 -0
- package/dist/chunk-VWOEUM7C.cjs +3 -0
- package/dist/chunk-VWOEUM7C.cjs.map +1 -0
- package/dist/chunk-XIBQV4XW.js +2 -0
- package/dist/chunk-XIBQV4XW.js.map +1 -0
- package/dist/chunk-XLHA5YPH.js +2 -0
- package/dist/chunk-XLHA5YPH.js.map +1 -0
- package/dist/core.cjs +1 -1
- package/dist/core.d.cts +3 -21
- package/dist/core.d.ts +3 -21
- package/dist/core.js +1 -1
- package/dist/errors-CiA83qw2.d.cts +510 -0
- package/dist/errors-CiA83qw2.d.ts +510 -0
- package/dist/grasshopper.cjs +1 -1
- package/dist/grasshopper.d.cts +75 -142
- package/dist/grasshopper.d.ts +75 -142
- package/dist/grasshopper.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +3 -5
- package/dist/index.d.ts +3 -5
- package/dist/index.js +1 -1
- package/dist/visualization-3HFOMXUY.cjs +2 -0
- package/dist/visualization-3HFOMXUY.cjs.map +1 -0
- package/dist/visualization-XXHESVUI.js +2 -0
- package/dist/visualization-XXHESVUI.js.map +1 -0
- package/dist/visualization.cjs +1 -1
- package/dist/visualization.cjs.map +1 -1
- package/dist/visualization.d.cts +1 -76
- package/dist/visualization.d.ts +1 -76
- package/dist/visualization.js +1 -1
- package/dist/visualization.js.map +1 -1
- package/package.json +1 -1
- package/dist/base-dtik4Dlu.d.cts +0 -138
- package/dist/base-dtik4Dlu.d.ts +0 -138
- package/dist/chunk-2NFN5ERT.cjs +0 -2
- package/dist/chunk-2NFN5ERT.cjs.map +0 -1
- package/dist/chunk-BKGFHI2J.js +0 -2
- package/dist/chunk-BKGFHI2J.js.map +0 -1
- package/dist/chunk-CZCPL35F.js +0 -3
- package/dist/chunk-CZCPL35F.js.map +0 -1
- package/dist/chunk-JSS6OQML.cjs +0 -2
- package/dist/chunk-JSS6OQML.cjs.map +0 -1
- package/dist/chunk-XULONXVP.cjs +0 -3
- package/dist/chunk-XULONXVP.cjs.map +0 -1
- package/dist/chunk-XZUTU46G.js +0 -2
- package/dist/chunk-XZUTU46G.js.map +0 -1
- package/dist/schemas-Ct7lU-IH.d.cts +0 -247
- package/dist/schemas-Ct7lU-IH.d.ts +0 -247
- package/dist/types-B24K2LG4.d.cts +0 -85
- package/dist/types-B24K2LG4.d.ts +0 -85
|
@@ -0,0 +1,510 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rhino model unit types supported by Rhino.Compute
|
|
3
|
+
*/
|
|
4
|
+
type RhinoModelUnit = 'None' | 'Microns' | 'Millimeters' | 'Centimeters' | 'Meters' | 'Kilometers' | 'Microinches' | 'Mils' | 'Inches' | 'Feet' | 'Miles' | 'CustomUnits' | 'Angstroms' | 'Nanometers' | 'Decimeters' | 'Dekameters' | 'Hectometers' | 'Megameters' | 'Gigameters' | 'Yards' | 'PrinterPoints' | 'PrinterPicas' | 'NauticalMiles' | 'AstronomicalUnits' | 'LightYears' | 'Parsecs' | 'Unset';
|
|
5
|
+
/**
|
|
6
|
+
* Retry policy for transient errors (network, 502, 503, 504, optionally 429).
|
|
7
|
+
*
|
|
8
|
+
* Retries use exponential backoff with jitter, capped at `maxDelayMs`.
|
|
9
|
+
* If the server returns `Retry-After`, that value is honored instead.
|
|
10
|
+
*/
|
|
11
|
+
interface RetryPolicy {
|
|
12
|
+
/** Maximum number of retry attempts after the initial request (default: 0). */
|
|
13
|
+
attempts?: number;
|
|
14
|
+
/** Base delay in milliseconds for exponential backoff (default: 500). */
|
|
15
|
+
baseDelayMs?: number;
|
|
16
|
+
/** Upper bound for backoff delay (default: 30_000). */
|
|
17
|
+
maxDelayMs?: number;
|
|
18
|
+
/** Whether to retry on 429 responses (default: true — honors Retry-After). */
|
|
19
|
+
retryOn429?: boolean;
|
|
20
|
+
}
|
|
21
|
+
interface ComputeConfig {
|
|
22
|
+
/** The base URL of the Rhino Compute server (e.g., http://localhost:6500) */
|
|
23
|
+
serverUrl: string;
|
|
24
|
+
/** Optional API key for authenticating with the server (RhinoComputeKey) */
|
|
25
|
+
apiKey?: string;
|
|
26
|
+
/** Optional Bearer token for authentication (e.g., when behind a proxy or API gateway) */
|
|
27
|
+
authToken?: string;
|
|
28
|
+
/** Enable debug logging to the console */
|
|
29
|
+
debug?: boolean;
|
|
30
|
+
/** Suppress browser security warnings in the console */
|
|
31
|
+
suppressBrowserWarning?: boolean;
|
|
32
|
+
/** @deprecated Renamed to `suppressBrowserWarning`. */
|
|
33
|
+
suppressClientSideWarning?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Per-request timeout in milliseconds. Set to `0` to disable (useful for long
|
|
36
|
+
* solves where any timeout is the wrong answer). Default: no timeout.
|
|
37
|
+
*
|
|
38
|
+
* Uses `AbortSignal.timeout` so the timer is not throttled when the tab is hidden.
|
|
39
|
+
*/
|
|
40
|
+
timeoutMs?: number;
|
|
41
|
+
/**
|
|
42
|
+
* Retry policy for transient errors. Default: no retries.
|
|
43
|
+
*/
|
|
44
|
+
retry?: RetryPolicy;
|
|
45
|
+
/**
|
|
46
|
+
* Optional caller-supplied AbortSignal. Composes with the internal timeout —
|
|
47
|
+
* whichever fires first wins. Lets callers cancel in-flight requests
|
|
48
|
+
* (e.g. on component unmount or when superseding a stale solve).
|
|
49
|
+
*/
|
|
50
|
+
signal?: AbortSignal;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Grasshopper types
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Grasshopper-style data tree branch path
|
|
59
|
+
* @example "{0}", "{0;0}", "{0;1;2}"
|
|
60
|
+
*/
|
|
61
|
+
type DataTreePath = `{${string}}`;
|
|
62
|
+
/**
|
|
63
|
+
* Represents a data item in a data tree
|
|
64
|
+
*/
|
|
65
|
+
interface DataItem {
|
|
66
|
+
/** The type of the data, inferred from the Grasshopper GOO class */
|
|
67
|
+
type: string;
|
|
68
|
+
/** The actual returned data as a string that may need to be parsed */
|
|
69
|
+
data: string;
|
|
70
|
+
/** The grasshopper refrence id of the output */
|
|
71
|
+
id: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Grasshopper-style data tree for input defaults
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* const numericTree: DataTreeDefault<number> = {
|
|
78
|
+
* "{0}": [1, 2, 3],
|
|
79
|
+
* "{0;0}": [4, 5],
|
|
80
|
+
* "{1}": [6]
|
|
81
|
+
* };
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
type DataTreeDefault<T = any> = {
|
|
85
|
+
[K in DataTreePath]?: T[];
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Data structure for InnerTreeData matching Rhino Compute responses
|
|
89
|
+
*/
|
|
90
|
+
type InnerTreeData = {
|
|
91
|
+
[path in DataTreePath]: DataItem[];
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Tree with parameter metadata (used in compute responses)
|
|
95
|
+
*/
|
|
96
|
+
interface DataTree {
|
|
97
|
+
InnerTree: InnerTreeData;
|
|
98
|
+
ParamName: string;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Output types supported from Grasshopper/Rhino Compute
|
|
102
|
+
*/
|
|
103
|
+
type OutputType = 'System.String' | 'System.Double' | 'System.Int32' | 'System.Boolean' | 'Rhino.Geometry.Point3d' | 'Rhino.Geometry.Line' | 'Rhino.Geometry.Circle' | 'Rhino.Geometry.Arc' | 'Rhino.Geometry.NurbsCurve' | 'Rhino.Geometry.Brep' | 'Rhino.Geometry.Mesh' | 'Rhino.Geometry.Vector3d' | 'Rhino.Geometry.Plane' | 'Rhino.Geometry.Box' | string;
|
|
104
|
+
/**
|
|
105
|
+
* Union type for all possible default value types
|
|
106
|
+
*/
|
|
107
|
+
type DefaultValue<T> = T | T[] | DataTreeDefault<T> | undefined | null;
|
|
108
|
+
/**
|
|
109
|
+
* Base properties common to all processed input types.
|
|
110
|
+
* Note: `groupName` and `id` require the custom Rhino Compute branch.
|
|
111
|
+
*/
|
|
112
|
+
interface BaseInputType {
|
|
113
|
+
description: string;
|
|
114
|
+
name: string;
|
|
115
|
+
nickname: string | null;
|
|
116
|
+
treeAccess: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Name of the group this parameter belongs to.
|
|
119
|
+
* @requires Custom branch of compute.rhino3d
|
|
120
|
+
*/
|
|
121
|
+
groupName?: string;
|
|
122
|
+
/**
|
|
123
|
+
* Unique identifier for the parameter.
|
|
124
|
+
* @requires Custom branch of compute.rhino3d
|
|
125
|
+
*/
|
|
126
|
+
id?: string;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Numeric input type (Number or Integer)
|
|
130
|
+
*/
|
|
131
|
+
interface NumericInputType extends BaseInputType {
|
|
132
|
+
paramType: 'Number' | 'Integer';
|
|
133
|
+
minimum?: number | null;
|
|
134
|
+
maximum?: number | null;
|
|
135
|
+
atLeast?: number | null;
|
|
136
|
+
atMost?: number | null;
|
|
137
|
+
stepSize?: number | null;
|
|
138
|
+
default: DefaultValue<number>;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Text input type
|
|
142
|
+
*/
|
|
143
|
+
interface TextInputType extends BaseInputType {
|
|
144
|
+
paramType: 'Text';
|
|
145
|
+
default: DefaultValue<string>;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Boolean input type
|
|
149
|
+
*/
|
|
150
|
+
interface BooleanInputType extends BaseInputType {
|
|
151
|
+
paramType: 'Boolean';
|
|
152
|
+
default: DefaultValue<boolean>;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Geometry input type (generic geometry)
|
|
156
|
+
*/
|
|
157
|
+
interface GeometryInputType extends BaseInputType {
|
|
158
|
+
paramType: 'Geometry';
|
|
159
|
+
default: DefaultValue<object | string>;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* ValueList input type (dropdown/select)
|
|
163
|
+
*/
|
|
164
|
+
interface ValueListInputType extends BaseInputType {
|
|
165
|
+
paramType: 'ValueList';
|
|
166
|
+
values: Record<string, string>;
|
|
167
|
+
default?: string;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* File input type
|
|
171
|
+
*/
|
|
172
|
+
interface FileInputType extends BaseInputType {
|
|
173
|
+
paramType: 'File';
|
|
174
|
+
acceptedFormats?: string[];
|
|
175
|
+
default: DefaultValue<object | string>;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Color input type (stored as hex string)
|
|
179
|
+
*/
|
|
180
|
+
interface ColorInputType extends BaseInputType {
|
|
181
|
+
paramType: 'Color';
|
|
182
|
+
default: DefaultValue<string>;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Discriminated union of all input parameter types
|
|
186
|
+
*/
|
|
187
|
+
type InputParam = NumericInputType | BooleanInputType | TextInputType | ValueListInputType | GeometryInputType | FileInputType | ColorInputType;
|
|
188
|
+
/**
|
|
189
|
+
* Base Grasshopper schema properties shared by config, args, and response
|
|
190
|
+
*/
|
|
191
|
+
interface GrasshopperBaseSchema {
|
|
192
|
+
/** Absolute tolerance used in computation */
|
|
193
|
+
absolutetolerance?: number | null;
|
|
194
|
+
/** Angular tolerance used in computation */
|
|
195
|
+
angletolerance?: number | null;
|
|
196
|
+
/** Model units used */
|
|
197
|
+
modelunits?: RhinoModelUnit | null;
|
|
198
|
+
/** Data version (7 or 8) */
|
|
199
|
+
dataversion?: 7 | 8 | null;
|
|
200
|
+
/** Whether to use cached solution */
|
|
201
|
+
cachesolve?: boolean | null;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Definition source (used in args and response)
|
|
205
|
+
*/
|
|
206
|
+
interface GrasshopperDefinitionSource {
|
|
207
|
+
/** Base64 encoded algorithm (if embedded) */
|
|
208
|
+
algo?: string | null;
|
|
209
|
+
/** URL pointer to definition file */
|
|
210
|
+
pointer?: string | null;
|
|
211
|
+
/** Filename of the definition */
|
|
212
|
+
filename?: string | null;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Configuration for Grasshopper compute operations
|
|
216
|
+
* Combines server config with optional Grasshopper-specific computation settings
|
|
217
|
+
*
|
|
218
|
+
* Note: The definition source (pointer/algo) is NOT part of config.
|
|
219
|
+
* Instead, pass the definition directly to methods like solve(), getIO(), etc.
|
|
220
|
+
*/
|
|
221
|
+
interface GrasshopperComputeConfig extends ComputeConfig {
|
|
222
|
+
/** Absolute tolerance used in computation */
|
|
223
|
+
absolutetolerance?: number | null;
|
|
224
|
+
/** Angular tolerance used in computation */
|
|
225
|
+
angletolerance?: number | null;
|
|
226
|
+
/** Model units used */
|
|
227
|
+
modelunits?: RhinoModelUnit | null;
|
|
228
|
+
/** Data version (7 or 8) */
|
|
229
|
+
dataversion?: 7 | 8 | null;
|
|
230
|
+
/** Whether to use cached solution */
|
|
231
|
+
cachesolve?: boolean | null;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Raw I/O response schema from API (PascalCase)
|
|
235
|
+
*
|
|
236
|
+
* This is the direct response format from the Rhino Compute server API.
|
|
237
|
+
* All property names are in PascalCase, which is typical for .NET APIs.
|
|
238
|
+
* This raw response is converted to camelCase by the camelcaseKeys() function
|
|
239
|
+
* in the fetchDefinitionIO() method.
|
|
240
|
+
*/
|
|
241
|
+
interface IoResponseSchema {
|
|
242
|
+
description: string;
|
|
243
|
+
filename: string;
|
|
244
|
+
cachekey: string;
|
|
245
|
+
inputnames: string[];
|
|
246
|
+
outputnames: string[];
|
|
247
|
+
icon: string | null;
|
|
248
|
+
inputs: InputParamSchema[];
|
|
249
|
+
outputs: OutputParamSchema[];
|
|
250
|
+
warnings: any[];
|
|
251
|
+
errors: any[];
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Arguments sent to Grasshopper compute endpoint
|
|
255
|
+
* Includes config options + definition source + input values
|
|
256
|
+
*/
|
|
257
|
+
interface GrasshopperRequestSchema extends GrasshopperBaseSchema, GrasshopperDefinitionSource {
|
|
258
|
+
/** Input values organized by parameter */
|
|
259
|
+
values?: DataTree[];
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Response from Grasshopper compute server
|
|
263
|
+
* Includes all schema fields + computed results
|
|
264
|
+
*/
|
|
265
|
+
interface GrasshopperComputeResponse extends GrasshopperBaseSchema, GrasshopperDefinitionSource {
|
|
266
|
+
/** Whether cache was used (always present in response) */
|
|
267
|
+
cachesolve: boolean;
|
|
268
|
+
/** Model units (always present in response) */
|
|
269
|
+
modelunits: RhinoModelUnit;
|
|
270
|
+
/** Base64 encoded algorithm (always present in response) */
|
|
271
|
+
algo: string;
|
|
272
|
+
/** Filename of the definition (always present in response) */
|
|
273
|
+
filename: string | null;
|
|
274
|
+
/** Data version */
|
|
275
|
+
dataversion: 7 | 8;
|
|
276
|
+
/** Recursion level used */
|
|
277
|
+
recursionlevel?: number;
|
|
278
|
+
/** Output values organized by parameter */
|
|
279
|
+
values: DataTree[];
|
|
280
|
+
/** Computation errors */
|
|
281
|
+
errors?: string[];
|
|
282
|
+
/** Computation warnings */
|
|
283
|
+
warnings?: string[];
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Output parameter
|
|
287
|
+
*/
|
|
288
|
+
interface OutputParamSchema {
|
|
289
|
+
name: string;
|
|
290
|
+
nickname: string | null;
|
|
291
|
+
paramType: string;
|
|
292
|
+
/**
|
|
293
|
+
* Grasshopper parameter instance GUID
|
|
294
|
+
*/
|
|
295
|
+
id: string;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Input parameter
|
|
299
|
+
*/
|
|
300
|
+
interface InputParamSchema {
|
|
301
|
+
/**
|
|
302
|
+
* Grasshopper parameter instance GUID
|
|
303
|
+
*/
|
|
304
|
+
id: string;
|
|
305
|
+
name: string;
|
|
306
|
+
nickname: string | null;
|
|
307
|
+
description: string;
|
|
308
|
+
paramType: string;
|
|
309
|
+
treeAccess: boolean;
|
|
310
|
+
minimum: number | null;
|
|
311
|
+
maximum: number | null;
|
|
312
|
+
atLeast: number;
|
|
313
|
+
atMost: number;
|
|
314
|
+
stepSize?: number;
|
|
315
|
+
default: any;
|
|
316
|
+
/**
|
|
317
|
+
* Key-value pairs for dropdown options
|
|
318
|
+
*/
|
|
319
|
+
values?: Record<string, string>;
|
|
320
|
+
/**
|
|
321
|
+
* Accepted file formats for File input
|
|
322
|
+
*/
|
|
323
|
+
acceptedFormats?: string[];
|
|
324
|
+
groupName?: string | null;
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Parsed input/output structure with raw schemas
|
|
328
|
+
*/
|
|
329
|
+
interface GrasshopperParsedIORaw {
|
|
330
|
+
inputs: InputParamSchema[];
|
|
331
|
+
outputs: OutputParamSchema[];
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Per-input parse failure. The corresponding entry in `inputs` was filled
|
|
335
|
+
* with a safe default so the rest of the pipeline can keep going — but the
|
|
336
|
+
* caller should surface this so the user knows their definition has a
|
|
337
|
+
* misconfigured parameter.
|
|
338
|
+
*/
|
|
339
|
+
interface InputParseError {
|
|
340
|
+
/** The input's `name` (or `'unknown'` if the schema didn't have one). */
|
|
341
|
+
inputName: string;
|
|
342
|
+
/** The declared paramType from the raw schema. */
|
|
343
|
+
paramType: string;
|
|
344
|
+
/** Human-readable reason from the underlying RhinoComputeError. */
|
|
345
|
+
message: string;
|
|
346
|
+
/** Error code from the underlying RhinoComputeError, if available. */
|
|
347
|
+
code?: string;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Parsed input/output structure with processed types.
|
|
351
|
+
*
|
|
352
|
+
* `parseErrors` is populated when one or more inputs failed validation and
|
|
353
|
+
* fell back to a safe default. The result is still usable, but the UI should
|
|
354
|
+
* surface these so the user can fix their definition.
|
|
355
|
+
*/
|
|
356
|
+
interface GrasshopperParsedIO {
|
|
357
|
+
inputs: InputParam[];
|
|
358
|
+
outputs: OutputParamSchema[];
|
|
359
|
+
parseErrors?: InputParseError[];
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* ComputeServerStats provides methods to query Rhino Compute server statistics.
|
|
364
|
+
*
|
|
365
|
+
* @public Use this for server health monitoring and statistics.
|
|
366
|
+
*
|
|
367
|
+
* @example
|
|
368
|
+
* ```typescript
|
|
369
|
+
* const stats = new ComputeServerStats('http://localhost:6500', 'your-api-key');
|
|
370
|
+
*
|
|
371
|
+
* try {
|
|
372
|
+
* const isOnline = await stats.isServerOnline();
|
|
373
|
+
* const children = await stats.getActiveChildren();
|
|
374
|
+
* const version = await stats.getVersion();
|
|
375
|
+
*
|
|
376
|
+
* // Or get everything at once
|
|
377
|
+
* const allStats = await stats.getServerStats();
|
|
378
|
+
* } finally {
|
|
379
|
+
* await stats.dispose(); // Clean up resources
|
|
380
|
+
* }
|
|
381
|
+
* ```
|
|
382
|
+
*/
|
|
383
|
+
declare class ComputeServerStats {
|
|
384
|
+
private readonly serverUrl;
|
|
385
|
+
private readonly apiKey?;
|
|
386
|
+
private disposed;
|
|
387
|
+
private activeMonitors;
|
|
388
|
+
private activeTimeouts;
|
|
389
|
+
/**
|
|
390
|
+
* @param serverUrl - Base URL of the Rhino Compute server with http:// or https:// scheme (e.g., 'http://localhost:6500')
|
|
391
|
+
* @param apiKey - Optional API key for authentication
|
|
392
|
+
*/
|
|
393
|
+
constructor(serverUrl: string, apiKey?: string);
|
|
394
|
+
/**
|
|
395
|
+
* Build request headers with optional API key.
|
|
396
|
+
*/
|
|
397
|
+
private buildHeaders;
|
|
398
|
+
/**
|
|
399
|
+
* Check if the server is online.
|
|
400
|
+
*/
|
|
401
|
+
isServerOnline(): Promise<boolean>;
|
|
402
|
+
/**
|
|
403
|
+
* Get the number of active child processes on the server.
|
|
404
|
+
*
|
|
405
|
+
* @returns Number of active children, or null if unavailable
|
|
406
|
+
*/
|
|
407
|
+
getActiveChildren(): Promise<number | null>;
|
|
408
|
+
/**
|
|
409
|
+
* Get the server version information.
|
|
410
|
+
*
|
|
411
|
+
* @returns Version object with rhino, compute, and git_sha, or null if unavailable
|
|
412
|
+
*/
|
|
413
|
+
getVersion(): Promise<{
|
|
414
|
+
rhino: string;
|
|
415
|
+
compute: string;
|
|
416
|
+
git_sha: string | null;
|
|
417
|
+
} | null>;
|
|
418
|
+
/**
|
|
419
|
+
* Get comprehensive server statistics.
|
|
420
|
+
* Fetches all available server information in parallel.
|
|
421
|
+
*
|
|
422
|
+
* @returns Object containing server status and available stats
|
|
423
|
+
*/
|
|
424
|
+
getServerStats(): Promise<{
|
|
425
|
+
isOnline: boolean;
|
|
426
|
+
version?: {
|
|
427
|
+
rhino: string;
|
|
428
|
+
compute: string;
|
|
429
|
+
git_sha: string | null;
|
|
430
|
+
};
|
|
431
|
+
activeChildren?: number;
|
|
432
|
+
}>;
|
|
433
|
+
/**
|
|
434
|
+
* Continuously monitor server stats at specified interval.
|
|
435
|
+
*
|
|
436
|
+
* @param callback - Function called with stats on each interval
|
|
437
|
+
* @param intervalMs - Milliseconds between checks (default: 5000)
|
|
438
|
+
* @returns Function to stop monitoring
|
|
439
|
+
*
|
|
440
|
+
* @example
|
|
441
|
+
* ```typescript
|
|
442
|
+
* const stopMonitoring = stats.monitor((data) => {
|
|
443
|
+
* console.log('Server stats:', data);
|
|
444
|
+
* }, 3000);
|
|
445
|
+
*
|
|
446
|
+
* // Later...
|
|
447
|
+
* stopMonitoring();
|
|
448
|
+
* ```
|
|
449
|
+
*/
|
|
450
|
+
monitor(callback: (stats: Awaited<ReturnType<typeof this.getServerStats>>) => void, intervalMs?: number): () => void;
|
|
451
|
+
/**
|
|
452
|
+
* Disposes of all resources and stops all active monitors.
|
|
453
|
+
* Call this when you're done using the stats instance.
|
|
454
|
+
*/
|
|
455
|
+
dispose(): Promise<void>;
|
|
456
|
+
/**
|
|
457
|
+
* Ensures the instance hasn't been disposed.
|
|
458
|
+
*/
|
|
459
|
+
private ensureNotDisposed;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* Error types and codes for `@selvajs/compute`.
|
|
464
|
+
*/
|
|
465
|
+
declare const ErrorCodes: {
|
|
466
|
+
readonly NETWORK_ERROR: "NETWORK_ERROR";
|
|
467
|
+
readonly AUTH_ERROR: "AUTH_ERROR";
|
|
468
|
+
readonly VALIDATION_ERROR: "VALIDATION_ERROR";
|
|
469
|
+
readonly COMPUTATION_ERROR: "COMPUTATION_ERROR";
|
|
470
|
+
readonly TIMEOUT_ERROR: "TIMEOUT_ERROR";
|
|
471
|
+
readonly CORS_ERROR: "CORS_ERROR";
|
|
472
|
+
readonly UNKNOWN_ERROR: "UNKNOWN_ERROR";
|
|
473
|
+
readonly INVALID_STATE: "INVALID_STATE";
|
|
474
|
+
readonly INVALID_INPUT: "INVALID_INPUT";
|
|
475
|
+
readonly INVALID_CONFIG: "INVALID_CONFIG";
|
|
476
|
+
readonly BROWSER_ONLY: "BROWSER_ONLY";
|
|
477
|
+
readonly ENVIRONMENT_ERROR: "ENVIRONMENT_ERROR";
|
|
478
|
+
readonly ENCODING_ERROR: "ENCODING_ERROR";
|
|
479
|
+
/** Scheduler latest-wins: this call was replaced by a newer one. */
|
|
480
|
+
readonly SUPERSEDED: "SUPERSEDED";
|
|
481
|
+
/** Scheduler / caller-supplied AbortSignal: this call was aborted. */
|
|
482
|
+
readonly ABORTED: "ABORTED";
|
|
483
|
+
};
|
|
484
|
+
type ErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];
|
|
485
|
+
/**
|
|
486
|
+
* Simplified error for Rhino Compute operations
|
|
487
|
+
*
|
|
488
|
+
* @public Use this for error handling with error codes and context.
|
|
489
|
+
*/
|
|
490
|
+
declare class RhinoComputeError extends Error {
|
|
491
|
+
readonly code: string;
|
|
492
|
+
readonly statusCode?: number;
|
|
493
|
+
readonly context?: Record<string, unknown>;
|
|
494
|
+
readonly originalError?: Error;
|
|
495
|
+
constructor(message: string, code?: string, options?: {
|
|
496
|
+
statusCode?: number;
|
|
497
|
+
context?: Record<string, unknown>;
|
|
498
|
+
originalError?: Error;
|
|
499
|
+
});
|
|
500
|
+
/**
|
|
501
|
+
* Create an error for missing/empty values
|
|
502
|
+
*/
|
|
503
|
+
static missingValues(inputName: string, expectedType?: string, context?: Record<string, unknown>): RhinoComputeError;
|
|
504
|
+
/**
|
|
505
|
+
* Create an error for unknown parameter type
|
|
506
|
+
*/
|
|
507
|
+
static unknownParamType(paramType: string, paramName?: string, context?: Record<string, unknown>): RhinoComputeError;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
export { type BooleanInputType as B, type ComputeConfig as C, type DataItem as D, type ErrorCode as E, type FileInputType as F, type GeometryInputType as G, type InnerTreeData as I, type NumericInputType as N, type OutputParamSchema as O, type RetryPolicy as R, type TextInputType as T, type ValueListInputType as V, ComputeServerStats as a, type DataTree as b, type DataTreeDefault as c, type DataTreePath as d, type DefaultValue as e, ErrorCodes as f, type GrasshopperComputeConfig as g, type GrasshopperComputeResponse as h, type GrasshopperParsedIO as i, type GrasshopperParsedIORaw as j, type GrasshopperRequestSchema as k, type InputParam as l, type InputParamSchema as m, type OutputType as n, RhinoComputeError as o, type RhinoModelUnit as p, type IoResponseSchema as q };
|