@selvajs/compute 1.5.3 → 2.0.0-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.
Files changed (66) hide show
  1. package/dist/chunk-3FH7FKLG.cjs +2 -0
  2. package/dist/chunk-3FH7FKLG.cjs.map +1 -0
  3. package/dist/chunk-DELOBV2Q.js +2 -0
  4. package/dist/chunk-DELOBV2Q.js.map +1 -0
  5. package/dist/chunk-GTTKNF4G.js +4 -0
  6. package/dist/chunk-GTTKNF4G.js.map +1 -0
  7. package/dist/chunk-JFLD2UCY.cjs +2 -0
  8. package/dist/chunk-JFLD2UCY.cjs.map +1 -0
  9. package/dist/chunk-MA6YB3YZ.cjs +4 -0
  10. package/dist/chunk-MA6YB3YZ.cjs.map +1 -0
  11. package/dist/chunk-MKW2KTPT.js +2 -0
  12. package/dist/chunk-MKW2KTPT.js.map +1 -0
  13. package/dist/core.cjs +1 -1
  14. package/dist/core.cjs.map +1 -1
  15. package/dist/core.d.cts +10 -15
  16. package/dist/core.d.ts +10 -15
  17. package/dist/core.js +1 -1
  18. package/dist/grasshopper.cjs +1 -1
  19. package/dist/grasshopper.cjs.map +1 -1
  20. package/dist/grasshopper.d.cts +77 -101
  21. package/dist/grasshopper.d.ts +77 -101
  22. package/dist/grasshopper.js +1 -1
  23. package/dist/handle-files-DsrxHKHP.d.cts +262 -0
  24. package/dist/handle-files-DsrxHKHP.d.ts +262 -0
  25. package/dist/index.cjs +1 -1
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.d.cts +4 -4
  28. package/dist/index.d.ts +4 -4
  29. package/dist/index.js +1 -1
  30. package/dist/{types-Dfeei0dD.d.cts → types-CJ092lxB.d.cts} +116 -73
  31. package/dist/types-D1SkNje_.d.cts +87 -0
  32. package/dist/types-D1SkNje_.d.ts +87 -0
  33. package/dist/{types-Dfeei0dD.d.ts → types-XCUrJGby.d.ts} +116 -73
  34. package/dist/visualization-GU7JIB4V.cjs +2 -0
  35. package/dist/visualization-GU7JIB4V.cjs.map +1 -0
  36. package/dist/visualization-WIUVT2FZ.js +2 -0
  37. package/dist/visualization.cjs +1 -1
  38. package/dist/visualization.cjs.map +1 -1
  39. package/dist/visualization.d.cts +16 -21
  40. package/dist/visualization.d.ts +16 -21
  41. package/dist/visualization.js +1 -1
  42. package/package.json +18 -7
  43. package/dist/chunk-GZYSQSLH.cjs +0 -2
  44. package/dist/chunk-GZYSQSLH.cjs.map +0 -1
  45. package/dist/chunk-JZYEMZZ5.js +0 -2
  46. package/dist/chunk-JZYEMZZ5.js.map +0 -1
  47. package/dist/chunk-OEDLGVIQ.js +0 -2
  48. package/dist/chunk-OEDLGVIQ.js.map +0 -1
  49. package/dist/chunk-OW6HV6QP.js +0 -2
  50. package/dist/chunk-OW6HV6QP.js.map +0 -1
  51. package/dist/chunk-RBNF6MNH.cjs +0 -3
  52. package/dist/chunk-RBNF6MNH.cjs.map +0 -1
  53. package/dist/chunk-SVEXPGHW.cjs +0 -2
  54. package/dist/chunk-SVEXPGHW.cjs.map +0 -1
  55. package/dist/chunk-XBIEAJBK.js +0 -3
  56. package/dist/chunk-XBIEAJBK.js.map +0 -1
  57. package/dist/chunk-ZRQRYG6F.cjs +0 -2
  58. package/dist/chunk-ZRQRYG6F.cjs.map +0 -1
  59. package/dist/errors-CEy4nM1J.d.cts +0 -149
  60. package/dist/errors-CEy4nM1J.d.ts +0 -149
  61. package/dist/types-COCuQEMk.d.cts +0 -93
  62. package/dist/types-COCuQEMk.d.ts +0 -93
  63. package/dist/visualization-ENMBHWIN.js +0 -2
  64. package/dist/visualization-TBPFFBFU.cjs +0 -2
  65. package/dist/visualization-TBPFFBFU.cjs.map +0 -1
  66. /package/dist/{visualization-ENMBHWIN.js.map → visualization-WIUVT2FZ.js.map} +0 -0
