@layr-labs/ecloud-sdk 1.0.0-devep7 → 1.0.0

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.
@@ -0,0 +1,167 @@
1
+ import { Address } from 'viem';
2
+
3
+ /**
4
+ * Non-interactive validation utilities for SDK
5
+ *
6
+ * These functions validate parameters without any interactive prompts.
7
+ * They either return the validated value or throw an error.
8
+ */
9
+
10
+ /**
11
+ * Validate app name format
12
+ * @throws Error if name is invalid
13
+ */
14
+ declare function validateAppName(name: string): void;
15
+ /**
16
+ * Validate Docker image reference format
17
+ * @returns true if valid, error message string if invalid
18
+ */
19
+ declare function validateImageReference(value: string): true | string;
20
+ /**
21
+ * Validate image reference and throw if invalid
22
+ * @throws Error if image reference is invalid
23
+ */
24
+ declare function assertValidImageReference(value: string): void;
25
+ /**
26
+ * Extract app name from image reference
27
+ */
28
+ declare function extractAppNameFromImage(imageRef: string): string;
29
+ /**
30
+ * Validate that a file path exists
31
+ * @returns true if valid, error message string if invalid
32
+ */
33
+ declare function validateFilePath(value: string): true | string;
34
+ /**
35
+ * Validate file path and throw if invalid
36
+ * @throws Error if file path is invalid or doesn't exist
37
+ */
38
+ declare function assertValidFilePath(value: string): void;
39
+ /**
40
+ * Validate instance type SKU against available types
41
+ * @returns the validated SKU
42
+ * @throws Error if SKU is not in the available types list
43
+ */
44
+ declare function validateInstanceTypeSKU(sku: string, availableTypes: Array<{
45
+ sku: string;
46
+ }>): string;
47
+ /**
48
+ * Validate private key format
49
+ * Matches Go's common.ValidatePrivateKey() function
50
+ */
51
+ declare function validatePrivateKeyFormat(key: string): boolean;
52
+ /**
53
+ * Validate private key and throw if invalid
54
+ * @throws Error if private key format is invalid
55
+ */
56
+ declare function assertValidPrivateKey(key: string): void;
57
+ /**
58
+ * Validate URL format
59
+ * @returns undefined if valid, error message string if invalid
60
+ */
61
+ declare function validateURL(rawURL: string): string | undefined;
62
+ /**
63
+ * Validate X/Twitter URL format
64
+ * @returns undefined if valid, error message string if invalid
65
+ */
66
+ declare function validateXURL(rawURL: string): string | undefined;
67
+ /**
68
+ * Validate description length
69
+ * @returns undefined if valid, error message string if invalid
70
+ */
71
+ declare function validateDescription(description: string): string | undefined;
72
+ /**
73
+ * Validate image file path
74
+ * @returns undefined if valid, error message string if invalid
75
+ */
76
+ declare function validateImagePath(filePath: string): string | undefined;
77
+ /**
78
+ * Validate and normalize app ID address
79
+ * @param appID - App ID (must be a valid address)
80
+ * @returns Normalized app address
81
+ * @throws Error if app ID is not a valid address
82
+ *
83
+ * Note: Name resolution should be handled by CLI before calling SDK functions.
84
+ * The SDK only accepts resolved addresses.
85
+ */
86
+ declare function validateAppID(appID: string | Address): Address;
87
+ type LogVisibility = "public" | "private" | "off";
88
+ /**
89
+ * Validate and convert log visibility setting to internal format
90
+ * @param logVisibility - Log visibility setting
91
+ * @returns Object with logRedirect and publicLogs settings
92
+ * @throws Error if log visibility value is invalid
93
+ */
94
+ declare function validateLogVisibility(logVisibility: LogVisibility): {
95
+ logRedirect: string;
96
+ publicLogs: boolean;
97
+ };
98
+ type ResourceUsageMonitoring = "enable" | "disable";
99
+ /**
100
+ * Validate and convert resource usage monitoring setting to internal format
101
+ * @param resourceUsageMonitoring - Resource usage monitoring setting
102
+ * @returns The resourceUsageAllow value for the Dockerfile label ("always" or "never")
103
+ * @throws Error if resource usage monitoring value is invalid
104
+ */
105
+ declare function validateResourceUsageMonitoring(resourceUsageMonitoring: ResourceUsageMonitoring | undefined): string;
106
+ /**
107
+ * Sanitize string (HTML escape and trim)
108
+ */
109
+ declare function sanitizeString(s: string): string;
110
+ /**
111
+ * Sanitize URL (add https:// if missing, validate)
112
+ * @throws Error if URL is invalid after sanitization
113
+ */
114
+ declare function sanitizeURL(rawURL: string): string;
115
+ /**
116
+ * Sanitize X/Twitter URL (handle username-only input, normalize)
117
+ * @throws Error if URL is invalid after sanitization
118
+ */
119
+ declare function sanitizeXURL(rawURL: string): string;
120
+ interface DeployParams {
121
+ dockerfilePath?: string;
122
+ imageRef?: string;
123
+ appName: string;
124
+ envFilePath?: string;
125
+ instanceType: string;
126
+ logVisibility: LogVisibility;
127
+ }
128
+ /**
129
+ * Validate deploy parameters
130
+ * @throws Error if required parameters are missing or invalid
131
+ */
132
+ declare function validateDeployParams(params: Partial<DeployParams>): void;
133
+ interface UpgradeParams {
134
+ appID: string | Address;
135
+ dockerfilePath?: string;
136
+ imageRef?: string;
137
+ envFilePath?: string;
138
+ instanceType: string;
139
+ logVisibility: LogVisibility;
140
+ }
141
+ /**
142
+ * Validate upgrade parameters
143
+ * @throws Error if required parameters are missing or invalid
144
+ */
145
+ declare function validateUpgradeParams(params: Partial<UpgradeParams>): void;
146
+ interface CreateAppParams {
147
+ name: string;
148
+ language: string;
149
+ template?: string;
150
+ templateVersion?: string;
151
+ }
152
+ /**
153
+ * Validate create app parameters
154
+ * @throws Error if required parameters are missing or invalid
155
+ */
156
+ declare function validateCreateAppParams(params: Partial<CreateAppParams>): void;
157
+ interface LogsParams {
158
+ appID: string | Address;
159
+ watch?: boolean;
160
+ }
161
+ /**
162
+ * Validate logs parameters
163
+ * @throws Error if required parameters are missing or invalid
164
+ */
165
+ declare function validateLogsParams(params: Partial<LogsParams>): void;
166
+
167
+ export { type CreateAppParams as C, type DeployParams as D, type LogVisibility as L, type ResourceUsageMonitoring as R, type UpgradeParams as U, type LogsParams as a, assertValidImageReference as b, assertValidPrivateKey as c, sanitizeURL as d, extractAppNameFromImage as e, sanitizeXURL as f, validateAppName as g, validateCreateAppParams as h, validateDescription as i, validateImageReference as j, validateInstanceTypeSKU as k, validateLogVisibility as l, validateLogsParams as m, validatePrivateKeyFormat as n, validateURL as o, validateXURL as p, assertValidFilePath as q, validateDeployParams as r, sanitizeString as s, validateFilePath as t, validateImagePath as u, validateAppID as v, validateResourceUsageMonitoring as w, validateUpgradeParams as x };
@@ -0,0 +1,167 @@
1
+ import { Address } from 'viem';
2
+
3
+ /**
4
+ * Non-interactive validation utilities for SDK
5
+ *
6
+ * These functions validate parameters without any interactive prompts.
7
+ * They either return the validated value or throw an error.
8
+ */
9
+
10
+ /**
11
+ * Validate app name format
12
+ * @throws Error if name is invalid
13
+ */
14
+ declare function validateAppName(name: string): void;
15
+ /**
16
+ * Validate Docker image reference format
17
+ * @returns true if valid, error message string if invalid
18
+ */
19
+ declare function validateImageReference(value: string): true | string;
20
+ /**
21
+ * Validate image reference and throw if invalid
22
+ * @throws Error if image reference is invalid
23
+ */
24
+ declare function assertValidImageReference(value: string): void;
25
+ /**
26
+ * Extract app name from image reference
27
+ */
28
+ declare function extractAppNameFromImage(imageRef: string): string;
29
+ /**
30
+ * Validate that a file path exists
31
+ * @returns true if valid, error message string if invalid
32
+ */
33
+ declare function validateFilePath(value: string): true | string;
34
+ /**
35
+ * Validate file path and throw if invalid
36
+ * @throws Error if file path is invalid or doesn't exist
37
+ */
38
+ declare function assertValidFilePath(value: string): void;
39
+ /**
40
+ * Validate instance type SKU against available types
41
+ * @returns the validated SKU
42
+ * @throws Error if SKU is not in the available types list
43
+ */
44
+ declare function validateInstanceTypeSKU(sku: string, availableTypes: Array<{
45
+ sku: string;
46
+ }>): string;
47
+ /**
48
+ * Validate private key format
49
+ * Matches Go's common.ValidatePrivateKey() function
50
+ */
51
+ declare function validatePrivateKeyFormat(key: string): boolean;
52
+ /**
53
+ * Validate private key and throw if invalid
54
+ * @throws Error if private key format is invalid
55
+ */
56
+ declare function assertValidPrivateKey(key: string): void;
57
+ /**
58
+ * Validate URL format
59
+ * @returns undefined if valid, error message string if invalid
60
+ */
61
+ declare function validateURL(rawURL: string): string | undefined;
62
+ /**
63
+ * Validate X/Twitter URL format
64
+ * @returns undefined if valid, error message string if invalid
65
+ */
66
+ declare function validateXURL(rawURL: string): string | undefined;
67
+ /**
68
+ * Validate description length
69
+ * @returns undefined if valid, error message string if invalid
70
+ */
71
+ declare function validateDescription(description: string): string | undefined;
72
+ /**
73
+ * Validate image file path
74
+ * @returns undefined if valid, error message string if invalid
75
+ */
76
+ declare function validateImagePath(filePath: string): string | undefined;
77
+ /**
78
+ * Validate and normalize app ID address
79
+ * @param appID - App ID (must be a valid address)
80
+ * @returns Normalized app address
81
+ * @throws Error if app ID is not a valid address
82
+ *
83
+ * Note: Name resolution should be handled by CLI before calling SDK functions.
84
+ * The SDK only accepts resolved addresses.
85
+ */
86
+ declare function validateAppID(appID: string | Address): Address;
87
+ type LogVisibility = "public" | "private" | "off";
88
+ /**
89
+ * Validate and convert log visibility setting to internal format
90
+ * @param logVisibility - Log visibility setting
91
+ * @returns Object with logRedirect and publicLogs settings
92
+ * @throws Error if log visibility value is invalid
93
+ */
94
+ declare function validateLogVisibility(logVisibility: LogVisibility): {
95
+ logRedirect: string;
96
+ publicLogs: boolean;
97
+ };
98
+ type ResourceUsageMonitoring = "enable" | "disable";
99
+ /**
100
+ * Validate and convert resource usage monitoring setting to internal format
101
+ * @param resourceUsageMonitoring - Resource usage monitoring setting
102
+ * @returns The resourceUsageAllow value for the Dockerfile label ("always" or "never")
103
+ * @throws Error if resource usage monitoring value is invalid
104
+ */
105
+ declare function validateResourceUsageMonitoring(resourceUsageMonitoring: ResourceUsageMonitoring | undefined): string;
106
+ /**
107
+ * Sanitize string (HTML escape and trim)
108
+ */
109
+ declare function sanitizeString(s: string): string;
110
+ /**
111
+ * Sanitize URL (add https:// if missing, validate)
112
+ * @throws Error if URL is invalid after sanitization
113
+ */
114
+ declare function sanitizeURL(rawURL: string): string;
115
+ /**
116
+ * Sanitize X/Twitter URL (handle username-only input, normalize)
117
+ * @throws Error if URL is invalid after sanitization
118
+ */
119
+ declare function sanitizeXURL(rawURL: string): string;
120
+ interface DeployParams {
121
+ dockerfilePath?: string;
122
+ imageRef?: string;
123
+ appName: string;
124
+ envFilePath?: string;
125
+ instanceType: string;
126
+ logVisibility: LogVisibility;
127
+ }
128
+ /**
129
+ * Validate deploy parameters
130
+ * @throws Error if required parameters are missing or invalid
131
+ */
132
+ declare function validateDeployParams(params: Partial<DeployParams>): void;
133
+ interface UpgradeParams {
134
+ appID: string | Address;
135
+ dockerfilePath?: string;
136
+ imageRef?: string;
137
+ envFilePath?: string;
138
+ instanceType: string;
139
+ logVisibility: LogVisibility;
140
+ }
141
+ /**
142
+ * Validate upgrade parameters
143
+ * @throws Error if required parameters are missing or invalid
144
+ */
145
+ declare function validateUpgradeParams(params: Partial<UpgradeParams>): void;
146
+ interface CreateAppParams {
147
+ name: string;
148
+ language: string;
149
+ template?: string;
150
+ templateVersion?: string;
151
+ }
152
+ /**
153
+ * Validate create app parameters
154
+ * @throws Error if required parameters are missing or invalid
155
+ */
156
+ declare function validateCreateAppParams(params: Partial<CreateAppParams>): void;
157
+ interface LogsParams {
158
+ appID: string | Address;
159
+ watch?: boolean;
160
+ }
161
+ /**
162
+ * Validate logs parameters
163
+ * @throws Error if required parameters are missing or invalid
164
+ */
165
+ declare function validateLogsParams(params: Partial<LogsParams>): void;
166
+
167
+ export { type CreateAppParams as C, type DeployParams as D, type LogVisibility as L, type ResourceUsageMonitoring as R, type UpgradeParams as U, type LogsParams as a, assertValidImageReference as b, assertValidPrivateKey as c, sanitizeURL as d, extractAppNameFromImage as e, sanitizeXURL as f, validateAppName as g, validateCreateAppParams as h, validateDescription as i, validateImageReference as j, validateInstanceTypeSKU as k, validateLogVisibility as l, validateLogsParams as m, validatePrivateKeyFormat as n, validateURL as o, validateXURL as p, assertValidFilePath as q, validateDeployParams as r, sanitizeString as s, validateFilePath as t, validateImagePath as u, validateAppID as v, validateResourceUsageMonitoring as w, validateUpgradeParams as x };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@layr-labs/ecloud-sdk",
3
- "version": "1.0.0-devep7",
3
+ "version": "1.0.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -39,14 +39,13 @@
39
39
  }
