@layr-labs/ecloud-sdk 0.0.1-dev.1 → 0.0.1-dev.3

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 CHANGED
@@ -1,2 +1,2 @@
1
- version=0.0.1-dev.1
2
- commit=be757436b79faff7959b8375dbb051cc47cb0895
1
+ version=0.0.1-dev.3
2
+ commit=132bf294c352e04717bc6bfa0bd81f4bba205656
package/dist/index.cjs CHANGED
@@ -910,13 +910,15 @@ async function setupLayeredBuildDirectory(environmentConfig, layeredDockerfileCo
910
910
  // src/client/common/registry/digest.ts
911
911
  var child_process3 = __toESM(require("child_process"), 1);
912
912
  var import_util3 = require("util");
913
- var exec5 = (0, import_util3.promisify)(child_process3.exec);
913
+ var execFileAsync = (0, import_util3.promisify)(child_process3.execFile);
914
914
  async function getImageDigestAndName(imageRef) {
915
915
  try {
916
- const { stdout } = await exec5(`docker manifest inspect ${imageRef}`, {
917
- maxBuffer: 10 * 1024 * 1024
916
+ const { stdout } = await execFileAsync(
917
+ "docker",
918
+ ["manifest", "inspect", imageRef],
919
+ { maxBuffer: 10 * 1024 * 1024 }
918
920
  // 10MB buffer
919
- });
921
+ );
920
922
  const manifest = JSON.parse(stdout);
921
923
  if (manifest.manifests && manifest.manifests.length > 0) {
922
924
  return extractDigestFromMultiPlatform(manifest, imageRef);
@@ -951,7 +953,7 @@ function extractDigestFromMultiPlatform(manifest, imageRef) {
951
953
  }
952
954
  async function extractDigestFromSinglePlatform(manifest, imageRef) {
953
955
  try {
954
- const { stdout } = await exec5(`docker inspect ${imageRef}`, {
956
+ const { stdout } = await execFile("docker", ["inspect", imageRef], {
955
957
  maxBuffer: 10 * 1024 * 1024
956
958
  });
957
959
  const inspectData = JSON.parse(stdout);
@@ -2509,14 +2511,19 @@ var MAX_ADDRESS_COUNT = 5;
2509
2511
  var CanViewAppLogsPermission = "0x2fd3f2fe";
2510
2512
  var CanViewSensitiveAppInfoPermission = "0x0e67b22f";
2511
2513
  var CanUpdateAppProfilePermission = "0x036fef61";
2514
+ function getDefaultClientId() {
2515
+ const version = true ? "0.0.1-dev.3" : "0.0.0";
2516
+ return `ecloud-sdk/v${version}`;
2517
+ }
2512
2518
  var UserApiClient = class {
2513
- constructor(config, privateKey, rpcUrl) {
2519
+ constructor(config, privateKey, rpcUrl, clientId) {
2514
2520
  this.config = config;
2515
2521
  if (privateKey) {
2516
2522
  const privateKeyHex = addHexPrefix(privateKey);
2517
2523
  this.account = (0, import_accounts.privateKeyToAccount)(privateKeyHex);
2518
2524
  }
2519
2525
  this.rpcUrl = rpcUrl;
2526
+ this.clientId = clientId || getDefaultClientId();
2520
2527
  }
2521
2528
  async getInfos(appIDs, addressCount = 1) {
2522
2529
  const count = Math.min(addressCount, MAX_ADDRESS_COUNT);
@@ -2596,7 +2603,7 @@ var UserApiClient = class {
2596
2603
  formData.append("image", fileBuffer, fileName);
2597
2604
  }
2598
2605
  const headers = {
2599
- "x-client-id": "ecloud-cli/v0.0.1",
2606
+ "x-client-id": this.clientId,
2600
2607
  ...formData.getHeaders()
2601
2608
  };
2602
2609
  if (this.account) {
@@ -2645,7 +2652,7 @@ Please check:
2645
2652
  }
2646
2653
  async makeAuthenticatedRequest(url, permission) {
2647
2654
  const headers = {
2648
- "x-client-id": "ecloud-cli/v0.0.1"
2655
+ "x-client-id": this.clientId
2649
2656
  };
2650
2657
  if (permission && this.account) {
2651
2658
  const expiry = BigInt(Math.floor(Date.now() / 1e3) + 5 * 60);
@@ -4831,8 +4838,8 @@ var WATCH_POLL_INTERVAL_SECONDS = 5;
4831
4838
  var APP_STATUS_RUNNING = "Running";
4832
4839
  var APP_STATUS_FAILED = "Failed";
4833
4840
  async function watchUntilRunning(options, logger) {
4834
- const { environmentConfig, appId, privateKey, rpcUrl } = options;
4835
- const userApiClient = new UserApiClient(environmentConfig, privateKey, rpcUrl);
4841
+ const { environmentConfig, appId, privateKey, rpcUrl, clientId } = options;
4842
+ const userApiClient = new UserApiClient(environmentConfig, privateKey, rpcUrl, clientId);
4836
4843
  let initialStatus;
4837
4844
  let initialIP;
4838
4845
  let hasChanged = false;
@@ -4881,8 +4888,8 @@ async function watchUntilRunning(options, logger) {
4881
4888
  }
4882
4889
  var APP_STATUS_STOPPED = "Stopped";
4883
4890
  async function watchUntilUpgradeComplete(options, logger) {
4884
- const { environmentConfig, appId, privateKey, rpcUrl } = options;
4885
- const userApiClient = new UserApiClient(environmentConfig, privateKey, rpcUrl);
4891
+ const { environmentConfig, appId, privateKey, rpcUrl, clientId } = options;
4892
+ const userApiClient = new UserApiClient(environmentConfig, privateKey, rpcUrl, clientId);
4886
4893
  let initialStatus;
4887
4894
  let initialIP;
4888
4895
  let hasChanged = false;
@@ -5530,7 +5537,7 @@ async function executeDeploy(prepared, gas, logger = defaultLogger) {
5530
5537
  imageRef: prepared.imageRef
5531
5538
  };
5532
5539
  }
5533
- async function watchDeployment(appId, privateKey, rpcUrl, environment, logger = defaultLogger) {
5540
+ async function watchDeployment(appId, privateKey, rpcUrl, environment, logger = defaultLogger, clientId) {
5534
5541
  const environmentConfig = getEnvironmentConfig(environment);
5535
5542
  logger.info("Waiting for app to start...");
5536
5543
  return watchUntilRunning(
@@ -5538,7 +5545,8 @@ async function watchDeployment(appId, privateKey, rpcUrl, environment, logger =
5538
5545
  privateKey,
5539
5546
  rpcUrl,
5540
5547
  environmentConfig,
5541
- appId
5548
+ appId,
5549
+ clientId
5542
5550
  },
5543
5551
  logger
5544
5552
  );
@@ -5738,7 +5746,7 @@ async function executeUpgrade(prepared, gas, logger = defaultLogger) {
5738
5746
  txHash
5739
5747
  };
5740
5748
  }
5741
- async function watchUpgrade(appId, privateKey, rpcUrl, environment, logger = defaultLogger) {
5749
+ async function watchUpgrade(appId, privateKey, rpcUrl, environment, logger = defaultLogger, clientId) {
5742
5750
  const environmentConfig = getEnvironmentConfig(environment);
5743
5751
  logger.info("Waiting for upgrade to complete...");
5744
5752
  await watchUntilUpgradeComplete(
@@ -5746,7 +5754,8 @@ async function watchUpgrade(appId, privateKey, rpcUrl, environment, logger = def
5746
5754
  privateKey,
5747
5755
  rpcUrl,
5748
5756
  environmentConfig,
5749
- appId
5757
+ appId,
5758
+ clientId
5750
5759
  },
5751
5760
  logger
5752
5761
  );
@@ -5849,7 +5858,7 @@ var os2 = __toESM(require("os"), 1);
5849
5858
  var import_child_process2 = require("child_process");
5850
5859
  var import_util4 = require("util");
5851
5860
  var execAsync2 = (0, import_util4.promisify)(import_child_process2.exec);
5852
- var execFileAsync = (0, import_util4.promisify)(import_child_process2.execFile);
5861
+ var execFileAsync2 = (0, import_util4.promisify)(import_child_process2.execFile);
5853
5862
  async function fetchTemplate(repoURL, ref, targetDir, config, logger) {
5854
5863
  if (!repoURL) {
5855
5864
  throw new Error("repoURL is required");
@@ -5861,10 +5870,14 @@ Cloning repo: ${repoURL} \u2192 ${targetDir}
5861
5870
  await execAsync2(`git clone --no-checkout --progress ${repoURL} ${targetDir}`, {
5862
5871
  maxBuffer: 10 * 1024 * 1024
5863
5872
  });
5864
- await execFileAsync("git", ["-C", targetDir, "checkout", "--quiet", ref], {
5873
+ await execFileAsync2("git", ["-C", targetDir, "checkout", "--quiet", ref], {
5865
5874
  maxBuffer: 10 * 1024 * 1024
5866
5875
  });
5867
- await execAsync2(`git -C ${targetDir} submodule update --init --recursive --progress`);
5876
+ await execFileAsync2(
5877
+ "git",
5878
+ ["-C", targetDir, "submodule", "update", "--init", "--recursive", "--progress"],
5879
+ { maxBuffer: 10 * 1024 * 1024 }
5880
+ );
5868
5881
  logger.info(`Clone repo complete: ${repoURL}
5869
5882
  `);
5870
5883
  } catch (error) {
@@ -5905,14 +5918,14 @@ Cloning template: ${repoURL} \u2192 extracting ${subPath}
5905
5918
  }
5906
5919
  async function cloneSparse(repoURL, ref, subPath, tempDir) {
5907
5920
  try {
5908
- await execFileAsync("git", ["init", tempDir]);
5909
- await execFileAsync("git", ["-C", tempDir, "remote", "add", "origin", repoURL]);
5910
- await execFileAsync("git", ["-C", tempDir, "config", "core.sparseCheckout", "true"]);
5921
+ await execFileAsync2("git", ["init", tempDir]);
5922
+ await execFileAsync2("git", ["-C", tempDir, "remote", "add", "origin", repoURL]);
5923
+ await execFileAsync2("git", ["-C", tempDir, "config", "core.sparseCheckout", "true"]);
5911
5924
  const sparseCheckoutPath = path5.join(tempDir, ".git/info/sparse-checkout");
5912
5925
  fs5.writeFileSync(sparseCheckoutPath, `${subPath}
5913
5926
  `);
5914
- await execFileAsync("git", ["-C", tempDir, "fetch", "origin", ref]);
5915
- await execFileAsync("git", ["-C", tempDir, "checkout", ref]);
5927
+ await execFileAsync2("git", ["-C", tempDir, "fetch", "origin", ref]);
5928
+ await execFileAsync2("git", ["-C", tempDir, "checkout", ref]);
5916
5929
  } catch (error) {
5917
5930
  throw new Error(`Failed to clone sparse repository: ${error.message}`);
5918
5931
  }
@@ -6306,7 +6319,12 @@ async function logs(options, logger = defaultLogger) {
6306
6319
  }
6307
6320
  const appID = validateAppID(options.appID);
6308
6321
  const formattedApp = formatAppDisplay(environmentConfig.name, appID, "");
6309
- const userApiClient = new UserApiClient(environmentConfig, options.privateKey, rpcUrl);
6322
+ const userApiClient = new UserApiClient(
6323
+ environmentConfig,
6324
+ options.privateKey,
6325
+ rpcUrl,
6326
+ options.clientId
6327
+ );
6310
6328
  let logsText;
6311
6329
  let logsError = null;
6312
6330
  try {
@@ -6462,7 +6480,8 @@ function createAppModule(ctx) {
6462
6480
  privateKey,
6463
6481
  appID: opts.appID,
6464
6482
  watch: opts.watch,
6465
- environment: ctx.environment
6483
+ environment: ctx.environment,
6484
+ clientId: ctx.clientId
6466
6485
  },
6467
6486
  logger
6468
6487
  );
@@ -6923,12 +6942,13 @@ function generateNewPrivateKey() {
6923
6942
  }
6924
6943
 
6925
6944
  // src/client/common/utils/instance.ts
6926
- async function getCurrentInstanceType(preflightCtx, appID, logger) {
6945
+ async function getCurrentInstanceType(preflightCtx, appID, logger, clientId) {
6927
6946
  try {
6928
6947
  const userApiClient = new UserApiClient(
6929
6948
  preflightCtx.environmentConfig,
6930
6949
  preflightCtx.privateKey,
6931
- preflightCtx.rpcUrl
6950
+ preflightCtx.rpcUrl,
6951
+ clientId
6932
6952
  );
6933
6953
  const infos = await userApiClient.getInfos([appID], 1);
6934
6954
  if (infos.length === 0) {