@tensorlakeai/tensorlake 0.5.153 → 0.5.154
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/applications/index.cjs +131 -33
- package/dist/applications/index.cjs.map +1 -1
- package/dist/applications/index.js +131 -33
- package/dist/applications/index.js.map +1 -1
- package/dist/function-agent/main.cjs +1 -1
- package/dist/function-agent/main.js +1 -1
- package/dist/function-executor/main.cjs +2 -2
- package/dist/function-executor/main.js +2 -2
- package/dist/index.cjs +195 -61
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +70 -15
- package/dist/index.d.ts +70 -15
- package/dist/index.js +190 -61
- package/dist/index.js.map +1 -1
- package/dist/sandbox-image.cjs +129 -31
- package/dist/sandbox-image.cjs.map +1 -1
- package/dist/sandbox-image.js +129 -31
- package/dist/sandbox-image.js.map +1 -1
- package/package.json +7 -7
- package/runtime/function-executor/manifest.json +5 -5
- package/runtime/function-executor/package/dist/function-executor/main.js +2 -2
- package/runtime/function-executor/package/npm-shrinkwrap.json +2 -2
- package/runtime/function-executor/package/package.json +1 -1
- package/runtime/typescript-function-runner/manifest.json +5 -5
- package/runtime/typescript-function-runner/package/dist/function-agent/main.js +1 -1
- package/runtime/typescript-function-runner/package/npm-shrinkwrap.json +26 -26
- package/runtime/typescript-function-runner/package/package.json +7 -7
|
@@ -402,7 +402,7 @@ var NativeWorkerClient = class {
|
|
|
402
402
|
}
|
|
403
403
|
};
|
|
404
404
|
var runtimeKey = /* @__PURE__ */ Symbol.for(
|
|
405
|
-
`tensorlake.native.worker.${false ? "source" : "0.5.
|
|
405
|
+
`tensorlake.native.worker.${false ? "source" : "0.5.154"}.v1`
|
|
406
406
|
);
|
|
407
407
|
var runtimes = globalThis;
|
|
408
408
|
function configureNativeWorker(workerPath) {
|
|
@@ -390,7 +390,7 @@ var NativeWorkerClient = class {
|
|
|
390
390
|
}
|
|
391
391
|
};
|
|
392
392
|
var runtimeKey = /* @__PURE__ */ Symbol.for(
|
|
393
|
-
`tensorlake.native.worker.${false ? "source" : "0.5.
|
|
393
|
+
`tensorlake.native.worker.${false ? "source" : "0.5.154"}.v1`
|
|
394
394
|
);
|
|
395
395
|
var runtimes = globalThis;
|
|
396
396
|
function configureNativeWorker(workerPath) {
|
|
@@ -51,7 +51,7 @@ var cancelNativeCall = /* @__PURE__ */ Symbol.for("tensorlake.native.cancel.v1")
|
|
|
51
51
|
var closeNativeHandle = /* @__PURE__ */ Symbol.for("tensorlake.native.close.v1");
|
|
52
52
|
|
|
53
53
|
// src/defaults.ts
|
|
54
|
-
var SDK_VERSION = "0.5.
|
|
54
|
+
var SDK_VERSION = "0.5.154";
|
|
55
55
|
var API_URL = process.env.TENSORLAKE_API_URL ?? "https://api.tensorlake.ai";
|
|
56
56
|
var API_KEY = process.env.TENSORLAKE_API_KEY ?? void 0;
|
|
57
57
|
var NAMESPACE = process.env.INDEXIFY_NAMESPACE ?? "default";
|
|
@@ -247,7 +247,7 @@ var NativeWorkerClient = class {
|
|
|
247
247
|
}
|
|
248
248
|
};
|
|
249
249
|
var runtimeKey = /* @__PURE__ */ Symbol.for(
|
|
250
|
-
`tensorlake.native.worker.${false ? "source" : "0.5.
|
|
250
|
+
`tensorlake.native.worker.${false ? "source" : "0.5.154"}.v1`
|
|
251
251
|
);
|
|
252
252
|
var runtimes = globalThis;
|
|
253
253
|
function configureNativeWorker(workerPath) {
|
|
@@ -10,7 +10,7 @@ var cancelNativeCall = /* @__PURE__ */ Symbol.for("tensorlake.native.cancel.v1")
|
|
|
10
10
|
var closeNativeHandle = /* @__PURE__ */ Symbol.for("tensorlake.native.close.v1");
|
|
11
11
|
|
|
12
12
|
// src/defaults.ts
|
|
13
|
-
var SDK_VERSION = "0.5.
|
|
13
|
+
var SDK_VERSION = "0.5.154";
|
|
14
14
|
var API_URL = process.env.TENSORLAKE_API_URL ?? "https://api.tensorlake.ai";
|
|
15
15
|
var API_KEY = process.env.TENSORLAKE_API_KEY ?? void 0;
|
|
16
16
|
var NAMESPACE = process.env.INDEXIFY_NAMESPACE ?? "default";
|
|
@@ -206,7 +206,7 @@ var NativeWorkerClient = class {
|
|
|
206
206
|
}
|
|
207
207
|
};
|
|
208
208
|
var runtimeKey = /* @__PURE__ */ Symbol.for(
|
|
209
|
-
`tensorlake.native.worker.${false ? "source" : "0.5.
|
|
209
|
+
`tensorlake.native.worker.${false ? "source" : "0.5.154"}.v1`
|
|
210
210
|
);
|
|
211
211
|
var runtimes = globalThis;
|
|
212
212
|
function configureNativeWorker(workerPath) {
|
package/dist/index.cjs
CHANGED
|
@@ -49,7 +49,7 @@ var init_defaults = __esm({
|
|
|
49
49
|
"src/defaults.ts"() {
|
|
50
50
|
"use strict";
|
|
51
51
|
init_cjs_shims();
|
|
52
|
-
SDK_VERSION = "0.5.
|
|
52
|
+
SDK_VERSION = "0.5.154";
|
|
53
53
|
API_URL = process.env.TENSORLAKE_API_URL ?? "https://api.tensorlake.ai";
|
|
54
54
|
API_KEY = process.env.TENSORLAKE_API_KEY ?? void 0;
|
|
55
55
|
NAMESPACE = process.env.INDEXIFY_NAMESPACE ?? "default";
|
|
@@ -60,6 +60,20 @@ var init_defaults = __esm({
|
|
|
60
60
|
}
|
|
61
61
|
});
|
|
62
62
|
|
|
63
|
+
// src/enum.ts
|
|
64
|
+
function enumValue(values, value) {
|
|
65
|
+
return typeof value === "string" && Object.values(values).includes(value) ? value : values.UNKNOWN;
|
|
66
|
+
}
|
|
67
|
+
function withRaw(value, raw) {
|
|
68
|
+
return Object.defineProperty(value, "raw", { value: raw, enumerable: false, configurable: true });
|
|
69
|
+
}
|
|
70
|
+
var init_enum = __esm({
|
|
71
|
+
"src/enum.ts"() {
|
|
72
|
+
"use strict";
|
|
73
|
+
init_cjs_shims();
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
|
|
63
77
|
// src/errors.ts
|
|
64
78
|
function formatErrorDetails(errorDetails) {
|
|
65
79
|
if (errorDetails == null) return void 0;
|
|
@@ -498,7 +512,7 @@ var init_native_worker_client = __esm({
|
|
|
498
512
|
}
|
|
499
513
|
};
|
|
500
514
|
runtimeKey = /* @__PURE__ */ Symbol.for(
|
|
501
|
-
`tensorlake.native.worker.${false ? "source" : "0.5.
|
|
515
|
+
`tensorlake.native.worker.${false ? "source" : "0.5.154"}.v1`
|
|
502
516
|
);
|
|
503
517
|
runtimes = globalThis;
|
|
504
518
|
}
|
|
@@ -600,6 +614,7 @@ var init_models = __esm({
|
|
|
600
614
|
SnapshotStatus2["FAILED"] = "failed";
|
|
601
615
|
SnapshotStatus2["DELETING"] = "deleting";
|
|
602
616
|
SnapshotStatus2["REPLICATING"] = "replicating";
|
|
617
|
+
SnapshotStatus2["UNKNOWN"] = "unknown";
|
|
603
618
|
return SnapshotStatus2;
|
|
604
619
|
})(SnapshotStatus || {});
|
|
605
620
|
ProcessStatus = /* @__PURE__ */ ((ProcessStatus2) => {
|
|
@@ -4496,6 +4511,18 @@ __export(client_exports, {
|
|
|
4496
4511
|
DEFAULT_WAIT_POLL_INTERVAL_SEC: () => DEFAULT_WAIT_POLL_INTERVAL_SEC,
|
|
4497
4512
|
SandboxClient: () => SandboxClient
|
|
4498
4513
|
});
|
|
4514
|
+
function parseSnapshot(raw) {
|
|
4515
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
|
|
4516
|
+
throw new SandboxError("Invalid snapshot response: expected an object");
|
|
4517
|
+
}
|
|
4518
|
+
if (raw.status == null) {
|
|
4519
|
+
throw new SandboxError("Invalid snapshot response: missing status");
|
|
4520
|
+
}
|
|
4521
|
+
return withRaw({
|
|
4522
|
+
...fromSnakeKeys(raw, "snapshotId"),
|
|
4523
|
+
status: enumValue(SnapshotStatus, raw.status)
|
|
4524
|
+
}, raw);
|
|
4525
|
+
}
|
|
4499
4526
|
function requireReadOnlySnapshotPin(fileSystemId, mountPath, readOnly, snapshotId) {
|
|
4500
4527
|
if (snapshotId != null && readOnly !== true) {
|
|
4501
4528
|
throw new SandboxError(
|
|
@@ -4617,6 +4644,7 @@ var init_client = __esm({
|
|
|
4617
4644
|
"use strict";
|
|
4618
4645
|
init_cjs_shims();
|
|
4619
4646
|
init_defaults();
|
|
4647
|
+
init_enum();
|
|
4620
4648
|
init_errors();
|
|
4621
4649
|
init_native_worker_client();
|
|
4622
4650
|
init_native_sandbox();
|
|
@@ -5264,18 +5292,18 @@ var init_client = __esm({
|
|
|
5264
5292
|
* block automatically.
|
|
5265
5293
|
*/
|
|
5266
5294
|
async snapshot(sandboxId, options) {
|
|
5267
|
-
|
|
5295
|
+
const { json } = await callNative(
|
|
5268
5296
|
() => this.native.createSnapshot(sandboxId, options?.snapshotType ?? null),
|
|
5269
|
-
"snapshotId",
|
|
5270
5297
|
{ sandboxId, notFoundKind: "sandbox" }
|
|
5271
5298
|
);
|
|
5299
|
+
return parseSnapshot(JSON.parse(json));
|
|
5272
5300
|
}
|
|
5273
5301
|
/** Get current status and metadata for a snapshot by ID. */
|
|
5274
5302
|
async getSnapshot(snapshotId) {
|
|
5275
|
-
|
|
5276
|
-
() => this.native.getSnapshot(snapshotId)
|
|
5277
|
-
"snapshotId"
|
|
5303
|
+
const { traceId, json } = await callNative(
|
|
5304
|
+
() => this.native.getSnapshot(snapshotId)
|
|
5278
5305
|
);
|
|
5306
|
+
return Object.assign(parseSnapshot(JSON.parse(json)), { traceId });
|
|
5279
5307
|
}
|
|
5280
5308
|
/** List all snapshots in the namespace. */
|
|
5281
5309
|
async listSnapshots() {
|
|
@@ -5283,9 +5311,14 @@ var init_client = __esm({
|
|
|
5283
5311
|
() => this.native.listSnapshots()
|
|
5284
5312
|
);
|
|
5285
5313
|
const parsed = JSON.parse(json);
|
|
5286
|
-
|
|
5287
|
-
|
|
5288
|
-
|
|
5314
|
+
if (parsed !== null && (typeof parsed !== "object" || Array.isArray(parsed))) {
|
|
5315
|
+
throw new SandboxError("Invalid snapshot list response: expected an object");
|
|
5316
|
+
}
|
|
5317
|
+
const records = parsed?.snapshots ?? [];
|
|
5318
|
+
if (!Array.isArray(records)) {
|
|
5319
|
+
throw new SandboxError("Invalid snapshot list response: snapshots must be an array");
|
|
5320
|
+
}
|
|
5321
|
+
const snapshots = records.map((s) => parseSnapshot(s));
|
|
5289
5322
|
return Object.assign(snapshots, { traceId });
|
|
5290
5323
|
}
|
|
5291
5324
|
/** Delete a snapshot by ID. */
|
|
@@ -5850,6 +5883,9 @@ var init_native_binding = __esm({
|
|
|
5850
5883
|
});
|
|
5851
5884
|
|
|
5852
5885
|
// src/image-builds.ts
|
|
5886
|
+
function isConfirmedCancellation(outcome) {
|
|
5887
|
+
return outcome === "cancelled" /* CANCELLED */ || outcome === "already_cancelled" /* ALREADY_CANCELLED */ || outcome === "already_failed" /* ALREADY_FAILED */;
|
|
5888
|
+
}
|
|
5853
5889
|
function camelize(key) {
|
|
5854
5890
|
return key.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
|
|
5855
5891
|
}
|
|
@@ -5867,62 +5903,87 @@ function toImageBuildError(error) {
|
|
|
5867
5903
|
if (key === "category") continue;
|
|
5868
5904
|
details[camelize(key)] = value;
|
|
5869
5905
|
}
|
|
5906
|
+
details.code = enumValue(ImageBuildErrorCode, details.code || "internal" /* INTERNAL */);
|
|
5907
|
+
if ("activeKind" in details) details.activeKind = details.activeKind ? enumValue(ImageBuildKind, details.activeKind) : null;
|
|
5908
|
+
if ("activeStatus" in details) details.activeStatus = details.activeStatus ? enumValue(ImageBuildStatus, details.activeStatus) : null;
|
|
5909
|
+
if ("outcome" in details) details.outcome = details.outcome ? enumValue(ImageBuildCancellationOutcome, details.outcome) : null;
|
|
5910
|
+
if ("info" in details) details.info = buildInfoOrNull(details.info);
|
|
5870
5911
|
const typed = details;
|
|
5871
|
-
|
|
5872
|
-
|
|
5873
|
-
|
|
5874
|
-
|
|
5875
|
-
|
|
5876
|
-
|
|
5877
|
-
|
|
5878
|
-
|
|
5879
|
-
|
|
5880
|
-
|
|
5881
|
-
return new ImageBuildTimeoutError(typed);
|
|
5882
|
-
case "interrupted":
|
|
5883
|
-
return new ImageBuildInterruptedError(typed);
|
|
5884
|
-
default:
|
|
5885
|
-
return new ImageBuildError(typed);
|
|
5886
|
-
}
|
|
5912
|
+
const errors = {
|
|
5913
|
+
not_found: ImageBuildNotFoundError,
|
|
5914
|
+
image_build_in_progress: ImageBuildInProgressError,
|
|
5915
|
+
failed: ImageBuildFailedError,
|
|
5916
|
+
cancelled: ImageBuildCancelledError,
|
|
5917
|
+
timeout: ImageBuildTimeoutError,
|
|
5918
|
+
interrupted: ImageBuildInterruptedError
|
|
5919
|
+
};
|
|
5920
|
+
const ErrorClass = errors[typed.code] ?? ImageBuildError;
|
|
5921
|
+
return withRaw(new ErrorClass(typed), payload);
|
|
5887
5922
|
}
|
|
5888
5923
|
function camelizeRecord(value) {
|
|
5889
5924
|
const out = {};
|
|
5890
5925
|
for (const [key, inner] of Object.entries(value)) out[camelize(key)] = inner;
|
|
5891
5926
|
return out;
|
|
5892
5927
|
}
|
|
5893
|
-
function
|
|
5928
|
+
function buildInfoOrNull(value) {
|
|
5929
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
5930
|
+
try {
|
|
5931
|
+
return parseBuildInfo(value);
|
|
5932
|
+
} catch (error) {
|
|
5933
|
+
if (error instanceof ImageBuildError) return null;
|
|
5934
|
+
throw error;
|
|
5935
|
+
}
|
|
5936
|
+
}
|
|
5937
|
+
function decodeResponse(value) {
|
|
5938
|
+
try {
|
|
5939
|
+
const raw = typeof value === "string" ? JSON.parse(value) : value;
|
|
5940
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) throw new TypeError("expected a response object");
|
|
5941
|
+
return raw;
|
|
5942
|
+
} catch (error) {
|
|
5943
|
+
throw withRaw(new ImageBuildError({ code: "service" /* SERVICE */, message: `Invalid image-build response: ${String(error)}` }), { response: value });
|
|
5944
|
+
}
|
|
5945
|
+
}
|
|
5946
|
+
function parseBuildInfo(value) {
|
|
5947
|
+
const raw = decodeResponse(value);
|
|
5948
|
+
if (raw.status == null) {
|
|
5949
|
+
throw withRaw(new ImageBuildError({ code: "service" /* SERVICE */, message: "Invalid image-build response: missing status" }), { response: value });
|
|
5950
|
+
}
|
|
5951
|
+
const attempt = raw.attempt_no ?? 0;
|
|
5952
|
+
const attemptNo = Number(attempt);
|
|
5953
|
+
if (typeof attempt !== "number" && typeof attempt !== "string" || typeof attempt === "string" && attempt.trim() === "" || !Number.isSafeInteger(attemptNo)) {
|
|
5954
|
+
throw withRaw(new ImageBuildError({ code: "service" /* SERVICE */, message: "Invalid image-build attempt_no" }), { response: value });
|
|
5955
|
+
}
|
|
5894
5956
|
const camel = camelizeRecord(raw);
|
|
5895
5957
|
const result = raw.result && typeof raw.result === "object" ? camelizeRecord(raw.result) : null;
|
|
5896
|
-
return {
|
|
5958
|
+
return withRaw({
|
|
5897
5959
|
buildId: String(raw.build_id ?? ""),
|
|
5898
5960
|
clientRequestId: camel.clientRequestId ?? null,
|
|
5899
|
-
kind:
|
|
5961
|
+
kind: raw.kind ? enumValue(ImageBuildKind, raw.kind) : null,
|
|
5900
5962
|
name: raw.name ?? null,
|
|
5901
|
-
status:
|
|
5902
|
-
phase: raw.phase
|
|
5903
|
-
attemptNo
|
|
5963
|
+
status: enumValue(ImageBuildStatus, raw.status),
|
|
5964
|
+
phase: raw.phase ? enumValue(ImageBuildPhase, raw.phase) : null,
|
|
5965
|
+
attemptNo,
|
|
5904
5966
|
builderSandboxId: camel.builderSandboxId ?? null,
|
|
5905
5967
|
error: raw.error ?? null,
|
|
5906
5968
|
result,
|
|
5907
5969
|
operationDeadlineMs: camel.operationDeadlineMs ?? null,
|
|
5908
5970
|
createdAtMs: camel.createdAtMs ?? null,
|
|
5909
|
-
updatedAtMs: camel.updatedAtMs ?? null
|
|
5910
|
-
|
|
5911
|
-
};
|
|
5971
|
+
updatedAtMs: camel.updatedAtMs ?? null
|
|
5972
|
+
}, raw);
|
|
5912
5973
|
}
|
|
5913
5974
|
function parseResult(json) {
|
|
5914
|
-
return camelizeRecord(
|
|
5975
|
+
return camelizeRecord(decodeResponse(json));
|
|
5915
5976
|
}
|
|
5916
5977
|
function credentialsFromEnv() {
|
|
5917
5978
|
const context = __imageBuildInternals.buildContextFromEnv();
|
|
5918
5979
|
if (!context.apiKey) {
|
|
5919
5980
|
if (context.personalAccessToken) {
|
|
5920
5981
|
throw new ImageBuildError({
|
|
5921
|
-
code: "auth"
|
|
5982
|
+
code: "auth" /* AUTH */,
|
|
5922
5983
|
message: "Sandbox image SDKs require TENSORLAKE_API_KEY. Personal access tokens are CLI-only."
|
|
5923
5984
|
});
|
|
5924
5985
|
}
|
|
5925
|
-
throw new ImageBuildError({ code: "auth"
|
|
5986
|
+
throw new ImageBuildError({ code: "auth" /* AUTH */, message: "Missing TENSORLAKE_API_KEY credentials." });
|
|
5926
5987
|
}
|
|
5927
5988
|
return { apiUrl: context.apiUrl, bearerToken: context.apiKey, namespace: context.namespace };
|
|
5928
5989
|
}
|
|
@@ -5936,18 +5997,18 @@ function clientOptions(credentials) {
|
|
|
5936
5997
|
}
|
|
5937
5998
|
function rejectLegacyReference(buildId) {
|
|
5938
5999
|
if (typeof buildId !== "string" || buildId.trim().length === 0) {
|
|
5939
|
-
throw new ImageBuildError({ code: "usage"
|
|
6000
|
+
throw new ImageBuildError({ code: "usage" /* USAGE */, message: "buildId must be a non-empty string" });
|
|
5940
6001
|
}
|
|
5941
6002
|
if (buildId.startsWith("sandbox_template_")) {
|
|
5942
6003
|
throw new ImageBuildError({
|
|
5943
|
-
code: "usage"
|
|
6004
|
+
code: "usage" /* USAGE */,
|
|
5944
6005
|
message: `'${buildId}' is a legacy sandbox template id; legacy images have no build operation to get, wait for or cancel`,
|
|
5945
6006
|
buildId
|
|
5946
6007
|
});
|
|
5947
6008
|
}
|
|
5948
6009
|
if (buildId.startsWith("image_")) {
|
|
5949
6010
|
throw new ImageBuildError({
|
|
5950
|
-
code: "usage"
|
|
6011
|
+
code: "usage" /* USAGE */,
|
|
5951
6012
|
message: `'${buildId}' is an image id, not a build id; look the image up with findSandboxImageByName or use the build id admission returned`,
|
|
5952
6013
|
buildId
|
|
5953
6014
|
});
|
|
@@ -5994,8 +6055,15 @@ function makeEmitter(options) {
|
|
|
5994
6055
|
};
|
|
5995
6056
|
}
|
|
5996
6057
|
function decodeStarted(json, credentials) {
|
|
5997
|
-
const payload =
|
|
5998
|
-
|
|
6058
|
+
const payload = decodeResponse(json);
|
|
6059
|
+
const build = payload.build;
|
|
6060
|
+
if (!build || typeof build !== "object" || Array.isArray(build) || typeof build.build_id !== "string" || !build.build_id.trim()) {
|
|
6061
|
+
throw withRaw(new ImageBuildError({
|
|
6062
|
+
code: "service" /* SERVICE */,
|
|
6063
|
+
message: "Invalid image-build admission: expected a build with a non-empty build_id"
|
|
6064
|
+
}), { response: payload });
|
|
6065
|
+
}
|
|
6066
|
+
return new ImageBuildHandle(parseBuildInfo(build), credentials, payload.client_request_id);
|
|
5999
6067
|
}
|
|
6000
6068
|
async function startImageBuild(source, options = {}, deps = {}) {
|
|
6001
6069
|
const emitter = makeEmitter({ emit: deps.emit ?? options.emit, verbose: options.verbose });
|
|
@@ -6107,7 +6175,7 @@ async function getImageBuild(buildId) {
|
|
|
6107
6175
|
} catch (error) {
|
|
6108
6176
|
throw toImageBuildError(error);
|
|
6109
6177
|
}
|
|
6110
|
-
return new ImageBuildHandle(parseBuildInfo(
|
|
6178
|
+
return new ImageBuildHandle(parseBuildInfo(json), credentials);
|
|
6111
6179
|
}
|
|
6112
6180
|
async function waitImageBuild(buildId, options = {}) {
|
|
6113
6181
|
rejectLegacyReference(buildId);
|
|
@@ -6138,36 +6206,84 @@ async function cancelImageBuildWith(credentials, selector) {
|
|
|
6138
6206
|
} catch (error) {
|
|
6139
6207
|
throw toImageBuildError(error);
|
|
6140
6208
|
}
|
|
6141
|
-
const payload =
|
|
6142
|
-
const outcome =
|
|
6143
|
-
return {
|
|
6144
|
-
outcome,
|
|
6145
|
-
build: payload.build ? parseBuildInfo(payload.build) : null,
|
|
6146
|
-
confirmed: ["cancelled", "already_cancelled", "already_failed"].includes(outcome)
|
|
6147
|
-
};
|
|
6209
|
+
const payload = decodeResponse(json);
|
|
6210
|
+
const outcome = enumValue(ImageBuildCancellationOutcome, payload.outcome);
|
|
6211
|
+
return withRaw({ outcome, build: buildInfoOrNull(payload.build), confirmed: isConfirmedCancellation(outcome) }, payload);
|
|
6148
6212
|
}
|
|
6149
6213
|
async function cancelImageBuild(selector) {
|
|
6150
6214
|
const hasBuild = selector.buildId != null;
|
|
6151
6215
|
const hasRequest = selector.clientRequestId != null;
|
|
6152
6216
|
if (hasBuild === hasRequest) {
|
|
6153
6217
|
throw new ImageBuildError({
|
|
6154
|
-
code: "usage"
|
|
6218
|
+
code: "usage" /* USAGE */,
|
|
6155
6219
|
message: "pass exactly one of buildId or clientRequestId"
|
|
6156
6220
|
});
|
|
6157
6221
|
}
|
|
6158
6222
|
if (selector.buildId != null) rejectLegacyReference(selector.buildId);
|
|
6159
6223
|
return cancelImageBuildWith(credentialsFromEnv(), selector);
|
|
6160
6224
|
}
|
|
6161
|
-
var import_node_path2, import_node_os, import_node_fs, ImageBuildError, ImageBuildNotFoundError, ImageBuildInProgressError, ImageBuildFailedError, ImageBuildCancelledError, ImageBuildTimeoutError, ImageBuildInterruptedError, ImageBuildHandle;
|
|
6225
|
+
var import_node_path2, import_node_os, import_node_fs, ImageBuildStatus, ImageBuildPhase, ImageBuildKind, ImageBuildCancellationOutcome, ImageBuildErrorCode, ImageBuildError, ImageBuildNotFoundError, ImageBuildInProgressError, ImageBuildFailedError, ImageBuildCancelledError, ImageBuildTimeoutError, ImageBuildInterruptedError, ImageBuildHandle;
|
|
6162
6226
|
var init_image_builds = __esm({
|
|
6163
6227
|
"src/image-builds.ts"() {
|
|
6164
6228
|
"use strict";
|
|
6165
6229
|
init_cjs_shims();
|
|
6166
6230
|
import_node_path2 = __toESM(require("path"), 1);
|
|
6231
|
+
init_enum();
|
|
6167
6232
|
import_node_os = __toESM(require("os"), 1);
|
|
6168
6233
|
import_node_fs = require("fs");
|
|
6169
6234
|
init_image();
|
|
6170
6235
|
init_sandbox_image();
|
|
6236
|
+
ImageBuildStatus = /* @__PURE__ */ ((ImageBuildStatus2) => {
|
|
6237
|
+
ImageBuildStatus2["PENDING"] = "pending";
|
|
6238
|
+
ImageBuildStatus2["RUNNING"] = "running";
|
|
6239
|
+
ImageBuildStatus2["SUCCEEDED"] = "succeeded";
|
|
6240
|
+
ImageBuildStatus2["FAILED"] = "failed";
|
|
6241
|
+
ImageBuildStatus2["CANCELLED"] = "cancelled";
|
|
6242
|
+
ImageBuildStatus2["UNKNOWN"] = "unknown";
|
|
6243
|
+
return ImageBuildStatus2;
|
|
6244
|
+
})(ImageBuildStatus || {});
|
|
6245
|
+
ImageBuildPhase = /* @__PURE__ */ ((ImageBuildPhase2) => {
|
|
6246
|
+
ImageBuildPhase2["AWAITING_CONTEXT"] = "awaiting_context";
|
|
6247
|
+
ImageBuildPhase2["STARTING_BUILDER"] = "starting_builder";
|
|
6248
|
+
ImageBuildPhase2["EXECUTING"] = "executing";
|
|
6249
|
+
ImageBuildPhase2["SNAPSHOTTING"] = "snapshotting";
|
|
6250
|
+
ImageBuildPhase2["PUBLISHING"] = "publishing";
|
|
6251
|
+
ImageBuildPhase2["FINISHED"] = "finished";
|
|
6252
|
+
ImageBuildPhase2["UNKNOWN"] = "unknown";
|
|
6253
|
+
return ImageBuildPhase2;
|
|
6254
|
+
})(ImageBuildPhase || {});
|
|
6255
|
+
ImageBuildKind = /* @__PURE__ */ ((ImageBuildKind2) => {
|
|
6256
|
+
ImageBuildKind2["DOCKERFILE"] = "dockerfile";
|
|
6257
|
+
ImageBuildKind2["IMPORT"] = "import";
|
|
6258
|
+
ImageBuildKind2["DIRECT"] = "direct";
|
|
6259
|
+
ImageBuildKind2["UNKNOWN"] = "unknown";
|
|
6260
|
+
return ImageBuildKind2;
|
|
6261
|
+
})(ImageBuildKind || {});
|
|
6262
|
+
ImageBuildCancellationOutcome = /* @__PURE__ */ ((ImageBuildCancellationOutcome2) => {
|
|
6263
|
+
ImageBuildCancellationOutcome2["CANCELLED"] = "cancelled";
|
|
6264
|
+
ImageBuildCancellationOutcome2["ALREADY_CANCELLED"] = "already_cancelled";
|
|
6265
|
+
ImageBuildCancellationOutcome2["ALREADY_COMPLETED"] = "already_completed";
|
|
6266
|
+
ImageBuildCancellationOutcome2["ALREADY_FAILED"] = "already_failed";
|
|
6267
|
+
ImageBuildCancellationOutcome2["NOT_ADMITTED"] = "not_admitted";
|
|
6268
|
+
ImageBuildCancellationOutcome2["UNCONFIRMED"] = "unconfirmed";
|
|
6269
|
+
ImageBuildCancellationOutcome2["UNKNOWN"] = "unknown";
|
|
6270
|
+
return ImageBuildCancellationOutcome2;
|
|
6271
|
+
})(ImageBuildCancellationOutcome || {});
|
|
6272
|
+
ImageBuildErrorCode = /* @__PURE__ */ ((ImageBuildErrorCode2) => {
|
|
6273
|
+
ImageBuildErrorCode2["USAGE"] = "usage";
|
|
6274
|
+
ImageBuildErrorCode2["AUTH"] = "auth";
|
|
6275
|
+
ImageBuildErrorCode2["NOT_FOUND"] = "not_found";
|
|
6276
|
+
ImageBuildErrorCode2["IMAGE_BUILD_IN_PROGRESS"] = "image_build_in_progress";
|
|
6277
|
+
ImageBuildErrorCode2["CLIENT_REQUEST_ID_MISMATCH"] = "client_request_id_mismatch";
|
|
6278
|
+
ImageBuildErrorCode2["FAILED"] = "failed";
|
|
6279
|
+
ImageBuildErrorCode2["CANCELLED"] = "cancelled";
|
|
6280
|
+
ImageBuildErrorCode2["TIMEOUT"] = "timeout";
|
|
6281
|
+
ImageBuildErrorCode2["INTERRUPTED"] = "interrupted";
|
|
6282
|
+
ImageBuildErrorCode2["SERVICE"] = "service";
|
|
6283
|
+
ImageBuildErrorCode2["INTERNAL"] = "internal";
|
|
6284
|
+
ImageBuildErrorCode2["UNKNOWN"] = "unknown";
|
|
6285
|
+
return ImageBuildErrorCode2;
|
|
6286
|
+
})(ImageBuildErrorCode || {});
|
|
6171
6287
|
ImageBuildError = class extends Error {
|
|
6172
6288
|
code;
|
|
6173
6289
|
buildId;
|
|
@@ -6177,7 +6293,11 @@ var init_image_builds = __esm({
|
|
|
6177
6293
|
super(details.message);
|
|
6178
6294
|
this.name = "ImageBuildError";
|
|
6179
6295
|
this.code = details.code;
|
|
6180
|
-
this.details = details;
|
|
6296
|
+
this.details = { ...details };
|
|
6297
|
+
withRaw(this, {});
|
|
6298
|
+
if ("confirmed" in details) {
|
|
6299
|
+
this.details.confirmed = details.confirmed === true && isConfirmedCancellation(details.outcome);
|
|
6300
|
+
}
|
|
6181
6301
|
if (details.buildId) this.buildId = details.buildId;
|
|
6182
6302
|
if (details.clientRequestId) this.clientRequestId = details.clientRequestId;
|
|
6183
6303
|
}
|
|
@@ -6209,7 +6329,7 @@ var init_image_builds = __esm({
|
|
|
6209
6329
|
super(details);
|
|
6210
6330
|
this.name = "ImageBuildFailedError";
|
|
6211
6331
|
this.error = details.error ?? "no error recorded";
|
|
6212
|
-
if (details.info) this.info =
|
|
6332
|
+
if (details.info) this.info = details.info;
|
|
6213
6333
|
}
|
|
6214
6334
|
};
|
|
6215
6335
|
ImageBuildCancelledError = class extends ImageBuildError {
|
|
@@ -6217,7 +6337,7 @@ var init_image_builds = __esm({
|
|
|
6217
6337
|
constructor(details) {
|
|
6218
6338
|
super(details);
|
|
6219
6339
|
this.name = "ImageBuildCancelledError";
|
|
6220
|
-
if (details.info) this.info =
|
|
6340
|
+
if (details.info) this.info = details.info;
|
|
6221
6341
|
}
|
|
6222
6342
|
};
|
|
6223
6343
|
ImageBuildTimeoutError = class extends ImageBuildError {
|
|
@@ -6233,8 +6353,8 @@ var init_image_builds = __esm({
|
|
|
6233
6353
|
constructor(details) {
|
|
6234
6354
|
super(details);
|
|
6235
6355
|
this.name = "ImageBuildInterruptedError";
|
|
6236
|
-
this.outcome = details.outcome ?? "unconfirmed"
|
|
6237
|
-
this.confirmed = details.confirmed === true;
|
|
6356
|
+
this.outcome = details.outcome ?? "unconfirmed" /* UNCONFIRMED */;
|
|
6357
|
+
this.confirmed = this.details.confirmed === true;
|
|
6238
6358
|
if (details.result) this.result = details.result;
|
|
6239
6359
|
}
|
|
6240
6360
|
};
|
|
@@ -6267,7 +6387,7 @@ var init_image_builds = __esm({
|
|
|
6267
6387
|
} catch (error) {
|
|
6268
6388
|
throw toImageBuildError(error);
|
|
6269
6389
|
}
|
|
6270
|
-
this.#info = parseBuildInfo(
|
|
6390
|
+
this.#info = parseBuildInfo(json);
|
|
6271
6391
|
return this.#info;
|
|
6272
6392
|
}
|
|
6273
6393
|
/**
|
|
@@ -6288,8 +6408,12 @@ var init_image_builds = __esm({
|
|
|
6288
6408
|
)
|
|
6289
6409
|
);
|
|
6290
6410
|
emitter.rethrow();
|
|
6291
|
-
const
|
|
6292
|
-
|
|
6411
|
+
const raw = decodeResponse(json);
|
|
6412
|
+
const result = camelizeRecord(raw);
|
|
6413
|
+
this.#info = withRaw(
|
|
6414
|
+
{ ...this.#info, status: "succeeded" /* SUCCEEDED */, result },
|
|
6415
|
+
{ ...this.#info.raw, status: "succeeded", result: raw }
|
|
6416
|
+
);
|
|
6293
6417
|
return result;
|
|
6294
6418
|
}
|
|
6295
6419
|
/** Cancel this build by its id (the sufficient selector). */
|
|
@@ -6873,14 +6997,19 @@ __export(index_exports, {
|
|
|
6873
6997
|
Headers: () => Headers,
|
|
6874
6998
|
HttpBody: () => HttpBody,
|
|
6875
6999
|
Image: () => Image,
|
|
7000
|
+
ImageBuildCancellationOutcome: () => ImageBuildCancellationOutcome,
|
|
6876
7001
|
ImageBuildCancelledError: () => ImageBuildCancelledError,
|
|
6877
7002
|
ImageBuildError: () => ImageBuildError,
|
|
7003
|
+
ImageBuildErrorCode: () => ImageBuildErrorCode,
|
|
6878
7004
|
ImageBuildFailedError: () => ImageBuildFailedError,
|
|
6879
7005
|
ImageBuildHandle: () => ImageBuildHandle,
|
|
6880
7006
|
ImageBuildInProgressError: () => ImageBuildInProgressError,
|
|
6881
7007
|
ImageBuildInterruptedError: () => ImageBuildInterruptedError,
|
|
7008
|
+
ImageBuildKind: () => ImageBuildKind,
|
|
6882
7009
|
ImageBuildNotFoundError: () => ImageBuildNotFoundError,
|
|
6883
7010
|
ImageBuildOperationType: () => ImageBuildOperationType,
|
|
7011
|
+
ImageBuildPhase: () => ImageBuildPhase,
|
|
7012
|
+
ImageBuildStatus: () => ImageBuildStatus,
|
|
6884
7013
|
ImageBuildTimeoutError: () => ImageBuildTimeoutError,
|
|
6885
7014
|
MountError: () => MountError,
|
|
6886
7015
|
OutputMode: () => OutputMode,
|
|
@@ -10503,14 +10632,19 @@ init_models();
|
|
|
10503
10632
|
Headers,
|
|
10504
10633
|
HttpBody,
|
|
10505
10634
|
Image,
|
|
10635
|
+
ImageBuildCancellationOutcome,
|
|
10506
10636
|
ImageBuildCancelledError,
|
|
10507
10637
|
ImageBuildError,
|
|
10638
|
+
ImageBuildErrorCode,
|
|
10508
10639
|
ImageBuildFailedError,
|
|
10509
10640
|
ImageBuildHandle,
|
|
10510
10641
|
ImageBuildInProgressError,
|
|
10511
10642
|
ImageBuildInterruptedError,
|
|
10643
|
+
ImageBuildKind,
|
|
10512
10644
|
ImageBuildNotFoundError,
|
|
10513
10645
|
ImageBuildOperationType,
|
|
10646
|
+
ImageBuildPhase,
|
|
10647
|
+
ImageBuildStatus,
|
|
10514
10648
|
ImageBuildTimeoutError,
|
|
10515
10649
|
MountError,
|
|
10516
10650
|
OutputMode,
|