tensorlake 0.5.130 → 0.5.132
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 +27 -0
- package/dist/applications/index.cjs +492 -708
- package/dist/applications/index.cjs.map +1 -1
- package/dist/applications/index.d.cts +3 -3
- package/dist/applications/index.d.ts +3 -3
- package/dist/applications/index.js +493 -713
- package/dist/applications/index.js.map +1 -1
- package/dist/function-agent/main.cjs +5 -2
- package/dist/function-agent/main.cjs.map +1 -1
- package/dist/function-agent/main.js +6 -3
- package/dist/function-agent/main.js.map +1 -1
- package/dist/function-executor/main.cjs +6 -3
- package/dist/function-executor/main.cjs.map +1 -1
- package/dist/function-executor/main.js +7 -4
- package/dist/function-executor/main.js.map +1 -1
- package/dist/index.cjs +129 -421
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -26
- package/dist/index.d.ts +16 -26
- package/dist/index.js +130 -426
- package/dist/index.js.map +1 -1
- package/dist/native-worker.cjs +1 -0
- package/dist/native-worker.cjs.map +1 -1
- package/dist/native-worker.js +1 -0
- package/dist/native-worker.js.map +1 -1
- package/dist/{remote-DRCCuRth.d.cts → remote-D95Y6Czr.d.cts} +1 -1
- package/dist/{remote-0dzBqScB.d.ts → remote-omwTzbfj.d.ts} +1 -1
- package/dist/{sandbox-image-Bf5bcxtO.d.cts → sandbox-image-ChzWDeZy.d.cts} +2 -0
- package/dist/{sandbox-image-Bf5bcxtO.d.ts → sandbox-image-ChzWDeZy.d.ts} +2 -0
- package/dist/sandbox-image.cjs +476 -453
- package/dist/sandbox-image.cjs.map +1 -1
- package/dist/sandbox-image.d.cts +1 -1
- package/dist/sandbox-image.d.ts +1 -1
- package/dist/sandbox-image.js +475 -456
- package/dist/sandbox-image.js.map +1 -1
- package/package.json +8 -8
- package/runtime/function-executor/manifest.json +14 -14
- package/runtime/function-executor/package/dist/function-executor/main.js +7 -4
- package/runtime/function-executor/package/dist/function-executor/main.js.map +1 -1
- package/runtime/function-executor/package/dist/native-worker.cjs +1 -0
- package/runtime/function-executor/package/dist/native-worker.cjs.map +1 -1
- package/runtime/function-executor/package/npm-shrinkwrap.json +2 -12
- package/runtime/function-executor/package/package.json +1 -2
- package/runtime/typescript-function-runner/manifest.json +13 -13
- package/runtime/typescript-function-runner/package/dist/function-agent/main.js +6 -3
- package/runtime/typescript-function-runner/package/dist/function-agent/main.js.map +1 -1
- package/runtime/typescript-function-runner/package/dist/native-worker.cjs +1 -0
- package/runtime/typescript-function-runner/package/dist/native-worker.cjs.map +1 -1
- package/runtime/typescript-function-runner/package/npm-shrinkwrap.json +20 -29
- package/runtime/typescript-function-runner/package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -41,12 +41,12 @@ var init_esm_shims = __esm({
|
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
// src/defaults.ts
|
|
44
|
-
var SDK_VERSION, API_URL, API_KEY, NAMESPACE, SANDBOX_PROXY_URL, DEFAULT_HTTP_TIMEOUT_MS, MAX_RETRIES, RETRY_BACKOFF_MS
|
|
44
|
+
var SDK_VERSION, API_URL, API_KEY, NAMESPACE, SANDBOX_PROXY_URL, DEFAULT_HTTP_TIMEOUT_MS, MAX_RETRIES, RETRY_BACKOFF_MS;
|
|
45
45
|
var init_defaults = __esm({
|
|
46
46
|
"src/defaults.ts"() {
|
|
47
47
|
"use strict";
|
|
48
48
|
init_esm_shims();
|
|
49
|
-
SDK_VERSION = "0.5.
|
|
49
|
+
SDK_VERSION = "0.5.132";
|
|
50
50
|
API_URL = process.env.TENSORLAKE_API_URL ?? "https://api.tensorlake.ai";
|
|
51
51
|
API_KEY = process.env.TENSORLAKE_API_KEY ?? void 0;
|
|
52
52
|
NAMESPACE = process.env.INDEXIFY_NAMESPACE ?? "default";
|
|
@@ -54,33 +54,10 @@ var init_defaults = __esm({
|
|
|
54
54
|
DEFAULT_HTTP_TIMEOUT_MS = 3e5;
|
|
55
55
|
MAX_RETRIES = 3;
|
|
56
56
|
RETRY_BACKOFF_MS = 500;
|
|
57
|
-
RETRYABLE_STATUS_CODES = /* @__PURE__ */ new Set([429, 502, 503, 504]);
|
|
58
57
|
}
|
|
59
58
|
});
|
|
60
59
|
|
|
61
60
|
// src/errors.ts
|
|
62
|
-
function describeError(err) {
|
|
63
|
-
const parts = [];
|
|
64
|
-
const seen = /* @__PURE__ */ new Set();
|
|
65
|
-
let current = err;
|
|
66
|
-
for (let depth = 0; depth < 6; depth++) {
|
|
67
|
-
if (current == null || typeof current !== "object" || seen.has(current)) {
|
|
68
|
-
break;
|
|
69
|
-
}
|
|
70
|
-
seen.add(current);
|
|
71
|
-
const e = current;
|
|
72
|
-
const message = typeof e.message === "string" ? e.message.trim() : "";
|
|
73
|
-
const code = typeof e.code === "string" ? e.code : void 0;
|
|
74
|
-
let segment = message;
|
|
75
|
-
if (code && (!message || !message.includes(code))) {
|
|
76
|
-
segment = segment ? `${segment} (${code})` : code;
|
|
77
|
-
}
|
|
78
|
-
if (segment && !parts.includes(segment)) parts.push(segment);
|
|
79
|
-
current = e.cause;
|
|
80
|
-
}
|
|
81
|
-
if (parts.length > 0) return parts.join(": ");
|
|
82
|
-
return err instanceof Error ? err.message : String(err);
|
|
83
|
-
}
|
|
84
61
|
function formatErrorDetails(errorDetails) {
|
|
85
62
|
if (errorDetails == null) return void 0;
|
|
86
63
|
if (typeof errorDetails === "string") {
|
|
@@ -280,9 +257,14 @@ var init_url = __esm({
|
|
|
280
257
|
|
|
281
258
|
// src/native-worker-client.ts
|
|
282
259
|
import { createRequire } from "module";
|
|
283
|
-
import {
|
|
260
|
+
import { Worker } from "worker_threads";
|
|
284
261
|
function createWorkerBinding(runtime) {
|
|
285
262
|
return {
|
|
263
|
+
NativeCloudClient: class {
|
|
264
|
+
constructor(...args) {
|
|
265
|
+
return runtime.handle("NativeCloudClient", args);
|
|
266
|
+
}
|
|
267
|
+
},
|
|
286
268
|
NativeSandboxClient: class {
|
|
287
269
|
constructor(...args) {
|
|
288
270
|
return runtime.handle("NativeSandboxClient", args);
|
|
@@ -398,7 +380,10 @@ var init_native_worker_client = __esm({
|
|
|
398
380
|
getWorker() {
|
|
399
381
|
if (this.worker) return this.worker;
|
|
400
382
|
const worker = new Worker(this.workerPath(), {
|
|
401
|
-
|
|
383
|
+
// The bundled worker needs no application loaders or telemetry preloads.
|
|
384
|
+
// NODE_OPTIONS is parsed independently of execArgv by Node.
|
|
385
|
+
execArgv: [],
|
|
386
|
+
env: { ...process.env, NODE_OPTIONS: "" },
|
|
402
387
|
name: "tensorlake-native"
|
|
403
388
|
});
|
|
404
389
|
this.worker = worker;
|
|
@@ -472,7 +457,7 @@ var init_native_worker_client = __esm({
|
|
|
472
457
|
}
|
|
473
458
|
};
|
|
474
459
|
runtimeKey = /* @__PURE__ */ Symbol.for(
|
|
475
|
-
`tensorlake.native.worker.${false ? "source" : "0.5.
|
|
460
|
+
`tensorlake.native.worker.${false ? "source" : "0.5.132"}.v1`
|
|
476
461
|
);
|
|
477
462
|
runtimes = globalThis;
|
|
478
463
|
}
|
|
@@ -4584,6 +4569,8 @@ var init_client = __esm({
|
|
|
4584
4569
|
"H100",
|
|
4585
4570
|
"T4",
|
|
4586
4571
|
"A6000",
|
|
4572
|
+
"RTX-PRO-6000",
|
|
4573
|
+
"L40",
|
|
4587
4574
|
"A10"
|
|
4588
4575
|
]);
|
|
4589
4576
|
SandboxClient = class _SandboxClient {
|
|
@@ -5075,7 +5062,7 @@ var init_client = __esm({
|
|
|
5075
5062
|
resources: {
|
|
5076
5063
|
cpus: options.cpus ?? 1,
|
|
5077
5064
|
memory_mb: options.memoryMb ?? 1024,
|
|
5078
|
-
|
|
5065
|
+
...options.diskMb != null ? { disk_mb: options.diskMb } : {}
|
|
5079
5066
|
},
|
|
5080
5067
|
timeout_secs: options.timeoutSecs ?? 0
|
|
5081
5068
|
};
|
|
@@ -5112,7 +5099,10 @@ var init_client = __esm({
|
|
|
5112
5099
|
* network policy, set it to replace the policy, or pass `null` to remove the
|
|
5113
5100
|
* policy entirely. On a change the service recycles the pool's unclaimed
|
|
5114
5101
|
* warm containers onto the new policy, while containers already claimed by
|
|
5115
|
-
* sandboxes keep the policy they booted with.
|
|
5102
|
+
* sandboxes keep the policy they booted with. CPU, memory, disk, image, and
|
|
5103
|
+
* entrypoint changes likewise recycle unclaimed warm containers
|
|
5104
|
+
* asynchronously. If suitable capacity is unavailable, stale warm
|
|
5105
|
+
* containers are not used as a fallback.
|
|
5116
5106
|
*/
|
|
5117
5107
|
async updatePool(poolId, options) {
|
|
5118
5108
|
const body = {
|
|
@@ -5120,7 +5110,7 @@ var init_client = __esm({
|
|
|
5120
5110
|
resources: {
|
|
5121
5111
|
cpus: options.cpus ?? 1,
|
|
5122
5112
|
memory_mb: options.memoryMb ?? 1024,
|
|
5123
|
-
|
|
5113
|
+
...options.diskMb != null ? { disk_mb: options.diskMb } : {}
|
|
5124
5114
|
},
|
|
5125
5115
|
timeout_secs: options.timeoutSecs ?? 0
|
|
5126
5116
|
};
|
|
@@ -5289,374 +5279,87 @@ var init_client = __esm({
|
|
|
5289
5279
|
}
|
|
5290
5280
|
});
|
|
5291
5281
|
|
|
5292
|
-
// src/
|
|
5293
|
-
|
|
5294
|
-
|
|
5295
|
-
|
|
5296
|
-
|
|
5297
|
-
|
|
5298
|
-
|
|
5299
|
-
|
|
5300
|
-
|
|
5301
|
-
}
|
|
5302
|
-
|
|
5303
|
-
|
|
5304
|
-
|
|
5305
|
-
|
|
5306
|
-
|
|
5307
|
-
}
|
|
5308
|
-
|
|
5309
|
-
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
|
|
5314
|
-
|
|
5315
|
-
|
|
5316
|
-
|
|
5317
|
-
|
|
5318
|
-
|
|
5319
|
-
return
|
|
5320
|
-
}
|
|
5321
|
-
|
|
5322
|
-
|
|
5323
|
-
|
|
5324
|
-
const parsed = JSON.parse(body);
|
|
5325
|
-
if (parsed.message) message = parsed.message;
|
|
5326
|
-
else if (parsed.error) message = parsed.error;
|
|
5327
|
-
} catch {
|
|
5328
|
-
}
|
|
5329
|
-
if (status === 404) {
|
|
5330
|
-
if (path4.includes("sandbox-pools") || path4.includes("pools")) {
|
|
5331
|
-
const match = path4.match(/sandbox-pools\/([^/]+)/);
|
|
5332
|
-
if (match) throw new PoolNotFoundError(match[1]);
|
|
5333
|
-
}
|
|
5334
|
-
if (path4.includes("sandboxes")) {
|
|
5335
|
-
const match = path4.match(/sandboxes\/([^/]+)/);
|
|
5336
|
-
if (match) throw new SandboxNotFoundError(match[1]);
|
|
5337
|
-
}
|
|
5338
|
-
throw new RemoteAPIError(404, message);
|
|
5339
|
-
}
|
|
5340
|
-
if (status === 409) {
|
|
5341
|
-
if (path4.includes("sandbox-pools") || path4.includes("pools")) {
|
|
5342
|
-
const match = path4.match(/sandbox-pools\/([^/]+)/);
|
|
5343
|
-
if (match) throw new PoolInUseError(match[1], message);
|
|
5344
|
-
}
|
|
5345
|
-
}
|
|
5346
|
-
throw new RemoteAPIError(status, message);
|
|
5347
|
-
}
|
|
5348
|
-
function anySignal(signals) {
|
|
5349
|
-
const controller = new AbortController();
|
|
5350
|
-
for (const signal of signals) {
|
|
5351
|
-
if (signal.aborted) {
|
|
5352
|
-
controller.abort(signal.reason);
|
|
5353
|
-
return controller.signal;
|
|
5354
|
-
}
|
|
5355
|
-
signal.addEventListener("abort", () => controller.abort(signal.reason), {
|
|
5356
|
-
once: true
|
|
5357
|
-
});
|
|
5358
|
-
}
|
|
5359
|
-
return controller.signal;
|
|
5360
|
-
}
|
|
5361
|
-
function sleep3(ms) {
|
|
5362
|
-
return new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
5363
|
-
}
|
|
5364
|
-
var REQUEST_TIMEOUT_HEADER, HttpClient;
|
|
5365
|
-
var init_http = __esm({
|
|
5366
|
-
"src/http.ts"() {
|
|
5282
|
+
// src/native-cloud.ts
|
|
5283
|
+
async function serializeRequest(method, path4, options) {
|
|
5284
|
+
const headers = { ...options?.headers };
|
|
5285
|
+
let body = options?.body;
|
|
5286
|
+
if (options?.json !== void 0) {
|
|
5287
|
+
body = JSON.stringify(options.json);
|
|
5288
|
+
if (!Object.keys(headers).some((key) => key.toLowerCase() === "content-type")) {
|
|
5289
|
+
headers["Content-Type"] = "application/json";
|
|
5290
|
+
}
|
|
5291
|
+
}
|
|
5292
|
+
const request = {
|
|
5293
|
+
method,
|
|
5294
|
+
path: path4,
|
|
5295
|
+
headersJson: JSON.stringify(headers),
|
|
5296
|
+
statusOnlyCodes: [...options?.statusOnlyCodes ?? []]
|
|
5297
|
+
};
|
|
5298
|
+
if (body instanceof FormData) {
|
|
5299
|
+
request.parts = [];
|
|
5300
|
+
for (const [name, value] of body.entries()) {
|
|
5301
|
+
request.parts.push(typeof value === "string" ? { name, data: Buffer.from(value) } : { name, data: Buffer.from(await value.arrayBuffer()), filename: value.name, contentType: value.type || "application/octet-stream" });
|
|
5302
|
+
}
|
|
5303
|
+
} else if (body !== void 0) {
|
|
5304
|
+
if (body instanceof Blob) request.body = Buffer.from(await body.arrayBuffer());
|
|
5305
|
+
else if (typeof body === "string") request.body = Buffer.from(body);
|
|
5306
|
+
else if (body instanceof ArrayBuffer) request.body = Buffer.from(new Uint8Array(body));
|
|
5307
|
+
else request.body = Buffer.from(body);
|
|
5308
|
+
}
|
|
5309
|
+
return request;
|
|
5310
|
+
}
|
|
5311
|
+
var NativeCloudTransport;
|
|
5312
|
+
var init_native_cloud = __esm({
|
|
5313
|
+
"src/native-cloud.ts"() {
|
|
5367
5314
|
"use strict";
|
|
5368
5315
|
init_esm_shims();
|
|
5369
|
-
|
|
5370
|
-
|
|
5371
|
-
|
|
5372
|
-
REQUEST_TIMEOUT_HEADER = "X-Tensorlake-Request-Timeout-Ms";
|
|
5373
|
-
setGlobalDispatcher(
|
|
5374
|
-
new Agent({
|
|
5375
|
-
keepAliveTimeout: 6e4,
|
|
5376
|
-
allowH2: true
|
|
5377
|
-
})
|
|
5378
|
-
);
|
|
5379
|
-
HttpClient = class _HttpClient {
|
|
5380
|
-
baseUrl;
|
|
5381
|
-
headers;
|
|
5382
|
-
maxRetries;
|
|
5383
|
-
retryBackoffMs;
|
|
5384
|
-
timeoutMs;
|
|
5385
|
-
abortController = null;
|
|
5316
|
+
init_native_sandbox();
|
|
5317
|
+
init_native_worker_client();
|
|
5318
|
+
NativeCloudTransport = class {
|
|
5386
5319
|
constructor(options) {
|
|
5387
|
-
|
|
5388
|
-
|
|
5389
|
-
|
|
5390
|
-
this.retryBackoffMs = options.retryBackoffMs ?? RETRY_BACKOFF_MS;
|
|
5391
|
-
this.timeoutMs = options.timeoutMs === void 0 ? DEFAULT_HTTP_TIMEOUT_MS : options.timeoutMs;
|
|
5392
|
-
this.headers = {
|
|
5393
|
-
"User-Agent": `tensorlake-typescript-sdk/${SDK_VERSION}`
|
|
5394
|
-
};
|
|
5395
|
-
if (this.timeoutMs != null) {
|
|
5396
|
-
this.headers[REQUEST_TIMEOUT_HEADER] = String(this.timeoutMs);
|
|
5397
|
-
}
|
|
5398
|
-
if (options.apiKey) {
|
|
5399
|
-
this.headers["Authorization"] = `Bearer ${options.apiKey}`;
|
|
5400
|
-
}
|
|
5401
|
-
if (options.organizationId) {
|
|
5402
|
-
this.headers["X-Forwarded-Organization-Id"] = options.organizationId;
|
|
5403
|
-
}
|
|
5404
|
-
if (options.projectId) {
|
|
5405
|
-
this.headers["X-Forwarded-Project-Id"] = options.projectId;
|
|
5406
|
-
}
|
|
5407
|
-
if (options.hostHeader) {
|
|
5408
|
-
this.headers["Host"] = options.hostHeader;
|
|
5409
|
-
}
|
|
5410
|
-
if (options.sandboxIdHeader) {
|
|
5411
|
-
this.headers["X-Tensorlake-Sandbox-Id"] = options.sandboxIdHeader;
|
|
5320
|
+
this.options = options;
|
|
5321
|
+
if (!Number.isSafeInteger(options.maxRetries) || options.maxRetries < 0 || options.maxRetries > 4294967295) {
|
|
5322
|
+
throw new RangeError("maxRetries must be a non-negative 32-bit integer");
|
|
5412
5323
|
}
|
|
5413
|
-
if (options.
|
|
5414
|
-
|
|
5324
|
+
if (!Number.isFinite(options.retryBackoffMs) || options.retryBackoffMs < 0) {
|
|
5325
|
+
throw new RangeError("retryBackoffMs must be a non-negative finite number");
|
|
5415
5326
|
}
|
|
5416
5327
|
}
|
|
5328
|
+
native;
|
|
5329
|
+
closed = false;
|
|
5330
|
+
client() {
|
|
5331
|
+
if (this.closed) throw new Error("Tensorlake native client is closed");
|
|
5332
|
+
if (this.native) return this.native;
|
|
5333
|
+
const ctor = loadNativeSandboxBinding().NativeCloudClient;
|
|
5334
|
+
if (!ctor) throw new Error("Native binding does not export NativeCloudClient; rebuild with 'npm run build:native'");
|
|
5335
|
+
return this.native = new ctor(JSON.stringify(this.options));
|
|
5336
|
+
}
|
|
5417
5337
|
close() {
|
|
5418
|
-
this.
|
|
5419
|
-
this.
|
|
5420
|
-
|
|
5421
|
-
/** Make a JSON request, returning the parsed response body. */
|
|
5422
|
-
async requestJson(method, path4, options) {
|
|
5423
|
-
const response = await this.requestResponse(method, path4, {
|
|
5424
|
-
json: options?.body,
|
|
5425
|
-
headers: options?.headers,
|
|
5426
|
-
signal: options?.signal,
|
|
5427
|
-
retryableStatusCodes: options?.retryableStatusCodes,
|
|
5428
|
-
allowedErrorStatusCodes: options?.allowedErrorStatusCodes,
|
|
5429
|
-
allowHttpErrors: options?.allowHttpErrors
|
|
5430
|
-
});
|
|
5431
|
-
const text = await response.text();
|
|
5432
|
-
const data = text ? JSON.parse(text) : void 0;
|
|
5433
|
-
return withTraceId(data, response.traceId);
|
|
5434
|
-
}
|
|
5435
|
-
/** Make a request returning raw bytes. */
|
|
5436
|
-
async requestBytes(method, path4, options) {
|
|
5437
|
-
const headers = { ...options?.headers ?? {} };
|
|
5438
|
-
if (options?.contentType) {
|
|
5439
|
-
headers["Content-Type"] = options.contentType;
|
|
5440
|
-
}
|
|
5441
|
-
const response = await this.requestResponse(method, path4, {
|
|
5442
|
-
body: options?.body,
|
|
5443
|
-
headers,
|
|
5444
|
-
signal: options?.signal
|
|
5445
|
-
});
|
|
5446
|
-
const buffer = await response.arrayBuffer();
|
|
5447
|
-
return withTraceId(new Uint8Array(buffer), response.traceId);
|
|
5448
|
-
}
|
|
5449
|
-
/** Make a request and return the response body as an SSE stream. */
|
|
5450
|
-
async requestStream(method, path4, options) {
|
|
5451
|
-
const response = await this.requestResponse(method, path4, {
|
|
5452
|
-
json: options?.json,
|
|
5453
|
-
headers: { Accept: "text/event-stream" },
|
|
5454
|
-
signal: options?.signal
|
|
5455
|
-
});
|
|
5456
|
-
if (!response.body) {
|
|
5457
|
-
throw new RemoteAPIError(
|
|
5458
|
-
response.status,
|
|
5459
|
-
"No response body for SSE stream"
|
|
5460
|
-
);
|
|
5461
|
-
}
|
|
5462
|
-
return withTraceId(response.body, response.traceId);
|
|
5338
|
+
this.closed = true;
|
|
5339
|
+
releaseNativeHandle(this.native ?? null);
|
|
5340
|
+
this.native = void 0;
|
|
5463
5341
|
}
|
|
5464
|
-
/** Make a request and return the raw Response. */
|
|
5465
5342
|
async requestResponse(method, path4, options) {
|
|
5466
|
-
const
|
|
5467
|
-
|
|
5468
|
-
|
|
5469
|
-
|
|
5470
|
-
|
|
5471
|
-
if (hasJsonBody && !hasHeader(headers, "Content-Type")) {
|
|
5472
|
-
headers["Content-Type"] = "application/json";
|
|
5473
|
-
}
|
|
5474
|
-
const body = hasJsonBody ? JSON.stringify(options?.json) : normalizeRequestBody(options?.body);
|
|
5475
|
-
const { response, traceId } = await this.doFetch(
|
|
5476
|
-
method,
|
|
5477
|
-
path4,
|
|
5478
|
-
body,
|
|
5479
|
-
headers,
|
|
5480
|
-
options?.signal,
|
|
5481
|
-
options?.allowHttpErrors ?? false,
|
|
5482
|
-
options?.retryableStatusCodes ?? RETRYABLE_STATUS_CODES,
|
|
5483
|
-
options?.allowedErrorStatusCodes ?? /* @__PURE__ */ new Set()
|
|
5484
|
-
);
|
|
5485
|
-
return withTraceId(response, traceId);
|
|
5486
|
-
}
|
|
5487
|
-
static makeTraceparent() {
|
|
5488
|
-
const randomHex = (bytes) => Array.from(crypto.getRandomValues(new Uint8Array(bytes))).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
5489
|
-
const traceId = randomHex(16);
|
|
5490
|
-
const spanId = randomHex(8);
|
|
5491
|
-
return { traceparent: `00-${traceId}-${spanId}-01`, traceId };
|
|
5492
|
-
}
|
|
5493
|
-
async doFetch(method, path4, body, headers, signal, allowHttpErrors = false, retryableStatusCodes = RETRYABLE_STATUS_CODES, allowedErrorStatusCodes = /* @__PURE__ */ new Set()) {
|
|
5494
|
-
const url = `${this.baseUrl}${path4}`;
|
|
5495
|
-
const { traceparent, traceId } = _HttpClient.makeTraceparent();
|
|
5496
|
-
headers["traceparent"] = traceparent;
|
|
5497
|
-
let lastError;
|
|
5498
|
-
const operationStart = nowMs();
|
|
5499
|
-
const timingPath = sdkTimingPayloadsEnabled() ? path4 : stripPathPayload(path4);
|
|
5500
|
-
for (let attempt = 0; attempt <= this.maxRetries; attempt++) {
|
|
5501
|
-
if (attempt > 0) {
|
|
5502
|
-
const delay = this.retryBackoffMs * Math.pow(2, attempt - 1);
|
|
5503
|
-
logSdkTimingEvent("http.request", "retry_sleep_start", {
|
|
5504
|
-
method,
|
|
5505
|
-
path: timingPath,
|
|
5506
|
-
attempt,
|
|
5507
|
-
delay_ms: delay,
|
|
5508
|
-
server_trace_id: traceId
|
|
5509
|
-
});
|
|
5510
|
-
await sleep3(delay);
|
|
5511
|
-
}
|
|
5512
|
-
this.abortController = new AbortController();
|
|
5513
|
-
let timedOut = false;
|
|
5514
|
-
const timeoutId = this.timeoutMs == null ? null : setTimeout(() => {
|
|
5515
|
-
timedOut = true;
|
|
5516
|
-
this.abortController?.abort();
|
|
5517
|
-
}, this.timeoutMs);
|
|
5518
|
-
const combinedSignal = signal ? anySignal([signal, this.abortController.signal]) : this.abortController.signal;
|
|
5519
|
-
const attemptStart = nowMs();
|
|
5520
|
-
try {
|
|
5521
|
-
const response = await undiciFetch(url, {
|
|
5522
|
-
method,
|
|
5523
|
-
headers,
|
|
5524
|
-
body,
|
|
5525
|
-
signal: combinedSignal
|
|
5526
|
-
});
|
|
5527
|
-
if (timeoutId != null) clearTimeout(timeoutId);
|
|
5528
|
-
logSdkTiming("http.request", "headers", attemptStart, {
|
|
5529
|
-
method,
|
|
5530
|
-
path: timingPath,
|
|
5531
|
-
status: response.status,
|
|
5532
|
-
attempt,
|
|
5533
|
-
server_trace_id: traceId
|
|
5534
|
-
});
|
|
5535
|
-
if (response.ok) {
|
|
5536
|
-
logSdkTiming("http.request", "complete", operationStart, {
|
|
5537
|
-
method,
|
|
5538
|
-
path: timingPath,
|
|
5539
|
-
status: response.status,
|
|
5540
|
-
attempts: attempt + 1,
|
|
5541
|
-
server_trace_id: traceId
|
|
5542
|
-
});
|
|
5543
|
-
return { response, traceId };
|
|
5544
|
-
}
|
|
5545
|
-
if (retryableStatusCodes.has(response.status) && attempt < this.maxRetries) {
|
|
5546
|
-
lastError = new RemoteAPIError(
|
|
5547
|
-
response.status,
|
|
5548
|
-
await response.text().catch(() => "")
|
|
5549
|
-
);
|
|
5550
|
-
logSdkTimingEvent("http.request", "retryable_status", {
|
|
5551
|
-
method,
|
|
5552
|
-
path: timingPath,
|
|
5553
|
-
status: response.status,
|
|
5554
|
-
attempt,
|
|
5555
|
-
server_trace_id: traceId
|
|
5556
|
-
});
|
|
5557
|
-
continue;
|
|
5558
|
-
}
|
|
5559
|
-
if (allowHttpErrors || allowedErrorStatusCodes.has(response.status)) {
|
|
5560
|
-
logSdkTiming("http.request", "complete", operationStart, {
|
|
5561
|
-
method,
|
|
5562
|
-
path: timingPath,
|
|
5563
|
-
status: response.status,
|
|
5564
|
-
attempts: attempt + 1,
|
|
5565
|
-
server_trace_id: traceId
|
|
5566
|
-
});
|
|
5567
|
-
return { response, traceId };
|
|
5568
|
-
}
|
|
5569
|
-
const errorBody = await response.text().catch(() => "");
|
|
5570
|
-
throwMappedError(response.status, errorBody, path4);
|
|
5571
|
-
} catch (err) {
|
|
5572
|
-
if (timeoutId != null) clearTimeout(timeoutId);
|
|
5573
|
-
if (err instanceof RemoteAPIError || err instanceof SandboxNotFoundError || err instanceof PoolNotFoundError || err instanceof PoolInUseError) {
|
|
5574
|
-
throw err;
|
|
5575
|
-
}
|
|
5576
|
-
if (signal?.aborted && !timedOut) {
|
|
5577
|
-
throw new SandboxConnectionError("request aborted by caller", {
|
|
5578
|
-
cause: err
|
|
5579
|
-
});
|
|
5580
|
-
}
|
|
5581
|
-
lastError = err instanceof Error ? err : new Error(String(err));
|
|
5582
|
-
logSdkTiming("http.request", "error", attemptStart, {
|
|
5583
|
-
method,
|
|
5584
|
-
path: timingPath,
|
|
5585
|
-
attempt,
|
|
5586
|
-
server_trace_id: traceId,
|
|
5587
|
-
error: timedOut ? `request timed out after ${this.timeoutMs}ms` : describeError(err)
|
|
5588
|
-
});
|
|
5589
|
-
if (attempt >= this.maxRetries) {
|
|
5590
|
-
const detail = timedOut ? `request timed out after ${this.timeoutMs}ms` : describeError(err);
|
|
5591
|
-
throw new SandboxConnectionError(detail, { cause: err });
|
|
5592
|
-
}
|
|
5593
|
-
}
|
|
5594
|
-
}
|
|
5595
|
-
throw new SandboxConnectionError(
|
|
5596
|
-
lastError ? describeError(lastError) : "request failed",
|
|
5597
|
-
{ cause: lastError }
|
|
5343
|
+
const request = await serializeRequest(method, path4, options);
|
|
5344
|
+
const raw = await callNative(() => this.client().request(request));
|
|
5345
|
+
const response = new Response(
|
|
5346
|
+
[204, 205, 304].includes(raw.status) ? null : Uint8Array.from(raw.data).buffer,
|
|
5347
|
+
{ status: raw.status, headers: JSON.parse(raw.headersJson) }
|
|
5598
5348
|
);
|
|
5349
|
+
return Object.assign(response, { traceId: raw.traceId });
|
|
5599
5350
|
}
|
|
5600
|
-
|
|
5601
|
-
|
|
5602
|
-
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
async function* parseSSEMessages(stream, signal) {
|
|
5606
|
-
const reader = stream.getReader();
|
|
5607
|
-
const decoder = new TextDecoder();
|
|
5608
|
-
let buffer = "";
|
|
5609
|
-
try {
|
|
5610
|
-
while (true) {
|
|
5611
|
-
if (signal?.aborted) break;
|
|
5612
|
-
const { done, value } = await reader.read();
|
|
5613
|
-
if (done) break;
|
|
5614
|
-
buffer += decoder.decode(value, { stream: true });
|
|
5615
|
-
const parts = buffer.split(/\r?\n\r?\n/);
|
|
5616
|
-
buffer = parts.pop() ?? "";
|
|
5617
|
-
for (const part of parts) {
|
|
5618
|
-
const lines = part.split(/\r?\n/);
|
|
5619
|
-
const dataLines = [];
|
|
5620
|
-
let event;
|
|
5621
|
-
let id;
|
|
5622
|
-
for (const line of lines) {
|
|
5623
|
-
if (!line || line.startsWith(":")) continue;
|
|
5624
|
-
const separator = line.indexOf(":");
|
|
5625
|
-
const field = separator === -1 ? line : line.slice(0, separator);
|
|
5626
|
-
let value2 = separator === -1 ? "" : line.slice(separator + 1);
|
|
5627
|
-
if (value2.startsWith(" ")) {
|
|
5628
|
-
value2 = value2.slice(1);
|
|
5629
|
-
}
|
|
5630
|
-
if (field === "data") {
|
|
5631
|
-
dataLines.push(value2);
|
|
5632
|
-
} else if (field === "event") {
|
|
5633
|
-
event = value2;
|
|
5634
|
-
} else if (field === "id") {
|
|
5635
|
-
id = value2;
|
|
5636
|
-
}
|
|
5637
|
-
}
|
|
5638
|
-
if (dataLines.length > 0 || event || id) {
|
|
5639
|
-
yield { data: dataLines.join("\n"), event, id };
|
|
5640
|
-
}
|
|
5351
|
+
async requestJson(method, path4) {
|
|
5352
|
+
const response = await this.requestResponse(method, path4);
|
|
5353
|
+
const text = await response.text();
|
|
5354
|
+
const value = text ? JSON.parse(text) : null;
|
|
5355
|
+
return Object.assign(value ?? {}, { traceId: response.traceId });
|
|
5641
5356
|
}
|
|
5642
|
-
|
|
5643
|
-
|
|
5644
|
-
|
|
5645
|
-
|
|
5646
|
-
}
|
|
5647
|
-
|
|
5648
|
-
for await (const message of parseSSEMessages(stream, signal)) {
|
|
5649
|
-
if (!message.data) continue;
|
|
5650
|
-
try {
|
|
5651
|
-
yield JSON.parse(message.data);
|
|
5652
|
-
} catch {
|
|
5653
|
-
}
|
|
5654
|
-
}
|
|
5655
|
-
}
|
|
5656
|
-
var init_sse = __esm({
|
|
5657
|
-
"src/sse.ts"() {
|
|
5658
|
-
"use strict";
|
|
5659
|
-
init_esm_shims();
|
|
5357
|
+
async *stream(method, path4, signal) {
|
|
5358
|
+
if (signal?.aborted) return;
|
|
5359
|
+
const request = await serializeRequest(method, path4, { headers: { Accept: "text/event-stream" } });
|
|
5360
|
+
yield* nativeEventStream((emit) => this.client().stream(request, emit), void 0, signal);
|
|
5361
|
+
}
|
|
5362
|
+
};
|
|
5660
5363
|
}
|
|
5661
5364
|
});
|
|
5662
5365
|
|
|
@@ -5759,11 +5462,10 @@ var init_cloud_client = __esm({
|
|
|
5759
5462
|
"use strict";
|
|
5760
5463
|
init_esm_shims();
|
|
5761
5464
|
init_defaults();
|
|
5762
|
-
|
|
5465
|
+
init_native_cloud();
|
|
5763
5466
|
init_models();
|
|
5764
|
-
init_sse();
|
|
5765
5467
|
CloudClient = class _CloudClient {
|
|
5766
|
-
|
|
5468
|
+
transport;
|
|
5767
5469
|
organizationId;
|
|
5768
5470
|
projectId;
|
|
5769
5471
|
namespace;
|
|
@@ -5771,20 +5473,22 @@ var init_cloud_client = __esm({
|
|
|
5771
5473
|
this.organizationId = options?.organizationId;
|
|
5772
5474
|
this.projectId = options?.projectId;
|
|
5773
5475
|
this.namespace = options?.namespace ?? NAMESPACE;
|
|
5774
|
-
this.
|
|
5476
|
+
this.transport = new NativeCloudTransport({
|
|
5775
5477
|
baseUrl: options?.apiUrl ?? API_URL,
|
|
5776
5478
|
apiKey: options?.apiKey ?? API_KEY,
|
|
5777
5479
|
organizationId: this.organizationId,
|
|
5778
5480
|
projectId: this.projectId,
|
|
5779
5481
|
maxRetries: options?.maxRetries ?? MAX_RETRIES,
|
|
5780
|
-
retryBackoffMs: options?.retryBackoffMs ?? RETRY_BACKOFF_MS
|
|
5482
|
+
retryBackoffMs: options?.retryBackoffMs ?? RETRY_BACKOFF_MS,
|
|
5483
|
+
timeoutMs: DEFAULT_HTTP_TIMEOUT_MS,
|
|
5484
|
+
userAgent: `tensorlake-typescript-sdk/${SDK_VERSION}`
|
|
5781
5485
|
});
|
|
5782
5486
|
}
|
|
5783
5487
|
static forCloud(options) {
|
|
5784
5488
|
return new _CloudClient(options);
|
|
5785
5489
|
}
|
|
5786
5490
|
close() {
|
|
5787
|
-
this.
|
|
5491
|
+
this.transport.close();
|
|
5788
5492
|
}
|
|
5789
5493
|
async upsertApplication(manifest, codeZip, upgradeRunningRequests = false) {
|
|
5790
5494
|
const applicationManifest = { ...manifest };
|
|
@@ -5812,18 +5516,18 @@ var init_cloud_client = __esm({
|
|
|
5812
5516
|
"upgrade_requests_to_latest_code",
|
|
5813
5517
|
String(upgradeRunningRequests)
|
|
5814
5518
|
);
|
|
5815
|
-
await this.
|
|
5519
|
+
await this.transport.requestResponse("POST", this.namespacePath("applications"), {
|
|
5816
5520
|
body: form
|
|
5817
5521
|
});
|
|
5818
5522
|
}
|
|
5819
5523
|
async deleteApplication(applicationName) {
|
|
5820
|
-
await this.
|
|
5524
|
+
await this.transport.requestResponse(
|
|
5821
5525
|
"DELETE",
|
|
5822
5526
|
this.namespacePath(`applications/${encodeURIComponent(applicationName)}`)
|
|
5823
5527
|
);
|
|
5824
5528
|
}
|
|
5825
5529
|
async deleteSandboxImage(imageName) {
|
|
5826
|
-
await this.
|
|
5530
|
+
await this.transport.requestResponse(
|
|
5827
5531
|
"DELETE",
|
|
5828
5532
|
this.namespacePath(`sandbox-images/${encodeURIComponent(imageName)}`)
|
|
5829
5533
|
);
|
|
@@ -5842,10 +5546,10 @@ var init_cloud_client = __esm({
|
|
|
5842
5546
|
options?.organizationId,
|
|
5843
5547
|
options?.projectId
|
|
5844
5548
|
);
|
|
5845
|
-
const response = await this.
|
|
5549
|
+
const response = await this.transport.requestResponse(
|
|
5846
5550
|
"GET",
|
|
5847
5551
|
`${base}/by-name/${encodeURIComponent(imageName)}`,
|
|
5848
|
-
{
|
|
5552
|
+
{ statusOnlyCodes: /* @__PURE__ */ new Set([404]) }
|
|
5849
5553
|
);
|
|
5850
5554
|
if (response.status === 404) {
|
|
5851
5555
|
return null;
|
|
@@ -5867,7 +5571,7 @@ var init_cloud_client = __esm({
|
|
|
5867
5571
|
let path4 = `${base}?pageSize=100`;
|
|
5868
5572
|
const templates = [];
|
|
5869
5573
|
while (path4 !== null) {
|
|
5870
|
-
const page = await this.
|
|
5574
|
+
const page = await this.transport.requestJson(
|
|
5871
5575
|
"GET",
|
|
5872
5576
|
path4
|
|
5873
5577
|
);
|
|
@@ -5880,7 +5584,7 @@ var init_cloud_client = __esm({
|
|
|
5880
5584
|
return templates;
|
|
5881
5585
|
}
|
|
5882
5586
|
async applications() {
|
|
5883
|
-
const raw = await this.
|
|
5587
|
+
const raw = await this.transport.requestJson(
|
|
5884
5588
|
"GET",
|
|
5885
5589
|
this.namespacePath("applications")
|
|
5886
5590
|
);
|
|
@@ -5889,7 +5593,7 @@ var init_cloud_client = __esm({
|
|
|
5889
5593
|
);
|
|
5890
5594
|
}
|
|
5891
5595
|
async applicationManifest(applicationName) {
|
|
5892
|
-
const raw = await this.
|
|
5596
|
+
const raw = await this.transport.requestJson(
|
|
5893
5597
|
"GET",
|
|
5894
5598
|
this.namespacePath(`applications/${encodeURIComponent(applicationName)}`)
|
|
5895
5599
|
);
|
|
@@ -5899,10 +5603,10 @@ var init_cloud_client = __esm({
|
|
|
5899
5603
|
const path4 = this.namespacePath(
|
|
5900
5604
|
`applications/${encodeURIComponent(applicationName)}`
|
|
5901
5605
|
);
|
|
5902
|
-
const response = inputs.length === 0 ? await this.
|
|
5606
|
+
const response = inputs.length === 0 ? await this.transport.requestResponse("POST", path4, {
|
|
5903
5607
|
body: new Uint8Array(),
|
|
5904
5608
|
headers: { Accept: "application/json" }
|
|
5905
|
-
}) : inputs.length === 1 && inputs[0].name === "0" ? await this.
|
|
5609
|
+
}) : inputs.length === 1 && inputs[0].name === "0" ? await this.transport.requestResponse("POST", path4, {
|
|
5906
5610
|
body: toRequestBody(inputs[0].data),
|
|
5907
5611
|
headers: {
|
|
5908
5612
|
Accept: "application/json",
|
|
@@ -5917,13 +5621,13 @@ var init_cloud_client = __esm({
|
|
|
5917
5621
|
return requestId;
|
|
5918
5622
|
}
|
|
5919
5623
|
async waitOnRequestCompletion(applicationName, requestId) {
|
|
5920
|
-
const stream =
|
|
5624
|
+
const stream = this.transport.stream(
|
|
5921
5625
|
"GET",
|
|
5922
5626
|
this.namespacePath(
|
|
5923
5627
|
`applications/${encodeURIComponent(applicationName)}/requests/${encodeURIComponent(requestId)}/progress`
|
|
5924
5628
|
)
|
|
5925
5629
|
);
|
|
5926
|
-
for await (const event of
|
|
5630
|
+
for await (const event of stream) {
|
|
5927
5631
|
if (Object.prototype.hasOwnProperty.call(event, "RequestFinished")) {
|
|
5928
5632
|
return;
|
|
5929
5633
|
}
|
|
@@ -5931,7 +5635,7 @@ var init_cloud_client = __esm({
|
|
|
5931
5635
|
throw new Error("progress stream ended before request completion");
|
|
5932
5636
|
}
|
|
5933
5637
|
async requestMetadata(applicationName, requestId) {
|
|
5934
|
-
const raw = await this.
|
|
5638
|
+
const raw = await this.transport.requestJson(
|
|
5935
5639
|
"GET",
|
|
5936
5640
|
this.namespacePath(
|
|
5937
5641
|
`applications/${encodeURIComponent(applicationName)}/requests/${encodeURIComponent(requestId)}`
|
|
@@ -5940,7 +5644,7 @@ var init_cloud_client = __esm({
|
|
|
5940
5644
|
return fromSnakeKeys(raw);
|
|
5941
5645
|
}
|
|
5942
5646
|
async requestOutput(applicationName, requestId) {
|
|
5943
|
-
const response = await this.
|
|
5647
|
+
const response = await this.transport.requestResponse(
|
|
5944
5648
|
"GET",
|
|
5945
5649
|
this.namespacePath(
|
|
5946
5650
|
`applications/${encodeURIComponent(applicationName)}/requests/${encodeURIComponent(requestId)}/output`
|
|
@@ -5958,7 +5662,7 @@ var init_cloud_client = __esm({
|
|
|
5958
5662
|
options?.organizationId,
|
|
5959
5663
|
options?.projectId
|
|
5960
5664
|
);
|
|
5961
|
-
const raw = await this.
|
|
5665
|
+
const raw = await this.transport.requestJson("GET", base);
|
|
5962
5666
|
const pageSize = Math.max(0, options?.pageSize ?? 100);
|
|
5963
5667
|
return Object.assign(
|
|
5964
5668
|
{
|
|
@@ -5973,7 +5677,7 @@ var init_cloud_client = __esm({
|
|
|
5973
5677
|
options?.organizationId,
|
|
5974
5678
|
options?.projectId
|
|
5975
5679
|
);
|
|
5976
|
-
const raw = await this.
|
|
5680
|
+
const raw = await this.transport.requestJson(
|
|
5977
5681
|
"GET",
|
|
5978
5682
|
`${base}/${encodeURIComponent(secretId)}`
|
|
5979
5683
|
);
|
|
@@ -5998,24 +5702,24 @@ var init_cloud_client = __esm({
|
|
|
5998
5702
|
options?.organizationId,
|
|
5999
5703
|
options?.projectId
|
|
6000
5704
|
);
|
|
6001
|
-
await this.
|
|
5705
|
+
await this.transport.requestResponse(
|
|
6002
5706
|
"DELETE",
|
|
6003
5707
|
`${base}/${encodeURIComponent(secretId)}`
|
|
6004
5708
|
);
|
|
6005
5709
|
}
|
|
6006
5710
|
async upsertSecret(base, secret) {
|
|
6007
|
-
let response = await this.
|
|
5711
|
+
let response = await this.transport.requestResponse("POST", base, {
|
|
6008
5712
|
json: secret,
|
|
6009
5713
|
headers: { "Idempotency-Key": nanoid() },
|
|
6010
|
-
|
|
5714
|
+
statusOnlyCodes: /* @__PURE__ */ new Set([409])
|
|
6011
5715
|
});
|
|
6012
5716
|
if (response.status === 409) {
|
|
6013
5717
|
const prefix = base.slice(0, -"/secrets".length);
|
|
6014
|
-
const existing = await this.
|
|
5718
|
+
const existing = await this.transport.requestJson(
|
|
6015
5719
|
"GET",
|
|
6016
5720
|
`${prefix}/secret-names/${encodeURIComponent(secret.name)}`
|
|
6017
5721
|
);
|
|
6018
|
-
response = await this.
|
|
5722
|
+
response = await this.transport.requestResponse(
|
|
6019
5723
|
"POST",
|
|
6020
5724
|
`${base}/${encodeURIComponent(existing.id)}/versions`,
|
|
6021
5725
|
{
|
|
@@ -6041,7 +5745,7 @@ var init_cloud_client = __esm({
|
|
|
6041
5745
|
new Blob([toBlobPart(request.buildContext)]),
|
|
6042
5746
|
"context.tar.gz"
|
|
6043
5747
|
);
|
|
6044
|
-
const response = await this.
|
|
5748
|
+
const response = await this.transport.requestResponse(
|
|
6045
5749
|
"PUT",
|
|
6046
5750
|
`${trimTrailingSlashes2(buildServicePath)}/builds`,
|
|
6047
5751
|
{ body: form }
|
|
@@ -6051,7 +5755,7 @@ var init_cloud_client = __esm({
|
|
|
6051
5755
|
}
|
|
6052
5756
|
async createApplicationBuild(buildServicePath, request, imageContexts) {
|
|
6053
5757
|
const form = createApplicationBuildForm(request, imageContexts);
|
|
6054
|
-
const response = await this.
|
|
5758
|
+
const response = await this.transport.requestResponse(
|
|
6055
5759
|
"POST",
|
|
6056
5760
|
trimTrailingSlashes2(buildServicePath),
|
|
6057
5761
|
{ body: form }
|
|
@@ -6060,39 +5764,39 @@ var init_cloud_client = __esm({
|
|
|
6060
5764
|
return fromSnakeKeys(raw);
|
|
6061
5765
|
}
|
|
6062
5766
|
async applicationBuildInfo(buildServicePath, applicationBuildId) {
|
|
6063
|
-
const raw = await this.
|
|
5767
|
+
const raw = await this.transport.requestJson(
|
|
6064
5768
|
"GET",
|
|
6065
5769
|
`${trimTrailingSlashes2(buildServicePath)}/${encodeURIComponent(applicationBuildId)}`
|
|
6066
5770
|
);
|
|
6067
5771
|
return fromSnakeKeys(raw);
|
|
6068
5772
|
}
|
|
6069
5773
|
async cancelApplicationBuild(buildServicePath, applicationBuildId) {
|
|
6070
|
-
const raw = await this.
|
|
5774
|
+
const raw = await this.transport.requestJson(
|
|
6071
5775
|
"POST",
|
|
6072
5776
|
`${trimTrailingSlashes2(buildServicePath)}/${encodeURIComponent(applicationBuildId)}/cancel`
|
|
6073
5777
|
);
|
|
6074
5778
|
return fromSnakeKeys(raw);
|
|
6075
5779
|
}
|
|
6076
5780
|
async buildInfo(buildServicePath, buildId) {
|
|
6077
|
-
const raw = await this.
|
|
5781
|
+
const raw = await this.transport.requestJson(
|
|
6078
5782
|
"GET",
|
|
6079
5783
|
`${trimTrailingSlashes2(buildServicePath)}/builds/${encodeURIComponent(buildId)}`
|
|
6080
5784
|
);
|
|
6081
5785
|
return fromSnakeKeys(raw);
|
|
6082
5786
|
}
|
|
6083
5787
|
async cancelBuild(buildServicePath, buildId) {
|
|
6084
|
-
await this.
|
|
5788
|
+
await this.transport.requestResponse(
|
|
6085
5789
|
"POST",
|
|
6086
5790
|
`${trimTrailingSlashes2(buildServicePath)}/builds/${encodeURIComponent(buildId)}/cancel`
|
|
6087
5791
|
);
|
|
6088
5792
|
}
|
|
6089
5793
|
async *streamBuildLogs(buildServicePath, buildId, signal) {
|
|
6090
|
-
const stream =
|
|
5794
|
+
const stream = this.transport.stream(
|
|
6091
5795
|
"GET",
|
|
6092
5796
|
`${trimTrailingSlashes2(buildServicePath)}/builds/${encodeURIComponent(buildId)}/logs`,
|
|
6093
|
-
|
|
5797
|
+
signal
|
|
6094
5798
|
);
|
|
6095
|
-
for await (const event of
|
|
5799
|
+
for await (const event of stream) {
|
|
6096
5800
|
yield fromSnakeKeys(event);
|
|
6097
5801
|
}
|
|
6098
5802
|
}
|
|
@@ -6105,7 +5809,7 @@ var init_cloud_client = __esm({
|
|
|
6105
5809
|
input.name
|
|
6106
5810
|
);
|
|
6107
5811
|
}
|
|
6108
|
-
return this.
|
|
5812
|
+
return this.transport.requestResponse("POST", path4, {
|
|
6109
5813
|
body: form,
|
|
6110
5814
|
headers: { Accept: "application/json" }
|
|
6111
5815
|
});
|
|
@@ -6114,10 +5818,10 @@ var init_cloud_client = __esm({
|
|
|
6114
5818
|
return `/v1/namespaces/${encodeURIComponent(this.namespace)}/${subpath.replace(/^\/+/, "")}`;
|
|
6115
5819
|
}
|
|
6116
5820
|
async existingApplicationPublicEndpointId(applicationName) {
|
|
6117
|
-
const response = await this.
|
|
5821
|
+
const response = await this.transport.requestResponse(
|
|
6118
5822
|
"GET",
|
|
6119
5823
|
this.namespacePath(`applications/${encodeURIComponent(applicationName)}`),
|
|
6120
|
-
{
|
|
5824
|
+
{ statusOnlyCodes: /* @__PURE__ */ new Set([404]) }
|
|
6121
5825
|
);
|
|
6122
5826
|
if (response.status === 404) {
|
|
6123
5827
|
return void 0;
|