@@ -0,0 +1,262 @@
1
+ /**
2
+ * ComputeServerStats provides methods to query Rhino Compute server statistics.
3
+ *
4
+ * @public Use this for server health monitoring and statistics.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * const stats = new ComputeServerStats('http://localhost:6500', 'your-api-key');
9
+ *
10
+ * try {
11
+ * const isOnline = await stats.isServerOnline();
12
+ * const children = await stats.getActiveChildren();
13
+ * const version = await stats.getVersion();
14
+ *
15
+ * // Or get everything at once
16
+ * const allStats = await stats.getServerStats();
17
+ * } finally {
18
+ * await stats.dispose(); // Clean up resources
19
+ * }
20
+ * ```
21
+ */
22
+ declare class ComputeServerStats {
23
+ private readonly serverUrl;
24
+ private readonly apiKey?;
25
+ private disposed;
26
+ private activeMonitors;
27
+ private activeTimeouts;
28
+ /**
29
+ * @param serverUrl - Base URL of the Rhino Compute server with http:// or https:// scheme (e.g., 'http://localhost:6500')
30
+ * @param apiKey - Optional API key for authentication
31
+ */
32
+ constructor(serverUrl: string, apiKey?: string);
33
+ /**
34
+ * Build request headers with optional API key.
35
+ */
36
+ private buildHeaders;
37
+ /**
38
+ * Check if the server is online.
39
+ */
40
+ isServerOnline(): Promise<boolean>;
41
+ /**
42
+ * Get the number of active child processes on the server.
43
+ *
44
+ * @returns Number of active children, or null if unavailable
45
+ */
46
+ getActiveChildren(): Promise<number | null>;
47
+ /**
48
+ * Get the server version information.
49
+ *
50
+ * @returns Version object with rhino, compute, and git_sha, or null if unavailable
51
+ */
52
+ getVersion(): Promise<{
53
+ rhino: string;
54
+ compute: string;
55
+ git_sha: string | null;
56
+ } | null>;
57
+ /**
58
+ * Get comprehensive server statistics.
59
+ * Fetches all available server information in parallel.
60
+ *
61
+ * @returns Object containing server status and available stats
62
+ */
63
+ getServerStats(): Promise<{
64
+ isOnline: boolean;
65
+ version?: {
66
+ rhino: string;
67
+ compute: string;
68
+ git_sha: string | null;
69
+ };
70
+ activeChildren?: number;
71
+ }>;
72
+ /**
73
+ * Purge the server's solve-results / URL-data cache.
74
+ *
75
+ * POSTs to `cache/purge` and returns the number of entries removed, or `null`
76
+ * if the request failed. This clears cached solve responses and fetched
77
+ * definition-URL data; it does NOT evict the definition cache (active
78
+ * `pointer` references stay valid).
79
+ *
80
+ * **Caveat:** `cache/purge` is forwarded by the rhino.compute proxy to a
81
+ * single round-robin-selected child, so in a multi-child deployment one call
82
+ * purges one child's cache. Call repeatedly (or size the pool to 1) if you
83
+ * need a fleet-wide purge.
84
+ *
85
+ * @returns Number of entries removed, or `null` on failure.
86
+ *
87
+ * @example
88
+ * ```ts
89
+ * const removed = await stats.purgeCache();
90
+ * if (removed !== null) console.log(`Purged ${removed} cached solves`);
91
+ * ```
92
+ */
93
+ purgeCache(): Promise<number | null>;
94
+ /**
95
+ * Continuously monitor server stats at specified interval.
96
+ *
97
+ * @param callback - Function called with stats on each interval
98
+ * @param intervalMs - Milliseconds between checks (default: 5000)
99
+ * @returns Function to stop monitoring
100
+ *
101
+ * @example
102
+ * ```typescript
103
+ * const stopMonitoring = stats.monitor((data) => {
104
+ * console.log('Server stats:', data);
105
+ * }, 3000);
106
+ *
107
+ * // Later...
108
+ * stopMonitoring();
109
+ * ```
110
+ */
111
+ monitor(callback: (stats: Awaited<ReturnType<typeof this.getServerStats>>) => void, intervalMs?: number): () => void;
112
+ /**
113
+ * Disposes of all resources and stops all active monitors.
114
+ * Call this when you're done using the stats instance.
115
+ */
116
+ dispose(): Promise<void>;
117
+ /**
118
+ * Ensures the instance hasn't been disposed.
119
+ */
120
+ private ensureNotDisposed;
121
+ }
122
+
123
+ /**
124
+ * Error types and codes for `@selvajs/compute`.
125
+ */
126
+ declare const ErrorCodes: {
127
+ readonly NETWORK_ERROR: "NETWORK_ERROR";
128
+ readonly AUTH_ERROR: "AUTH_ERROR";
129
+ readonly VALIDATION_ERROR: "VALIDATION_ERROR";
130
+ readonly COMPUTATION_ERROR: "COMPUTATION_ERROR";
131
+ readonly TIMEOUT_ERROR: "TIMEOUT_ERROR";
132
+ readonly CORS_ERROR: "CORS_ERROR";
133
+ readonly UNKNOWN_ERROR: "UNKNOWN_ERROR";
134
+ readonly INVALID_STATE: "INVALID_STATE";
135
+ readonly INVALID_INPUT: "INVALID_INPUT";
136
+ readonly INVALID_CONFIG: "INVALID_CONFIG";
137
+ readonly BROWSER_ONLY: "BROWSER_ONLY";
138
+ readonly ENVIRONMENT_ERROR: "ENVIRONMENT_ERROR";
139
+ readonly ENCODING_ERROR: "ENCODING_ERROR";
140
+ /** An input's `default` had a shape the normalizer didn't recognize (no innerTree key). */
141
+ readonly MALFORMED_DEFAULT: "MALFORMED_DEFAULT";
142
+ /** Scheduler latest-wins: this call was replaced by a newer one. */
143
+ readonly SUPERSEDED: "SUPERSEDED";
144
+ /** Scheduler / caller-supplied AbortSignal: this call was aborted. */
145
+ readonly ABORTED: "ABORTED";
146
+ };
147
+ type ErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];
148
+ /**
149
+ * Simplified error for Rhino Compute operations
150
+ *
151
+ * @public Use this for error handling with error codes and context.
152
+ */
153
+ declare class RhinoComputeError extends Error {
154
+ readonly code: string;
155
+ readonly statusCode?: number;
156
+ readonly context?: Record<string, unknown>;
157
+ readonly originalError?: Error;
158
+ constructor(message: string, code?: string, options?: {
159
+ statusCode?: number;
160
+ context?: Record<string, unknown>;
161
+ originalError?: Error;
162
+ });
163
+ /**
164
+ * Create an error for missing/empty values
165
+ */
166
+ static missingValues(inputName: string, expectedType?: string, context?: Record<string, unknown>): RhinoComputeError;
167
+ /**
168
+ * Create an error for unknown parameter type
169
+ */
170
+ static unknownParamType(paramType: string, paramName?: string, context?: Record<string, unknown>): RhinoComputeError;
171
+ }
172
+
173
+ /**
174
+ * Represents raw file data from Grasshopper/Rhino Compute response.
175
+ *
176
+ * This type encapsulates file output from compute operations, with metadata
177
+ * for processing (decoding, naming, organization). Files are typically combined
178
+ * with additional files and packaged into a ZIP archive for download.
179
+ *
180
+ * @see {@link ProcessedFile} for the normalized format after processing
181
+ * @see {@link extractFilesFromComputeResponse} for extraction from compute responses
182
+ */
183
+ type FileData = {
184
+ /** Base filename without extension (e.g., "model") */
185
+ fileName: string;
186
+ /** File content as a base64-encoded or plain string, depending on {@link IsBase64Encoded} */
187
+ data: string;
188
+ /** File extension including the dot (e.g., ".3dm", ".json"). Appended to {@link FileName} to create the full filename */
189
+ fileType: string;
190
+ /** Whether {@link Data} is base64-encoded. If true, must be decoded to binary before use. If false, can be used as a plain text string */
191
+ isBase64Encoded: boolean;
192
+ /** Directory path for organizing the file in archive structures (e.g., ZIP). Typically empty string for root-level files, or a path like "subfolder/nested" */
193
+ subFolder: string;
194
+ };
195
+ /**
196
+ * Represents a normalized, processed file ready for consumption or archival.
197
+ *
198
+ * This is the unified intermediate format produced by processing both {@link FileData}
199
+ * and {@link FileBaseInfo}. Files in this format are ready to be packaged into archives
200
+ * (e.g., ZIP files) or returned to callers for programmatic use.
201
+ *
202
+ * @see {@link FileData} for raw compute response files
203
+ * @see {@link FileBaseInfo} for external file references
204
+ */
205
+ type ProcessedFile = {
206
+ /** Full filename including extension (e.g., "model.3dm") */
207
+ fileName: string;
208
+ /** File content as either binary data or text. Binary format (Uint8Array) is used for decoded base64 or fetched binary files; text format is used for plain text content */
209
+ content: Uint8Array | string;
210
+ /** File path for archive organization (e.g., "subfolder/model.3dm"). Used when creating ZIP archives or other hierarchical structures */
211
+ path: string;
212
+ };
213
+ /**
214
+ * Represents a reference to an external file to be included in file operations.
215
+ *
216
+ * This type is used to specify additional files (beyond compute response files)
217
+ * that should be fetched and included when processing files. The file is fetched
218
+ * from the provided URL and processed as a {@link ProcessedFile}.
219
+ *
220
+ *
221
+ * @see {@link FileData} for files from compute responses
222
+ * @see {@link fetchRemoteFiles} for how FileBaseInfo is processed (fetched and converted)
223
+ */
224
+ type FileBaseInfo = {
225
+ /** Destination filename for the file in the archive or result set (e.g., "additional-data.json") */
226
+ fileName: string;
227
+ /** URL to fetch the file from. Must be accessible from the runtime environment */
228
+ filePath: string;
229
+ };
230
+
231
+ /**
232
+ * Extracts and processes files from compute response data without downloading them.
233
+ * Returns an array of ProcessedFile objects that can be used programmatically.
234
+ *
235
+ * @param downloadableFiles - An array of FileData items from the compute response.
236
+ * @param additionalFiles - Optional additional files to include (fetched from URLs).
237
+ * @returns A Promise resolving to an array of ProcessedFile objects.
238
+ * @throws Will throw an error if file processing fails.
239
+ *
240
+ * @example
241
+ * const files = await extractFilesFromComputeResponse(fileData);
242
+ * files.forEach(file => {
243
+ * console.log(`File: ${file.fileName}, Size: ${file.content.length}`);
244
+ * });
245
+ */
246
+ declare const extractFilesFromComputeResponse: (downloadableFiles: FileData[], additionalFiles?: FileBaseInfo[] | FileBaseInfo | null) => Promise<ProcessedFile[]>;
247
+ /**
248
+ * Downloads files from a compute response as a ZIP archive.
249
+ * Packages multiple files into a single ZIP file and triggers a browser download.
250
+ *
251
+ * @param downloadableFiles - An array of FileData items from the compute response.
252
+ * @param additionalFiles - Optional additional files to include in the ZIP (fetched from URLs).
253
+ * @param fileFoldername - The name of the ZIP file (without extension).
254
+ * @throws Will throw an error if the file handling or download fails.
255
+ *
256
+ * @example
257
+ * await downloadDataFromComputeResponse(fileData, null, 'my-export');
258
+ * // Downloads 'my-export.zip'
259
+ */
260
+ declare const downloadFileData: (downloadableFiles: FileData[], fileFoldername: string, additionalFiles?: FileBaseInfo[] | FileBaseInfo | null) => Promise<void>;
261
+
262
+ export { ComputeServerStats as C, type ErrorCode as E, type FileBaseInfo as F, type ProcessedFile as P, RhinoComputeError as R, ErrorCodes as a, type FileData as b, downloadFileData as d, extractFilesFromComputeResponse as e };
@@ -0,0 +1,262 @@
1
+ /**
2
+ * ComputeServerStats provides methods to query Rhino Compute server statistics.
3
+ *
4
+ * @public Use this for server health monitoring and statistics.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * const stats = new ComputeServerStats('http://localhost:6500', 'your-api-key');
9
+ *
10
+ * try {
11
+ * const isOnline = await stats.isServerOnline();
12
+ * const children = await stats.getActiveChildren();
13
+ * const version = await stats.getVersion();
14
+ *
15
+ * // Or get everything at once
16
+ * const allStats = await stats.getServerStats();
17
+ * } finally {
18
+ * await stats.dispose(); // Clean up resources
19
+ * }
20
+ * ```
21
+ */
22
+ declare class ComputeServerStats {
23
+ private readonly serverUrl;
24
+ private readonly apiKey?;
25
+ private disposed;
26
+ private activeMonitors;
27
+ private activeTimeouts;
28
+ /**
29
+ * @param serverUrl - Base URL of the Rhino Compute server with http:// or https:// scheme (e.g., 'http://localhost:6500')
30
+ * @param apiKey - Optional API key for authentication
31
+ */
32
+ constructor(serverUrl: string, apiKey?: string);
33
+ /**
34
+ * Build request headers with optional API key.
35
+ */
36
+ private buildHeaders;
37
+ /**
38
+ * Check if the server is online.
39
+ */
40
+ isServerOnline(): Promise<boolean>;
41
+ /**
42
+ * Get the number of active child processes on the server.
43
+ *
44
+ * @returns Number of active children, or null if unavailable
45
+ */
46
+ getActiveChildren(): Promise<number | null>;
47
+ /**
48
+ * Get the server version information.
49
+ *
50
+ * @returns Version object with rhino, compute, and git_sha, or null if unavailable
51
+ */
52
+ getVersion(): Promise<{
53
+ rhino: string;
54
+ compute: string;
55
+ git_sha: string | null;
56
+ } | null>;
57
+ /**
58
+ * Get comprehensive server statistics.
59
+ * Fetches all available server information in parallel.
60
+ *
61
+ * @returns Object containing server status and available stats
62
+ */
63
+ getServerStats(): Promise<{
64
+ isOnline: boolean;
65
+ version?: {
66
+ rhino: string;
67
+ compute: string;
68
+ git_sha: string | null;
69
+ };
70
+ activeChildren?: number;
71
+ }>;
72
+ /**
73
+ * Purge the server's solve-results / URL-data cache.
74
+ *
75
+ * POSTs to `cache/purge` and returns the number of entries removed, or `null`
76
+ * if the request failed. This clears cached solve responses and fetched
77
+ * definition-URL data; it does NOT evict the definition cache (active
78
+ * `pointer` references stay valid).
79
+ *
80
+ * **Caveat:** `cache/purge` is forwarded by the rhino.compute proxy to a
81
+ * single round-robin-selected child, so in a multi-child deployment one call
82
+ * purges one child's cache. Call repeatedly (or size the pool to 1) if you
83
+ * need a fleet-wide purge.
84
+ *
85
+ * @returns Number of entries removed, or `null` on failure.
86
+ *
87
+ * @example
88
+ * ```ts
89
+ * const removed = await stats.purgeCache();
90
+ * if (removed !== null) console.log(`Purged ${removed} cached solves`);
91
+ * ```
92
+ */
93
+ purgeCache(): Promise<number | null>;
94
+ /**
95
+ * Continuously monitor server stats at specified interval.
96
+ *
97
+ * @param callback - Function called with stats on each interval
98
+ * @param intervalMs - Milliseconds between checks (default: 5000)
99
+ * @returns Function to stop monitoring
100
+ *
101
+ * @example
102
+ * ```typescript
103
+ * const stopMonitoring = stats.monitor((data) => {
104
+ * console.log('Server stats:', data);
105
+ * }, 3000);
106
+ *
107
+ * // Later...
108
+ * stopMonitoring();
109
+ * ```
110
+ */
111
+ monitor(callback: (stats: Awaited<ReturnType<typeof this.getServerStats>>) => void, intervalMs?: number): () => void;
112
+ /**
113
+ * Disposes of all resources and stops all active monitors.
114
+ * Call this when you're done using the stats instance.
115
+ */
116
+ dispose(): Promise<void>;
117
+ /**
118
+ * Ensures the instance hasn't been disposed.
119
+ */
120
+ private ensureNotDisposed;
121
+ }
122
+
123
+ /**
124
+ * Error types and codes for `@selvajs/compute`.
125
+ */
126
+ declare const ErrorCodes: {
127
+ readonly NETWORK_ERROR: "NETWORK_ERROR";
128
+ readonly AUTH_ERROR: "AUTH_ERROR";
129
+ readonly VALIDATION_ERROR: "VALIDATION_ERROR";
130
+ readonly COMPUTATION_ERROR: "COMPUTATION_ERROR";
131
+ readonly TIMEOUT_ERROR: "TIMEOUT_ERROR";
132
+ readonly CORS_ERROR: "CORS_ERROR";
133
+ readonly UNKNOWN_ERROR: "UNKNOWN_ERROR";
134
+ readonly INVALID_STATE: "INVALID_STATE";
135
+ readonly INVALID_INPUT: "INVALID_INPUT";
136
+ readonly INVALID_CONFIG: "INVALID_CONFIG";
137
+ readonly BROWSER_ONLY: "BROWSER_ONLY";
138
+ readonly ENVIRONMENT_ERROR: "ENVIRONMENT_ERROR";
139
+ readonly ENCODING_ERROR: "ENCODING_ERROR";
140
+ /** An input's `default` had a shape the normalizer didn't recognize (no innerTree key). */
141
+ readonly MALFORMED_DEFAULT: "MALFORMED_DEFAULT";
142
+ /** Scheduler latest-wins: this call was replaced by a newer one. */
143
+ readonly SUPERSEDED: "SUPERSEDED";
144
+ /** Scheduler / caller-supplied AbortSignal: this call was aborted. */
145
+ readonly ABORTED: "ABORTED";
146
+ };
147
+ type ErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];
148
+ /**
149
+ * Simplified error for Rhino Compute operations
150
+ *
151
+ * @public Use this for error handling with error codes and context.
152
+ */
153
+ declare class RhinoComputeError extends Error {
154
+ readonly code: string;
155
+ readonly statusCode?: number;
156
+ readonly context?: Record<string, unknown>;
157
+ readonly originalError?: Error;
158
+ constructor(message: string, code?: string, options?: {
159
+ statusCode?: number;
160
+ context?: Record<string, unknown>;
161
+ originalError?: Error;
162
+ });
163
+ /**
164
+ * Create an error for missing/empty values
165
+ */
166
+ static missingValues(inputName: string, expectedType?: string, context?: Record<string, unknown>): RhinoComputeError;
167
+ /**
168
+ * Create an error for unknown parameter type
169
+ */
170
+ static unknownParamType(paramType: string, paramName?: string, context?: Record<string, unknown>): RhinoComputeError;
171
+ }
172
+
173
+ /**
174
+ * Represents raw file data from Grasshopper/Rhino Compute response.
175
+ *
176
+ * This type encapsulates file output from compute operations, with metadata
177
+ * for processing (decoding, naming, organization). Files are typically combined
178
+ * with additional files and packaged into a ZIP archive for download.
179
+ *
180
+ * @see {@link ProcessedFile} for the normalized format after processing
181
+ * @see {@link extractFilesFromComputeResponse} for extraction from compute responses
182
+ */
183
+ type FileData = {
184
+ /** Base filename without extension (e.g., "model") */
185
+ fileName: string;
186
+ /** File content as a base64-encoded or plain string, depending on {@link IsBase64Encoded} */
187
+ data: string;
188
+ /** File extension including the dot (e.g., ".3dm", ".json"). Appended to {@link FileName} to create the full filename */
189
+ fileType: string;
190
+ /** Whether {@link Data} is base64-encoded. If true, must be decoded to binary before use. If false, can be used as a plain text string */
191
+ isBase64Encoded: boolean;
192
+ /** Directory path for organizing the file in archive structures (e.g., ZIP). Typically empty string for root-level files, or a path like "subfolder/nested" */
193
+ subFolder: string;
194
+ };
195
+ /**
196
+ * Represents a normalized, processed file ready for consumption or archival.
197
+ *
198
+ * This is the unified intermediate format produced by processing both {@link FileData}
199
+ * and {@link FileBaseInfo}. Files in this format are ready to be packaged into archives
200
+ * (e.g., ZIP files) or returned to callers for programmatic use.
201
+ *
202
+ * @see {@link FileData} for raw compute response files
203
+ * @see {@link FileBaseInfo} for external file references
204
+ */
205
+ type ProcessedFile = {
206
+ /** Full filename including extension (e.g., "model.3dm") */
207
+ fileName: string;
208
+ /** File content as either binary data or text. Binary format (Uint8Array) is used for decoded base64 or fetched binary files; text format is used for plain text content */
209
+ content: Uint8Array | string;
210
+ /** File path for archive organization (e.g., "subfolder/model.3dm"). Used when creating ZIP archives or other hierarchical structures */
211
+ path: string;
212
+ };
213
+ /**
214
+ * Represents a reference to an external file to be included in file operations.
215
+ *
216
+ * This type is used to specify additional files (beyond compute response files)
217
+ * that should be fetched and included when processing files. The file is fetched
218
+ * from the provided URL and processed as a {@link ProcessedFile}.
219
+ *
220
+ *
221
+ * @see {@link FileData} for files from compute responses
222
+ * @see {@link fetchRemoteFiles} for how FileBaseInfo is processed (fetched and converted)
223
+ */
224
+ type FileBaseInfo = {
225
+ /** Destination filename for the file in the archive or result set (e.g., "additional-data.json") */
226
+ fileName: string;
227
+ /** URL to fetch the file from. Must be accessible from the runtime environment */
228
+ filePath: string;
229
+ };
230
+
231
+ /**
232
+ * Extracts and processes files from compute response data without downloading them.
233
+ * Returns an array of ProcessedFile objects that can be used programmatically.
234
+ *
235
+ * @param downloadableFiles - An array of FileData items from the compute response.
236
+ * @param additionalFiles - Optional additional files to include (fetched from URLs).
237
+ * @returns A Promise resolving to an array of ProcessedFile objects.
238
+ * @throws Will throw an error if file processing fails.
239
+ *
240
+ * @example
241
+ * const files = await extractFilesFromComputeResponse(fileData);
242
+ * files.forEach(file => {
243
+ * console.log(`File: ${file.fileName}, Size: ${file.content.length}`);
244
+ * });
245
+ */
246
+ declare const extractFilesFromComputeResponse: (downloadableFiles: FileData[], additionalFiles?: FileBaseInfo[] | FileBaseInfo | null) => Promise<ProcessedFile[]>;
247
+ /**
248
+ * Downloads files from a compute response as a ZIP archive.
249
+ * Packages multiple files into a single ZIP file and triggers a browser download.
250
+ *
251
+ * @param downloadableFiles - An array of FileData items from the compute response.
252
+ * @param additionalFiles - Optional additional files to include in the ZIP (fetched from URLs).
253
+ * @param fileFoldername - The name of the ZIP file (without extension).
254
+ * @throws Will throw an error if the file handling or download fails.
255
+ *
256
+ * @example
257
+ * await downloadDataFromComputeResponse(fileData, null, 'my-export');
258
+ * // Downloads 'my-export.zip'
259
+ */
260
+ declare const downloadFileData: (downloadableFiles: FileData[], fileFoldername: string, additionalFiles?: FileBaseInfo[] | FileBaseInfo | null) => Promise<void>;
261
+
262
+ export { ComputeServerStats as C, type ErrorCode as E, type FileBaseInfo as F, type ProcessedFile as P, RhinoComputeError as R, ErrorCodes as a, type FileData as b, downloadFileData as d, extractFilesFromComputeResponse as e };
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkGZYSQSLHcjs = require('./chunk-GZYSQSLH.cjs');require('./chunk-ZRQRYG6F.cjs');var _chunkRBNF6MNHcjs = require('./chunk-RBNF6MNH.cjs');exports.ComputeServerStats = _chunkRBNF6MNHcjs.i; exports.ErrorCodes = _chunkRBNF6MNHcjs.c; exports.GrasshopperClient = _chunkGZYSQSLHcjs.c; exports.GrasshopperResponseProcessor = _chunkGZYSQSLHcjs.f; exports.RhinoComputeError = _chunkRBNF6MNHcjs.d; exports.SolveScheduler = _chunkGZYSQSLHcjs.b; exports.TreeBuilder = _chunkGZYSQSLHcjs.l; exports.camelcaseKeys = _chunkRBNF6MNHcjs.k; exports.downloadFileData = _chunkGZYSQSLHcjs.e; exports.enableDebugLogging = _chunkRBNF6MNHcjs.g; exports.extractFilesFromComputeResponse = _chunkGZYSQSLHcjs.d; exports.fetchDefinitionIO = _chunkGZYSQSLHcjs.j; exports.fetchParsedDefinitionIO = _chunkGZYSQSLHcjs.k; exports.fetchRhinoCompute = _chunkRBNF6MNHcjs.h; exports.getLogger = _chunkRBNF6MNHcjs.e; exports.hashSolveInput = _chunkGZYSQSLHcjs.a; exports.processInput = _chunkGZYSQSLHcjs.h; exports.processInputs = _chunkGZYSQSLHcjs.i; exports.setLogger = _chunkRBNF6MNHcjs.f; exports.solveGrasshopperDefinition = _chunkGZYSQSLHcjs.g; exports.toCamelCase = _chunkRBNF6MNHcjs.j;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk3FH7FKLGcjs = require('./chunk-3FH7FKLG.cjs');var _chunkMA6YB3YZcjs = require('./chunk-MA6YB3YZ.cjs');exports.ComputeServerStats = _chunkMA6YB3YZcjs.j; exports.ErrorCodes = _chunkMA6YB3YZcjs.c; exports.GrasshopperClient = _chunk3FH7FKLGcjs.d; exports.GrasshopperResponseProcessor = _chunk3FH7FKLGcjs.e; exports.RhinoComputeError = _chunkMA6YB3YZcjs.d; exports.SolveScheduler = _chunk3FH7FKLGcjs.c; exports.TreeBuilder = _chunk3FH7FKLGcjs.j; exports.camelcaseKeys = _chunkMA6YB3YZcjs.l; exports.downloadFileData = _chunkMA6YB3YZcjs.r; exports.enableDebugLogging = _chunkMA6YB3YZcjs.g; exports.extractFilesFromComputeResponse = _chunkMA6YB3YZcjs.q; exports.fetchDefinitionIO = _chunk3FH7FKLGcjs.h; exports.fetchParsedDefinitionIO = _chunk3FH7FKLGcjs.i; exports.fetchRhinoCompute = _chunkMA6YB3YZcjs.h; exports.getLogger = _chunkMA6YB3YZcjs.e; exports.hashSolveInput = _chunk3FH7FKLGcjs.b; exports.processInput = _chunk3FH7FKLGcjs.f; exports.processInputs = _chunk3FH7FKLGcjs.g; exports.setLogger = _chunkMA6YB3YZcjs.f; exports.solveGrasshopperDefinition = _chunk3FH7FKLGcjs.a; exports.toCamelCase = _chunkMA6YB3YZcjs.k;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/selva-compute/selva-compute/dist/index.cjs"],"names":[],"mappings":"AAAA,iIAAqH,gCAA6B,wDAAuF,u/BAA8d","file":"/home/runner/work/selva-compute/selva-compute/dist/index.cjs"}
1
+ {"version":3,"sources":["/home/runner/work/selva-compute/selva-compute/dist/index.cjs"],"names":[],"mappings":"AAAA,iIAAuG,wDAAqG,u/BAA8d","file":"/home/runner/work/selva-compute/selva-compute/dist/index.cjs"}
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { Logger, camelcaseKeys, enableDebugLogging, fetchRhinoCompute, getLogger, setLogger, toCamelCase } from './core.cjs';
2
- export { C as ComputeServerStats, E as ErrorCode, a as ErrorCodes, R as RhinoComputeError } from './errors-CEy4nM1J.cjs';
3
- export { B as BooleanInputType, C as ComputeConfig, D as DataItem, a as DataTree, b as DataTreeDefault, c as DataTreePath, d as DefaultValue, F as FileInputType, G as GeometryInputType, e as GrasshopperComputeConfig, f as GrasshopperComputeResponse, g as GrasshopperParsedIO, h as GrasshopperParsedIORaw, i as GrasshopperRequestSchema, I as InnerTreeData, j as InputParam, k as InputParamSchema, N as NumericInputType, O as OutputParamSchema, l as OutputType, R as RetryPolicy, m as RhinoModelUnit, T as TextInputType, V as ValueListInputType } from './types-Dfeei0dD.cjs';
4
- export { CacheOptions, DataTreeValue, FileBaseInfo, FileData, GetValuesOptions, GetValuesResult, GrasshopperClient, GrasshopperResponseProcessor, ParsedContext, ProcessedFile, SchedulerMode, SolveContext, SolveExecutor, SolveOptions, SolveResult, SolveScheduler, SolveSchedulerOptions, TreeBuilder, downloadFileData, extractFilesFromComputeResponse, fetchDefinitionIO, fetchParsedDefinitionIO, hashSolveInput, processInput, processInputs, solveGrasshopperDefinition } from './grasshopper.cjs';
2
+ export { C as ComputeServerStats, E as ErrorCode, a as ErrorCodes, F as FileBaseInfo, b as FileData, P as ProcessedFile, R as RhinoComputeError, d as downloadFileData, e as extractFilesFromComputeResponse } from './handle-files-DsrxHKHP.cjs';
3
+ export { C as ComputeConfig, R as RetryPolicy, a as RhinoModelUnit, S as ServerTiming } from './types-D1SkNje_.cjs';
4
+ export { CacheOptions, DataTreeValue, GetValuesOptions, GetValuesResult, GrasshopperClient, GrasshopperResponseProcessor, ParsedContext, SchedulerMode, SolveContext, SolveExecutor, SolveOptions, SolveResult, SolveScheduler, SolveSchedulerOptions, TreeBuilder, fetchDefinitionIO, fetchParsedDefinitionIO, hashSolveInput, processInput, processInputs, solveGrasshopperDefinition } from './grasshopper.cjs';
5
+ export { B as BooleanInputType, D as DataItem, a as DataTree, b as DataTreeDefault, c as DataTreePath, d as DefaultValue, F as FileInputType, G as GeometryInputType, e as GrasshopperComputeConfig, f as GrasshopperComputeResponse, g as GrasshopperParsedIO, h as GrasshopperParsedIORaw, i as GrasshopperRequestSchema, I as InnerTreeData, j as InputParam, k as InputParamSchema, N as NumericInputType, O as OutputParamSchema, l as OutputType, T as TextInputType, V as ValueListInputType } from './types-CJ092lxB.cjs';
5
6
  import 'three';