40
40
  },
41
41
  "scripts": {
42
- "build": "pnpm run fetch:runtime-binaries && tsup",
43
- "build:dev": "BUILD_TYPE=dev pnpm run fetch:runtime-binaries && tsup",
42
+ "build": "tsup",
43
+ "build:dev": "BUILD_TYPE=dev tsup",
44
44
  "prepublishOnly": "cp ../../README.md .",
45
45
  "lint": "eslint .",
46
46
  "format": "prettier --check .",
47
47
  "format:fix": "prettier --write .",
48
- "typecheck": "tsc --noEmit",
49
- "fetch:runtime-binaries": "pnpm -w exec tsx packages/sdk/scripts/fetch-runtime-binaries.ts"
48
+ "typecheck": "tsc --noEmit"
50
49
  },
51
50
  "dependencies": {
52
51
  "@inquirer/prompts": "7.10.1",
@@ -1,194 +0,0 @@
1
- import { Address, WalletClient, PublicClient, Hex } from 'viem';
2
- import { H as Logger, E as EnvironmentConfig, n as DeployAppOpts, A as AppId, ab as UpgradeAppOpts, R as PrepareDeployOpts, V as PreparedDeploy, G as GasEstimate, Q as PrepareDeployFromVerifiableBuildOpts, v as ExecuteDeployResult, U as PrepareUpgradeOpts, Y as PreparedUpgrade, T as PrepareUpgradeFromVerifiableBuildOpts, x as ExecuteUpgradeResult, c as AppProfile, d as AppProfileResponse, L as LifecycleOpts, b as AppConfig } from './index-XhjPvHIY.js';
3
-
4
- /**
5
- * Create command
6
- *
7
- * Creates a new app project from a template
8
- *
9
- * NOTE: This SDK function is non-interactive. All required parameters must be
10
- * provided explicitly. Use the CLI for interactive parameter collection.
11
- */
12
-
13
- /**
14
- * Required create app options for SDK (non-interactive)
15
- */
16
- interface SDKCreateAppOpts {
17
- /** Project name - required */
18
- name: string;
19
- /** Programming language - required (typescript, golang, rust, python) */
20
- language: string;
21
- /** Template name/category (e.g., "minimal") or custom template URL - optional, defaults to first available */
22
- template?: string;
23
- /** Template version/ref - optional */
24
- templateVersion?: string;
25
- /** Verbose output - optional */
26
- verbose?: boolean;
27
- /** Skip telemetry (used when called from CLI) - optional */
28
- skipTelemetry?: boolean;
29
- }
30
- /**
31
- * Legacy interface for backward compatibility
32
- * @deprecated Use SDKCreateAppOpts instead
33
- */
34
- interface CreateAppOpts {
35
- name?: string;
36
- language?: string;
37
- template?: string;
38
- templateVersion?: string;
39
- verbose?: boolean;
40
- skipTelemetry?: boolean;
41
- }
42
- declare const PRIMARY_LANGUAGES: string[];
43
- /**
44
- * Get available template categories for a language
45
- */
46
- declare function getAvailableTemplates(language: string): Promise<Array<{
47
- name: string;
48
- description: string;
49
- }>>;
50
- /**
51
- * Create a new app project from template
52
- *
53
- * This function is non-interactive and requires all parameters to be provided explicitly.
54
- *
55
- * @param options - Required options including name and language
56
- * @param logger - Optional logger instance
57
- * @throws Error if required parameters are missing or invalid
58
- */
59
- declare function createApp(options: SDKCreateAppOpts | CreateAppOpts, logger?: Logger): Promise<void>;
60
-
61
- /**
62
- * Logs command
63
- *
64
- * View app logs with optional watch mode
65
- *
66
- * NOTE: This SDK function is non-interactive. All required parameters must be
67
- * provided explicitly. Use the CLI for interactive parameter collection.
68
- */
69
-
70
- /**
71
- * Required logs options for SDK (non-interactive)
72
- */
73
- interface LogsOptions {
74
- /** App ID (address) or app name - required */
75
- appID: string | Address;
76
- /** Watch logs continuously - optional */
77
- watch?: boolean;
78
- /** Client ID for API requests - optional */
79
- clientId?: string;
80
- }
81
- /**
82
- * View app logs
83
- *
84
- * This function is non-interactive and requires appID to be provided explicitly.
85
- *
86
- * @param options - Required options including appID
87
- * @param walletClient - Viem WalletClient for signing requests
88
- * @param publicClient - Viem PublicClient for chain queries
89
- * @param environmentConfig - Environment configuration
90
- * @param logger - Optional logger instance
91
- * @param skipTelemetry - Skip telemetry (for CLI usage)
92
- * @throws Error if appID is missing or invalid
93
- */
94
- declare function logs(options: LogsOptions, walletClient: WalletClient, publicClient: PublicClient, environmentConfig: EnvironmentConfig, logger?: Logger, skipTelemetry?: boolean): Promise<void>;
95
-
96
- /**
97
- * Main App namespace entry point
98
- */
99
-
100
- /**
101
- * Encode start app call data for gas estimation
102
- */
103
- declare function encodeStartAppData(appId: AppId): Hex;
104
- /**
105
- * Encode stop app call data for gas estimation
106
- */
107
- declare function encodeStopAppData(appId: AppId): Hex;
108
- /**
109
- * Encode terminate app call data for gas estimation
110
- */
111
- declare function encodeTerminateAppData(appId: AppId): Hex;
112
- interface AppModule {
113
- create: (opts: CreateAppOpts) => Promise<void>;
114
- deploy: (opts: DeployAppOpts) => Promise<{
115
- appId: AppId;
116
- tx: Hex;
117
- appName: string;
118
- imageRef: string;
119
- ipAddress?: string;
120
- }>;
121
- upgrade: (appId: AppId, opts: UpgradeAppOpts) => Promise<{
122
- tx: Hex;
123
- appId: AppId;
124
- imageRef: string;
125
- }>;
126
- prepareDeploy: (opts: PrepareDeployOpts) => Promise<{
127
- prepared: PreparedDeploy;
128
- gasEstimate: GasEstimate;
129
- }>;
130
- prepareDeployFromVerifiableBuild: (opts: PrepareDeployFromVerifiableBuildOpts) => Promise<{
131
- prepared: PreparedDeploy;
132
- gasEstimate: GasEstimate;
133
- }>;
134
- executeDeploy: (prepared: PreparedDeploy, gas?: GasEstimate) => Promise<ExecuteDeployResult>;
135
- watchDeployment: (appId: AppId) => Promise<string | undefined>;
136
- prepareUpgrade: (appId: AppId, opts: PrepareUpgradeOpts) => Promise<{
137
- prepared: PreparedUpgrade;
138
- gasEstimate: GasEstimate;
139
- }>;
140
- prepareUpgradeFromVerifiableBuild: (appId: AppId, opts: PrepareUpgradeFromVerifiableBuildOpts) => Promise<{
141
- prepared: PreparedUpgrade;
142
- gasEstimate: GasEstimate;
143
- }>;
144
- executeUpgrade: (prepared: PreparedUpgrade, gas?: GasEstimate) => Promise<ExecuteUpgradeResult>;
145
- watchUpgrade: (appId: AppId) => Promise<void>;
146
- setProfile: (appId: AppId, profile: AppProfile) => Promise<AppProfileResponse>;
147
- logs: (opts: LogsOptions) => Promise<void>;
148
- start: (appId: AppId, opts?: LifecycleOpts) => Promise<{
149
- tx: Hex | false;
150
- }>;
151
- stop: (appId: AppId, opts?: LifecycleOpts) => Promise<{
152
- tx: Hex | false;
153
- }>;
154
- terminate: (appId: AppId, opts?: LifecycleOpts) => Promise<{
155
- tx: Hex | false;
156
- }>;
157
- getBillingType: (appId: AppId) => Promise<number>;
158
- getAppsByBillingAccount: (account: Address, offset: bigint, limit: bigint) => Promise<{
159
- apps: Address[];
160
- appConfigs: AppConfig[];
161
- }>;
162
- isDelegated: () => Promise<boolean>;
163
- undelegate: () => Promise<{
164
- tx: Hex | false;
165
- }>;
166
- }
167
- interface AppModuleConfig {
168
- verbose?: boolean;
169
- walletClient: WalletClient;
170
- publicClient: PublicClient;
171
- environment: string;
172
- clientId?: string;
173
- skipTelemetry?: boolean;
174
- }
175
- declare function createAppModule(ctx: AppModuleConfig): AppModule;
176
-
177
- /**
178
- * Main Compute namespace entry point
179
- */
180
-
181
- interface ComputeModule {
182
- app: AppModule;
183
- }
184
- interface ComputeModuleConfig {
185
- verbose?: boolean;
186
- walletClient: WalletClient;
187
- publicClient: PublicClient;
188
- environment: string;
189
- clientId?: string;
190
- skipTelemetry?: boolean;
191
- }
192
- declare function createComputeModule(config: ComputeModuleConfig): ComputeModule;
193
-
194
- export { type AppModule as A, type ComputeModule as C, type LogsOptions as L, PRIMARY_LANGUAGES as P, type SDKCreateAppOpts as S, type ComputeModuleConfig as a, type CreateAppOpts as b, createApp as c, createComputeModule as d, encodeStartAppData as e, encodeStopAppData as f, encodeTerminateAppData as g, getAvailableTemplates as h, type AppModuleConfig as i, createAppModule as j, logs as l };