@selvajs/compute 5.0.0 → 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 +24 -1
- package/dist/grasshopper.js +19 -4
- 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;
|
|
@@ -12,6 +12,12 @@ interface ServerLimits {
|
|
|
12
12
|
maxRequestBytes: number;
|
|
13
13
|
/** A stale definition pointer answers `definition_not_cached`, so pointer reuse is safe. */
|
|
14
14
|
signalsStaleDefinition: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Changes whenever the server's plugins may have: it restarted (how a plugin is redeployed) or
|
|
17
|
+
* recycled its children. A solve result from another deployment may be wrong. `null` when the
|
|
18
|
+
* server doesn't report one.
|
|
19
|
+
*/
|
|
20
|
+
deploymentId: string | null;
|
|
15
21
|
}
|
|
16
22
|
interface ServerStats {
|
|
17
23
|
isOnline: boolean;
|
|
@@ -736,6 +742,16 @@ interface SchedulerSolveOptions {
|
|
|
736
742
|
signal?: AbortSignal;
|
|
737
743
|
/** Per-solve live-event callback. Not part of the cache key: it names where events go, not what is solved. */
|
|
738
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>;
|
|
739
755
|
/**
|
|
740
756
|
* This call's `Server-Timing` breakdown, after the client config's own `onServerTiming`.
|
|
741
757
|
* Never fires for a `fromCache` hit, which sends no request.
|
|
@@ -918,6 +934,13 @@ interface SolveOptions {
|
|
|
918
934
|
retry?: RetryPolicy;
|
|
919
935
|
/** Per-solve live-event callback, forwarded onto the request body. */
|
|
920
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>;
|
|
921
944
|
}
|
|
922
945
|
/** Options for {@link GrasshopperClient.create} that shape construction, not the solves. */
|
|
923
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.
|
|
@@ -186,7 +186,8 @@ var ComputeServerStats = class ComputeServerStats {
|
|
|
186
186
|
return {
|
|
187
187
|
timeoutSeconds: json.timeoutSeconds,
|
|
188
188
|
maxRequestBytes: json.maxRequestBytes,
|
|
189
|
-
signalsStaleDefinition: json.signalsStaleDefinition === true
|
|
189
|
+
signalsStaleDefinition: json.signalsStaleDefinition === true,
|
|
190
|
+
deploymentId: typeof json.deploymentId === "string" && json.deploymentId !== "" ? json.deploymentId : null
|
|
190
191
|
};
|
|
191
192
|
}
|
|
192
193
|
/**
|
|
@@ -1801,6 +1802,7 @@ var SolveScheduler = class {
|
|
|
1801
1802
|
lastStateSeq = 0;
|
|
1802
1803
|
disposed = false;
|
|
1803
1804
|
constructor(executor, baseConfig, options = {}) {
|
|
1805
|
+
assertSessionId(baseConfig.sessionId);
|
|
1804
1806
|
this.executor = executor;
|
|
1805
1807
|
this.baseConfig = baseConfig;
|
|
1806
1808
|
this.mode = options.mode ?? "latest-wins";
|
|
@@ -1896,6 +1898,11 @@ var SolveScheduler = class {
|
|
|
1896
1898
|
/** {@link solve}, also resolving with whether this call hit the cache and how long it took. */
|
|
1897
1899
|
solveDetailed(definition, dataTree, options) {
|
|
1898
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
|
+
}
|
|
1899
1906
|
const hashes = new SolveInputHashes(() => this.hashDefinitionMemo(definition), dataTree);
|
|
1900
1907
|
let key = "";
|
|
1901
1908
|
if (this.cache.enabled || this.onStart || this.onSettle || this.onSuperseded) try {
|
|
@@ -1943,6 +1950,8 @@ var SolveScheduler = class {
|
|
|
1943
1950
|
reject,
|
|
1944
1951
|
externalSignal: options?.signal,
|
|
1945
1952
|
selvaevents: options?.selvaevents,
|
|
1953
|
+
sessionId: options?.sessionId,
|
|
1954
|
+
headers: options?.headers,
|
|
1946
1955
|
onServerTiming: options?.onServerTiming
|
|
1947
1956
|
};
|
|
1948
1957
|
if (item.externalSignal) {
|
|
@@ -2052,7 +2061,9 @@ var SolveScheduler = class {
|
|
|
2052
2061
|
signal: controller.signal,
|
|
2053
2062
|
...this.timeoutMs !== void 0 && { timeoutMs: this.timeoutMs },
|
|
2054
2063
|
...this.retry !== void 0 && { retry: this.retry },
|
|
2055
|
-
...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) }
|
|
2056
2067
|
};
|
|
2057
2068
|
const callTiming = item.onServerTiming;
|
|
2058
2069
|
if (callTiming) {
|
|
@@ -2301,6 +2312,7 @@ var GrasshopperClient = class GrasshopperClient {
|
|
|
2301
2312
|
*/
|
|
2302
2313
|
static CREATE_PROBE_TIMEOUT_MS = 2e3;
|
|
2303
2314
|
constructor(config) {
|
|
2315
|
+
assertSessionId(config.sessionId);
|
|
2304
2316
|
this.config = {
|
|
2305
2317
|
...config,
|
|
2306
2318
|
serverUrl: validateServerUrl(config.serverUrl),
|
|
@@ -2394,12 +2406,15 @@ var GrasshopperClient = class GrasshopperClient {
|
|
|
2394
2406
|
if (typeof definition === "string" && !definition.trim()) throw new ComputeError("Definition URL/content is required", ErrorCodes.INVALID_INPUT, { context: { receivedUrl: definition } });
|
|
2395
2407
|
else if (definition instanceof Uint8Array && definition.length === 0) throw new ComputeError("Definition content is empty", ErrorCodes.INVALID_INPUT);
|
|
2396
2408
|
else if (isDefinitionRef(definition) && !definition.key.trim()) throw new ComputeError("DefinitionRef key is empty", ErrorCodes.INVALID_INPUT);
|
|
2409
|
+
assertSessionId(options?.sessionId);
|
|
2397
2410
|
const result = await solveGrasshopperDefinition(dataTree, definition, {
|
|
2398
2411
|
...this.config,
|
|
2399
2412
|
...options?.signal !== void 0 && { signal: options.signal },
|
|
2400
2413
|
...options?.timeoutMs !== void 0 && { timeoutMs: options.timeoutMs },
|
|
2401
2414
|
...options?.retry !== void 0 && { retry: options.retry },
|
|
2402
|
-
...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) }
|
|
2403
2418
|
});
|
|
2404
2419
|
const solveErrors = readField(result, "errors");
|
|
2405
2420
|
if (Array.isArray(solveErrors) && solveErrors.length > 0) throw new ComputeError(solveErrors.map(String).join("; ") || "Computation failed", ErrorCodes.COMPUTATION_ERROR, { context: {
|