6
- import './types-COCuQEMk.cjs';
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { Logger, camelcaseKeys, enableDebugLogging, fetchRhinoCompute, getLogger, setLogger, toCamelCase } from './core.js';
2
- export { C as ComputeServerStats, E as ErrorCode, a as ErrorCodes, R as RhinoComputeError } from './errors-CEy4nM1J.js';
3
- export { B as BooleanInputType, C as ComputeConfig, D as DataItem, a as DataTree, b as DataTreeDefault, c as DataTreePath, d as DefaultValue, F as FileInputType, G as GeometryInputType, e as GrasshopperComputeConfig, f as GrasshopperComputeResponse, g as GrasshopperParsedIO, h as GrasshopperParsedIORaw, i as GrasshopperRequestSchema, I as InnerTreeData, j as InputParam, k as InputParamSchema, N as NumericInputType, O as OutputParamSchema, l as OutputType, R as RetryPolicy, m as RhinoModelUnit, T as TextInputType, V as ValueListInputType } from './types-Dfeei0dD.js';
4
- export { CacheOptions, DataTreeValue, FileBaseInfo, FileData, GetValuesOptions, GetValuesResult, GrasshopperClient, GrasshopperResponseProcessor, ParsedContext, ProcessedFile, SchedulerMode, SolveContext, SolveExecutor, SolveOptions, SolveResult, SolveScheduler, SolveSchedulerOptions, TreeBuilder, downloadFileData, extractFilesFromComputeResponse, fetchDefinitionIO, fetchParsedDefinitionIO, hashSolveInput, processInput, processInputs, solveGrasshopperDefinition } from './grasshopper.js';
2
+ export { C as ComputeServerStats, E as ErrorCode, a as ErrorCodes, F as FileBaseInfo, b as FileData, P as ProcessedFile, R as RhinoComputeError, d as downloadFileData, e as extractFilesFromComputeResponse } from './handle-files-DsrxHKHP.js';
3
+ export { C as ComputeConfig, R as RetryPolicy, a as RhinoModelUnit, S as ServerTiming } from './types-D1SkNje_.js';
4
+ export { CacheOptions, DataTreeValue, GetValuesOptions, GetValuesResult, GrasshopperClient, GrasshopperResponseProcessor, ParsedContext, SchedulerMode, SolveContext, SolveExecutor, SolveOptions, SolveResult, SolveScheduler, SolveSchedulerOptions, TreeBuilder, fetchDefinitionIO, fetchParsedDefinitionIO, hashSolveInput, processInput, processInputs, solveGrasshopperDefinition } from './grasshopper.js';
5
+ export { B as BooleanInputType, D as DataItem, a as DataTree, b as DataTreeDefault, c as DataTreePath, d as DefaultValue, F as FileInputType, G as GeometryInputType, e as GrasshopperComputeConfig, f as GrasshopperComputeResponse, g as GrasshopperParsedIO, h as GrasshopperParsedIORaw, i as GrasshopperRequestSchema, I as InnerTreeData, j as InputParam, k as InputParamSchema, N as NumericInputType, O as OutputParamSchema, l as OutputType, T as TextInputType, V as ValueListInputType } from './types-XCUrJGby.js';
5
6
  import 'three';
