@selvajs/compute 1.5.0
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/LICENSE.md +21 -0
- package/README.md +106 -0
- package/dist/base-dtik4Dlu.d.cts +138 -0
- package/dist/base-dtik4Dlu.d.ts +138 -0
- package/dist/chunk-FRSLCR7G.cjs +2 -0
- package/dist/chunk-FRSLCR7G.cjs.map +1 -0
- package/dist/chunk-IJZNCO5X.cjs +3 -0
- package/dist/chunk-IJZNCO5X.cjs.map +1 -0
- package/dist/chunk-LNIUUPA5.cjs +2 -0
- package/dist/chunk-LNIUUPA5.cjs.map +1 -0
- package/dist/chunk-PZ4HZLFJ.js +2 -0
- package/dist/chunk-PZ4HZLFJ.js.map +1 -0
- package/dist/chunk-VK2TSW7S.js +3 -0
- package/dist/chunk-VK2TSW7S.js.map +1 -0
- package/dist/chunk-WXQGTKU6.js +2 -0
- package/dist/chunk-WXQGTKU6.js.map +1 -0
- package/dist/core.cjs +2 -0
- package/dist/core.cjs.map +1 -0
- package/dist/core.d.cts +140 -0
- package/dist/core.d.ts +140 -0
- package/dist/core.js +2 -0
- package/dist/core.js.map +1 -0
- package/dist/grasshopper.cjs +2 -0
- package/dist/grasshopper.cjs.map +1 -0
- package/dist/grasshopper.d.cts +1014 -0
- package/dist/grasshopper.d.ts +1014 -0
- package/dist/grasshopper.js +2 -0
- package/dist/grasshopper.js.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/schemas-Ct7lU-IH.d.cts +247 -0
- package/dist/schemas-Ct7lU-IH.d.ts +247 -0
- package/dist/types-B24K2LG4.d.cts +85 -0
- package/dist/types-B24K2LG4.d.ts +85 -0
- package/dist/visualization.cjs +2 -0
- package/dist/visualization.cjs.map +1 -0
- package/dist/visualization.d.cts +205 -0
- package/dist/visualization.d.ts +205 -0
- package/dist/visualization.js +2 -0
- package/dist/visualization.js.map +1 -0
- package/package.json +122 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["d:\\Coding\\selva-compute\\dist\\core.cjs"],"names":[],"mappings":"AAAA,iIAAgG,yZAAwL","file":"D:\\Coding\\selva-compute\\dist\\core.cjs"}
|
package/dist/core.d.cts
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { C as ComputeConfig, G as GrasshopperComputeConfig, d as GrasshopperComputeResponse, h as IoResponseSchema } from './schemas-Ct7lU-IH.cjs';
|
|
2
|
+
export { R as RetryPolicy, g as RhinoModelUnit } from './schemas-Ct7lU-IH.cjs';
|
|
3
|
+
export { C as ComputeServerStats, R as RhinoComputeError } from './base-dtik4Dlu.cjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Valid endpoints for Rhino Compute (improved response type handling).
|
|
7
|
+
*/
|
|
8
|
+
type Endpoint = 'grasshopper' | 'io' | string;
|
|
9
|
+
type EndpointResponseMap = {
|
|
10
|
+
grasshopper: GrasshopperComputeResponse;
|
|
11
|
+
io: IoResponseSchema;
|
|
12
|
+
};
|
|
13
|
+
type ComputeResponseFor<E extends string> = E extends keyof EndpointResponseMap ? EndpointResponseMap[E] : unknown;
|
|
14
|
+
/**
|
|
15
|
+
* Generic Rhino Compute fetch function.
|
|
16
|
+
* Sends a POST request to any Compute endpoint with pre-prepared arguments.
|
|
17
|
+
*
|
|
18
|
+
* Use this for advanced, low-level control over compute requests. For most use cases, prefer higher-level APIs.
|
|
19
|
+
*
|
|
20
|
+
* @typeParam E - The endpoint name (e.g., 'grasshopper', 'io'). Determines the response type for better type safety.
|
|
21
|
+
* @param endpoint - The Compute API endpoint (e.g., 'grasshopper', 'io', 'mesh').
|
|
22
|
+
* @param args - Pre-prepared arguments for the request body.
|
|
23
|
+
* @param config - Compute configuration (server URL, API key, timeout, debug, retry, signal).
|
|
24
|
+
* @returns The parsed JSON response from the server, typed according to the endpoint.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* // Basic usage for the Grasshopper endpoint:
|
|
28
|
+
* const response = await fetchRhinoCompute(
|
|
29
|
+
* 'grasshopper',
|
|
30
|
+
* { ... },
|
|
31
|
+
* {
|
|
32
|
+
* serverUrl: 'https://my-server.com',
|
|
33
|
+
* debug: true,
|
|
34
|
+
* timeoutMs: 30_000,
|
|
35
|
+
* retry: { attempts: 2 },
|
|
36
|
+
* signal: controller.signal,
|
|
37
|
+
* }
|
|
38
|
+
* );
|
|
39
|
+
*/
|
|
40
|
+
declare function fetchRhinoCompute<E extends Endpoint>(endpoint: E, args: Record<string, any>, config: ComputeConfig | GrasshopperComputeConfig): Promise<ComputeResponseFor<E>>;
|
|
41
|
+
|
|
42
|
+
declare const ErrorCodes: {
|
|
43
|
+
readonly NETWORK_ERROR: "NETWORK_ERROR";
|
|
44
|
+
readonly AUTH_ERROR: "AUTH_ERROR";
|
|
45
|
+
readonly VALIDATION_ERROR: "VALIDATION_ERROR";
|
|
46
|
+
readonly COMPUTATION_ERROR: "COMPUTATION_ERROR";
|
|
47
|
+
readonly TIMEOUT_ERROR: "TIMEOUT_ERROR";
|
|
48
|
+
readonly CORS_ERROR: "CORS_ERROR";
|
|
49
|
+
readonly UNKNOWN_ERROR: "UNKNOWN_ERROR";
|
|
50
|
+
readonly INVALID_STATE: "INVALID_STATE";
|
|
51
|
+
readonly INVALID_INPUT: "INVALID_INPUT";
|
|
52
|
+
readonly INVALID_CONFIG: "INVALID_CONFIG";
|
|
53
|
+
readonly BROWSER_ONLY: "BROWSER_ONLY";
|
|
54
|
+
readonly ENVIRONMENT_ERROR: "ENVIRONMENT_ERROR";
|
|
55
|
+
readonly ENCODING_ERROR: "ENCODING_ERROR";
|
|
56
|
+
};
|
|
57
|
+
type ErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Logger interface for structured logging
|
|
61
|
+
*
|
|
62
|
+
* @public Implement this interface to provide custom logging behavior.
|
|
63
|
+
*/
|
|
64
|
+
interface Logger {
|
|
65
|
+
debug(message: string, ...args: unknown[]): void;
|
|
66
|
+
info(message: string, ...args: unknown[]): void;
|
|
67
|
+
warn(message: string, ...args: unknown[]): void;
|
|
68
|
+
error(message: string, ...args: unknown[]): void;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Get the current logger instance
|
|
72
|
+
*
|
|
73
|
+
* @returns The current logger instance
|
|
74
|
+
*/
|
|
75
|
+
declare function getLogger(): Logger;
|
|
76
|
+
/**
|
|
77
|
+
* Set a custom logger instance
|
|
78
|
+
*
|
|
79
|
+
* @public Use this to configure custom logging behavior.
|
|
80
|
+
*
|
|
81
|
+
* @param logger - Custom logger implementation or null to disable logging
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* import { setLogger } from '@selvajs/compute';
|
|
86
|
+
*
|
|
87
|
+
* // Enable console logging
|
|
88
|
+
* setLogger(console);
|
|
89
|
+
*
|
|
90
|
+
* // Use a custom logger
|
|
91
|
+
* setLogger({
|
|
92
|
+
* debug: (msg, ...args) => myLogger.debug(msg, ...args),
|
|
93
|
+
* info: (msg, ...args) => myLogger.info(msg, ...args),
|
|
94
|
+
* warn: (msg, ...args) => myLogger.warn(msg, ...args),
|
|
95
|
+
* error: (msg, ...args) => myLogger.error(msg, ...args)
|
|
96
|
+
* });
|
|
97
|
+
*
|
|
98
|
+
* // Disable logging
|
|
99
|
+
* setLogger(null);
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
declare function setLogger(logger: Logger | Console | null): void;
|
|
103
|
+
/**
|
|
104
|
+
* Enable debug logging to console
|
|
105
|
+
*
|
|
106
|
+
* @public Convenience method to enable console logging.
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```typescript
|
|
110
|
+
* import { enableDebugLogging } from '@selvajs/compute';
|
|
111
|
+
*
|
|
112
|
+
* enableDebugLogging();
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
declare function enableDebugLogging(): void;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Converts a string to camelCase.
|
|
119
|
+
* @param str - The string to convert
|
|
120
|
+
* @param options - Options object
|
|
121
|
+
* - preserveSpaces: If true, spaces are preserved (default: false)
|
|
122
|
+
*/
|
|
123
|
+
declare function toCamelCase(str: string, options?: {
|
|
124
|
+
preserveSpaces?: boolean;
|
|
125
|
+
}): string;
|
|
126
|
+
/**
|
|
127
|
+
* Recursively converts all object keys to camelCase.
|
|
128
|
+
* @param obj - The object to process
|
|
129
|
+
* @param options - Options object
|
|
130
|
+
* - deep: If true, process deeply
|
|
131
|
+
* - preserveSpaces: If true, spaces are preserved in keys
|
|
132
|
+
* @returns The new object with camelCased keys
|
|
133
|
+
* @internal
|
|
134
|
+
*/
|
|
135
|
+
declare function camelcaseKeys(obj: unknown, options?: {
|
|
136
|
+
deep?: boolean;
|
|
137
|
+
preserveSpaces?: boolean;
|
|
138
|
+
}): unknown;
|
|
139
|
+
|
|
140
|
+
export { ComputeConfig, type ErrorCode, ErrorCodes, type Logger, camelcaseKeys, enableDebugLogging, fetchRhinoCompute, getLogger, setLogger, toCamelCase };
|
package/dist/core.d.ts
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { C as ComputeConfig, G as GrasshopperComputeConfig, d as GrasshopperComputeResponse, h as IoResponseSchema } from './schemas-Ct7lU-IH.js';
|
|
2
|
+
export { R as RetryPolicy, g as RhinoModelUnit } from './schemas-Ct7lU-IH.js';
|
|
3
|
+
export { C as ComputeServerStats, R as RhinoComputeError } from './base-dtik4Dlu.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Valid endpoints for Rhino Compute (improved response type handling).
|
|
7
|
+
*/
|
|
8
|
+
type Endpoint = 'grasshopper' | 'io' | string;
|
|
9
|
+
type EndpointResponseMap = {
|
|
10
|
+
grasshopper: GrasshopperComputeResponse;
|
|
11
|
+
io: IoResponseSchema;
|
|
12
|
+
};
|
|
13
|
+
type ComputeResponseFor<E extends string> = E extends keyof EndpointResponseMap ? EndpointResponseMap[E] : unknown;
|
|
14
|
+
/**
|
|
15
|
+
* Generic Rhino Compute fetch function.
|
|
16
|
+
* Sends a POST request to any Compute endpoint with pre-prepared arguments.
|
|
17
|
+
*
|
|
18
|
+
* Use this for advanced, low-level control over compute requests. For most use cases, prefer higher-level APIs.
|
|
19
|
+
*
|
|
20
|
+
* @typeParam E - The endpoint name (e.g., 'grasshopper', 'io'). Determines the response type for better type safety.
|
|
21
|
+
* @param endpoint - The Compute API endpoint (e.g., 'grasshopper', 'io', 'mesh').
|
|
22
|
+
* @param args - Pre-prepared arguments for the request body.
|
|
23
|
+
* @param config - Compute configuration (server URL, API key, timeout, debug, retry, signal).
|
|
24
|
+
* @returns The parsed JSON response from the server, typed according to the endpoint.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* // Basic usage for the Grasshopper endpoint:
|
|
28
|
+
* const response = await fetchRhinoCompute(
|
|
29
|
+
* 'grasshopper',
|
|
30
|
+
* { ... },
|
|
31
|
+
* {
|
|
32
|
+
* serverUrl: 'https://my-server.com',
|
|
33
|
+
* debug: true,
|
|
34
|
+
* timeoutMs: 30_000,
|
|
35
|
+
* retry: { attempts: 2 },
|
|
36
|
+
* signal: controller.signal,
|
|
37
|
+
* }
|
|
38
|
+
* );
|
|
39
|
+
*/
|
|
40
|
+
declare function fetchRhinoCompute<E extends Endpoint>(endpoint: E, args: Record<string, any>, config: ComputeConfig | GrasshopperComputeConfig): Promise<ComputeResponseFor<E>>;
|
|
41
|
+
|
|
42
|
+
declare const ErrorCodes: {
|
|
43
|
+
readonly NETWORK_ERROR: "NETWORK_ERROR";
|
|
44
|
+
readonly AUTH_ERROR: "AUTH_ERROR";
|
|
45
|
+
readonly VALIDATION_ERROR: "VALIDATION_ERROR";
|
|
46
|
+
readonly COMPUTATION_ERROR: "COMPUTATION_ERROR";
|
|
47
|
+
readonly TIMEOUT_ERROR: "TIMEOUT_ERROR";
|
|
48
|
+
readonly CORS_ERROR: "CORS_ERROR";
|
|
49
|
+
readonly UNKNOWN_ERROR: "UNKNOWN_ERROR";
|
|
50
|
+
readonly INVALID_STATE: "INVALID_STATE";
|
|
51
|
+
readonly INVALID_INPUT: "INVALID_INPUT";
|
|
52
|
+
readonly INVALID_CONFIG: "INVALID_CONFIG";
|
|
53
|
+
readonly BROWSER_ONLY: "BROWSER_ONLY";
|
|
54
|
+
readonly ENVIRONMENT_ERROR: "ENVIRONMENT_ERROR";
|
|
55
|
+
readonly ENCODING_ERROR: "ENCODING_ERROR";
|
|
56
|
+
};
|
|
57
|
+
type ErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Logger interface for structured logging
|
|
61
|
+
*
|
|
62
|
+
* @public Implement this interface to provide custom logging behavior.
|
|
63
|
+
*/
|
|
64
|
+
interface Logger {
|
|
65
|
+
debug(message: string, ...args: unknown[]): void;
|
|
66
|
+
info(message: string, ...args: unknown[]): void;
|
|
67
|
+
warn(message: string, ...args: unknown[]): void;
|
|
68
|
+
error(message: string, ...args: unknown[]): void;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Get the current logger instance
|
|
72
|
+
*
|
|
73
|
+
* @returns The current logger instance
|
|
74
|
+
*/
|
|
75
|
+
declare function getLogger(): Logger;
|
|
76
|
+
/**
|
|
77
|
+
* Set a custom logger instance
|
|
78
|
+
*
|
|
79
|
+
* @public Use this to configure custom logging behavior.
|
|
80
|
+
*
|
|
81
|
+
* @param logger - Custom logger implementation or null to disable logging
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* import { setLogger } from '@selvajs/compute';
|
|
86
|
+
*
|
|
87
|
+
* // Enable console logging
|
|
88
|
+
* setLogger(console);
|
|
89
|
+
*
|
|
90
|
+
* // Use a custom logger
|
|
91
|
+
* setLogger({
|
|
92
|
+
* debug: (msg, ...args) => myLogger.debug(msg, ...args),
|
|
93
|
+
* info: (msg, ...args) => myLogger.info(msg, ...args),
|
|
94
|
+
* warn: (msg, ...args) => myLogger.warn(msg, ...args),
|
|
95
|
+
* error: (msg, ...args) => myLogger.error(msg, ...args)
|
|
96
|
+
* });
|
|
97
|
+
*
|
|
98
|
+
* // Disable logging
|
|
99
|
+
* setLogger(null);
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
declare function setLogger(logger: Logger | Console | null): void;
|
|
103
|
+
/**
|
|
104
|
+
* Enable debug logging to console
|
|
105
|
+
*
|
|
106
|
+
* @public Convenience method to enable console logging.
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```typescript
|
|
110
|
+
* import { enableDebugLogging } from '@selvajs/compute';
|
|
111
|
+
*
|
|
112
|
+
* enableDebugLogging();
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
declare function enableDebugLogging(): void;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Converts a string to camelCase.
|
|
119
|
+
* @param str - The string to convert
|
|
120
|
+
* @param options - Options object
|
|
121
|
+
* - preserveSpaces: If true, spaces are preserved (default: false)
|
|
122
|
+
*/
|
|
123
|
+
declare function toCamelCase(str: string, options?: {
|
|
124
|
+
preserveSpaces?: boolean;
|
|
125
|
+
}): string;
|
|
126
|
+
/**
|
|
127
|
+
* Recursively converts all object keys to camelCase.
|
|
128
|
+
* @param obj - The object to process
|
|
129
|
+
* @param options - Options object
|
|
130
|
+
* - deep: If true, process deeply
|
|
131
|
+
* - preserveSpaces: If true, spaces are preserved in keys
|
|
132
|
+
* @returns The new object with camelCased keys
|
|
133
|
+
* @internal
|
|
134
|
+
*/
|
|
135
|
+
declare function camelcaseKeys(obj: unknown, options?: {
|
|
136
|
+
deep?: boolean;
|
|
137
|
+
preserveSpaces?: boolean;
|
|
138
|
+
}): unknown;
|
|
139
|
+
|
|
140
|
+
export { ComputeConfig, type ErrorCode, ErrorCodes, type Logger, camelcaseKeys, enableDebugLogging, fetchRhinoCompute, getLogger, setLogger, toCamelCase };
|
package/dist/core.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{c as a,d as b,e as c,f as d,g as e,h as f,i as g,j as h,k as i}from"./chunk-VK2TSW7S.js";export{g as ComputeServerStats,a as ErrorCodes,b as RhinoComputeError,i as camelcaseKeys,e as enableDebugLogging,f as fetchRhinoCompute,c as getLogger,d as setLogger,h as toCamelCase};
|
|
2
|
+
//# sourceMappingURL=core.js.map
|
package/dist/core.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkFRSLCR7Gcjs = require('./chunk-FRSLCR7G.cjs');require('./chunk-LNIUUPA5.cjs');var _chunkIJZNCO5Xcjs = require('./chunk-IJZNCO5X.cjs');exports.GrasshopperClient = _chunkFRSLCR7Gcjs.c; exports.GrasshopperResponseProcessor = _chunkFRSLCR7Gcjs.f; exports.RhinoComputeError = _chunkIJZNCO5Xcjs.d; exports.SolveScheduler = _chunkFRSLCR7Gcjs.b; exports.TreeBuilder = _chunkFRSLCR7Gcjs.l; exports.downloadFileData = _chunkFRSLCR7Gcjs.e; exports.extractFilesFromComputeResponse = _chunkFRSLCR7Gcjs.d; exports.fetchDefinitionIO = _chunkFRSLCR7Gcjs.j; exports.fetchParsedDefinitionIO = _chunkFRSLCR7Gcjs.k; exports.hashSolveInput = _chunkFRSLCR7Gcjs.a; exports.processInput = _chunkFRSLCR7Gcjs.h; exports.processInputs = _chunkFRSLCR7Gcjs.i; exports.solveGrasshopperDefinition = _chunkFRSLCR7Gcjs.g;
|
|
2
|
+
//# sourceMappingURL=grasshopper.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["d:\\Coding\\selva-compute\\dist\\grasshopper.cjs"],"names":[],"mappings":"AAAA,iIAAqH,gCAA6B,wDAAyC,8oBAAqU","file":"D:\\Coding\\selva-compute\\dist\\grasshopper.cjs"}
|