@layr-labs/ecloud-sdk 0.0.1-dev.1 → 0.0.1-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/index.cjs +27 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +29 -18
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1119,7 +1119,8 @@ declare class UserApiClient {
|
|
|
1119
1119
|
private readonly config;
|
|
1120
1120
|
private readonly account?;
|
|
1121
1121
|
private readonly rpcUrl?;
|
|
1122
|
-
|
|
1122
|
+
private readonly clientId;
|
|
1123
|
+
constructor(config: EnvironmentConfig, privateKey?: string | Hex, rpcUrl?: string, clientId?: string);
|
|
1123
1124
|
getInfos(appIDs: Address[], addressCount?: number): Promise<AppInfo[]>;
|
|
1124
1125
|
/**
|
|
1125
1126
|
* Get available SKUs (instance types) from UserAPI
|
package/dist/index.d.ts
CHANGED
|
@@ -1119,7 +1119,8 @@ declare class UserApiClient {
|
|
|
1119
1119
|
private readonly config;
|
|
1120
1120
|
private readonly account?;
|
|
1121
1121
|
private readonly rpcUrl?;
|
|
1122
|
-
|
|
1122
|
+
private readonly clientId;
|
|
1123
|
+
constructor(config: EnvironmentConfig, privateKey?: string | Hex, rpcUrl?: string, clientId?: string);
|
|
1123
1124
|
getInfos(appIDs: Address[], addressCount?: number): Promise<AppInfo[]>;
|
|
1124
1125
|
/**
|
|
1125
1126
|
* Get available SKUs (instance types) from UserAPI
|
package/dist/index.js
CHANGED
|
@@ -805,13 +805,15 @@ async function setupLayeredBuildDirectory(environmentConfig, layeredDockerfileCo
|
|
|
805
805
|
// src/client/common/registry/digest.ts
|
|
806
806
|
import * as child_process3 from "child_process";
|
|
807
807
|
import { promisify as promisify3 } from "util";
|
|
808
|
-
var
|
|
808
|
+
var execFileAsync = promisify3(child_process3.execFile);
|
|
809
809
|
async function getImageDigestAndName(imageRef) {
|
|
810
810
|
try {
|
|
811
|
-
const { stdout } = await
|
|
812
|
-
|
|
811
|
+
const { stdout } = await execFileAsync(
|
|
812
|
+
"docker",
|
|
813
|
+
["manifest", "inspect", imageRef],
|
|
814
|
+
{ maxBuffer: 10 * 1024 * 1024 }
|
|
813
815
|
// 10MB buffer
|
|
814
|
-
|
|
816
|
+
);
|
|
815
817
|
const manifest = JSON.parse(stdout);
|
|
816
818
|
if (manifest.manifests && manifest.manifests.length > 0) {
|
|
817
819
|
return extractDigestFromMultiPlatform(manifest, imageRef);
|
|
@@ -846,7 +848,7 @@ function extractDigestFromMultiPlatform(manifest, imageRef) {
|
|
|
846
848
|
}
|
|
847
849
|
async function extractDigestFromSinglePlatform(manifest, imageRef) {
|
|
848
850
|
try {
|
|
849
|
-
const { stdout } = await
|
|
851
|
+
const { stdout } = await execFile("docker", ["inspect", imageRef], {
|
|
850
852
|
maxBuffer: 10 * 1024 * 1024
|
|
851
853
|
});
|
|
852
854
|
const inspectData = JSON.parse(stdout);
|
|
@@ -2417,14 +2419,19 @@ var MAX_ADDRESS_COUNT = 5;
|
|
|
2417
2419
|
var CanViewAppLogsPermission = "0x2fd3f2fe";
|
|
2418
2420
|
var CanViewSensitiveAppInfoPermission = "0x0e67b22f";
|
|
2419
2421
|
var CanUpdateAppProfilePermission = "0x036fef61";
|
|
2422
|
+
function getDefaultClientId() {
|
|
2423
|
+
const version = true ? "0.0.1-dev.2" : "0.0.0";
|
|
2424
|
+
return `ecloud-sdk/v${version}`;
|
|
2425
|
+
}
|
|
2420
2426
|
var UserApiClient = class {
|
|
2421
|
-
constructor(config, privateKey, rpcUrl) {
|
|
2427
|
+
constructor(config, privateKey, rpcUrl, clientId) {
|
|
2422
2428
|
this.config = config;
|
|
2423
2429
|
if (privateKey) {
|
|
2424
2430
|
const privateKeyHex = addHexPrefix(privateKey);
|
|
2425
2431
|
this.account = privateKeyToAccount(privateKeyHex);
|
|
2426
2432
|
}
|
|
2427
2433
|
this.rpcUrl = rpcUrl;
|
|
2434
|
+
this.clientId = clientId || getDefaultClientId();
|
|
2428
2435
|
}
|
|
2429
2436
|
async getInfos(appIDs, addressCount = 1) {
|
|
2430
2437
|
const count = Math.min(addressCount, MAX_ADDRESS_COUNT);
|
|
@@ -2504,7 +2511,7 @@ var UserApiClient = class {
|
|
|
2504
2511
|
formData.append("image", fileBuffer, fileName);
|
|
2505
2512
|
}
|
|
2506
2513
|
const headers = {
|
|
2507
|
-
"x-client-id":
|
|
2514
|
+
"x-client-id": this.clientId,
|
|
2508
2515
|
...formData.getHeaders()
|
|
2509
2516
|
};
|
|
2510
2517
|
if (this.account) {
|
|
@@ -2553,7 +2560,7 @@ Please check:
|
|
|
2553
2560
|
}
|
|
2554
2561
|
async makeAuthenticatedRequest(url, permission) {
|
|
2555
2562
|
const headers = {
|
|
2556
|
-
"x-client-id":
|
|
2563
|
+
"x-client-id": this.clientId
|
|
2557
2564
|
};
|
|
2558
2565
|
if (permission && this.account) {
|
|
2559
2566
|
const expiry = BigInt(Math.floor(Date.now() / 1e3) + 5 * 60);
|
|
@@ -5754,10 +5761,10 @@ function getCategoryDescriptions(catalog, language) {
|
|
|
5754
5761
|
import * as fs5 from "fs";
|
|
5755
5762
|
import * as path5 from "path";
|
|
5756
5763
|
import * as os2 from "os";
|
|
5757
|
-
import { exec as
|
|
5764
|
+
import { exec as exec4, execFile as execFile3 } from "child_process";
|
|
5758
5765
|
import { promisify as promisify4 } from "util";
|
|
5759
|
-
var execAsync2 = promisify4(
|
|
5760
|
-
var
|
|
5766
|
+
var execAsync2 = promisify4(exec4);
|
|
5767
|
+
var execFileAsync2 = promisify4(execFile3);
|
|
5761
5768
|
async function fetchTemplate(repoURL, ref, targetDir, config, logger) {
|
|
5762
5769
|
if (!repoURL) {
|
|
5763
5770
|
throw new Error("repoURL is required");
|
|
@@ -5769,10 +5776,14 @@ Cloning repo: ${repoURL} \u2192 ${targetDir}
|
|
|
5769
5776
|
await execAsync2(`git clone --no-checkout --progress ${repoURL} ${targetDir}`, {
|
|
5770
5777
|
maxBuffer: 10 * 1024 * 1024
|
|
5771
5778
|
});
|
|
5772
|
-
await
|
|
5779
|
+
await execFileAsync2("git", ["-C", targetDir, "checkout", "--quiet", ref], {
|
|
5773
5780
|
maxBuffer: 10 * 1024 * 1024
|
|
5774
5781
|
});
|
|
5775
|
-
await
|
|
5782
|
+
await execFileAsync2(
|
|
5783
|
+
"git",
|
|
5784
|
+
["-C", targetDir, "submodule", "update", "--init", "--recursive", "--progress"],
|
|
5785
|
+
{ maxBuffer: 10 * 1024 * 1024 }
|
|
5786
|
+
);
|
|
5776
5787
|
logger.info(`Clone repo complete: ${repoURL}
|
|
5777
5788
|
`);
|
|
5778
5789
|
} catch (error) {
|
|
@@ -5813,14 +5824,14 @@ Cloning template: ${repoURL} \u2192 extracting ${subPath}
|
|
|
5813
5824
|
}
|
|
5814
5825
|
async function cloneSparse(repoURL, ref, subPath, tempDir) {
|
|
5815
5826
|
try {
|
|
5816
|
-
await
|
|
5817
|
-
await
|
|
5818
|
-
await
|
|
5827
|
+
await execFileAsync2("git", ["init", tempDir]);
|
|
5828
|
+
await execFileAsync2("git", ["-C", tempDir, "remote", "add", "origin", repoURL]);
|
|
5829
|
+
await execFileAsync2("git", ["-C", tempDir, "config", "core.sparseCheckout", "true"]);
|
|
5819
5830
|
const sparseCheckoutPath = path5.join(tempDir, ".git/info/sparse-checkout");
|
|
5820
5831
|
fs5.writeFileSync(sparseCheckoutPath, `${subPath}
|
|
5821
5832
|
`);
|
|
5822
|
-
await
|
|
5823
|
-
await
|
|
5833
|
+
await execFileAsync2("git", ["-C", tempDir, "fetch", "origin", ref]);
|
|
5834
|
+
await execFileAsync2("git", ["-C", tempDir, "checkout", ref]);
|
|
5824
5835
|
} catch (error) {
|
|
5825
5836
|
throw new Error(`Failed to clone sparse repository: ${error.message}`);
|
|
5826
5837
|
}
|