@selvajs/compute 5.0.1 → 5.1.0-beta.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/dist/core.d.ts +1 -1
- package/dist/core.js +1 -1
- package/dist/grasshopper.d.ts +18 -1
- package/dist/grasshopper.js +17 -3
- package/dist/grasshopper.js.map +1 -1
- package/dist/{handle-files-D-4X4Uh_.js → handle-files-CzqBN3MP.js} +193 -162
- package/dist/handle-files-CzqBN3MP.js.map +1 -0
- package/dist/{types-Dm9QFVvA.d.ts → types-CcKxH26w.d.ts} +26 -3
- package/package.json +1 -1
- package/dist/handle-files-D-4X4Uh_.js.map +0 -1
package/dist/core.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as DefinitionRef, c as ComputeAuth, d as ServerErrorCodeMap, f as ServerTiming, h as ErrorCodes, i as ProcessedFile, l as ComputeConfig, m as ErrorCode, n as FileBaseInfo, o as SolveDefinition, p as ComputeError, r as FileData, s as isDefinitionRef, t as DownloadOptions, u as RetryPolicy } from "./types-
|
|
1
|
+
import { a as DefinitionRef, c as ComputeAuth, d as ServerErrorCodeMap, f as ServerTiming, h as ErrorCodes, i as ProcessedFile, l as ComputeConfig, m as ErrorCode, n as FileBaseInfo, o as SolveDefinition, p as ComputeError, r as FileData, s as isDefinitionRef, t as DownloadOptions, u as RetryPolicy } from "./types-CcKxH26w.js";
|
|
2
2
|
/**
|
|
3
3
|
* POST `args` as JSON to `<serverUrl>/<endpoint>` with retry, timeout and abort handling, and
|
|
4
4
|
* return the parsed response. Most callers want a higher-level API.
|
package/dist/core.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { L as ComputeError, S as DEFAULT_BLOCKED_HOST, R as ErrorCodes, d as classifyProbeFailure, y as decodeBase64ToBinary, t as downloadFileData, n as downloadFileDataByRoot, P as enableDebugLogging, r as extractFilesFromComputeResponse, l as fetchCompute, F as getLogger, a as groupFilesByRoot, E as hasField, s as isDefinitionRef, D as readField, I as setLogger, o as subFolderSegments, C as validateServerUrl } from "./handle-files-CzqBN3MP.js";
|
package/dist/grasshopper.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as ComputeAuth, f as ServerTiming, l as ComputeConfig, n as FileBaseInfo, o as SolveDefinition, p as ComputeError, u as RetryPolicy } from "./types-
|
|
1
|
+
import { c as ComputeAuth, f as ServerTiming, l as ComputeConfig, n as FileBaseInfo, o as SolveDefinition, p as ComputeError, u as RetryPolicy } from "./types-CcKxH26w.js";
|
|
2
2
|
interface ServerVersion {
|
|
3
3
|
rhino: string;
|
|
4
4
|
compute: string;
|
|
@@ -742,6 +742,16 @@ interface SchedulerSolveOptions {
|
|
|
742
742
|
signal?: AbortSignal;
|
|
743
743
|
/** Per-solve live-event callback. Not part of the cache key: it names where events go, not what is solved. */
|
|
744
744
|
selvaevents?: SelvaEventTarget;
|
|
745
|
+
/**
|
|
746
|
+
* Routes this solve to its session's warm child; see `ComputeConfig.sessionId`. Not part of the
|
|
747
|
+
* cache key, so sessions still share cached results.
|
|
748
|
+
*/
|
|
749
|
+
sessionId?: string;
|
|
750
|
+
/**
|
|
751
|
+
* Request headers for this solve only. One replaces a client config header of any casing; the
|
|
752
|
+
* transport's own still win. Not part of the cache key.
|
|
753
|
+
*/
|
|
754
|
+
headers?: Record<string, string>;
|
|
745
755
|
/**
|
|
746
756
|
* This call's `Server-Timing` breakdown, after the client config's own `onServerTiming`.
|
|
747
757
|
* Never fires for a `fromCache` hit, which sends no request.
|
|
@@ -924,6 +934,13 @@ interface SolveOptions {
|
|
|
924
934
|
retry?: RetryPolicy;
|
|
925
935
|
/** Per-solve live-event callback, forwarded onto the request body. */
|
|
926
936
|
selvaevents?: SelvaEventTarget;
|
|
937
|
+
/** Routes this solve to its session's warm child; see {@link ComputeConfig.sessionId}. */
|
|
938
|
+
sessionId?: string;
|
|
939
|
+
/**
|
|
940
|
+
* Request headers for this solve only. One replaces a client config header of any casing; the
|
|
941
|
+
* transport's own still win.
|
|
942
|
+
*/
|
|
943
|
+
headers?: Record<string, string>;
|
|
927
944
|
}
|
|
928
945
|
/** Options for {@link GrasshopperClient.create} that shape construction, not the solves. */
|
|
929
946
|
interface CreateClientOptions {
|
package/dist/grasshopper.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as buildAuthHeaders, C as validateServerUrl, D as readField, E as hasField, F as getLogger, L as ComputeError, M as withJsonContentType, N as warnIfClientSide, O as sleep, R as ErrorCodes, T as redactUrl, _ as readBodyText, b as detectBase64Payload, c as isDefinitionUrl, d as classifyProbeFailure, f as isRedirect, g as raceSignal, h as composeSignal, i as isBase64Flag, j as mergeUnder, k as assertSessionId, l as fetchCompute, m as setResponseWireSize, p as getResponseWireSize, s as isDefinitionRef, t as downloadFileData, u as validateNumbers, v as base64ByteArray, w as tryParseJson, x as encodeStringToBase64, z as abortedByCaller } from "./handle-files-CzqBN3MP.js";
|
|
2
2
|
// src/grasshopper/server/compute-server-stats.ts
|
|
3
3
|
/**
|
|
4
4
|
* Server health and control: liveness, version, child processes, cache purges.
|
|
@@ -1802,6 +1802,7 @@ var SolveScheduler = class {
|
|
|
1802
1802
|
lastStateSeq = 0;
|
|
1803
1803
|
disposed = false;
|
|
1804
1804
|
constructor(executor, baseConfig, options = {}) {
|
|
1805
|
+
assertSessionId(baseConfig.sessionId);
|
|
1805
1806
|
this.executor = executor;
|
|
1806
1807
|
this.baseConfig = baseConfig;
|
|
1807
1808
|
this.mode = options.mode ?? "latest-wins";
|
|
@@ -1897,6 +1898,11 @@ var SolveScheduler = class {
|
|
|
1897
1898
|
/** {@link solve}, also resolving with whether this call hit the cache and how long it took. */
|
|
1898
1899
|
solveDetailed(definition, dataTree, options) {
|
|
1899
1900
|
if (this.disposed) return Promise.reject(new ComputeError("SolveScheduler has been disposed and cannot be used", ErrorCodes.INVALID_STATE));
|
|
1901
|
+
try {
|
|
1902
|
+
assertSessionId(options?.sessionId);
|
|
1903
|
+
} catch (error) {
|
|
1904
|
+
return Promise.reject(error);
|
|
1905
|
+
}
|
|
1900
1906
|
const hashes = new SolveInputHashes(() => this.hashDefinitionMemo(definition), dataTree);
|
|
1901
1907
|
let key = "";
|
|
1902
1908
|
if (this.cache.enabled || this.onStart || this.onSettle || this.onSuperseded) try {
|
|
@@ -1944,6 +1950,8 @@ var SolveScheduler = class {
|
|
|
1944
1950
|
reject,
|
|
1945
1951
|
externalSignal: options?.signal,
|
|
1946
1952
|
selvaevents: options?.selvaevents,
|
|
1953
|
+
sessionId: options?.sessionId,
|
|
1954
|
+
headers: options?.headers,
|
|
1947
1955
|
onServerTiming: options?.onServerTiming
|
|
1948
1956
|
};
|
|
1949
1957
|
if (item.externalSignal) {
|
|
@@ -2053,7 +2061,9 @@ var SolveScheduler = class {
|
|
|
2053
2061
|
signal: controller.signal,
|
|
2054
2062
|
...this.timeoutMs !== void 0 && { timeoutMs: this.timeoutMs },
|
|
2055
2063
|
...this.retry !== void 0 && { retry: this.retry },
|
|
2056
|
-
...item.selvaevents !== void 0 && { selvaevents: item.selvaevents }
|
|
2064
|
+
...item.selvaevents !== void 0 && { selvaevents: item.selvaevents },
|
|
2065
|
+
...item.sessionId !== void 0 && { sessionId: item.sessionId },
|
|
2066
|
+
...item.headers !== void 0 && { headers: mergeUnder(this.baseConfig.headers, item.headers) }
|
|
2057
2067
|
};
|
|
2058
2068
|
const callTiming = item.onServerTiming;
|
|
2059
2069
|
if (callTiming) {
|
|
@@ -2302,6 +2312,7 @@ var GrasshopperClient = class GrasshopperClient {
|
|
|
2302
2312
|
*/
|
|
2303
2313
|
static CREATE_PROBE_TIMEOUT_MS = 2e3;
|
|
2304
2314
|
constructor(config) {
|
|
2315
|
+
assertSessionId(config.sessionId);
|
|
2305
2316
|
this.config = {
|
|
2306
2317
|
...config,
|
|
2307
2318
|
serverUrl: validateServerUrl(config.serverUrl),
|
|
@@ -2395,12 +2406,15 @@ var GrasshopperClient = class GrasshopperClient {
|
|
|
2395
2406
|
if (typeof definition === "string" && !definition.trim()) throw new ComputeError("Definition URL/content is required", ErrorCodes.INVALID_INPUT, { context: { receivedUrl: definition } });
|
|
2396
2407
|
else if (definition instanceof Uint8Array && definition.length === 0) throw new ComputeError("Definition content is empty", ErrorCodes.INVALID_INPUT);
|
|
2397
2408
|
else if (isDefinitionRef(definition) && !definition.key.trim()) throw new ComputeError("DefinitionRef key is empty", ErrorCodes.INVALID_INPUT);
|
|
2409
|
+
assertSessionId(options?.sessionId);
|
|
2398
2410
|
const result = await solveGrasshopperDefinition(dataTree, definition, {
|
|
2399
2411
|
...this.config,
|
|
2400
2412
|
...options?.signal !== void 0 && { signal: options.signal },
|
|
2401
2413
|
...options?.timeoutMs !== void 0 && { timeoutMs: options.timeoutMs },
|
|
2402
2414
|
...options?.retry !== void 0 && { retry: options.retry },
|
|
2403
|
-
...options?.selvaevents !== void 0 && { selvaevents: options.selvaevents }
|
|
2415
|
+
...options?.selvaevents !== void 0 && { selvaevents: options.selvaevents },
|
|
2416
|
+
...options?.sessionId !== void 0 && { sessionId: options.sessionId },
|
|
2417
|
+
...options?.headers !== void 0 && { headers: mergeUnder(this.config.headers, options.headers) }
|
|
2404
2418
|
});
|
|
2405
2419
|
const solveErrors = readField(result, "errors");
|
|
2406
2420
|
if (Array.isArray(solveErrors) && solveErrors.length > 0) throw new ComputeError(solveErrors.map(String).join("; ") || "Computation failed", ErrorCodes.COMPUTATION_ERROR, { context: {
|