@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 +2 -2
- package/dist/index.cjs +48 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -4
- package/dist/index.d.ts +9 -4
- package/dist/index.js +50 -30
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -292,6 +292,8 @@ interface SDKLogsOptions {
|
|
|
292
292
|
privateKey?: string;
|
|
293
293
|
/** RPC URL - optional, uses environment default */
|
|
294
294
|
rpcUrl?: string;
|
|
295
|
+
/** Client ID for API requests - optional */
|
|
296
|
+
clientId?: string;
|
|
295
297
|
}
|
|
296
298
|
/**
|
|
297
299
|
* Legacy interface for backward compatibility
|
|
@@ -303,6 +305,7 @@ interface LogsOptions {
|
|
|
303
305
|
environment?: string;
|
|
304
306
|
privateKey?: string;
|
|
305
307
|
rpcUrl?: string;
|
|
308
|
+
clientId?: string;
|
|
306
309
|
}
|
|
307
310
|
/**
|
|
308
311
|
* View app logs
|
|
@@ -364,6 +367,7 @@ interface AppModuleConfig {
|
|
|
364
367
|
privateKey: `0x${string}`;
|
|
365
368
|
rpcUrl: string;
|
|
366
369
|
environment: string;
|
|
370
|
+
clientId?: string;
|
|
367
371
|
}
|
|
368
372
|
declare function createAppModule(ctx: AppModuleConfig): AppModule;
|
|
369
373
|
|
|
@@ -743,7 +747,7 @@ declare function executeDeploy(prepared: PreparedDeploy, gas: {
|
|
|
743
747
|
* Call this after executeDeploy to wait for the app to be provisioned.
|
|
744
748
|
* Can be called separately to allow for intermediate operations (e.g., profile upload).
|
|
745
749
|
*/
|
|
746
|
-
declare function watchDeployment(appId: string, privateKey: string, rpcUrl: string, environment: string, logger?: Logger): Promise<string | undefined>;
|
|
750
|
+
declare function watchDeployment(appId: string, privateKey: string, rpcUrl: string, environment: string, logger?: Logger, clientId?: string): Promise<string | undefined>;
|
|
747
751
|
|
|
748
752
|
/**
|
|
749
753
|
* Main upgrade function
|
|
@@ -845,7 +849,7 @@ declare function executeUpgrade(prepared: PreparedUpgrade, gas: {
|
|
|
845
849
|
* Call this after executeUpgrade to wait for the upgrade to finish.
|
|
846
850
|
* Can be called separately to allow for intermediate operations.
|
|
847
851
|
*/
|
|
848
|
-
declare function watchUpgrade(appId: string, privateKey: string, rpcUrl: string, environment: string, logger?: Logger): Promise<void>;
|
|
852
|
+
declare function watchUpgrade(appId: string, privateKey: string, rpcUrl: string, environment: string, logger?: Logger, clientId?: string): Promise<void>;
|
|
849
853
|
|
|
850
854
|
/**
|
|
851
855
|
* Environment configuration for different networks
|
|
@@ -1082,7 +1086,7 @@ interface PreflightContext {
|
|
|
1082
1086
|
* Returns empty string if unable to fetch (API unavailable, app info not ready, etc.).
|
|
1083
1087
|
* This is used as a convenience default for the upgrade flow.
|
|
1084
1088
|
*/
|
|
1085
|
-
declare function getCurrentInstanceType(preflightCtx: PreflightContext, appID: Address, logger: Logger): Promise<string>;
|
|
1089
|
+
declare function getCurrentInstanceType(preflightCtx: PreflightContext, appID: Address, logger: Logger, clientId?: string): Promise<string>;
|
|
1086
1090
|
|
|
1087
1091
|
/**
|
|
1088
1092
|
* UserAPI Client to manage interactions with the coordinator
|
|
@@ -1119,7 +1123,8 @@ declare class UserApiClient {
|
|
|
1119
1123
|
private readonly config;
|
|
1120
1124
|
private readonly account?;
|
|
1121
1125
|
private readonly rpcUrl?;
|
|
1122
|
-
|
|
1126
|
+
private readonly clientId;
|
|
1127
|
+
constructor(config: EnvironmentConfig, privateKey?: string | Hex, rpcUrl?: string, clientId?: string);
|
|
1123
1128
|
getInfos(appIDs: Address[], addressCount?: number): Promise<AppInfo[]>;
|
|
1124
1129
|
/**
|
|
1125
1130
|
* Get available SKUs (instance types) from UserAPI
|
package/dist/index.d.ts
CHANGED
|
@@ -292,6 +292,8 @@ interface SDKLogsOptions {
|
|
|
292
292
|
privateKey?: string;
|
|
293
293
|
/** RPC URL - optional, uses environment default */
|
|
294
294
|
rpcUrl?: string;
|
|
295
|
+
/** Client ID for API requests - optional */
|
|
296
|
+
clientId?: string;
|
|
295
297
|
}
|
|
296
298
|
/**
|
|
297
299
|
* Legacy interface for backward compatibility
|
|
@@ -303,6 +305,7 @@ interface LogsOptions {
|
|
|
303
305
|
environment?: string;
|
|
304
306
|
privateKey?: string;
|
|
305
307
|
rpcUrl?: string;
|
|
308
|
+
clientId?: string;
|
|
306
309
|
}
|
|
307
310
|
/**
|
|
308
311
|
* View app logs
|
|
@@ -364,6 +367,7 @@ interface AppModuleConfig {
|
|
|
364
367
|
privateKey: `0x${string}`;
|
|
365
368
|
rpcUrl: string;
|
|
366
369
|
environment: string;
|
|
370
|
+
clientId?: string;
|
|
367
371
|
}
|
|
368
372
|
declare function createAppModule(ctx: AppModuleConfig): AppModule;
|
|
369
373
|
|
|
@@ -743,7 +747,7 @@ declare function executeDeploy(prepared: PreparedDeploy, gas: {
|
|
|
743
747
|
* Call this after executeDeploy to wait for the app to be provisioned.
|
|
744
748
|
* Can be called separately to allow for intermediate operations (e.g., profile upload).
|
|
745
749
|
*/
|
|
746
|
-
declare function watchDeployment(appId: string, privateKey: string, rpcUrl: string, environment: string, logger?: Logger): Promise<string | undefined>;
|
|
750
|
+
declare function watchDeployment(appId: string, privateKey: string, rpcUrl: string, environment: string, logger?: Logger, clientId?: string): Promise<string | undefined>;
|
|
747
751
|
|
|
748
752
|
/**
|
|
749
753
|
* Main upgrade function
|
|
@@ -845,7 +849,7 @@ declare function executeUpgrade(prepared: PreparedUpgrade, gas: {
|
|
|
845
849
|
* Call this after executeUpgrade to wait for the upgrade to finish.
|
|
846
850
|
* Can be called separately to allow for intermediate operations.
|
|
847
851
|
*/
|
|
848
|
-
declare function watchUpgrade(appId: string, privateKey: string, rpcUrl: string, environment: string, logger?: Logger): Promise<void>;
|
|
852
|
+
declare function watchUpgrade(appId: string, privateKey: string, rpcUrl: string, environment: string, logger?: Logger, clientId?: string): Promise<void>;
|
|
849
853
|
|
|
850
854
|
/**
|
|
851
855
|
* Environment configuration for different networks
|
|
@@ -1082,7 +1086,7 @@ interface PreflightContext {
|
|
|
1082
1086
|
* Returns empty string if unable to fetch (API unavailable, app info not ready, etc.).
|
|
1083
1087
|
* This is used as a convenience default for the upgrade flow.
|
|
1084
1088
|
*/
|
|
1085
|
-
declare function getCurrentInstanceType(preflightCtx: PreflightContext, appID: Address, logger: Logger): Promise<string>;
|
|
1089
|
+
declare function getCurrentInstanceType(preflightCtx: PreflightContext, appID: Address, logger: Logger, clientId?: string): Promise<string>;
|
|
1086
1090
|
|
|
1087
1091
|
/**
|
|
1088
1092
|
* UserAPI Client to manage interactions with the coordinator
|
|
@@ -1119,7 +1123,8 @@ declare class UserApiClient {
|
|
|
1119
1123
|
private readonly config;
|
|
1120
1124
|
private readonly account?;
|
|
1121
1125
|
private readonly rpcUrl?;
|
|
1122
|
-
|
|
1126
|
+
private readonly clientId;
|
|
1127
|
+
constructor(config: EnvironmentConfig, privateKey?: string | Hex, rpcUrl?: string, clientId?: string);
|
|
1123
1128
|
getInfos(appIDs: Address[], addressCount?: number): Promise<AppInfo[]>;
|
|
1124
1129
|
/**
|
|
1125
1130
|
* 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.3" : "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);
|
|
@@ -4739,8 +4746,8 @@ var WATCH_POLL_INTERVAL_SECONDS = 5;
|
|
|
4739
4746
|
var APP_STATUS_RUNNING = "Running";
|
|
4740
4747
|
var APP_STATUS_FAILED = "Failed";
|
|
4741
4748
|
async function watchUntilRunning(options, logger) {
|
|
4742
|
-
const { environmentConfig, appId, privateKey, rpcUrl } = options;
|
|
4743
|
-
const userApiClient = new UserApiClient(environmentConfig, privateKey, rpcUrl);
|
|
4749
|
+
const { environmentConfig, appId, privateKey, rpcUrl, clientId } = options;
|
|
4750
|
+
const userApiClient = new UserApiClient(environmentConfig, privateKey, rpcUrl, clientId);
|
|
4744
4751
|
let initialStatus;
|
|
4745
4752
|
let initialIP;
|
|
4746
4753
|
let hasChanged = false;
|
|
@@ -4789,8 +4796,8 @@ async function watchUntilRunning(options, logger) {
|
|
|
4789
4796
|
}
|
|
4790
4797
|
var APP_STATUS_STOPPED = "Stopped";
|
|
4791
4798
|
async function watchUntilUpgradeComplete(options, logger) {
|
|
4792
|
-
const { environmentConfig, appId, privateKey, rpcUrl } = options;
|
|
4793
|
-
const userApiClient = new UserApiClient(environmentConfig, privateKey, rpcUrl);
|
|
4799
|
+
const { environmentConfig, appId, privateKey, rpcUrl, clientId } = options;
|
|
4800
|
+
const userApiClient = new UserApiClient(environmentConfig, privateKey, rpcUrl, clientId);
|
|
4794
4801
|
let initialStatus;
|
|
4795
4802
|
let initialIP;
|
|
4796
4803
|
let hasChanged = false;
|
|
@@ -5438,7 +5445,7 @@ async function executeDeploy(prepared, gas, logger = defaultLogger) {
|
|
|
5438
5445
|
imageRef: prepared.imageRef
|
|
5439
5446
|
};
|
|
5440
5447
|
}
|
|
5441
|
-
async function watchDeployment(appId, privateKey, rpcUrl, environment, logger = defaultLogger) {
|
|
5448
|
+
async function watchDeployment(appId, privateKey, rpcUrl, environment, logger = defaultLogger, clientId) {
|
|
5442
5449
|
const environmentConfig = getEnvironmentConfig(environment);
|
|
5443
5450
|
logger.info("Waiting for app to start...");
|
|
5444
5451
|
return watchUntilRunning(
|
|
@@ -5446,7 +5453,8 @@ async function watchDeployment(appId, privateKey, rpcUrl, environment, logger =
|
|
|
5446
5453
|
privateKey,
|
|
5447
5454
|
rpcUrl,
|
|
5448
5455
|
environmentConfig,
|
|
5449
|
-
appId
|
|
5456
|
+
appId,
|
|
5457
|
+
clientId
|
|
5450
5458
|
},
|
|
5451
5459
|
logger
|
|
5452
5460
|
);
|
|
@@ -5646,7 +5654,7 @@ async function executeUpgrade(prepared, gas, logger = defaultLogger) {
|
|
|
5646
5654
|
txHash
|
|
5647
5655
|
};
|
|
5648
5656
|
}
|
|
5649
|
-
async function watchUpgrade(appId, privateKey, rpcUrl, environment, logger = defaultLogger) {
|
|
5657
|
+
async function watchUpgrade(appId, privateKey, rpcUrl, environment, logger = defaultLogger, clientId) {
|
|
5650
5658
|
const environmentConfig = getEnvironmentConfig(environment);
|
|
5651
5659
|
logger.info("Waiting for upgrade to complete...");
|
|
5652
5660
|
await watchUntilUpgradeComplete(
|
|
@@ -5654,7 +5662,8 @@ async function watchUpgrade(appId, privateKey, rpcUrl, environment, logger = def
|
|
|
5654
5662
|
privateKey,
|
|
5655
5663
|
rpcUrl,
|
|
5656
5664
|
environmentConfig,
|
|
5657
|
-
appId
|
|
5665
|
+
appId,
|
|
5666
|
+
clientId
|
|
5658
5667
|
},
|
|
5659
5668
|
logger
|
|
5660
5669
|
);
|
|
@@ -5754,10 +5763,10 @@ function getCategoryDescriptions(catalog, language) {
|
|
|
5754
5763
|
import * as fs5 from "fs";
|
|
5755
5764
|
import * as path5 from "path";
|
|
5756
5765
|
import * as os2 from "os";
|
|
5757
|
-
import { exec as
|
|
5766
|
+
import { exec as exec4, execFile as execFile3 } from "child_process";
|
|
5758
5767
|
import { promisify as promisify4 } from "util";
|
|
5759
|
-
var execAsync2 = promisify4(
|
|
5760
|
-
var
|
|
5768
|
+
var execAsync2 = promisify4(exec4);
|
|
5769
|
+
var execFileAsync2 = promisify4(execFile3);
|
|
5761
5770
|
async function fetchTemplate(repoURL, ref, targetDir, config, logger) {
|
|
5762
5771
|
if (!repoURL) {
|
|
5763
5772
|
throw new Error("repoURL is required");
|
|
@@ -5769,10 +5778,14 @@ Cloning repo: ${repoURL} \u2192 ${targetDir}
|
|
|
5769
5778
|
await execAsync2(`git clone --no-checkout --progress ${repoURL} ${targetDir}`, {
|
|
5770
5779
|
maxBuffer: 10 * 1024 * 1024
|
|
5771
5780
|
});
|
|
5772
|
-
await
|
|
5781
|
+
await execFileAsync2("git", ["-C", targetDir, "checkout", "--quiet", ref], {
|
|
5773
5782
|
maxBuffer: 10 * 1024 * 1024
|
|
5774
5783
|
});
|
|
5775
|
-
await
|
|
5784
|
+
await execFileAsync2(
|
|
5785
|
+
"git",
|
|
5786
|
+
["-C", targetDir, "submodule", "update", "--init", "--recursive", "--progress"],
|
|
5787
|
+
{ maxBuffer: 10 * 1024 * 1024 }
|
|
5788
|
+
);
|
|
5776
5789
|
logger.info(`Clone repo complete: ${repoURL}
|
|
5777
5790
|
`);
|
|
5778
5791
|
} catch (error) {
|
|
@@ -5813,14 +5826,14 @@ Cloning template: ${repoURL} \u2192 extracting ${subPath}
|
|
|
5813
5826
|
}
|
|
5814
5827
|
async function cloneSparse(repoURL, ref, subPath, tempDir) {
|
|
5815
5828
|
try {
|
|
5816
|
-
await
|
|
5817
|
-
await
|
|
5818
|
-
await
|
|
5829
|
+
await execFileAsync2("git", ["init", tempDir]);
|
|
5830
|
+
await execFileAsync2("git", ["-C", tempDir, "remote", "add", "origin", repoURL]);
|
|
5831
|
+
await execFileAsync2("git", ["-C", tempDir, "config", "core.sparseCheckout", "true"]);
|
|
5819
5832
|
const sparseCheckoutPath = path5.join(tempDir, ".git/info/sparse-checkout");
|
|
5820
5833
|
fs5.writeFileSync(sparseCheckoutPath, `${subPath}
|
|
5821
5834
|
`);
|
|
5822
|
-
await
|
|
5823
|
-
await
|
|
5835
|
+
await execFileAsync2("git", ["-C", tempDir, "fetch", "origin", ref]);
|
|
5836
|
+
await execFileAsync2("git", ["-C", tempDir, "checkout", ref]);
|
|
5824
5837
|
} catch (error) {
|
|
5825
5838
|
throw new Error(`Failed to clone sparse repository: ${error.message}`);
|
|
5826
5839
|
}
|
|
@@ -6214,7 +6227,12 @@ async function logs(options, logger = defaultLogger) {
|
|
|
6214
6227
|
}
|
|
6215
6228
|
const appID = validateAppID(options.appID);
|
|
6216
6229
|
const formattedApp = formatAppDisplay(environmentConfig.name, appID, "");
|
|
6217
|
-
const userApiClient = new UserApiClient(
|
|
6230
|
+
const userApiClient = new UserApiClient(
|
|
6231
|
+
environmentConfig,
|
|
6232
|
+
options.privateKey,
|
|
6233
|
+
rpcUrl,
|
|
6234
|
+
options.clientId
|
|
6235
|
+
);
|
|
6218
6236
|
let logsText;
|
|
6219
6237
|
let logsError = null;
|
|
6220
6238
|
try {
|
|
@@ -6370,7 +6388,8 @@ function createAppModule(ctx) {
|
|
|
6370
6388
|
privateKey,
|
|
6371
6389
|
appID: opts.appID,
|
|
6372
6390
|
watch: opts.watch,
|
|
6373
|
-
environment: ctx.environment
|
|
6391
|
+
environment: ctx.environment,
|
|
6392
|
+
clientId: ctx.clientId
|
|
6374
6393
|
},
|
|
6375
6394
|
logger
|
|
6376
6395
|
);
|
|
@@ -6831,12 +6850,13 @@ function generateNewPrivateKey() {
|
|
|
6831
6850
|
}
|
|
6832
6851
|
|
|
6833
6852
|
// src/client/common/utils/instance.ts
|
|
6834
|
-
async function getCurrentInstanceType(preflightCtx, appID, logger) {
|
|
6853
|
+
async function getCurrentInstanceType(preflightCtx, appID, logger, clientId) {
|
|
6835
6854
|
try {
|
|
6836
6855
|
const userApiClient = new UserApiClient(
|
|
6837
6856
|
preflightCtx.environmentConfig,
|
|
6838
6857
|
preflightCtx.privateKey,
|
|
6839
|
-
preflightCtx.rpcUrl
|
|
6858
|
+
preflightCtx.rpcUrl,
|
|
6859
|
+
clientId
|
|
6840
6860
|
);
|
|
6841
6861
|
const infos = await userApiClient.getInfos([appID], 1);
|
|
6842
6862
|
if (infos.length === 0) {
|