@watasu/sdk 0.1.5 → 0.1.24
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/README.md +145 -2
- package/dist/commands.d.ts +33 -4
- package/dist/commands.js +68 -17
- package/dist/errors.d.ts +3 -0
- package/dist/errors.js +8 -0
- package/dist/filesystem.d.ts +80 -13
- package/dist/filesystem.js +184 -9
- package/dist/git.d.ts +171 -0
- package/dist/git.js +277 -0
- package/dist/index.d.ts +16 -6
- package/dist/index.js +9 -4
- package/dist/process.d.ts +56 -0
- package/dist/process.js +137 -0
- package/dist/processSocket.d.ts +2 -0
- package/dist/processSocket.js +9 -1
- package/dist/pty.d.ts +37 -0
- package/dist/pty.js +90 -0
- package/dist/sandbox.d.ts +145 -25
- package/dist/sandbox.js +312 -45
- package/dist/template.d.ts +232 -0
- package/dist/template.js +624 -0
- package/dist/terminal.d.ts +41 -0
- package/dist/terminal.js +74 -0
- package/dist/transport.d.ts +1 -0
- package/dist/transport.js +3 -0
- package/package.json +1 -1
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { ConnectionOpts } from './connectionConfig.js';
|
|
2
|
+
export type TemplateBuildStatus = 'building' | 'waiting' | 'ready' | 'error';
|
|
3
|
+
export interface BuildInfo {
|
|
4
|
+
/** First template alias. Prefer `name` for new code. */
|
|
5
|
+
alias: string;
|
|
6
|
+
/** Template name passed to the build call. */
|
|
7
|
+
name: string;
|
|
8
|
+
/** Tags assigned to this build. */
|
|
9
|
+
tags: string[];
|
|
10
|
+
/** Template identifier. */
|
|
11
|
+
templateId: string;
|
|
12
|
+
/** Build identifier. */
|
|
13
|
+
buildId: string;
|
|
14
|
+
}
|
|
15
|
+
export interface LogEntry {
|
|
16
|
+
timestamp?: Date;
|
|
17
|
+
level: string;
|
|
18
|
+
message: string;
|
|
19
|
+
}
|
|
20
|
+
export interface BuildStatusReason {
|
|
21
|
+
message: string;
|
|
22
|
+
step?: string;
|
|
23
|
+
logEntries: LogEntry[];
|
|
24
|
+
}
|
|
25
|
+
export interface TemplateBuildStatusResponse {
|
|
26
|
+
buildID: string;
|
|
27
|
+
templateID: string;
|
|
28
|
+
status: TemplateBuildStatus;
|
|
29
|
+
logEntries: LogEntry[];
|
|
30
|
+
logs: string[];
|
|
31
|
+
reason?: BuildStatusReason;
|
|
32
|
+
}
|
|
33
|
+
export interface TemplateTagInfo {
|
|
34
|
+
buildId: string;
|
|
35
|
+
tags: string[];
|
|
36
|
+
}
|
|
37
|
+
export interface TemplateTag {
|
|
38
|
+
tag: string;
|
|
39
|
+
buildId: string;
|
|
40
|
+
createdAt: Date;
|
|
41
|
+
}
|
|
42
|
+
export interface TemplateOptions {
|
|
43
|
+
fileContextPath?: string;
|
|
44
|
+
fileIgnorePatterns?: string[];
|
|
45
|
+
}
|
|
46
|
+
export interface CopyOptions {
|
|
47
|
+
forceUpload?: true;
|
|
48
|
+
user?: string;
|
|
49
|
+
mode?: number;
|
|
50
|
+
resolveSymlinks?: boolean;
|
|
51
|
+
}
|
|
52
|
+
export interface BasicBuildOptions {
|
|
53
|
+
alias?: string;
|
|
54
|
+
tags?: string[];
|
|
55
|
+
cpuCount?: number;
|
|
56
|
+
memoryMB?: number;
|
|
57
|
+
skipCache?: boolean;
|
|
58
|
+
onBuildLogs?: (entry: LogEntry) => void;
|
|
59
|
+
team?: string;
|
|
60
|
+
}
|
|
61
|
+
export type BuildOptions = ConnectionOpts & BasicBuildOptions;
|
|
62
|
+
export type GetBuildStatusOptions = ConnectionOpts & {
|
|
63
|
+
logsOffset?: number;
|
|
64
|
+
};
|
|
65
|
+
export type TemplateClass = TemplateBase;
|
|
66
|
+
export type CopyItem = {
|
|
67
|
+
src: string | string[];
|
|
68
|
+
dest: string;
|
|
69
|
+
forceUpload?: true;
|
|
70
|
+
user?: string;
|
|
71
|
+
mode?: number;
|
|
72
|
+
resolveSymlinks?: boolean;
|
|
73
|
+
};
|
|
74
|
+
export type TemplateBuilder = TemplateBase;
|
|
75
|
+
export type TemplateFinal = TemplateBase;
|
|
76
|
+
export type TemplateFromImage = TemplateBase;
|
|
77
|
+
export type ReadyCommand = string | ReadyCmd;
|
|
78
|
+
interface TemplateFileSpec {
|
|
79
|
+
path: string;
|
|
80
|
+
content_b64: string;
|
|
81
|
+
source_path?: string;
|
|
82
|
+
mode?: number;
|
|
83
|
+
user?: string;
|
|
84
|
+
}
|
|
85
|
+
interface BuildSpec {
|
|
86
|
+
base?: string;
|
|
87
|
+
packages?: Record<string, string[]>;
|
|
88
|
+
files?: TemplateFileSpec[];
|
|
89
|
+
setup?: string[];
|
|
90
|
+
env?: Record<string, string>;
|
|
91
|
+
start_cmd?: string;
|
|
92
|
+
ready_cmd?: string;
|
|
93
|
+
}
|
|
94
|
+
/** Ready-check command wrapper accepted by template builders. */
|
|
95
|
+
export declare class ReadyCmd {
|
|
96
|
+
private readonly cmd;
|
|
97
|
+
constructor(cmd: string);
|
|
98
|
+
/** Return the shell command used as the ready check. */
|
|
99
|
+
getCmd(): string;
|
|
100
|
+
}
|
|
101
|
+
/** Return a ready check that waits for a TCP port to listen. */
|
|
102
|
+
export declare function waitForPort(port: number): ReadyCmd;
|
|
103
|
+
/** Return a ready check that waits for a URL to return an HTTP status code. */
|
|
104
|
+
export declare function waitForURL(url: string, statusCode?: number): ReadyCmd;
|
|
105
|
+
/** Alias for `waitForURL`. */
|
|
106
|
+
export declare const waitForUrl: typeof waitForURL;
|
|
107
|
+
/** Return a ready check that waits for a process name. */
|
|
108
|
+
export declare function waitForProcess(processName: string): ReadyCmd;
|
|
109
|
+
/** Return a ready check that waits for a file to exist. */
|
|
110
|
+
export declare function waitForFile(filename: string): ReadyCmd;
|
|
111
|
+
/** Return a ready check that waits for a fixed duration in milliseconds. */
|
|
112
|
+
export declare function waitForTimeout(timeout: number): ReadyCmd;
|
|
113
|
+
/** Chainable template builder for Watasu package-spec template builds. */
|
|
114
|
+
export declare class TemplateBase {
|
|
115
|
+
private base;
|
|
116
|
+
private packages;
|
|
117
|
+
private files;
|
|
118
|
+
private setup;
|
|
119
|
+
private env;
|
|
120
|
+
private currentWorkdir;
|
|
121
|
+
private currentUser;
|
|
122
|
+
private startCmd;
|
|
123
|
+
private readyCmd;
|
|
124
|
+
private force;
|
|
125
|
+
private readonly fileContextPath;
|
|
126
|
+
private readonly fileIgnorePatterns;
|
|
127
|
+
constructor(options?: TemplateOptions);
|
|
128
|
+
static build(template: TemplateClass, name: string, options?: Omit<BuildOptions, 'alias'>): Promise<BuildInfo>;
|
|
129
|
+
static build(template: TemplateClass, options: BuildOptions): Promise<BuildInfo>;
|
|
130
|
+
static buildInBackground(template: TemplateClass, name: string, options?: Omit<BuildOptions, 'alias'>): Promise<BuildInfo>;
|
|
131
|
+
static buildInBackground(template: TemplateClass, options: BuildOptions): Promise<BuildInfo>;
|
|
132
|
+
static getBuildStatus(data: Pick<BuildInfo, 'templateId' | 'buildId'>, options?: GetBuildStatusOptions): Promise<TemplateBuildStatusResponse>;
|
|
133
|
+
static exists(name: string, options?: ConnectionOpts): Promise<boolean>;
|
|
134
|
+
static aliasExists(alias: string, options?: ConnectionOpts): Promise<boolean>;
|
|
135
|
+
static assignTags(targetName: string, tags: string | string[], options?: ConnectionOpts): Promise<TemplateTagInfo>;
|
|
136
|
+
static removeTags(name: string, tags: string | string[], options?: ConnectionOpts): Promise<void>;
|
|
137
|
+
static getTags(templateId: string, options?: ConnectionOpts): Promise<TemplateTag[]>;
|
|
138
|
+
static toJSON(template: TemplateClass): Promise<string>;
|
|
139
|
+
static toDockerfile(template: TemplateClass): string;
|
|
140
|
+
fromDebianImage(_variant?: string): TemplateBuilder;
|
|
141
|
+
fromUbuntuImage(_variant?: string): TemplateBuilder;
|
|
142
|
+
fromPythonImage(_version?: string): TemplateBuilder;
|
|
143
|
+
fromNodeImage(_variant?: string): TemplateBuilder;
|
|
144
|
+
fromBunImage(_variant?: string): TemplateBuilder;
|
|
145
|
+
fromBaseImage(): TemplateBuilder;
|
|
146
|
+
fromImage(_baseImage: string, _credentials?: {
|
|
147
|
+
username: string;
|
|
148
|
+
password: string;
|
|
149
|
+
}): TemplateBuilder;
|
|
150
|
+
fromAWSRegistry(_image: string, _credentials: {
|
|
151
|
+
accessKeyId: string;
|
|
152
|
+
secretAccessKey: string;
|
|
153
|
+
region: string;
|
|
154
|
+
}): TemplateBuilder;
|
|
155
|
+
fromGCPRegistry(_image: string, _credentials: {
|
|
156
|
+
serviceAccountJSON: object | string;
|
|
157
|
+
}): TemplateBuilder;
|
|
158
|
+
fromTemplate(template: string): TemplateBuilder;
|
|
159
|
+
fromDockerfile(dockerfileContentOrPath: string): TemplateBuilder;
|
|
160
|
+
copy(src: string | string[], dest: string, options?: CopyOptions): TemplateBuilder;
|
|
161
|
+
copyItems(items: CopyItem[]): TemplateBuilder;
|
|
162
|
+
remove(path: string | string[], options?: {
|
|
163
|
+
force?: boolean;
|
|
164
|
+
recursive?: boolean;
|
|
165
|
+
user?: string;
|
|
166
|
+
}): TemplateBuilder;
|
|
167
|
+
rename(src: string, dest: string, options?: {
|
|
168
|
+
force?: boolean;
|
|
169
|
+
user?: string;
|
|
170
|
+
}): TemplateBuilder;
|
|
171
|
+
makeDir(path: string | string[], options?: {
|
|
172
|
+
mode?: number;
|
|
173
|
+
user?: string;
|
|
174
|
+
}): TemplateBuilder;
|
|
175
|
+
makeSymlink(src: string, dest: string, options?: {
|
|
176
|
+
force?: boolean;
|
|
177
|
+
user?: string;
|
|
178
|
+
}): TemplateBuilder;
|
|
179
|
+
runCmd(command: string | string[], options?: {
|
|
180
|
+
user?: string;
|
|
181
|
+
}): TemplateBuilder;
|
|
182
|
+
setWorkdir(workdir: string): TemplateBuilder;
|
|
183
|
+
setUser(user: string): TemplateBuilder;
|
|
184
|
+
pipInstall(packages?: string | string[], options?: {
|
|
185
|
+
g?: boolean;
|
|
186
|
+
}): TemplateBuilder;
|
|
187
|
+
npmInstall(packages?: string | string[], options?: {
|
|
188
|
+
g?: boolean;
|
|
189
|
+
dev?: boolean;
|
|
190
|
+
}): TemplateBuilder;
|
|
191
|
+
bunInstall(packages?: string | string[], options?: {
|
|
192
|
+
g?: boolean;
|
|
193
|
+
dev?: boolean;
|
|
194
|
+
}): TemplateBuilder;
|
|
195
|
+
aptInstall(packages: string | string[], _options?: {
|
|
196
|
+
noInstallRecommends?: boolean;
|
|
197
|
+
fixMissing?: boolean;
|
|
198
|
+
}): TemplateBuilder;
|
|
199
|
+
addMcpServer(servers: string | string[]): TemplateBuilder;
|
|
200
|
+
gitClone(url: string, path?: string, options?: {
|
|
201
|
+
branch?: string;
|
|
202
|
+
depth?: number;
|
|
203
|
+
user?: string;
|
|
204
|
+
}): TemplateBuilder;
|
|
205
|
+
setStartCmd(startCommand: string, readyCommand: ReadyCommand): TemplateFinal;
|
|
206
|
+
setReadyCmd(readyCommand: ReadyCommand): TemplateFinal;
|
|
207
|
+
setEnvs(envs: Record<string, string>): TemplateBuilder;
|
|
208
|
+
skipCache(): TemplateBuilder;
|
|
209
|
+
toBuildSpec(): BuildSpec;
|
|
210
|
+
private addPackages;
|
|
211
|
+
private addCopySource;
|
|
212
|
+
private addFileSpec;
|
|
213
|
+
private resolveContextPath;
|
|
214
|
+
private ignored;
|
|
215
|
+
private commandWithContext;
|
|
216
|
+
private toDockerfile;
|
|
217
|
+
}
|
|
218
|
+
export interface TemplateFactory {
|
|
219
|
+
(options?: TemplateOptions): TemplateFromImage;
|
|
220
|
+
build: typeof TemplateBase.build;
|
|
221
|
+
buildInBackground: typeof TemplateBase.buildInBackground;
|
|
222
|
+
getBuildStatus: typeof TemplateBase.getBuildStatus;
|
|
223
|
+
exists: typeof TemplateBase.exists;
|
|
224
|
+
aliasExists: typeof TemplateBase.aliasExists;
|
|
225
|
+
assignTags: typeof TemplateBase.assignTags;
|
|
226
|
+
removeTags: typeof TemplateBase.removeTags;
|
|
227
|
+
getTags: typeof TemplateBase.getTags;
|
|
228
|
+
toJSON: typeof TemplateBase.toJSON;
|
|
229
|
+
toDockerfile: typeof TemplateBase.toDockerfile;
|
|
230
|
+
}
|
|
231
|
+
export declare const Template: TemplateFactory;
|
|
232
|
+
export {};
|