@layr-labs/ecloud-sdk 0.2.0-dev.1 → 0.2.0-dev.2
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/VERSION +2 -2
- package/dist/billing.cjs.map +1 -1
- package/dist/billing.d.cts +1 -1
- package/dist/billing.d.ts +1 -1
- package/dist/billing.js +2 -2
- package/dist/{chunk-GB4GM4C2.js → chunk-2RORGPLX.js} +2 -2
- package/dist/chunk-2RORGPLX.js.map +1 -0
- package/dist/{chunk-O7EU5JL7.js → chunk-4SKRNFKQ.js} +105 -535
- package/dist/chunk-4SKRNFKQ.js.map +1 -0
- package/dist/{chunk-FY7UU55U.js → chunk-ZEZS5CNB.js} +30 -106
- package/dist/chunk-ZEZS5CNB.js.map +1 -0
- package/dist/{compute-CF2HOXed.d.ts → compute-B_ibIORD.d.cts} +15 -101
- package/dist/{compute-CbmjA8kJ.d.cts → compute-gpepEsn3.d.ts} +15 -101
- package/dist/compute.cjs +62 -850
- package/dist/compute.cjs.map +1 -1
- package/dist/compute.d.cts +2 -2
- package/dist/compute.d.ts +2 -2
- package/dist/compute.js +2 -2
- package/dist/{index-D2QufVB9.d.ts → index-D-SUX3IG.d.cts} +6 -130
- package/dist/{index-D2QufVB9.d.cts → index-D-SUX3IG.d.ts} +6 -130
- package/dist/index.cjs +100 -989
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +231 -334
- package/dist/index.d.ts +231 -334
- package/dist/index.js +3 -376
- package/dist/index.js.map +1 -1
- package/package.json +1 -2
- package/dist/chunk-FY7UU55U.js.map +0 -1
- package/dist/chunk-GB4GM4C2.js.map +0 -1
- package/dist/chunk-O7EU5JL7.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -30,20 +30,10 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
-
AuthRequiredError: () => AuthRequiredError,
|
|
34
|
-
BUILD_STATUS: () => BUILD_STATUS,
|
|
35
|
-
BadRequestError: () => BadRequestError,
|
|
36
|
-
BuildError: () => BuildError,
|
|
37
|
-
BuildFailedError: () => BuildFailedError,
|
|
38
|
-
ConflictError: () => ConflictError,
|
|
39
|
-
ForbiddenError: () => ForbiddenError,
|
|
40
33
|
NoopClient: () => NoopClient,
|
|
41
|
-
NotFoundError: () => NotFoundError,
|
|
42
34
|
PRIMARY_LANGUAGES: () => PRIMARY_LANGUAGES,
|
|
43
35
|
PostHogClient: () => PostHogClient,
|
|
44
|
-
TimeoutError: () => TimeoutError,
|
|
45
36
|
UserApiClient: () => UserApiClient,
|
|
46
|
-
addHexPrefix: () => addHexPrefix,
|
|
47
37
|
addMetric: () => addMetric,
|
|
48
38
|
addMetricWithDimensions: () => addMetricWithDimensions,
|
|
49
39
|
assertValidFilePath: () => assertValidFilePath,
|
|
@@ -53,7 +43,6 @@ __export(index_exports, {
|
|
|
53
43
|
createApp: () => createApp,
|
|
54
44
|
createAppEnvironment: () => createAppEnvironment,
|
|
55
45
|
createBillingModule: () => createBillingModule,
|
|
56
|
-
createBuildModule: () => createBuildModule,
|
|
57
46
|
createComputeModule: () => createComputeModule,
|
|
58
47
|
createECloudClient: () => createECloudClient,
|
|
59
48
|
createMetricsContext: () => createMetricsContext,
|
|
@@ -97,15 +86,12 @@ __export(index_exports, {
|
|
|
97
86
|
listStoredKeys: () => listStoredKeys,
|
|
98
87
|
logs: () => logs,
|
|
99
88
|
prepareDeploy: () => prepareDeploy,
|
|
100
|
-
prepareDeployFromVerifiableBuild: () => prepareDeployFromVerifiableBuild,
|
|
101
89
|
prepareUpgrade: () => prepareUpgrade,
|
|
102
|
-
prepareUpgradeFromVerifiableBuild: () => prepareUpgradeFromVerifiableBuild,
|
|
103
90
|
requirePrivateKey: () => requirePrivateKey,
|
|
104
91
|
sanitizeString: () => sanitizeString,
|
|
105
92
|
sanitizeURL: () => sanitizeURL,
|
|
106
93
|
sanitizeXURL: () => sanitizeXURL,
|
|
107
94
|
storePrivateKey: () => storePrivateKey,
|
|
108
|
-
stripHexPrefix: () => stripHexPrefix,
|
|
109
95
|
validateAppID: () => validateAppID,
|
|
110
96
|
validateAppName: () => validateAppName,
|
|
111
97
|
validateCreateAppParams: () => validateCreateAppParams,
|
|
@@ -131,7 +117,6 @@ module.exports = __toCommonJS(index_exports);
|
|
|
131
117
|
|
|
132
118
|
// src/client/modules/compute/app/index.ts
|
|
133
119
|
var import_viem9 = require("viem");
|
|
134
|
-
var import_accounts5 = require("viem/accounts");
|
|
135
120
|
|
|
136
121
|
// src/client/common/config/environment.ts
|
|
137
122
|
var SEPOLIA_CHAIN_ID = 11155111;
|
|
@@ -272,7 +257,6 @@ async function buildDockerImage(buildContext, dockerfilePath, tag, logger) {
|
|
|
272
257
|
tag,
|
|
273
258
|
"-f",
|
|
274
259
|
dockerfilePath,
|
|
275
|
-
"--load",
|
|
276
260
|
"--progress=plain",
|
|
277
261
|
buildContext
|
|
278
262
|
];
|
|
@@ -398,7 +382,7 @@ async function pullDockerImage(docker, imageTag, platform2 = "linux/amd64", logg
|
|
|
398
382
|
var child_process2 = __toESM(require("child_process"), 1);
|
|
399
383
|
var import_child_process = require("child_process");
|
|
400
384
|
var import_util2 = require("util");
|
|
401
|
-
var
|
|
385
|
+
var execAsync = (0, import_util2.promisify)(import_child_process.exec);
|
|
402
386
|
async function pushDockerImage(docker, imageRef, logger) {
|
|
403
387
|
logger?.info?.(`Pushing image ${imageRef}...`);
|
|
404
388
|
return new Promise((resolve2, reject) => {
|
|
@@ -439,9 +423,9 @@ async function pushDockerImage(docker, imageRef, logger) {
|
|
|
439
423
|
if (!output.includes("digest:") && !output.includes("pushed") && !output.includes("Pushed")) {
|
|
440
424
|
logger?.debug?.("No clear success indicator in push output, verifying...");
|
|
441
425
|
}
|
|
426
|
+
logger?.info?.("Image push completed successfully");
|
|
442
427
|
try {
|
|
443
428
|
await verifyImageExists(imageRef, logger);
|
|
444
|
-
logger?.info?.("Image push completed successfully");
|
|
445
429
|
resolve2();
|
|
446
430
|
} catch (error) {
|
|
447
431
|
reject(error);
|
|
@@ -465,7 +449,7 @@ async function verifyImageExists(imageRef, logger) {
|
|
|
465
449
|
let retries = 5;
|
|
466
450
|
while (retries > 0) {
|
|
467
451
|
try {
|
|
468
|
-
await
|
|
452
|
+
await execAsync(`docker manifest inspect ${imageRef}`, {
|
|
469
453
|
maxBuffer: 10 * 1024 * 1024,
|
|
470
454
|
timeout: 1e4
|
|
471
455
|
// 10 second timeout
|
|
@@ -939,10 +923,10 @@ async function setupLayeredBuildDirectory(environmentConfig, layeredDockerfileCo
|
|
|
939
923
|
// src/client/common/registry/digest.ts
|
|
940
924
|
var child_process3 = __toESM(require("child_process"), 1);
|
|
941
925
|
var import_util3 = require("util");
|
|
942
|
-
var
|
|
926
|
+
var execFileAsync = (0, import_util3.promisify)(child_process3.execFile);
|
|
943
927
|
async function getImageDigestAndName(imageRef) {
|
|
944
928
|
try {
|
|
945
|
-
const { stdout } = await
|
|
929
|
+
const { stdout } = await execFileAsync(
|
|
946
930
|
"docker",
|
|
947
931
|
["manifest", "inspect", imageRef],
|
|
948
932
|
{ maxBuffer: 10 * 1024 * 1024 }
|
|
@@ -982,7 +966,7 @@ function extractDigestFromMultiPlatform(manifest, imageRef) {
|
|
|
982
966
|
}
|
|
983
967
|
async function extractDigestFromSinglePlatform(manifest, imageRef) {
|
|
984
968
|
try {
|
|
985
|
-
const { stdout } = await
|
|
969
|
+
const { stdout } = await execFileAsync("docker", ["inspect", imageRef], {
|
|
986
970
|
maxBuffer: 10 * 1024 * 1024
|
|
987
971
|
});
|
|
988
972
|
const inspectData = JSON.parse(stdout);
|
|
@@ -1280,67 +1264,6 @@ Please verify the image exists: docker manifest inspect ${finalImageRef}`
|
|
|
1280
1264
|
};
|
|
1281
1265
|
}
|
|
1282
1266
|
|
|
1283
|
-
// src/client/common/release/prebuilt.ts
|
|
1284
|
-
async function createReleaseFromImageDigest(options, logger) {
|
|
1285
|
-
const { imageRef, imageDigest, envFilePath, instanceType, environmentConfig, appId } = options;
|
|
1286
|
-
if (!/^sha256:[0-9a-f]{64}$/i.test(imageDigest)) {
|
|
1287
|
-
throw new Error(`imageDigest must be in format sha256:<64 hex>, got: ${imageDigest}`);
|
|
1288
|
-
}
|
|
1289
|
-
let publicEnv = {};
|
|
1290
|
-
let privateEnv = {};
|
|
1291
|
-
if (envFilePath) {
|
|
1292
|
-
logger.info("Parsing environment file...");
|
|
1293
|
-
const parsed = parseAndValidateEnvFile(envFilePath);
|
|
1294
|
-
publicEnv = parsed.public;
|
|
1295
|
-
privateEnv = parsed.private;
|
|
1296
|
-
} else {
|
|
1297
|
-
logger.info("Continuing without environment file");
|
|
1298
|
-
}
|
|
1299
|
-
publicEnv["EIGEN_MACHINE_TYPE_PUBLIC"] = instanceType;
|
|
1300
|
-
logger.info(`Instance type: ${instanceType}`);
|
|
1301
|
-
logger.info("Encrypting environment variables...");
|
|
1302
|
-
const { encryptionKey } = getKMSKeysForEnvironment(
|
|
1303
|
-
environmentConfig.name,
|
|
1304
|
-
environmentConfig.build
|
|
1305
|
-
);
|
|
1306
|
-
const protectedHeaders = getAppProtectedHeaders(appId);
|
|
1307
|
-
const privateEnvBytes = Buffer.from(JSON.stringify(privateEnv));
|
|
1308
|
-
const encryptedEnvStr = await encryptRSAOAEPAndAES256GCM(
|
|
1309
|
-
encryptionKey,
|
|
1310
|
-
privateEnvBytes,
|
|
1311
|
-
protectedHeaders
|
|
1312
|
-
);
|
|
1313
|
-
const digestHex = imageDigest.split(":")[1];
|
|
1314
|
-
const digestBytes = new Uint8Array(Buffer.from(digestHex, "hex"));
|
|
1315
|
-
if (digestBytes.length !== 32) {
|
|
1316
|
-
throw new Error(`Digest must be exactly 32 bytes, got ${digestBytes.length}`);
|
|
1317
|
-
}
|
|
1318
|
-
const registry = extractRegistryNameNoDocker(imageRef);
|
|
1319
|
-
return {
|
|
1320
|
-
rmsRelease: {
|
|
1321
|
-
artifacts: [{ digest: digestBytes, registry }],
|
|
1322
|
-
upgradeByTime: Math.floor(Date.now() / 1e3) + 3600
|
|
1323
|
-
},
|
|
1324
|
-
publicEnv: new Uint8Array(Buffer.from(JSON.stringify(publicEnv))),
|
|
1325
|
-
encryptedEnv: new Uint8Array(Buffer.from(encryptedEnvStr))
|
|
1326
|
-
};
|
|
1327
|
-
}
|
|
1328
|
-
function extractRegistryNameNoDocker(imageRef) {
|
|
1329
|
-
let name = imageRef;
|
|
1330
|
-
const tagIndex = name.lastIndexOf(":");
|
|
1331
|
-
if (tagIndex !== -1 && !name.substring(tagIndex + 1).includes("/")) {
|
|
1332
|
-
name = name.substring(0, tagIndex);
|
|
1333
|
-
}
|
|
1334
|
-
const digestIndex = name.indexOf("@");
|
|
1335
|
-
if (digestIndex !== -1) {
|
|
1336
|
-
name = name.substring(0, digestIndex);
|
|
1337
|
-
}
|
|
1338
|
-
if ([...name].filter((c) => c === "/").length === 1) {
|
|
1339
|
-
name = `docker.io/${name}`;
|
|
1340
|
-
}
|
|
1341
|
-
return name;
|
|
1342
|
-
}
|
|
1343
|
-
|
|
1344
1267
|
// src/client/common/contract/caller.ts
|
|
1345
1268
|
var import_accounts2 = require("viem/accounts");
|
|
1346
1269
|
|
|
@@ -2377,55 +2300,27 @@ var ERC7702Delegator_default = [
|
|
|
2377
2300
|
];
|
|
2378
2301
|
|
|
2379
2302
|
// src/client/common/contract/eip7702.ts
|
|
2380
|
-
var EXECUTE_BATCH_MODE = "0x0100000000000000000000000000000000000000000000000000000000000000";
|
|
2381
|
-
var GAS_LIMIT_BUFFER_PERCENTAGE = 20n;
|
|
2382
|
-
var GAS_PRICE_BUFFER_PERCENTAGE = 100n;
|
|
2383
|
-
function encodeExecuteBatchData(executions) {
|
|
2384
|
-
const encodedExecutions = (0, import_viem.encodeAbiParameters)(
|
|
2385
|
-
[
|
|
2386
|
-
{
|
|
2387
|
-
type: "tuple[]",
|
|
2388
|
-
components: [
|
|
2389
|
-
{ name: "target", type: "address" },
|
|
2390
|
-
{ name: "value", type: "uint256" },
|
|
2391
|
-
{ name: "callData", type: "bytes" }
|
|
2392
|
-
]
|
|
2393
|
-
}
|
|
2394
|
-
],
|
|
2395
|
-
[executions]
|
|
2396
|
-
);
|
|
2397
|
-
return (0, import_viem.encodeFunctionData)({
|
|
2398
|
-
abi: ERC7702Delegator_default,
|
|
2399
|
-
functionName: "execute",
|
|
2400
|
-
args: [EXECUTE_BATCH_MODE, encodedExecutions]
|
|
2401
|
-
});
|
|
2402
|
-
}
|
|
2403
2303
|
async function estimateBatchGas(options) {
|
|
2404
|
-
const { publicClient,
|
|
2405
|
-
const
|
|
2406
|
-
const
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
data: executeBatchData
|
|
2413
|
-
})
|
|
2414
|
-
]);
|
|
2415
|
-
const baseFee = block.baseFeePerGas ?? 0n;
|
|
2416
|
-
const maxFeePerGas = (baseFee + gasTipCap) * (100n + GAS_PRICE_BUFFER_PERCENTAGE) / 100n;
|
|
2417
|
-
const gasLimit = estimatedGas * (100n + GAS_LIMIT_BUFFER_PERCENTAGE) / 100n;
|
|
2304
|
+
const { publicClient, executions } = options;
|
|
2305
|
+
const fees = await publicClient.estimateFeesPerGas();
|
|
2306
|
+
const baseGas = 100000n;
|
|
2307
|
+
const perExecutionGas = 50000n;
|
|
2308
|
+
const estimatedGas = baseGas + BigInt(executions.length) * perExecutionGas;
|
|
2309
|
+
const gasLimit = estimatedGas * 120n / 100n;
|
|
2310
|
+
const maxFeePerGas = fees.maxFeePerGas;
|
|
2311
|
+
const maxPriorityFeePerGas = fees.maxPriorityFeePerGas;
|
|
2418
2312
|
const maxCostWei = gasLimit * maxFeePerGas;
|
|
2313
|
+
const maxCostEth = formatETH(maxCostWei);
|
|
2419
2314
|
return {
|
|
2420
2315
|
gasLimit,
|
|
2421
2316
|
maxFeePerGas,
|
|
2422
|
-
maxPriorityFeePerGas
|
|
2317
|
+
maxPriorityFeePerGas,
|
|
2423
2318
|
maxCostWei,
|
|
2424
|
-
maxCostEth
|
|
2319
|
+
maxCostEth
|
|
2425
2320
|
};
|
|
2426
2321
|
}
|
|
2427
2322
|
async function checkERC7702Delegation(publicClient, account, delegatorAddress) {
|
|
2428
|
-
const code = await publicClient.
|
|
2323
|
+
const code = await publicClient.getBytecode({ address: account });
|
|
2429
2324
|
if (!code) {
|
|
2430
2325
|
return false;
|
|
2431
2326
|
}
|
|
@@ -2442,7 +2337,36 @@ async function executeBatch(options, logger) {
|
|
|
2442
2337
|
if (!chain) {
|
|
2443
2338
|
throw new Error("Wallet client must have a chain");
|
|
2444
2339
|
}
|
|
2445
|
-
const
|
|
2340
|
+
const encodedExecutions = (0, import_viem.encodeAbiParameters)(
|
|
2341
|
+
[
|
|
2342
|
+
{
|
|
2343
|
+
type: "tuple[]",
|
|
2344
|
+
components: [
|
|
2345
|
+
{ name: "target", type: "address" },
|
|
2346
|
+
{ name: "value", type: "uint256" },
|
|
2347
|
+
{ name: "callData", type: "bytes" }
|
|
2348
|
+
]
|
|
2349
|
+
}
|
|
2350
|
+
],
|
|
2351
|
+
[executions]
|
|
2352
|
+
);
|
|
2353
|
+
const executeBatchMode = "0x0100000000000000000000000000000000000000000000000000000000000000";
|
|
2354
|
+
let executeBatchData;
|
|
2355
|
+
try {
|
|
2356
|
+
executeBatchData = (0, import_viem.encodeFunctionData)({
|
|
2357
|
+
abi: ERC7702Delegator_default,
|
|
2358
|
+
functionName: "execute",
|
|
2359
|
+
args: [executeBatchMode, encodedExecutions]
|
|
2360
|
+
});
|
|
2361
|
+
} catch {
|
|
2362
|
+
const functionSignature = "execute(bytes32,bytes)";
|
|
2363
|
+
const selector = (0, import_viem.keccak256)((0, import_viem.toBytes)(functionSignature)).slice(0, 10);
|
|
2364
|
+
const encodedParams = (0, import_viem.encodeAbiParameters)(
|
|
2365
|
+
[{ type: "bytes32" }, { type: "bytes" }],
|
|
2366
|
+
[executeBatchMode, encodedExecutions]
|
|
2367
|
+
);
|
|
2368
|
+
executeBatchData = (0, import_viem.concat)([selector, encodedParams]);
|
|
2369
|
+
}
|
|
2446
2370
|
const isDelegated2 = await checkERC7702Delegation(
|
|
2447
2371
|
publicClient,
|
|
2448
2372
|
account.address,
|
|
@@ -2596,23 +2520,12 @@ function stripHexPrefix(value) {
|
|
|
2596
2520
|
}
|
|
2597
2521
|
|
|
2598
2522
|
// src/client/common/utils/userapi.ts
|
|
2599
|
-
function isJsonObject(value) {
|
|
2600
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2601
|
-
}
|
|
2602
|
-
function readString(obj, key) {
|
|
2603
|
-
const v = obj[key];
|
|
2604
|
-
return typeof v === "string" ? v : void 0;
|
|
2605
|
-
}
|
|
2606
|
-
function readNumber(obj, key) {
|
|
2607
|
-
const v = obj[key];
|
|
2608
|
-
return typeof v === "number" && Number.isFinite(v) ? v : void 0;
|
|
2609
|
-
}
|
|
2610
2523
|
var MAX_ADDRESS_COUNT = 5;
|
|
2611
2524
|
var CanViewAppLogsPermission = "0x2fd3f2fe";
|
|
2612
2525
|
var CanViewSensitiveAppInfoPermission = "0x0e67b22f";
|
|
2613
2526
|
var CanUpdateAppProfilePermission = "0x036fef61";
|
|
2614
2527
|
function getDefaultClientId() {
|
|
2615
|
-
const version = true ? "0.2.0-dev.
|
|
2528
|
+
const version = true ? "0.2.0-dev.2" : "0.0.0";
|
|
2616
2529
|
return `ecloud-sdk/v${version}`;
|
|
2617
2530
|
}
|
|
2618
2531
|
var UserApiClient = class {
|
|
@@ -2646,31 +2559,6 @@ var UserApiClient = class {
|
|
|
2646
2559
|
};
|
|
2647
2560
|
});
|
|
2648
2561
|
}
|
|
2649
|
-
/**
|
|
2650
|
-
* Get app details from UserAPI (includes releases and build/provenance info when available).
|
|
2651
|
-
*
|
|
2652
|
-
* Endpoint: GET /apps/:appAddress
|
|
2653
|
-
*/
|
|
2654
|
-
async getApp(appAddress) {
|
|
2655
|
-
const endpoint = `${this.config.userApiServerURL}/apps/${appAddress}`;
|
|
2656
|
-
const res = await this.makeAuthenticatedRequest(endpoint);
|
|
2657
|
-
const raw = await res.json();
|
|
2658
|
-
if (!isJsonObject(raw)) {
|
|
2659
|
-
throw new Error("Unexpected /apps/:id response: expected object");
|
|
2660
|
-
}
|
|
2661
|
-
const id = readString(raw, "id");
|
|
2662
|
-
if (!id) {
|
|
2663
|
-
throw new Error("Unexpected /apps/:id response: missing 'id'");
|
|
2664
|
-
}
|
|
2665
|
-
const releasesRaw = raw.releases;
|
|
2666
|
-
const releases = Array.isArray(releasesRaw) ? releasesRaw.map((r) => transformAppRelease(r)).filter((r) => !!r) : [];
|
|
2667
|
-
return {
|
|
2668
|
-
id,
|
|
2669
|
-
creator: readString(raw, "creator"),
|
|
2670
|
-
contractStatus: readString(raw, "contract_status") ?? readString(raw, "contractStatus"),
|
|
2671
|
-
releases
|
|
2672
|
-
};
|
|
2673
|
-
}
|
|
2674
2562
|
/**
|
|
2675
2563
|
* Get available SKUs (instance types) from UserAPI
|
|
2676
2564
|
*/
|
|
@@ -2843,48 +2731,6 @@ Please check:
|
|
|
2843
2731
|
};
|
|
2844
2732
|
}
|
|
2845
2733
|
};
|
|
2846
|
-
function transformAppReleaseBuild(raw) {
|
|
2847
|
-
if (!isJsonObject(raw)) return void 0;
|
|
2848
|
-
const depsRaw = raw.dependencies;
|
|
2849
|
-
const deps = isJsonObject(depsRaw) ? Object.fromEntries(
|
|
2850
|
-
Object.entries(depsRaw).flatMap(([digest, depRaw]) => {
|
|
2851
|
-
const parsed = transformAppReleaseBuild(depRaw);
|
|
2852
|
-
return parsed ? [[digest, parsed]] : [];
|
|
2853
|
-
})
|
|
2854
|
-
) : void 0;
|
|
2855
|
-
return {
|
|
2856
|
-
buildId: readString(raw, "build_id") ?? readString(raw, "buildId"),
|
|
2857
|
-
billingAddress: readString(raw, "billing_address") ?? readString(raw, "billingAddress"),
|
|
2858
|
-
repoUrl: readString(raw, "repo_url") ?? readString(raw, "repoUrl"),
|
|
2859
|
-
gitRef: readString(raw, "git_ref") ?? readString(raw, "gitRef"),
|
|
2860
|
-
status: readString(raw, "status"),
|
|
2861
|
-
buildType: readString(raw, "build_type") ?? readString(raw, "buildType"),
|
|
2862
|
-
imageName: readString(raw, "image_name") ?? readString(raw, "imageName"),
|
|
2863
|
-
imageDigest: readString(raw, "image_digest") ?? readString(raw, "imageDigest"),
|
|
2864
|
-
imageUrl: readString(raw, "image_url") ?? readString(raw, "imageUrl"),
|
|
2865
|
-
provenanceJson: raw.provenance_json ?? raw.provenanceJson,
|
|
2866
|
-
provenanceSignature: readString(raw, "provenance_signature") ?? readString(raw, "provenanceSignature"),
|
|
2867
|
-
createdAt: readString(raw, "created_at") ?? readString(raw, "createdAt"),
|
|
2868
|
-
updatedAt: readString(raw, "updated_at") ?? readString(raw, "updatedAt"),
|
|
2869
|
-
errorMessage: readString(raw, "error_message") ?? readString(raw, "errorMessage"),
|
|
2870
|
-
dependencies: deps
|
|
2871
|
-
};
|
|
2872
|
-
}
|
|
2873
|
-
function transformAppRelease(raw) {
|
|
2874
|
-
if (!isJsonObject(raw)) return void 0;
|
|
2875
|
-
return {
|
|
2876
|
-
appId: readString(raw, "appId") ?? readString(raw, "app_id"),
|
|
2877
|
-
rmsReleaseId: readString(raw, "rmsReleaseId") ?? readString(raw, "rms_release_id"),
|
|
2878
|
-
imageDigest: readString(raw, "imageDigest") ?? readString(raw, "image_digest"),
|
|
2879
|
-
registryUrl: readString(raw, "registryUrl") ?? readString(raw, "registry_url"),
|
|
2880
|
-
publicEnv: readString(raw, "publicEnv") ?? readString(raw, "public_env"),
|
|
2881
|
-
encryptedEnv: readString(raw, "encryptedEnv") ?? readString(raw, "encrypted_env"),
|
|
2882
|
-
upgradeByTime: readNumber(raw, "upgradeByTime") ?? readNumber(raw, "upgrade_by_time"),
|
|
2883
|
-
createdAt: readString(raw, "createdAt") ?? readString(raw, "created_at"),
|
|
2884
|
-
createdAtBlock: readString(raw, "createdAtBlock") ?? readString(raw, "created_at_block"),
|
|
2885
|
-
build: raw.build ? transformAppReleaseBuild(raw.build) : void 0
|
|
2886
|
-
};
|
|
2887
|
-
}
|
|
2888
2734
|
|
|
2889
2735
|
// src/client/common/utils/billing.ts
|
|
2890
2736
|
function isSubscriptionActive(status) {
|
|
@@ -4577,20 +4423,20 @@ async function prepareDeployBatch(options, logger) {
|
|
|
4577
4423
|
environmentConfig
|
|
4578
4424
|
};
|
|
4579
4425
|
}
|
|
4580
|
-
async function executeDeployBatch(
|
|
4426
|
+
async function executeDeployBatch(prepared, gas, logger) {
|
|
4581
4427
|
const pendingMessage = "Deploying new app...";
|
|
4582
4428
|
const txHash = await executeBatch(
|
|
4583
4429
|
{
|
|
4584
|
-
walletClient:
|
|
4585
|
-
publicClient:
|
|
4586
|
-
environmentConfig:
|
|
4587
|
-
executions:
|
|
4430
|
+
walletClient: prepared.walletClient,
|
|
4431
|
+
publicClient: prepared.publicClient,
|
|
4432
|
+
environmentConfig: prepared.environmentConfig,
|
|
4433
|
+
executions: prepared.executions,
|
|
4588
4434
|
pendingMessage,
|
|
4589
4435
|
gas
|
|
4590
4436
|
},
|
|
4591
4437
|
logger
|
|
4592
4438
|
);
|
|
4593
|
-
return { appId:
|
|
4439
|
+
return { appId: prepared.appId, txHash };
|
|
4594
4440
|
}
|
|
4595
4441
|
async function deployApp(options, logger) {
|
|
4596
4442
|
const prepared = await prepareDeployBatch(
|
|
@@ -4604,17 +4450,7 @@ async function deployApp(options, logger) {
|
|
|
4604
4450
|
},
|
|
4605
4451
|
logger
|
|
4606
4452
|
);
|
|
4607
|
-
|
|
4608
|
-
appId: prepared.appId,
|
|
4609
|
-
salt: prepared.salt,
|
|
4610
|
-
executions: prepared.executions
|
|
4611
|
-
};
|
|
4612
|
-
const context = {
|
|
4613
|
-
walletClient: prepared.walletClient,
|
|
4614
|
-
publicClient: prepared.publicClient,
|
|
4615
|
-
environmentConfig: prepared.environmentConfig
|
|
4616
|
-
};
|
|
4617
|
-
return executeDeployBatch(data, context, options.gas, logger);
|
|
4453
|
+
return executeDeployBatch(prepared, options.gas, logger);
|
|
4618
4454
|
}
|
|
4619
4455
|
async function prepareUpgradeBatch(options) {
|
|
4620
4456
|
const {
|
|
@@ -4710,14 +4546,14 @@ async function prepareUpgradeBatch(options) {
|
|
|
4710
4546
|
environmentConfig
|
|
4711
4547
|
};
|
|
4712
4548
|
}
|
|
4713
|
-
async function executeUpgradeBatch(
|
|
4714
|
-
const pendingMessage = `Upgrading app ${
|
|
4549
|
+
async function executeUpgradeBatch(prepared, gas, logger) {
|
|
4550
|
+
const pendingMessage = `Upgrading app ${prepared.appId}...`;
|
|
4715
4551
|
const txHash = await executeBatch(
|
|
4716
4552
|
{
|
|
4717
|
-
walletClient:
|
|
4718
|
-
publicClient:
|
|
4719
|
-
environmentConfig:
|
|
4720
|
-
executions:
|
|
4553
|
+
walletClient: prepared.walletClient,
|
|
4554
|
+
publicClient: prepared.publicClient,
|
|
4555
|
+
environmentConfig: prepared.environmentConfig,
|
|
4556
|
+
executions: prepared.executions,
|
|
4721
4557
|
pendingMessage,
|
|
4722
4558
|
gas
|
|
4723
4559
|
},
|
|
@@ -4735,16 +4571,7 @@ async function upgradeApp(options, logger) {
|
|
|
4735
4571
|
publicLogs: options.publicLogs,
|
|
4736
4572
|
needsPermissionChange: options.needsPermissionChange
|
|
4737
4573
|
});
|
|
4738
|
-
|
|
4739
|
-
appId: prepared.appId,
|
|
4740
|
-
executions: prepared.executions
|
|
4741
|
-
};
|
|
4742
|
-
const context = {
|
|
4743
|
-
walletClient: prepared.walletClient,
|
|
4744
|
-
publicClient: prepared.publicClient,
|
|
4745
|
-
environmentConfig: prepared.environmentConfig
|
|
4746
|
-
};
|
|
4747
|
-
return executeUpgradeBatch(data, context, options.gas, logger);
|
|
4574
|
+
return executeUpgradeBatch(prepared, options.gas, logger);
|
|
4748
4575
|
}
|
|
4749
4576
|
async function sendAndWaitForTransaction(options, logger) {
|
|
4750
4577
|
const {
|
|
@@ -5706,97 +5533,6 @@ async function withSDKTelemetry(options, action) {
|
|
|
5706
5533
|
}
|
|
5707
5534
|
|
|
5708
5535
|
// src/client/modules/compute/app/deploy.ts
|
|
5709
|
-
async function prepareDeployFromVerifiableBuild(options, logger = defaultLogger) {
|
|
5710
|
-
return withSDKTelemetry(
|
|
5711
|
-
{
|
|
5712
|
-
functionName: "prepareDeployFromVerifiableBuild",
|
|
5713
|
-
skipTelemetry: options.skipTelemetry,
|
|
5714
|
-
properties: {
|
|
5715
|
-
environment: options.environment || "sepolia"
|
|
5716
|
-
}
|
|
5717
|
-
},
|
|
5718
|
-
async () => {
|
|
5719
|
-
if (!options.privateKey) throw new Error("privateKey is required for deployment");
|
|
5720
|
-
if (!options.imageRef) throw new Error("imageRef is required for deployment");
|
|
5721
|
-
if (!options.imageDigest) throw new Error("imageDigest is required for deployment");
|
|
5722
|
-
assertValidImageReference(options.imageRef);
|
|
5723
|
-
validateAppName(options.appName);
|
|
5724
|
-
validateLogVisibility(options.logVisibility);
|
|
5725
|
-
if (!/^sha256:[0-9a-f]{64}$/i.test(options.imageDigest)) {
|
|
5726
|
-
throw new Error(
|
|
5727
|
-
`imageDigest must be in format sha256:<64 hex>, got: ${options.imageDigest}`
|
|
5728
|
-
);
|
|
5729
|
-
}
|
|
5730
|
-
const { publicLogs } = validateLogVisibility(options.logVisibility);
|
|
5731
|
-
validateResourceUsageMonitoring(options.resourceUsageMonitoring);
|
|
5732
|
-
logger.debug("Performing preflight checks...");
|
|
5733
|
-
const preflightCtx = await doPreflightChecks(
|
|
5734
|
-
{
|
|
5735
|
-
privateKey: options.privateKey,
|
|
5736
|
-
rpcUrl: options.rpcUrl,
|
|
5737
|
-
environment: options.environment
|
|
5738
|
-
},
|
|
5739
|
-
logger
|
|
5740
|
-
);
|
|
5741
|
-
logger.debug("Checking quota availability...");
|
|
5742
|
-
await checkQuotaAvailable(preflightCtx);
|
|
5743
|
-
const salt = generateRandomSalt();
|
|
5744
|
-
logger.debug(`Generated salt: ${Buffer.from(salt).toString("hex")}`);
|
|
5745
|
-
logger.debug("Calculating app ID...");
|
|
5746
|
-
const appIDToBeDeployed = await calculateAppID(
|
|
5747
|
-
preflightCtx.privateKey,
|
|
5748
|
-
options.rpcUrl || preflightCtx.rpcUrl,
|
|
5749
|
-
preflightCtx.environmentConfig,
|
|
5750
|
-
salt
|
|
5751
|
-
);
|
|
5752
|
-
logger.info(``);
|
|
5753
|
-
logger.info(`App ID: ${appIDToBeDeployed}`);
|
|
5754
|
-
logger.info(``);
|
|
5755
|
-
const release = await createReleaseFromImageDigest(
|
|
5756
|
-
{
|
|
5757
|
-
imageRef: options.imageRef,
|
|
5758
|
-
imageDigest: options.imageDigest,
|
|
5759
|
-
envFilePath: options.envFilePath,
|
|
5760
|
-
instanceType: options.instanceType,
|
|
5761
|
-
environmentConfig: preflightCtx.environmentConfig,
|
|
5762
|
-
appId: appIDToBeDeployed
|
|
5763
|
-
},
|
|
5764
|
-
logger
|
|
5765
|
-
);
|
|
5766
|
-
logger.debug("Preparing deploy batch...");
|
|
5767
|
-
const batch = await prepareDeployBatch(
|
|
5768
|
-
{
|
|
5769
|
-
privateKey: preflightCtx.privateKey,
|
|
5770
|
-
rpcUrl: options.rpcUrl || preflightCtx.rpcUrl,
|
|
5771
|
-
environmentConfig: preflightCtx.environmentConfig,
|
|
5772
|
-
salt,
|
|
5773
|
-
release,
|
|
5774
|
-
publicLogs
|
|
5775
|
-
},
|
|
5776
|
-
logger
|
|
5777
|
-
);
|
|
5778
|
-
logger.debug("Estimating gas...");
|
|
5779
|
-
const gasEstimate = await estimateBatchGas({
|
|
5780
|
-
publicClient: batch.publicClient,
|
|
5781
|
-
account: batch.walletClient.account.address,
|
|
5782
|
-
executions: batch.executions
|
|
5783
|
-
});
|
|
5784
|
-
const data = {
|
|
5785
|
-
appId: batch.appId,
|
|
5786
|
-
salt: batch.salt,
|
|
5787
|
-
executions: batch.executions
|
|
5788
|
-
};
|
|
5789
|
-
return {
|
|
5790
|
-
prepared: {
|
|
5791
|
-
data,
|
|
5792
|
-
appName: options.appName,
|
|
5793
|
-
imageRef: options.imageRef
|
|
5794
|
-
},
|
|
5795
|
-
gasEstimate
|
|
5796
|
-
};
|
|
5797
|
-
}
|
|
5798
|
-
);
|
|
5799
|
-
}
|
|
5800
5536
|
function validateDeployOptions(options) {
|
|
5801
5537
|
if (!options.privateKey) {
|
|
5802
5538
|
throw new Error("privateKey is required for deployment");
|
|
@@ -6017,27 +5753,26 @@ async function prepareDeploy(options, logger = defaultLogger) {
|
|
|
6017
5753
|
logger.debug("Estimating gas...");
|
|
6018
5754
|
const gasEstimate = await estimateBatchGas({
|
|
6019
5755
|
publicClient: batch.publicClient,
|
|
6020
|
-
|
|
5756
|
+
environmentConfig: batch.environmentConfig,
|
|
6021
5757
|
executions: batch.executions
|
|
6022
5758
|
});
|
|
6023
|
-
const data = {
|
|
6024
|
-
appId: batch.appId,
|
|
6025
|
-
salt: batch.salt,
|
|
6026
|
-
executions: batch.executions
|
|
6027
|
-
};
|
|
6028
5759
|
return {
|
|
6029
5760
|
prepared: {
|
|
6030
|
-
|
|
5761
|
+
batch,
|
|
6031
5762
|
appName,
|
|
6032
|
-
imageRef: finalImageRef
|
|
5763
|
+
imageRef: finalImageRef,
|
|
5764
|
+
preflightCtx: {
|
|
5765
|
+
privateKey: preflightCtx.privateKey,
|
|
5766
|
+
rpcUrl: preflightCtx.rpcUrl,
|
|
5767
|
+
environmentConfig: preflightCtx.environmentConfig
|
|
5768
|
+
}
|
|
6033
5769
|
},
|
|
6034
5770
|
gasEstimate
|
|
6035
5771
|
};
|
|
6036
5772
|
}
|
|
6037
5773
|
);
|
|
6038
5774
|
}
|
|
6039
|
-
async function executeDeploy(
|
|
6040
|
-
const { prepared, context, gas, logger = defaultLogger, skipTelemetry } = options;
|
|
5775
|
+
async function executeDeploy(prepared, gas, logger = defaultLogger, skipTelemetry) {
|
|
6041
5776
|
return withSDKTelemetry(
|
|
6042
5777
|
{
|
|
6043
5778
|
functionName: "executeDeploy",
|
|
@@ -6045,7 +5780,7 @@ async function executeDeploy(options) {
|
|
|
6045
5780
|
},
|
|
6046
5781
|
async () => {
|
|
6047
5782
|
logger.info("Deploying on-chain...");
|
|
6048
|
-
const { appId, txHash } = await executeDeployBatch(prepared.
|
|
5783
|
+
const { appId, txHash } = await executeDeployBatch(prepared.batch, gas, logger);
|
|
6049
5784
|
return {
|
|
6050
5785
|
appId,
|
|
6051
5786
|
txHash,
|
|
@@ -6107,81 +5842,6 @@ async function checkAppLogPermission(preflightCtx, appAddress, logger) {
|
|
|
6107
5842
|
}
|
|
6108
5843
|
|
|
6109
5844
|
// src/client/modules/compute/app/upgrade.ts
|
|
6110
|
-
async function prepareUpgradeFromVerifiableBuild(options, logger = defaultLogger) {
|
|
6111
|
-
return withSDKTelemetry(
|
|
6112
|
-
{
|
|
6113
|
-
functionName: "prepareUpgradeFromVerifiableBuild",
|
|
6114
|
-
skipTelemetry: options.skipTelemetry,
|
|
6115
|
-
properties: {
|
|
6116
|
-
environment: options.environment || "sepolia"
|
|
6117
|
-
}
|
|
6118
|
-
},
|
|
6119
|
-
async () => {
|
|
6120
|
-
logger.debug("Performing preflight checks...");
|
|
6121
|
-
const preflightCtx = await doPreflightChecks(
|
|
6122
|
-
{
|
|
6123
|
-
privateKey: options.privateKey,
|
|
6124
|
-
rpcUrl: options.rpcUrl,
|
|
6125
|
-
environment: options.environment
|
|
6126
|
-
},
|
|
6127
|
-
logger
|
|
6128
|
-
);
|
|
6129
|
-
const appID = validateUpgradeOptions(options);
|
|
6130
|
-
assertValidImageReference(options.imageRef);
|
|
6131
|
-
if (!/^sha256:[0-9a-f]{64}$/i.test(options.imageDigest)) {
|
|
6132
|
-
throw new Error(
|
|
6133
|
-
`imageDigest must be in format sha256:<64 hex>, got: ${options.imageDigest}`
|
|
6134
|
-
);
|
|
6135
|
-
}
|
|
6136
|
-
const { publicLogs } = validateLogVisibility(options.logVisibility);
|
|
6137
|
-
validateResourceUsageMonitoring(options.resourceUsageMonitoring);
|
|
6138
|
-
const envFilePath = options.envFilePath || "";
|
|
6139
|
-
logger.info("Preparing release (verifiable build, no local layering)...");
|
|
6140
|
-
const release = await createReleaseFromImageDigest(
|
|
6141
|
-
{
|
|
6142
|
-
imageRef: options.imageRef,
|
|
6143
|
-
imageDigest: options.imageDigest,
|
|
6144
|
-
envFilePath,
|
|
6145
|
-
instanceType: options.instanceType,
|
|
6146
|
-
environmentConfig: preflightCtx.environmentConfig,
|
|
6147
|
-
appId: appID
|
|
6148
|
-
},
|
|
6149
|
-
logger
|
|
6150
|
-
);
|
|
6151
|
-
logger.debug("Checking current log permission state...");
|
|
6152
|
-
const currentlyPublic = await checkAppLogPermission(preflightCtx, appID, logger);
|
|
6153
|
-
const needsPermissionChange = currentlyPublic !== publicLogs;
|
|
6154
|
-
logger.debug("Preparing upgrade batch...");
|
|
6155
|
-
const batch = await prepareUpgradeBatch({
|
|
6156
|
-
privateKey: preflightCtx.privateKey,
|
|
6157
|
-
rpcUrl: options.rpcUrl || preflightCtx.rpcUrl,
|
|
6158
|
-
environmentConfig: preflightCtx.environmentConfig,
|
|
6159
|
-
appId: appID,
|
|
6160
|
-
release,
|
|
6161
|
-
publicLogs,
|
|
6162
|
-
needsPermissionChange
|
|
6163
|
-
});
|
|
6164
|
-
logger.debug("Estimating gas...");
|
|
6165
|
-
const gasEstimate = await estimateBatchGas({
|
|
6166
|
-
publicClient: batch.publicClient,
|
|
6167
|
-
account: batch.walletClient.account.address,
|
|
6168
|
-
executions: batch.executions
|
|
6169
|
-
});
|
|
6170
|
-
const data = {
|
|
6171
|
-
appId: batch.appId,
|
|
6172
|
-
executions: batch.executions
|
|
6173
|
-
};
|
|
6174
|
-
return {
|
|
6175
|
-
prepared: {
|
|
6176
|
-
data,
|
|
6177
|
-
appId: appID,
|
|
6178
|
-
imageRef: options.imageRef
|
|
6179
|
-
},
|
|
6180
|
-
gasEstimate
|
|
6181
|
-
};
|
|
6182
|
-
}
|
|
6183
|
-
);
|
|
6184
|
-
}
|
|
6185
5845
|
function validateUpgradeOptions(options) {
|
|
6186
5846
|
if (!options.privateKey) {
|
|
6187
5847
|
throw new Error("privateKey is required for upgrade");
|
|
@@ -6344,26 +6004,26 @@ async function prepareUpgrade(options, logger = defaultLogger) {
|
|
|
6344
6004
|
logger.debug("Estimating gas...");
|
|
6345
6005
|
const gasEstimate = await estimateBatchGas({
|
|
6346
6006
|
publicClient: batch.publicClient,
|
|
6347
|
-
|
|
6007
|
+
environmentConfig: batch.environmentConfig,
|
|
6348
6008
|
executions: batch.executions
|
|
6349
6009
|
});
|
|
6350
|
-
const data = {
|
|
6351
|
-
appId: batch.appId,
|
|
6352
|
-
executions: batch.executions
|
|
6353
|
-
};
|
|
6354
6010
|
return {
|
|
6355
6011
|
prepared: {
|
|
6356
|
-
|
|
6012
|
+
batch,
|
|
6357
6013
|
appId: appID,
|
|
6358
|
-
imageRef: finalImageRef
|
|
6014
|
+
imageRef: finalImageRef,
|
|
6015
|
+
preflightCtx: {
|
|
6016
|
+
privateKey: preflightCtx.privateKey,
|
|
6017
|
+
rpcUrl: preflightCtx.rpcUrl,
|
|
6018
|
+
environmentConfig: preflightCtx.environmentConfig
|
|
6019
|
+
}
|
|
6359
6020
|
},
|
|
6360
6021
|
gasEstimate
|
|
6361
6022
|
};
|
|
6362
6023
|
}
|
|
6363
6024
|
);
|
|
6364
6025
|
}
|
|
6365
|
-
async function executeUpgrade(
|
|
6366
|
-
const { prepared, context, gas, logger = defaultLogger, skipTelemetry } = options;
|
|
6026
|
+
async function executeUpgrade(prepared, gas, logger = defaultLogger, skipTelemetry) {
|
|
6367
6027
|
return withSDKTelemetry(
|
|
6368
6028
|
{
|
|
6369
6029
|
functionName: "executeUpgrade",
|
|
@@ -6371,7 +6031,7 @@ async function executeUpgrade(options) {
|
|
|
6371
6031
|
},
|
|
6372
6032
|
async () => {
|
|
6373
6033
|
logger.info("Upgrading on-chain...");
|
|
6374
|
-
const txHash = await executeUpgradeBatch(prepared.
|
|
6034
|
+
const txHash = await executeUpgradeBatch(prepared.batch, gas, logger);
|
|
6375
6035
|
return {
|
|
6376
6036
|
appId: prepared.appId,
|
|
6377
6037
|
imageRef: prepared.imageRef,
|
|
@@ -6502,8 +6162,8 @@ var path5 = __toESM(require("path"), 1);
|
|
|
6502
6162
|
var os3 = __toESM(require("os"), 1);
|
|
6503
6163
|
var import_child_process2 = require("child_process");
|
|
6504
6164
|
var import_util4 = require("util");
|
|
6505
|
-
var
|
|
6506
|
-
var
|
|
6165
|
+
var execAsync2 = (0, import_util4.promisify)(import_child_process2.exec);
|
|
6166
|
+
var execFileAsync2 = (0, import_util4.promisify)(import_child_process2.execFile);
|
|
6507
6167
|
async function fetchTemplate(repoURL, ref, targetDir, config, logger) {
|
|
6508
6168
|
if (!repoURL) {
|
|
6509
6169
|
throw new Error("repoURL is required");
|
|
@@ -6512,13 +6172,13 @@ async function fetchTemplate(repoURL, ref, targetDir, config, logger) {
|
|
|
6512
6172
|
Cloning repo: ${repoURL} \u2192 ${targetDir}
|
|
6513
6173
|
`);
|
|
6514
6174
|
try {
|
|
6515
|
-
await
|
|
6175
|
+
await execAsync2(`git clone --no-checkout --progress ${repoURL} ${targetDir}`, {
|
|
6516
6176
|
maxBuffer: 10 * 1024 * 1024
|
|
6517
6177
|
});
|
|
6518
|
-
await
|
|
6178
|
+
await execFileAsync2("git", ["-C", targetDir, "checkout", "--quiet", ref], {
|
|
6519
6179
|
maxBuffer: 10 * 1024 * 1024
|
|
6520
6180
|
});
|
|
6521
|
-
await
|
|
6181
|
+
await execFileAsync2(
|
|
6522
6182
|
"git",
|
|
6523
6183
|
["-C", targetDir, "submodule", "update", "--init", "--recursive", "--progress"],
|
|
6524
6184
|
{ maxBuffer: 10 * 1024 * 1024 }
|
|
@@ -6563,14 +6223,14 @@ Cloning template: ${repoURL} \u2192 extracting ${subPath}
|
|
|
6563
6223
|
}
|
|
6564
6224
|
async function cloneSparse(repoURL, ref, subPath, tempDir) {
|
|
6565
6225
|
try {
|
|
6566
|
-
await
|
|
6567
|
-
await
|
|
6568
|
-
await
|
|
6226
|
+
await execFileAsync2("git", ["init", tempDir]);
|
|
6227
|
+
await execFileAsync2("git", ["-C", tempDir, "remote", "add", "origin", repoURL]);
|
|
6228
|
+
await execFileAsync2("git", ["-C", tempDir, "config", "core.sparseCheckout", "true"]);
|
|
6569
6229
|
const sparseCheckoutPath = path5.join(tempDir, ".git/info/sparse-checkout");
|
|
6570
6230
|
fs5.writeFileSync(sparseCheckoutPath, `${subPath}
|
|
6571
6231
|
`);
|
|
6572
|
-
await
|
|
6573
|
-
await
|
|
6232
|
+
await execFileAsync2("git", ["-C", tempDir, "fetch", "origin", ref]);
|
|
6233
|
+
await execFileAsync2("git", ["-C", tempDir, "checkout", ref]);
|
|
6574
6234
|
} catch (error) {
|
|
6575
6235
|
throw new Error(`Failed to clone sparse repository: ${error.message}`);
|
|
6576
6236
|
}
|
|
@@ -7145,187 +6805,6 @@ function createAppModule(ctx) {
|
|
|
7145
6805
|
imageRef: result.imageRef
|
|
7146
6806
|
};
|
|
7147
6807
|
},
|
|
7148
|
-
// Granular deploy control
|
|
7149
|
-
async prepareDeploy(opts) {
|
|
7150
|
-
return prepareDeploy(
|
|
7151
|
-
{
|
|
7152
|
-
privateKey,
|
|
7153
|
-
rpcUrl: ctx.rpcUrl,
|
|
7154
|
-
environment: ctx.environment,
|
|
7155
|
-
appName: opts.name,
|
|
7156
|
-
instanceType: opts.instanceType,
|
|
7157
|
-
dockerfilePath: opts.dockerfile,
|
|
7158
|
-
envFilePath: opts.envFile,
|
|
7159
|
-
imageRef: opts.imageRef,
|
|
7160
|
-
logVisibility: opts.logVisibility,
|
|
7161
|
-
resourceUsageMonitoring: opts.resourceUsageMonitoring,
|
|
7162
|
-
skipTelemetry
|
|
7163
|
-
},
|
|
7164
|
-
logger
|
|
7165
|
-
);
|
|
7166
|
-
},
|
|
7167
|
-
async prepareDeployFromVerifiableBuild(opts) {
|
|
7168
|
-
return prepareDeployFromVerifiableBuild(
|
|
7169
|
-
{
|
|
7170
|
-
privateKey,
|
|
7171
|
-
rpcUrl: ctx.rpcUrl,
|
|
7172
|
-
environment: ctx.environment,
|
|
7173
|
-
appName: opts.name,
|
|
7174
|
-
instanceType: opts.instanceType,
|
|
7175
|
-
envFilePath: opts.envFile,
|
|
7176
|
-
imageRef: opts.imageRef,
|
|
7177
|
-
imageDigest: opts.imageDigest,
|
|
7178
|
-
logVisibility: opts.logVisibility,
|
|
7179
|
-
resourceUsageMonitoring: opts.resourceUsageMonitoring,
|
|
7180
|
-
skipTelemetry
|
|
7181
|
-
},
|
|
7182
|
-
logger
|
|
7183
|
-
);
|
|
7184
|
-
},
|
|
7185
|
-
async executeDeploy(prepared, gas) {
|
|
7186
|
-
const account = (0, import_accounts5.privateKeyToAccount)(privateKey);
|
|
7187
|
-
const chain = getChainFromID(environment.chainID);
|
|
7188
|
-
const publicClient = (0, import_viem9.createPublicClient)({
|
|
7189
|
-
chain,
|
|
7190
|
-
transport: (0, import_viem9.http)(ctx.rpcUrl)
|
|
7191
|
-
});
|
|
7192
|
-
const walletClient = (0, import_viem9.createWalletClient)({
|
|
7193
|
-
account,
|
|
7194
|
-
chain,
|
|
7195
|
-
transport: (0, import_viem9.http)(ctx.rpcUrl)
|
|
7196
|
-
});
|
|
7197
|
-
const result = await executeDeploy({
|
|
7198
|
-
prepared,
|
|
7199
|
-
context: {
|
|
7200
|
-
walletClient,
|
|
7201
|
-
publicClient,
|
|
7202
|
-
environmentConfig: environment
|
|
7203
|
-
},
|
|
7204
|
-
gas,
|
|
7205
|
-
logger,
|
|
7206
|
-
skipTelemetry
|
|
7207
|
-
});
|
|
7208
|
-
return {
|
|
7209
|
-
appId: result.appId,
|
|
7210
|
-
txHash: result.txHash,
|
|
7211
|
-
appName: result.appName,
|
|
7212
|
-
imageRef: result.imageRef
|
|
7213
|
-
};
|
|
7214
|
-
},
|
|
7215
|
-
async watchDeployment(appId) {
|
|
7216
|
-
return watchDeployment(
|
|
7217
|
-
appId,
|
|
7218
|
-
privateKey,
|
|
7219
|
-
ctx.rpcUrl,
|
|
7220
|
-
ctx.environment,
|
|
7221
|
-
logger,
|
|
7222
|
-
ctx.clientId,
|
|
7223
|
-
skipTelemetry
|
|
7224
|
-
);
|
|
7225
|
-
},
|
|
7226
|
-
// Granular upgrade control
|
|
7227
|
-
async prepareUpgrade(appId, opts) {
|
|
7228
|
-
return prepareUpgrade(
|
|
7229
|
-
{
|
|
7230
|
-
appId,
|
|
7231
|
-
privateKey,
|
|
7232
|
-
rpcUrl: ctx.rpcUrl,
|
|
7233
|
-
environment: ctx.environment,
|
|
7234
|
-
instanceType: opts.instanceType,
|
|
7235
|
-
dockerfilePath: opts.dockerfile,
|
|
7236
|
-
envFilePath: opts.envFile,
|
|
7237
|
-
imageRef: opts.imageRef,
|
|
7238
|
-
logVisibility: opts.logVisibility,
|
|
7239
|
-
resourceUsageMonitoring: opts.resourceUsageMonitoring,
|
|
7240
|
-
skipTelemetry
|
|
7241
|
-
},
|
|
7242
|
-
logger
|
|
7243
|
-
);
|
|
7244
|
-
},
|
|
7245
|
-
async prepareUpgradeFromVerifiableBuild(appId, opts) {
|
|
7246
|
-
return prepareUpgradeFromVerifiableBuild(
|
|
7247
|
-
{
|
|
7248
|
-
appId,
|
|
7249
|
-
privateKey,
|
|
7250
|
-
rpcUrl: ctx.rpcUrl,
|
|
7251
|
-
environment: ctx.environment,
|
|
7252
|
-
instanceType: opts.instanceType,
|
|
7253
|
-
envFilePath: opts.envFile,
|
|
7254
|
-
imageRef: opts.imageRef,
|
|
7255
|
-
imageDigest: opts.imageDigest,
|
|
7256
|
-
logVisibility: opts.logVisibility,
|
|
7257
|
-
resourceUsageMonitoring: opts.resourceUsageMonitoring,
|
|
7258
|
-
skipTelemetry
|
|
7259
|
-
},
|
|
7260
|
-
logger
|
|
7261
|
-
);
|
|
7262
|
-
},
|
|
7263
|
-
async executeUpgrade(prepared, gas) {
|
|
7264
|
-
const account = (0, import_accounts5.privateKeyToAccount)(privateKey);
|
|
7265
|
-
const chain = getChainFromID(environment.chainID);
|
|
7266
|
-
const publicClient = (0, import_viem9.createPublicClient)({
|
|
7267
|
-
chain,
|
|
7268
|
-
transport: (0, import_viem9.http)(ctx.rpcUrl)
|
|
7269
|
-
});
|
|
7270
|
-
const walletClient = (0, import_viem9.createWalletClient)({
|
|
7271
|
-
account,
|
|
7272
|
-
chain,
|
|
7273
|
-
transport: (0, import_viem9.http)(ctx.rpcUrl)
|
|
7274
|
-
});
|
|
7275
|
-
const result = await executeUpgrade({
|
|
7276
|
-
prepared,
|
|
7277
|
-
context: {
|
|
7278
|
-
walletClient,
|
|
7279
|
-
publicClient,
|
|
7280
|
-
environmentConfig: environment
|
|
7281
|
-
},
|
|
7282
|
-
gas,
|
|
7283
|
-
logger,
|
|
7284
|
-
skipTelemetry
|
|
7285
|
-
});
|
|
7286
|
-
return {
|
|
7287
|
-
appId: result.appId,
|
|
7288
|
-
txHash: result.txHash,
|
|
7289
|
-
imageRef: result.imageRef
|
|
7290
|
-
};
|
|
7291
|
-
},
|
|
7292
|
-
async watchUpgrade(appId) {
|
|
7293
|
-
return watchUpgrade(
|
|
7294
|
-
appId,
|
|
7295
|
-
privateKey,
|
|
7296
|
-
ctx.rpcUrl,
|
|
7297
|
-
ctx.environment,
|
|
7298
|
-
logger,
|
|
7299
|
-
ctx.clientId,
|
|
7300
|
-
skipTelemetry
|
|
7301
|
-
);
|
|
7302
|
-
},
|
|
7303
|
-
// Profile management
|
|
7304
|
-
async setProfile(appId, profile) {
|
|
7305
|
-
return withSDKTelemetry(
|
|
7306
|
-
{
|
|
7307
|
-
functionName: "setProfile",
|
|
7308
|
-
skipTelemetry,
|
|
7309
|
-
properties: { environment: ctx.environment }
|
|
7310
|
-
},
|
|
7311
|
-
async () => {
|
|
7312
|
-
const userApiClient = new UserApiClient(
|
|
7313
|
-
environment,
|
|
7314
|
-
privateKey,
|
|
7315
|
-
ctx.rpcUrl,
|
|
7316
|
-
ctx.clientId
|
|
7317
|
-
);
|
|
7318
|
-
return userApiClient.uploadAppProfile(
|
|
7319
|
-
appId,
|
|
7320
|
-
profile.name,
|
|
7321
|
-
profile.website,
|
|
7322
|
-
profile.description,
|
|
7323
|
-
profile.xURL,
|
|
7324
|
-
profile.imagePath
|
|
7325
|
-
);
|
|
7326
|
-
}
|
|
7327
|
-
);
|
|
7328
|
-
},
|
|
7329
6808
|
async logs(opts) {
|
|
7330
6809
|
return logs(
|
|
7331
6810
|
{
|
|
@@ -7476,10 +6955,10 @@ function createComputeModule(config) {
|
|
|
7476
6955
|
|
|
7477
6956
|
// src/client/common/utils/billingapi.ts
|
|
7478
6957
|
var import_axios2 = __toESM(require("axios"), 1);
|
|
7479
|
-
var
|
|
6958
|
+
var import_accounts5 = require("viem/accounts");
|
|
7480
6959
|
var BillingApiClient = class {
|
|
7481
6960
|
constructor(config, privateKey) {
|
|
7482
|
-
this.account = (0,
|
|
6961
|
+
this.account = (0, import_accounts5.privateKeyToAccount)(privateKey);
|
|
7483
6962
|
this.config = config;
|
|
7484
6963
|
}
|
|
7485
6964
|
async createSubscription(productId = "compute") {
|
|
@@ -7549,7 +7028,7 @@ Please check:
|
|
|
7549
7028
|
|
|
7550
7029
|
// src/client/common/auth/keyring.ts
|
|
7551
7030
|
var import_keyring = require("@napi-rs/keyring");
|
|
7552
|
-
var
|
|
7031
|
+
var import_accounts6 = require("viem/accounts");
|
|
7553
7032
|
var SERVICE_NAME = "ecloud";
|
|
7554
7033
|
var ACCOUNT_NAME = "key";
|
|
7555
7034
|
var EIGENX_SERVICE_NAME = "eigenx-cli";
|
|
@@ -7694,7 +7173,7 @@ function validatePrivateKey2(privateKey) {
|
|
|
7694
7173
|
}
|
|
7695
7174
|
function getAddressFromPrivateKey(privateKey) {
|
|
7696
7175
|
const normalized = normalizePrivateKey(privateKey);
|
|
7697
|
-
return (0,
|
|
7176
|
+
return (0, import_accounts6.privateKeyToAddress)(normalized);
|
|
7698
7177
|
}
|
|
7699
7178
|
function decodeGoKeyringValue(rawValue) {
|
|
7700
7179
|
if (rawValue.startsWith(GO_KEYRING_BASE64_PREFIX)) {
|
|
@@ -7776,10 +7255,10 @@ async function requirePrivateKey(options) {
|
|
|
7776
7255
|
}
|
|
7777
7256
|
|
|
7778
7257
|
// src/client/common/auth/generate.ts
|
|
7779
|
-
var
|
|
7258
|
+
var import_accounts7 = require("viem/accounts");
|
|
7780
7259
|
function generateNewPrivateKey() {
|
|
7781
|
-
const privateKey = (0,
|
|
7782
|
-
const address = (0,
|
|
7260
|
+
const privateKey = (0, import_accounts7.generatePrivateKey)();
|
|
7261
|
+
const address = (0, import_accounts7.privateKeyToAddress)(privateKey);
|
|
7783
7262
|
return {
|
|
7784
7263
|
privateKey,
|
|
7785
7264
|
address
|
|
@@ -7881,360 +7360,6 @@ function createBillingModule(config) {
|
|
|
7881
7360
|
};
|
|
7882
7361
|
}
|
|
7883
7362
|
|
|
7884
|
-
// src/client/common/utils/buildapi.ts
|
|
7885
|
-
var import_axios3 = __toESM(require("axios"), 1);
|
|
7886
|
-
var import_accounts9 = require("viem/accounts");
|
|
7887
|
-
var BuildApiClient = class {
|
|
7888
|
-
constructor(options) {
|
|
7889
|
-
this.baseUrl = options.baseUrl.replace(/\/+$/, "");
|
|
7890
|
-
this.clientId = options.clientId;
|
|
7891
|
-
if (options.privateKey) {
|
|
7892
|
-
this.account = (0, import_accounts9.privateKeyToAccount)(options.privateKey);
|
|
7893
|
-
}
|
|
7894
|
-
}
|
|
7895
|
-
async submitBuild(payload) {
|
|
7896
|
-
return this.authenticatedJsonRequest("/builds", "POST", payload);
|
|
7897
|
-
}
|
|
7898
|
-
async getBuild(buildId) {
|
|
7899
|
-
return this.publicJsonRequest(`/builds/${encodeURIComponent(buildId)}`);
|
|
7900
|
-
}
|
|
7901
|
-
async getBuildByDigest(digest) {
|
|
7902
|
-
return this.publicJsonRequest(`/builds/image/${encodeURIComponent(digest)}`);
|
|
7903
|
-
}
|
|
7904
|
-
async verify(identifier) {
|
|
7905
|
-
return this.publicJsonRequest(`/builds/verify/${encodeURIComponent(identifier)}`);
|
|
7906
|
-
}
|
|
7907
|
-
async getLogs(buildId) {
|
|
7908
|
-
return this.authenticatedTextRequest(`/builds/${encodeURIComponent(buildId)}/logs`);
|
|
7909
|
-
}
|
|
7910
|
-
async listBuilds(params) {
|
|
7911
|
-
const res = await (0, import_axios3.default)({
|
|
7912
|
-
url: `${this.baseUrl}/builds`,
|
|
7913
|
-
method: "GET",
|
|
7914
|
-
params,
|
|
7915
|
-
headers: this.clientId ? { "x-client-id": this.clientId } : void 0,
|
|
7916
|
-
timeout: 6e4,
|
|
7917
|
-
validateStatus: () => true
|
|
7918
|
-
});
|
|
7919
|
-
if (res.status < 200 || res.status >= 300) throw buildApiHttpError(res);
|
|
7920
|
-
return res.data;
|
|
7921
|
-
}
|
|
7922
|
-
async publicJsonRequest(path8) {
|
|
7923
|
-
const res = await (0, import_axios3.default)({
|
|
7924
|
-
url: `${this.baseUrl}${path8}`,
|
|
7925
|
-
method: "GET",
|
|
7926
|
-
headers: this.clientId ? { "x-client-id": this.clientId } : void 0,
|
|
7927
|
-
timeout: 6e4,
|
|
7928
|
-
validateStatus: () => true
|
|
7929
|
-
});
|
|
7930
|
-
if (res.status < 200 || res.status >= 300) throw buildApiHttpError(res);
|
|
7931
|
-
return res.data;
|
|
7932
|
-
}
|
|
7933
|
-
async authenticatedJsonRequest(path8, method, body) {
|
|
7934
|
-
if (!this.account) throw new Error("Private key required for authenticated requests");
|
|
7935
|
-
const headers = {
|
|
7936
|
-
"Content-Type": "application/json"
|
|
7937
|
-
};
|
|
7938
|
-
if (this.clientId) headers["x-client-id"] = this.clientId;
|
|
7939
|
-
const expiry = BigInt(Math.floor(Date.now() / 1e3) + 60);
|
|
7940
|
-
const { signature } = await calculateBillingAuthSignature({
|
|
7941
|
-
account: this.account,
|
|
7942
|
-
product: "compute",
|
|
7943
|
-
expiry
|
|
7944
|
-
});
|
|
7945
|
-
headers.Authorization = `Bearer ${signature}`;
|
|
7946
|
-
headers["X-eigenx-expiry"] = expiry.toString();
|
|
7947
|
-
headers["X-Account"] = this.account.address;
|
|
7948
|
-
const res = await (0, import_axios3.default)({
|
|
7949
|
-
url: `${this.baseUrl}${path8}`,
|
|
7950
|
-
method,
|
|
7951
|
-
headers,
|
|
7952
|
-
data: body,
|
|
7953
|
-
timeout: 6e4,
|
|
7954
|
-
validateStatus: () => true
|
|
7955
|
-
});
|
|
7956
|
-
if (res.status < 200 || res.status >= 300) throw buildApiHttpError(res);
|
|
7957
|
-
return res.data;
|
|
7958
|
-
}
|
|
7959
|
-
async authenticatedTextRequest(path8) {
|
|
7960
|
-
if (!this.account) throw new Error("Private key required for authenticated requests");
|
|
7961
|
-
const headers = {};
|
|
7962
|
-
if (this.clientId) headers["x-client-id"] = this.clientId;
|
|
7963
|
-
const expiry = BigInt(Math.floor(Date.now() / 1e3) + 60);
|
|
7964
|
-
const { signature } = await calculateBillingAuthSignature({
|
|
7965
|
-
account: this.account,
|
|
7966
|
-
product: "compute",
|
|
7967
|
-
expiry
|
|
7968
|
-
});
|
|
7969
|
-
headers.Authorization = `Bearer ${signature}`;
|
|
7970
|
-
headers["X-eigenx-expiry"] = expiry.toString();
|
|
7971
|
-
headers["X-Account"] = this.account.address;
|
|
7972
|
-
const res = await (0, import_axios3.default)({
|
|
7973
|
-
url: `${this.baseUrl}${path8}`,
|
|
7974
|
-
method: "GET",
|
|
7975
|
-
headers,
|
|
7976
|
-
timeout: 6e4,
|
|
7977
|
-
responseType: "text",
|
|
7978
|
-
validateStatus: () => true
|
|
7979
|
-
});
|
|
7980
|
-
if (res.status < 200 || res.status >= 300) throw buildApiHttpError(res);
|
|
7981
|
-
return typeof res.data === "string" ? res.data : JSON.stringify(res.data);
|
|
7982
|
-
}
|
|
7983
|
-
};
|
|
7984
|
-
function buildApiHttpError(res) {
|
|
7985
|
-
const status = res.status;
|
|
7986
|
-
const body = typeof res.data === "string" ? res.data : res.data ? JSON.stringify(res.data) : "";
|
|
7987
|
-
const url = res.config?.url ? ` ${res.config.url}` : "";
|
|
7988
|
-
return new Error(`BuildAPI request failed: ${status}${url} - ${body || "Unknown error"}`);
|
|
7989
|
-
}
|
|
7990
|
-
|
|
7991
|
-
// src/client/modules/build/types.ts
|
|
7992
|
-
var BUILD_STATUS = {
|
|
7993
|
-
BUILDING: "building",
|
|
7994
|
-
SUCCESS: "success",
|
|
7995
|
-
FAILED: "failed"
|
|
7996
|
-
};
|
|
7997
|
-
|
|
7998
|
-
// src/client/modules/build/errors.ts
|
|
7999
|
-
var BuildError = class extends Error {
|
|
8000
|
-
constructor(message) {
|
|
8001
|
-
super(message);
|
|
8002
|
-
this.name = "BuildError";
|
|
8003
|
-
}
|
|
8004
|
-
};
|
|
8005
|
-
var AuthRequiredError = class extends BuildError {
|
|
8006
|
-
constructor(message = "Authentication required") {
|
|
8007
|
-
super(message);
|
|
8008
|
-
this.name = "AuthRequiredError";
|
|
8009
|
-
}
|
|
8010
|
-
};
|
|
8011
|
-
var BuildFailedError = class extends BuildError {
|
|
8012
|
-
constructor(message, buildId) {
|
|
8013
|
-
super(message);
|
|
8014
|
-
this.buildId = buildId;
|
|
8015
|
-
this.name = "BuildFailedError";
|
|
8016
|
-
}
|
|
8017
|
-
};
|
|
8018
|
-
var ConflictError = class extends BuildError {
|
|
8019
|
-
constructor(message = "Build already in progress") {
|
|
8020
|
-
super(message);
|
|
8021
|
-
this.name = "ConflictError";
|
|
8022
|
-
}
|
|
8023
|
-
};
|
|
8024
|
-
var NotFoundError = class extends BuildError {
|
|
8025
|
-
constructor(message = "Build not found") {
|
|
8026
|
-
super(message);
|
|
8027
|
-
this.name = "NotFoundError";
|
|
8028
|
-
}
|
|
8029
|
-
};
|
|
8030
|
-
var ForbiddenError = class extends BuildError {
|
|
8031
|
-
constructor(message = "Permission denied") {
|
|
8032
|
-
super(message);
|
|
8033
|
-
this.name = "ForbiddenError";
|
|
8034
|
-
}
|
|
8035
|
-
};
|
|
8036
|
-
var TimeoutError = class extends BuildError {
|
|
8037
|
-
constructor(message = "Operation timed out") {
|
|
8038
|
-
super(message);
|
|
8039
|
-
this.name = "TimeoutError";
|
|
8040
|
-
}
|
|
8041
|
-
};
|
|
8042
|
-
var BadRequestError = class extends BuildError {
|
|
8043
|
-
constructor(message = "Bad request") {
|
|
8044
|
-
super(message);
|
|
8045
|
-
this.name = "BadRequestError";
|
|
8046
|
-
}
|
|
8047
|
-
};
|
|
8048
|
-
|
|
8049
|
-
// src/client/modules/build/index.ts
|
|
8050
|
-
var DEFAULT_POLL_INTERVAL = 2e3;
|
|
8051
|
-
var DEFAULT_TIMEOUT = 30 * 60 * 1e3;
|
|
8052
|
-
function createBuildModule(config) {
|
|
8053
|
-
const { verbose = false, skipTelemetry = false } = config;
|
|
8054
|
-
const logger = getLogger(verbose);
|
|
8055
|
-
const environment = config.environment || "sepolia";
|
|
8056
|
-
const environmentConfig = getEnvironmentConfig(environment);
|
|
8057
|
-
const api = new BuildApiClient({
|
|
8058
|
-
baseUrl: environmentConfig.userApiServerURL,
|
|
8059
|
-
privateKey: config.privateKey ? addHexPrefix(config.privateKey) : void 0,
|
|
8060
|
-
clientId: config.clientId
|
|
8061
|
-
});
|
|
8062
|
-
return {
|
|
8063
|
-
async submit(request) {
|
|
8064
|
-
return withSDKTelemetry(
|
|
8065
|
-
{
|
|
8066
|
-
functionName: "build.submit",
|
|
8067
|
-
skipTelemetry,
|
|
8068
|
-
properties: { environment, repoUrl: request.repoUrl }
|
|
8069
|
-
},
|
|
8070
|
-
async () => {
|
|
8071
|
-
if (!config.privateKey) throw new AuthRequiredError("Private key required for submit()");
|
|
8072
|
-
const data = await api.submitBuild({
|
|
8073
|
-
repo_url: request.repoUrl,
|
|
8074
|
-
git_ref: request.gitRef,
|
|
8075
|
-
dockerfile_path: request.dockerfilePath ?? "Dockerfile",
|
|
8076
|
-
caddyfile_path: request.caddyfilePath,
|
|
8077
|
-
build_context_path: request.buildContextPath ?? ".",
|
|
8078
|
-
dependencies: request.dependencies ?? []
|
|
8079
|
-
});
|
|
8080
|
-
logger.debug(`Submitted build: ${data.build_id}`);
|
|
8081
|
-
return { buildId: data.build_id };
|
|
8082
|
-
}
|
|
8083
|
-
);
|
|
8084
|
-
},
|
|
8085
|
-
async list(options) {
|
|
8086
|
-
const { billingAddress, limit, offset } = options;
|
|
8087
|
-
return withSDKTelemetry(
|
|
8088
|
-
{
|
|
8089
|
-
functionName: "build.list",
|
|
8090
|
-
skipTelemetry,
|
|
8091
|
-
properties: {
|
|
8092
|
-
environment,
|
|
8093
|
-
billingAddress,
|
|
8094
|
-
...limit !== void 0 ? { limit: String(limit) } : {},
|
|
8095
|
-
...offset !== void 0 ? { offset: String(offset) } : {}
|
|
8096
|
-
}
|
|
8097
|
-
},
|
|
8098
|
-
async () => {
|
|
8099
|
-
const data = await api.listBuilds({
|
|
8100
|
-
billing_address: billingAddress,
|
|
8101
|
-
limit,
|
|
8102
|
-
offset
|
|
8103
|
-
});
|
|
8104
|
-
return Array.isArray(data) ? data.map(transformBuild) : [];
|
|
8105
|
-
}
|
|
8106
|
-
);
|
|
8107
|
-
},
|
|
8108
|
-
async get(buildId) {
|
|
8109
|
-
return withSDKTelemetry(
|
|
8110
|
-
{ functionName: "build.get", skipTelemetry, properties: { environment, buildId } },
|
|
8111
|
-
async () => transformBuild(await api.getBuild(buildId))
|
|
8112
|
-
);
|
|
8113
|
-
},
|
|
8114
|
-
async getByDigest(digest) {
|
|
8115
|
-
return withSDKTelemetry(
|
|
8116
|
-
{ functionName: "build.getByDigest", skipTelemetry, properties: { environment, digest } },
|
|
8117
|
-
async () => transformBuild(await api.getBuildByDigest(digest))
|
|
8118
|
-
);
|
|
8119
|
-
},
|
|
8120
|
-
async verify(identifier) {
|
|
8121
|
-
return withSDKTelemetry(
|
|
8122
|
-
{ functionName: "build.verify", skipTelemetry, properties: { environment, identifier } },
|
|
8123
|
-
async () => transformVerifyResult(await api.verify(identifier))
|
|
8124
|
-
);
|
|
8125
|
-
},
|
|
8126
|
-
async getLogs(buildId) {
|
|
8127
|
-
return withSDKTelemetry(
|
|
8128
|
-
{ functionName: "build.getLogs", skipTelemetry, properties: { environment, buildId } },
|
|
8129
|
-
async () => {
|
|
8130
|
-
if (!config.privateKey) throw new AuthRequiredError("Private key required for getLogs()");
|
|
8131
|
-
return api.getLogs(buildId);
|
|
8132
|
-
}
|
|
8133
|
-
);
|
|
8134
|
-
},
|
|
8135
|
-
async submitAndWait(request, options = {}) {
|
|
8136
|
-
const { buildId } = await this.submit(request);
|
|
8137
|
-
return this.waitForBuild(buildId, options);
|
|
8138
|
-
},
|
|
8139
|
-
async waitForBuild(buildId, options = {}) {
|
|
8140
|
-
const {
|
|
8141
|
-
onLog,
|
|
8142
|
-
onProgress,
|
|
8143
|
-
pollIntervalMs = DEFAULT_POLL_INTERVAL,
|
|
8144
|
-
timeoutMs = DEFAULT_TIMEOUT
|
|
8145
|
-
} = options;
|
|
8146
|
-
const startTime = Date.now();
|
|
8147
|
-
let lastLogLength = 0;
|
|
8148
|
-
while (true) {
|
|
8149
|
-
if (Date.now() - startTime > timeoutMs) {
|
|
8150
|
-
throw new TimeoutError(`Build timed out after ${timeoutMs}ms`);
|
|
8151
|
-
}
|
|
8152
|
-
const build = await this.get(buildId);
|
|
8153
|
-
let logs2 = "";
|
|
8154
|
-
try {
|
|
8155
|
-
logs2 = await this.getLogs(buildId);
|
|
8156
|
-
if (onLog && logs2.length > lastLogLength) {
|
|
8157
|
-
onLog(logs2.slice(lastLogLength));
|
|
8158
|
-
lastLogLength = logs2.length;
|
|
8159
|
-
}
|
|
8160
|
-
} catch {
|
|
8161
|
-
}
|
|
8162
|
-
onProgress?.({ build, logs: logs2 });
|
|
8163
|
-
if (build.status === BUILD_STATUS.SUCCESS) return build;
|
|
8164
|
-
if (build.status === BUILD_STATUS.FAILED) {
|
|
8165
|
-
throw new BuildFailedError(build.errorMessage ?? "Build failed", buildId);
|
|
8166
|
-
}
|
|
8167
|
-
await sleep2(pollIntervalMs);
|
|
8168
|
-
}
|
|
8169
|
-
},
|
|
8170
|
-
async *streamLogs(buildId, pollIntervalMs = DEFAULT_POLL_INTERVAL) {
|
|
8171
|
-
let lastLength = 0;
|
|
8172
|
-
while (true) {
|
|
8173
|
-
const build = await this.get(buildId);
|
|
8174
|
-
let logs2 = "";
|
|
8175
|
-
try {
|
|
8176
|
-
logs2 = await this.getLogs(buildId);
|
|
8177
|
-
} catch {
|
|
8178
|
-
}
|
|
8179
|
-
if (logs2.length > lastLength) {
|
|
8180
|
-
yield {
|
|
8181
|
-
content: logs2.slice(lastLength),
|
|
8182
|
-
totalLength: logs2.length,
|
|
8183
|
-
isComplete: build.status !== BUILD_STATUS.BUILDING,
|
|
8184
|
-
finalStatus: build.status !== BUILD_STATUS.BUILDING ? build.status : void 0
|
|
8185
|
-
};
|
|
8186
|
-
lastLength = logs2.length;
|
|
8187
|
-
}
|
|
8188
|
-
if (build.status !== BUILD_STATUS.BUILDING) break;
|
|
8189
|
-
await sleep2(pollIntervalMs);
|
|
8190
|
-
}
|
|
8191
|
-
}
|
|
8192
|
-
};
|
|
8193
|
-
}
|
|
8194
|
-
function sleep2(ms) {
|
|
8195
|
-
return new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
8196
|
-
}
|
|
8197
|
-
function transformBuild(raw) {
|
|
8198
|
-
return {
|
|
8199
|
-
buildId: raw.build_id,
|
|
8200
|
-
billingAddress: raw.billing_address,
|
|
8201
|
-
repoUrl: raw.repo_url,
|
|
8202
|
-
gitRef: raw.git_ref,
|
|
8203
|
-
status: raw.status,
|
|
8204
|
-
buildType: raw.build_type,
|
|
8205
|
-
imageName: raw.image_name,
|
|
8206
|
-
imageUrl: raw.image_url,
|
|
8207
|
-
imageDigest: raw.image_digest,
|
|
8208
|
-
provenanceJson: raw.provenance_json ?? void 0,
|
|
8209
|
-
provenanceSignature: raw.provenance_signature ?? void 0,
|
|
8210
|
-
errorMessage: raw.error_message ?? void 0,
|
|
8211
|
-
createdAt: raw.created_at,
|
|
8212
|
-
updatedAt: raw.updated_at,
|
|
8213
|
-
dependencies: raw.dependencies ? Object.fromEntries(Object.entries(raw.dependencies).map(([k, v]) => [k, transformBuild(v)])) : void 0
|
|
8214
|
-
};
|
|
8215
|
-
}
|
|
8216
|
-
function transformVerifyResult(raw) {
|
|
8217
|
-
if (raw.status === "verified") {
|
|
8218
|
-
return {
|
|
8219
|
-
status: "verified",
|
|
8220
|
-
buildId: raw.build_id,
|
|
8221
|
-
imageUrl: raw.image_url,
|
|
8222
|
-
imageDigest: raw.image_digest,
|
|
8223
|
-
repoUrl: raw.repo_url,
|
|
8224
|
-
gitRef: raw.git_ref,
|
|
8225
|
-
provenanceJson: raw.provenance_json,
|
|
8226
|
-
provenanceSignature: raw.provenance_signature,
|
|
8227
|
-
payloadType: raw.payload_type,
|
|
8228
|
-
payload: raw.payload
|
|
8229
|
-
};
|
|
8230
|
-
}
|
|
8231
|
-
return {
|
|
8232
|
-
status: "failed",
|
|
8233
|
-
error: raw.error,
|
|
8234
|
-
buildId: raw.build_id
|
|
8235
|
-
};
|
|
8236
|
-
}
|
|
8237
|
-
|
|
8238
7363
|
// src/client/common/utils/instance.ts
|
|
8239
7364
|
async function getCurrentInstanceType(preflightCtx, appID, logger, clientId) {
|
|
8240
7365
|
try {
|
|
@@ -8289,20 +7414,10 @@ function createECloudClient(cfg) {
|
|
|
8289
7414
|
}
|
|
8290
7415
|
// Annotate the CommonJS export names for ESM import in node:
|
|
8291
7416
|
0 && (module.exports = {
|
|
8292
|
-
AuthRequiredError,
|
|
8293
|
-
BUILD_STATUS,
|
|
8294
|
-
BadRequestError,
|
|
8295
|
-
BuildError,
|
|
8296
|
-
BuildFailedError,
|
|
8297
|
-
ConflictError,
|
|
8298
|
-
ForbiddenError,
|
|
8299
7417
|
NoopClient,
|
|
8300
|
-
NotFoundError,
|
|
8301
7418
|
PRIMARY_LANGUAGES,
|
|
8302
7419
|
PostHogClient,
|
|
8303
|
-
TimeoutError,
|
|
8304
7420
|
UserApiClient,
|
|
8305
|
-
addHexPrefix,
|
|
8306
7421
|
addMetric,
|
|
8307
7422
|
addMetricWithDimensions,
|
|
8308
7423
|
assertValidFilePath,
|
|
@@ -8312,7 +7427,6 @@ function createECloudClient(cfg) {
|
|
|
8312
7427
|
createApp,
|
|
8313
7428
|
createAppEnvironment,
|
|
8314
7429
|
createBillingModule,
|
|
8315
|
-
createBuildModule,
|
|
8316
7430
|
createComputeModule,
|
|
8317
7431
|
createECloudClient,
|
|
8318
7432
|
createMetricsContext,
|
|
@@ -8356,15 +7470,12 @@ function createECloudClient(cfg) {
|
|
|
8356
7470
|
listStoredKeys,
|
|
8357
7471
|
logs,
|
|
8358
7472
|
prepareDeploy,
|
|
8359
|
-
prepareDeployFromVerifiableBuild,
|
|
8360
7473
|
prepareUpgrade,
|
|
8361
|
-
prepareUpgradeFromVerifiableBuild,
|
|
8362
7474
|
requirePrivateKey,
|
|
8363
7475
|
sanitizeString,
|
|
8364
7476
|
sanitizeURL,
|
|
8365
7477
|
sanitizeXURL,
|
|
8366
7478
|
storePrivateKey,
|
|
8367
|
-
stripHexPrefix,
|
|
8368
7479
|
validateAppID,
|
|
8369
7480
|
validateAppName,
|
|
8370
7481
|
validateCreateAppParams,
|