6
- import './types-COCuQEMk.js';
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import{a as b,b as c,c as d,d as g,e as h,f as i,g as j,h as k,i as l,j as n,k as q,l as s}from"./chunk-JZYEMZZ5.js";import"./chunk-OW6HV6QP.js";import{c as o,d as r,e,f,g as m,h as p,i as t,j as x,k as a}from"./chunk-XBIEAJBK.js";export{t as ComputeServerStats,o as ErrorCodes,d as GrasshopperClient,i as GrasshopperResponseProcessor,r as RhinoComputeError,c as SolveScheduler,s as TreeBuilder,a as camelcaseKeys,h as downloadFileData,m as enableDebugLogging,g as extractFilesFromComputeResponse,n as fetchDefinitionIO,q as fetchParsedDefinitionIO,p as fetchRhinoCompute,e as getLogger,b as hashSolveInput,k as processInput,l as processInputs,f as setLogger,j as solveGrasshopperDefinition,x as toCamelCase};
1
+ import{a as d,b as g,c as h,d as i,e as j,f as k,g as l,h as n,i as q,j as s}from"./chunk-DELOBV2Q.js";import{c as o,d as r,e,f,g as m,h as p,j as t,k as x,l as a,q as b,r as c}from"./chunk-GTTKNF4G.js";export{t as ComputeServerStats,o as ErrorCodes,i as GrasshopperClient,j as GrasshopperResponseProcessor,r as RhinoComputeError,h as SolveScheduler,s as TreeBuilder,a as camelcaseKeys,c as downloadFileData,m as enableDebugLogging,b as extractFilesFromComputeResponse,n as fetchDefinitionIO,q as fetchParsedDefinitionIO,p as fetchRhinoCompute,e as getLogger,g as hashSolveInput,k as processInput,l as processInputs,f as setLogger,d as solveGrasshopperDefinition,x as toCamelCase};
2
2
  //# sourceMappingURL=index.js.map