@selvajs/compute 4.0.0-beta.1 → 4.0.0-beta.4
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 +7 -3
- package/dist/chunk-AYH5O3VG.js +4 -0
- package/dist/chunk-AYH5O3VG.js.map +1 -0
- package/dist/chunk-MLPWPV6F.cjs +4 -0
- package/dist/chunk-MLPWPV6F.cjs.map +1 -0
- package/dist/core.cjs +1 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +81 -56
- package/dist/core.d.ts +81 -56
- package/dist/core.js +1 -1
- package/dist/grasshopper.cjs +1 -1
- package/dist/grasshopper.cjs.map +1 -1
- package/dist/grasshopper.d.cts +371 -65
- package/dist/grasshopper.d.ts +371 -65
- package/dist/grasshopper.js +1 -1
- package/dist/grasshopper.js.map +1 -1
- package/dist/handle-files-DMK9bCOW.d.cts +231 -0
- package/dist/handle-files-DMK9bCOW.d.ts +231 -0
- package/dist/index.cjs +1 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -3
- package/dist/index.d.ts +2 -3
- package/dist/index.js +0 -1
- package/package.json +1 -1
- package/dist/chunk-BCVDB6AE.js +0 -2
- package/dist/chunk-BCVDB6AE.js.map +0 -1
- package/dist/chunk-BVMGO7IG.cjs +0 -2
- package/dist/chunk-BVMGO7IG.cjs.map +0 -1
- package/dist/chunk-LLUNR66G.cjs +0 -4
- package/dist/chunk-LLUNR66G.cjs.map +0 -1
- package/dist/chunk-XT3XWDDV.js +0 -4
- package/dist/chunk-XT3XWDDV.js.map +0 -1
- package/dist/handle-files-DcA24IkS.d.cts +0 -478
- package/dist/handle-files-DcA24IkS.d.ts +0 -478
|
@@ -1,478 +0,0 @@
|
|
|
1
|
-
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';
|
|
2
|
-
interface RetryPolicy {
|
|
3
|
-
/** Maximum number of retry attempts after the initial request (default: 0). */
|
|
4
|
-
attempts?: number;
|
|
5
|
-
/** Base delay in milliseconds for exponential backoff (default: 500). */
|
|
6
|
-
baseDelayMs?: number;
|
|
7
|
-
/** Upper bound for backoff delay (default: 30_000). */
|
|
8
|
-
maxDelayMs?: number;
|
|
9
|
-
/** Whether to retry on 429 responses (default: true — honors Retry-After). */
|
|
10
|
-
retryOn429?: boolean;
|
|
11
|
-
}
|
|
12
|
-
interface ComputeConfig {
|
|
13
|
-
serverUrl: string;
|
|
14
|
-
/** Optional API key for authenticating with the server (RhinoComputeKey) */
|
|
15
|
-
apiKey?: string;
|
|
16
|
-
/** Optional Bearer token for authentication (e.g., when behind a proxy or API gateway) */
|
|
17
|
-
authToken?: string;
|
|
18
|
-
headers?: Record<string, string>;
|
|
19
|
-
/** Enable debug logging to the console */
|
|
20
|
-
debug?: boolean;
|
|
21
|
-
/** Suppress browser security warnings in the console */
|
|
22
|
-
suppressBrowserWarning?: boolean;
|
|
23
|
-
/** @deprecated Renamed to `suppressBrowserWarning`. */
|
|
24
|
-
suppressClientSideWarning?: boolean;
|
|
25
|
-
timeoutMs?: number;
|
|
26
|
-
/**
|
|
27
|
-
* Retry policy for transient errors. Default: no retries.
|
|
28
|
-
*/
|
|
29
|
-
retry?: RetryPolicy;
|
|
30
|
-
/**
|
|
31
|
-
* Optional caller-supplied AbortSignal. Composes with the internal timeout —
|
|
32
|
-
* whichever fires first wins. Lets callers cancel in-flight requests
|
|
33
|
-
* (e.g. on component unmount or when superseding a stale solve).
|
|
34
|
-
*/
|
|
35
|
-
signal?: AbortSignal;
|
|
36
|
-
onServerTiming?: (timing: ServerTiming, requestId: string) => void;
|
|
37
|
-
}
|
|
38
|
-
interface ServerTiming {
|
|
39
|
-
decode?: number;
|
|
40
|
-
solve?: number;
|
|
41
|
-
encode?: number;
|
|
42
|
-
raw: string;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* ComputeServerStats provides methods to query Rhino Compute server statistics.
|
|
47
|
-
*
|
|
48
|
-
* @public Use this for server health monitoring and statistics.
|
|
49
|
-
*
|
|
50
|
-
* @example
|
|
51
|
-
* ```typescript
|
|
52
|
-
* const stats = new ComputeServerStats('http://localhost:6500', 'your-api-key');
|
|
53
|
-
*
|
|
54
|
-
* try {
|
|
55
|
-
* const isOnline = await stats.isServerOnline();
|
|
56
|
-
* const children = await stats.getActiveChildren();
|
|
57
|
-
* const version = await stats.getVersion();
|
|
58
|
-
*
|
|
59
|
-
* // Or get everything at once
|
|
60
|
-
* const allStats = await stats.getServerStats();
|
|
61
|
-
* } finally {
|
|
62
|
-
* await stats.dispose(); // Clean up resources
|
|
63
|
-
* }
|
|
64
|
-
* ```
|
|
65
|
-
*/
|
|
66
|
-
declare class ComputeServerStats {
|
|
67
|
-
private readonly serverUrl;
|
|
68
|
-
private readonly apiKey?;
|
|
69
|
-
private disposed;
|
|
70
|
-
private activeMonitors;
|
|
71
|
-
private activeTimeouts;
|
|
72
|
-
/** Timeout (ms) for the fast read/monitoring endpoints. */
|
|
73
|
-
private static readonly DEFAULT_TIMEOUT_MS;
|
|
74
|
-
/** Timeout (ms) for child-lifecycle POSTs — a cold Windows child can take ~30s to spawn. */
|
|
75
|
-
private static readonly LIFECYCLE_TIMEOUT_MS;
|
|
76
|
-
/** Floor for `monitor()`'s `intervalMs` — anything lower hot-loops the server. */
|
|
77
|
-
private static readonly MIN_MONITOR_INTERVAL_MS;
|
|
78
|
-
/**
|
|
79
|
-
* @param serverUrl - Base URL of the Rhino Compute server with http:// or https:// scheme (e.g., 'http://localhost:6500')
|
|
80
|
-
* @param apiKey - Optional API key for authentication
|
|
81
|
-
*/
|
|
82
|
-
constructor(serverUrl: string, apiKey?: string);
|
|
83
|
-
/**
|
|
84
|
-
* Build request headers with optional API key.
|
|
85
|
-
*/
|
|
86
|
-
private buildHeaders;
|
|
87
|
-
/**
|
|
88
|
-
* `fetch` wrapper that aborts after `timeoutMs` so a hung connection can't stall
|
|
89
|
-
* a probe (or the `monitor()` loop) forever. Pass `0` to disable the timeout.
|
|
90
|
-
*/
|
|
91
|
-
private fetchWithTimeout;
|
|
92
|
-
/**
|
|
93
|
-
* Check if the server is online.
|
|
94
|
-
*
|
|
95
|
-
* This is a single-sample probe: it returns `true` only on a 2xx from the
|
|
96
|
-
* proxy liveness root `/`, and `false` for every other outcome (non-2xx,
|
|
97
|
-
* network error, or timeout). A cold or briefly-busy-but-up server can therefore
|
|
98
|
-
* read as offline — callers that gate on this (e.g. client construction)
|
|
99
|
-
* should retry rather than treat a single `false` as authoritative.
|
|
100
|
-
*
|
|
101
|
-
* @param timeoutMs - Abort the probe after this many ms (default: 5000).
|
|
102
|
-
* Pass `0` to disable the timeout. Prevents a hung connection from
|
|
103
|
-
* stalling the caller indefinitely.
|
|
104
|
-
*/
|
|
105
|
-
isServerOnline(timeoutMs?: number): Promise<boolean>;
|
|
106
|
-
/**
|
|
107
|
-
* Get the number of active child processes on the server.
|
|
108
|
-
*
|
|
109
|
-
* By default the proxy's `/activechildren` endpoint will *spawn* children up
|
|
110
|
-
* to the configured count if none are running, then report the count — which
|
|
111
|
-
* wakes (and bills) an idle server. Pass `{ initialize: false }` for a passive
|
|
112
|
-
* read that reports the current count without spawning; use this for
|
|
113
|
-
* monitoring or before a purge/probe where you must not wake the server.
|
|
114
|
-
*
|
|
115
|
-
* @param options.initialize - When `false`, append `?initialize=false` so the
|
|
116
|
-
* server reports without spawning. Defaults to `true` (the server's default).
|
|
117
|
-
* @returns Number of active children, or null if unavailable
|
|
118
|
-
*/
|
|
119
|
-
getActiveChildren(options?: {
|
|
120
|
-
initialize?: boolean;
|
|
121
|
-
}): Promise<number | null>;
|
|
122
|
-
/**
|
|
123
|
-
* Get the server version information.
|
|
124
|
-
*
|
|
125
|
-
* @returns Version object with rhino, compute, and git_sha, or null if unavailable
|
|
126
|
-
*/
|
|
127
|
-
getVersion(): Promise<{
|
|
128
|
-
rhino: string;
|
|
129
|
-
compute: string;
|
|
130
|
-
git_sha: string | null;
|
|
131
|
-
} | null>;
|
|
132
|
-
/**
|
|
133
|
-
* Get the plugins installed on the server.
|
|
134
|
-
*
|
|
135
|
-
* Returns a `name → version` map of non-core plugins the server has loaded,
|
|
136
|
-
* or `null` if the request failed. Pass `kind` to choose which inventory:
|
|
137
|
-
* `'gh'` (default) lists Grasshopper add-on assemblies via
|
|
138
|
-
* `/plugins/gh/installed`; `'rhino'` lists Rhino plugins via
|
|
139
|
-
* `/plugins/rhino/installed`. Plugins that ship with Rhino / are core
|
|
140
|
-
* libraries are excluded by the server.
|
|
141
|
-
*
|
|
142
|
-
* @param kind - `'gh'` for Grasshopper add-ons (default) or `'rhino'` for Rhino plugins.
|
|
143
|
-
* @returns Map of plugin name to version, or `null` on failure.
|
|
144
|
-
*
|
|
145
|
-
* @example
|
|
146
|
-
* ```ts
|
|
147
|
-
* const gh = await stats.getInstalledPlugins(); // Grasshopper add-ons
|
|
148
|
-
* const selvaVersion = gh?.['Selva'] ?? null;
|
|
149
|
-
* ```
|
|
150
|
-
*/
|
|
151
|
-
getInstalledPlugins(kind?: 'gh' | 'rhino'): Promise<Record<string, string> | null>;
|
|
152
|
-
/**
|
|
153
|
-
* Get comprehensive server statistics.
|
|
154
|
-
* Fetches all available server information in parallel.
|
|
155
|
-
*
|
|
156
|
-
* @returns Object containing server status and available stats
|
|
157
|
-
*/
|
|
158
|
-
getServerStats(): Promise<{
|
|
159
|
-
isOnline: boolean;
|
|
160
|
-
version?: {
|
|
161
|
-
rhino: string;
|
|
162
|
-
compute: string;
|
|
163
|
-
git_sha: string | null;
|
|
164
|
-
};
|
|
165
|
-
activeChildren?: number;
|
|
166
|
-
}>;
|
|
167
|
-
/**
|
|
168
|
-
* Purge the server's solve-results / URL-data cache.
|
|
169
|
-
*
|
|
170
|
-
* POSTs to `cache/purge` and returns the number of entries removed, or `null`
|
|
171
|
-
* if the request failed. This clears cached solve responses and fetched
|
|
172
|
-
* definition-URL data; it does NOT evict the definition cache (active
|
|
173
|
-
* `pointer` references stay valid).
|
|
174
|
-
*
|
|
175
|
-
* **Caveat:** `cache/purge` is forwarded by the rhino.compute proxy to a
|
|
176
|
-
* single round-robin-selected child, so in a multi-child deployment one call
|
|
177
|
-
* purges one child's cache. Call repeatedly (or size the pool to 1) if you
|
|
178
|
-
* need a fleet-wide purge.
|
|
179
|
-
*
|
|
180
|
-
* @returns Number of entries removed, or `null` on failure.
|
|
181
|
-
*
|
|
182
|
-
* @example
|
|
183
|
-
* ```ts
|
|
184
|
-
* const removed = await stats.purgeCache();
|
|
185
|
-
* if (removed !== null) console.log(`Purged ${removed} cached solves`);
|
|
186
|
-
* ```
|
|
187
|
-
*/
|
|
188
|
-
purgeCache(): Promise<number | null>;
|
|
189
|
-
/**
|
|
190
|
-
* Best-effort fleet-wide cache purge across a multi-child deployment.
|
|
191
|
-
*
|
|
192
|
-
* A single {@link purgeCache} POST is forwarded by the rhino.compute proxy to
|
|
193
|
-
* just ONE round-robin-selected child, so the other children keep serving
|
|
194
|
-
* stale cached solves. There is no proxy endpoint that addresses children
|
|
195
|
-
* individually, so this method reads the active child count (passively, never
|
|
196
|
-
* spawning) and fires `2 × count` sequential purges, relying on the proxy's
|
|
197
|
-
* round-robin to spread the hits across the pool.
|
|
198
|
-
*
|
|
199
|
-
* **This is best-effort, not a guarantee.** Round-robin can revisit one child
|
|
200
|
-
* and skip another; under concurrent traffic the rotation drifts. The result's
|
|
201
|
-
* `confident` flag is `true` only when the server reports a single child (where
|
|
202
|
-
* one purge is exact) — surface it so callers don't over-promise. For a hard
|
|
203
|
-
* fleet-wide guarantee, run the deployment at `--childcount 1` or add a
|
|
204
|
-
* server-side fan-out endpoint.
|
|
205
|
-
*
|
|
206
|
-
* @returns `{ totalPurged, calls, children, confident }`, or `null` if the
|
|
207
|
-
* child count couldn't be read (server unreachable). `totalPurged` sums the
|
|
208
|
-
* per-call counts; `calls` is how many purges were issued; `children` is the
|
|
209
|
-
* reported pool size; `confident` is `true` only at a single-child pool.
|
|
210
|
-
*
|
|
211
|
-
* @example
|
|
212
|
-
* ```ts
|
|
213
|
-
* const r = await stats.purgeAllChildren();
|
|
214
|
-
* if (r && !r.confident) {
|
|
215
|
-
* console.warn(`Purged ~${r.totalPurged} across ${r.children} children (best-effort)`);
|
|
216
|
-
* }
|
|
217
|
-
* ```
|
|
218
|
-
*/
|
|
219
|
-
purgeAllChildren(): Promise<{
|
|
220
|
-
totalPurged: number;
|
|
221
|
-
calls: number;
|
|
222
|
-
children: number;
|
|
223
|
-
confident: boolean;
|
|
224
|
-
} | null>;
|
|
225
|
-
/**
|
|
226
|
-
* Get the server's current UTC clock.
|
|
227
|
-
*
|
|
228
|
-
* GETs `/servertime`, which the server emits as a JSON-encoded ISO-8601
|
|
229
|
-
* timestamp (e.g. `"2026-06-18T08:30:00Z"`). Useful for detecting clock skew
|
|
230
|
-
* between caller and server. Returns `null` if the request failed or the body
|
|
231
|
-
* isn't a parseable date.
|
|
232
|
-
*
|
|
233
|
-
* @returns A `Date` for the server's UTC time, or `null` on failure.
|
|
234
|
-
*/
|
|
235
|
-
getServerTime(): Promise<Date | null>;
|
|
236
|
-
/**
|
|
237
|
-
* Get how long the rhino.compute proxy has been idle.
|
|
238
|
-
*
|
|
239
|
-
* GETs `/idlespan` on the proxy, which returns the seconds elapsed since the
|
|
240
|
-
* last request was forwarded to a compute child. This is a proxy-level metric
|
|
241
|
-
* (not proxied to a child) used by autoscalers to decide when a node can be
|
|
242
|
-
* drained. Returns `null` if unavailable.
|
|
243
|
-
*
|
|
244
|
-
* @returns Idle time in seconds, or `null` on failure.
|
|
245
|
-
*/
|
|
246
|
-
getIdleSpan(): Promise<number | null>;
|
|
247
|
-
/**
|
|
248
|
-
* Fill the compute child pool up to the server's configured baseline.
|
|
249
|
-
*
|
|
250
|
-
* POSTs `/launch-children`. No-op when the pool is already at or above the
|
|
251
|
-
* configured `--childcount`. Returns `{ spawned, active }` — how many children
|
|
252
|
-
* were started and the resulting child count — or `null` on failure.
|
|
253
|
-
*
|
|
254
|
-
* To raise capacity above the baseline use {@link launchChild}; the baseline
|
|
255
|
-
* itself can only be changed by restarting rhino.compute.
|
|
256
|
-
*
|
|
257
|
-
* @returns `{ spawned, active }`, or `null` on failure.
|
|
258
|
-
*/
|
|
259
|
-
launchChildren(): Promise<{
|
|
260
|
-
spawned: number[];
|
|
261
|
-
active: number;
|
|
262
|
-
} | null>;
|
|
263
|
-
/**
|
|
264
|
-
* Add a single compute child to the pool, optionally on a specific port.
|
|
265
|
-
*
|
|
266
|
-
* POSTs `/launch-child` (with `?port=N` when `port` is given). Unlike
|
|
267
|
-
* {@link launchChildren}, this can push the pool above the baseline, up to the
|
|
268
|
-
* server's `MaxChildren` cap. Returns `{ spawned: [port] }` on success, or
|
|
269
|
-
* `null` on failure (server replies 400 for a bad port, 409 if the port is in
|
|
270
|
-
* use, 503 at the max-children cap).
|
|
271
|
-
*
|
|
272
|
-
* @param port - Optional specific port to launch on; otherwise the next free one.
|
|
273
|
-
* @returns `{ spawned }` listing the launched port, or `null` on failure.
|
|
274
|
-
*/
|
|
275
|
-
launchChild(port?: number): Promise<{
|
|
276
|
-
spawned: number[];
|
|
277
|
-
} | null>;
|
|
278
|
-
/**
|
|
279
|
-
* Gracefully shut down compute children without respawning them.
|
|
280
|
-
*
|
|
281
|
-
* POSTs `/shutdown-children`. With no `port` it shuts down every child; with
|
|
282
|
-
* `port` it targets just that one. Children do not respawn, but the next
|
|
283
|
-
* `/grasshopper` request auto-spawns the pool back to the baseline. Returns
|
|
284
|
-
* `{ shutdown, active }` — how many were stopped and the remaining count — or
|
|
285
|
-
* `null` on failure.
|
|
286
|
-
*
|
|
287
|
-
* @param port - Optional port to target; omit to shut down all children.
|
|
288
|
-
* @returns `{ shutdown, active }`, or `null` on failure.
|
|
289
|
-
*/
|
|
290
|
-
shutdownChildren(port?: number): Promise<{
|
|
291
|
-
shutdown: number;
|
|
292
|
-
active: number;
|
|
293
|
-
} | null>;
|
|
294
|
-
/**
|
|
295
|
-
* Shut down compute children and respawn replacements (rolling restart).
|
|
296
|
-
*
|
|
297
|
-
* POSTs `/recycle-children`. With no `port` it recycles every child; with
|
|
298
|
-
* `port` it recycles just that one. The server recycles sequentially (each
|
|
299
|
-
* replacement is serving before the next child is stopped) so the pool never
|
|
300
|
-
* drops to zero mid-recycle. Returns `{ shutdown, spawned, active }`, or
|
|
301
|
-
* `null` on failure.
|
|
302
|
-
*
|
|
303
|
-
* @param port - Optional port to target; omit to recycle all children.
|
|
304
|
-
* @returns `{ shutdown, spawned, active }`, or `null` on failure.
|
|
305
|
-
*/
|
|
306
|
-
recycleChildren(port?: number): Promise<{
|
|
307
|
-
shutdown: number;
|
|
308
|
-
spawned: number[];
|
|
309
|
-
active: number;
|
|
310
|
-
} | null>;
|
|
311
|
-
/**
|
|
312
|
-
* POST a control endpoint that replies with a JSON object and return it,
|
|
313
|
-
* degrading to `null` on any non-2xx, non-JSON, or network failure. Shared by
|
|
314
|
-
* the child-lifecycle methods so their failure semantics stay identical. Uses
|
|
315
|
-
* the longer lifecycle timeout since a spawn/recycle can take ~30s.
|
|
316
|
-
*/
|
|
317
|
-
private postJson;
|
|
318
|
-
/**
|
|
319
|
-
* Continuously monitor server stats at specified interval.
|
|
320
|
-
*
|
|
321
|
-
* @param callback - Function called with stats on each interval
|
|
322
|
-
* @param intervalMs - Milliseconds between checks (default: 5000). Must be a
|
|
323
|
-
* finite number of at least 100 ms — lower values would hot-loop the server.
|
|
324
|
-
* @returns Function to stop monitoring
|
|
325
|
-
* @throws {RangeError} If `intervalMs` is not a finite number >= 100.
|
|
326
|
-
*
|
|
327
|
-
* @example
|
|
328
|
-
* ```typescript
|
|
329
|
-
* const stopMonitoring = stats.monitor((data) => {
|
|
330
|
-
* console.log('Server stats:', data);
|
|
331
|
-
* }, 3000);
|
|
332
|
-
*
|
|
333
|
-
* // Later...
|
|
334
|
-
* stopMonitoring();
|
|
335
|
-
* ```
|
|
336
|
-
*/
|
|
337
|
-
monitor(callback: (stats: Awaited<ReturnType<typeof this.getServerStats>>) => void, intervalMs?: number): () => void;
|
|
338
|
-
/**
|
|
339
|
-
* Disposes of all resources and stops all active monitors.
|
|
340
|
-
* Call this when you're done using the stats instance.
|
|
341
|
-
*/
|
|
342
|
-
dispose(): Promise<void>;
|
|
343
|
-
/**
|
|
344
|
-
* Ensures the instance hasn't been disposed.
|
|
345
|
-
*/
|
|
346
|
-
private ensureNotDisposed;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
declare const ErrorCodes: {
|
|
350
|
-
readonly NETWORK_ERROR: "NETWORK_ERROR";
|
|
351
|
-
readonly AUTH_ERROR: "AUTH_ERROR";
|
|
352
|
-
readonly VALIDATION_ERROR: "VALIDATION_ERROR";
|
|
353
|
-
readonly COMPUTATION_ERROR: "COMPUTATION_ERROR";
|
|
354
|
-
readonly TIMEOUT_ERROR: "TIMEOUT_ERROR";
|
|
355
|
-
readonly CORS_ERROR: "CORS_ERROR";
|
|
356
|
-
/** HTTP 404 — the endpoint path does not exist on the server (usually a typo'd route or wrong server). Never retried. */
|
|
357
|
-
readonly NOT_FOUND: "NOT_FOUND";
|
|
358
|
-
/** HTTP 429 — the server is rate-limiting requests. Retried by default (honors `Retry-After`); see `RetryPolicy.retryOn429`. */
|
|
359
|
-
readonly RATE_LIMIT: "RATE_LIMIT";
|
|
360
|
-
/**
|
|
361
|
-
* The server answered 2xx but the body is deterministically not JSON (the
|
|
362
|
-
* response declared a non-JSON `Content-Type`, e.g. an HTML captive-portal or
|
|
363
|
-
* proxy login page, or a misconfigured endpoint). Never retried — refetching
|
|
364
|
-
* returns the same page.
|
|
365
|
-
*/
|
|
366
|
-
readonly INVALID_RESPONSE: "INVALID_RESPONSE";
|
|
367
|
-
readonly UNKNOWN_ERROR: "UNKNOWN_ERROR";
|
|
368
|
-
readonly INVALID_STATE: "INVALID_STATE";
|
|
369
|
-
readonly INVALID_INPUT: "INVALID_INPUT";
|
|
370
|
-
readonly INVALID_CONFIG: "INVALID_CONFIG";
|
|
371
|
-
readonly BROWSER_ONLY: "BROWSER_ONLY";
|
|
372
|
-
readonly ENVIRONMENT_ERROR: "ENVIRONMENT_ERROR";
|
|
373
|
-
readonly ENCODING_ERROR: "ENCODING_ERROR";
|
|
374
|
-
/** An input's `default` had a shape the normalizer didn't recognize (no innerTree key). */
|
|
375
|
-
readonly MALFORMED_DEFAULT: "MALFORMED_DEFAULT";
|
|
376
|
-
/** Scheduler latest-wins: this call was replaced by a newer one. */
|
|
377
|
-
readonly SUPERSEDED: "SUPERSEDED";
|
|
378
|
-
/** Scheduler / caller-supplied AbortSignal: this call was aborted. */
|
|
379
|
-
readonly ABORTED: "ABORTED";
|
|
380
|
-
/**
|
|
381
|
-
* Scheduler backpressure: the queue was already at `maxQueueDepth` when this
|
|
382
|
-
* call arrived, so it was shed immediately rather than queued. Retryable — the
|
|
383
|
-
* caller (or an HTTP layer, as 503 + Retry-After) should back off and retry.
|
|
384
|
-
* The error `context` carries `{ queueDepth, maxQueueDepth }`.
|
|
385
|
-
*/
|
|
386
|
-
readonly QUEUE_FULL: "QUEUE_FULL";
|
|
387
|
-
/**
|
|
388
|
-
* Scheduler backpressure: this call sat queued longer than `queueWaitMs`
|
|
389
|
-
* without starting, so it was shed before wasting compute on a stale request.
|
|
390
|
-
* Retryable. The error `context` carries `{ waitedMs, queueWaitMs }`.
|
|
391
|
-
*/
|
|
392
|
-
readonly QUEUE_TIMEOUT: "QUEUE_TIMEOUT";
|
|
393
|
-
/**
|
|
394
|
-
* A solve referenced a definition by `pointer` (server-side cache key), but the
|
|
395
|
-
* server no longer holds that definition (evicted / GC'd / a different child in
|
|
396
|
-
* the pool / server restarted). The caller should retry with the full
|
|
397
|
-
* definition. Surfaced when the server tags its error body with
|
|
398
|
-
* `code: "definition_not_cached"`, so it survives production message-scrubbing.
|
|
399
|
-
*/
|
|
400
|
-
readonly DEFINITION_NOT_CACHED: "DEFINITION_NOT_CACHED";
|
|
401
|
-
};
|
|
402
|
-
type ErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];
|
|
403
|
-
/**
|
|
404
|
-
* Simplified error for Rhino Compute operations
|
|
405
|
-
*
|
|
406
|
-
* @public Use this for error handling with error codes and context.
|
|
407
|
-
*/
|
|
408
|
-
declare class RhinoComputeError extends Error {
|
|
409
|
-
readonly code: ErrorCode;
|
|
410
|
-
readonly statusCode?: number;
|
|
411
|
-
readonly context?: Record<string, unknown>;
|
|
412
|
-
readonly originalError?: Error;
|
|
413
|
-
constructor(message: string, code?: ErrorCode, options?: {
|
|
414
|
-
statusCode?: number;
|
|
415
|
-
context?: Record<string, unknown>;
|
|
416
|
-
originalError?: Error;
|
|
417
|
-
});
|
|
418
|
-
/**
|
|
419
|
-
* Create an error for missing/empty values
|
|
420
|
-
*/
|
|
421
|
-
static missingValues(inputName: string, expectedType?: string, context?: Record<string, unknown>): RhinoComputeError;
|
|
422
|
-
/**
|
|
423
|
-
* Create an error for unknown parameter type
|
|
424
|
-
*/
|
|
425
|
-
static unknownParamType(paramType: string, paramName?: string, context?: Record<string, unknown>): RhinoComputeError;
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
/**
|
|
429
|
-
* Raw file data from Grasshopper/Rhino Compute response, with metadata for processing.
|
|
430
|
-
* Files are typically combined with additional files and packaged into a ZIP archive.
|
|
431
|
-
* @see {@link extractFilesFromComputeResponse} for extraction from compute responses
|
|
432
|
-
*/
|
|
433
|
-
type FileData = {
|
|
434
|
-
/** Base filename without extension (e.g., "model") */
|
|
435
|
-
fileName: string;
|
|
436
|
-
/** File content, base64-encoded or plain string depending on isBase64Encoded flag */
|
|
437
|
-
data: string;
|
|
438
|
-
/** File extension including the dot (e.g., ".3dm", ".json"). Appended to fileName to create the full filename */
|
|
439
|
-
fileType: string;
|
|
440
|
-
/** Whether data is base64-encoded. If true, must be decoded to binary before use */
|
|
441
|
-
isBase64Encoded: boolean;
|
|
442
|
-
/** Directory path for archive organization (e.g., "subfolder/nested"). Empty string for root-level files */
|
|
443
|
-
subFolder: string;
|
|
444
|
-
/** Arbitrary metadata attached in Grasshopper. Not interpreted by compute; passed through for downstream consumers. May be absent on older payloads */
|
|
445
|
-
metadata?: Record<string, string>;
|
|
446
|
-
};
|
|
447
|
-
/**
|
|
448
|
-
* Normalized file ready for consumption or archival.
|
|
449
|
-
* Unified intermediate format from FileData or FileBaseInfo, ready to be packaged into archives or returned to callers.
|
|
450
|
-
*/
|
|
451
|
-
type ProcessedFile = {
|
|
452
|
-
/** Full filename including extension (e.g., "model.3dm") */
|
|
453
|
-
fileName: string;
|
|
454
|
-
/** File content as binary data (Uint8Array for decoded base64 or fetched binary) or text */
|
|
455
|
-
content: Uint8Array | string;
|
|
456
|
-
/** File path for archive organization (e.g., "subfolder/model.3dm") */
|
|
457
|
-
path: string;
|
|
458
|
-
};
|
|
459
|
-
/**
|
|
460
|
-
* Reference to an external file to be fetched and included in file operations.
|
|
461
|
-
* Specifies additional files (beyond compute response files) to fetch and process as ProcessedFile.
|
|
462
|
-
* @see {@link fetchRemoteFiles} for how FileBaseInfo is fetched and converted
|
|
463
|
-
*/
|
|
464
|
-
type FileBaseInfo = {
|
|
465
|
-
/** Destination filename for the file in the archive or result set (e.g., "additional-data.json") */
|
|
466
|
-
fileName: string;
|
|
467
|
-
/** URL to fetch the file from. Must be accessible from the runtime environment */
|
|
468
|
-
filePath: string;
|
|
469
|
-
/** Optional directory path for archive organization (e.g., "extras/docs"). When omitted, file lands at archive root */
|
|
470
|
-
subFolder?: string;
|
|
471
|
-
};
|
|
472
|
-
|
|
473
|
-
/** Extracts and processes files from compute response data without downloading them. */
|
|
474
|
-
declare const extractFilesFromComputeResponse: (downloadableFiles: FileData[], additionalFiles?: FileBaseInfo[] | FileBaseInfo | null) => Promise<ProcessedFile[]>;
|
|
475
|
-
/** Downloads files from a compute response as a ZIP archive. */
|
|
476
|
-
declare const downloadFileData: (downloadableFiles: FileData[], fileFoldername: string, additionalFiles?: FileBaseInfo[] | FileBaseInfo | null) => Promise<void>;
|
|
477
|
-
|
|
478
|
-
export { type ComputeConfig as C, type ErrorCode as E, type FileBaseInfo as F, type ProcessedFile as P, type RetryPolicy as R, type ServerTiming as S, ComputeServerStats as a, ErrorCodes as b, type FileData as c, RhinoComputeError as d, type RhinoModelUnit as e, downloadFileData as f, extractFilesFromComputeResponse as g };
|