@boxd-sh/convex 0.1.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.
- package/LICENSE +21 -0
- package/README.md +264 -0
- package/dist/client/_generated/_ignore.d.ts +1 -0
- package/dist/client/_generated/_ignore.d.ts.map +1 -0
- package/dist/client/_generated/_ignore.js +3 -0
- package/dist/client/_generated/_ignore.js.map +1 -0
- package/dist/client/index.d.ts +327 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +126 -0
- package/dist/client/index.js.map +1 -0
- package/dist/component/_generated/api.d.ts +52 -0
- package/dist/component/_generated/api.d.ts.map +1 -0
- package/dist/component/_generated/api.js +31 -0
- package/dist/component/_generated/api.js.map +1 -0
- package/dist/component/_generated/component.d.ts +357 -0
- package/dist/component/_generated/component.d.ts.map +1 -0
- package/dist/component/_generated/component.js +11 -0
- package/dist/component/_generated/component.js.map +1 -0
- package/dist/component/_generated/dataModel.d.ts +46 -0
- package/dist/component/_generated/dataModel.d.ts.map +1 -0
- package/dist/component/_generated/dataModel.js +11 -0
- package/dist/component/_generated/dataModel.js.map +1 -0
- package/dist/component/_generated/server.d.ts +135 -0
- package/dist/component/_generated/server.d.ts.map +1 -0
- package/dist/component/_generated/server.js +80 -0
- package/dist/component/_generated/server.js.map +1 -0
- package/dist/component/boxd.d.ts +35 -0
- package/dist/component/boxd.d.ts.map +1 -0
- package/dist/component/boxd.js +144 -0
- package/dist/component/boxd.js.map +1 -0
- package/dist/component/convex.config.d.ts +6 -0
- package/dist/component/convex.config.d.ts.map +1 -0
- package/dist/component/convex.config.js +9 -0
- package/dist/component/convex.config.js.map +1 -0
- package/dist/component/errors.d.ts +25 -0
- package/dist/component/errors.d.ts.map +1 -0
- package/dist/component/errors.js +75 -0
- package/dist/component/errors.js.map +1 -0
- package/dist/component/exec.d.ts +25 -0
- package/dist/component/exec.d.ts.map +1 -0
- package/dist/component/exec.js +100 -0
- package/dist/component/exec.js.map +1 -0
- package/dist/component/executions.d.ts +70 -0
- package/dist/component/executions.d.ts.map +1 -0
- package/dist/component/executions.js +106 -0
- package/dist/component/executions.js.map +1 -0
- package/dist/component/files.d.ts +44 -0
- package/dist/component/files.d.ts.map +1 -0
- package/dist/component/files.js +105 -0
- package/dist/component/files.js.map +1 -0
- package/dist/component/limits.d.ts +33 -0
- package/dist/component/limits.d.ts.map +1 -0
- package/dist/component/limits.js +44 -0
- package/dist/component/limits.js.map +1 -0
- package/dist/component/machines.d.ts +337 -0
- package/dist/component/machines.d.ts.map +1 -0
- package/dist/component/machines.js +411 -0
- package/dist/component/machines.js.map +1 -0
- package/dist/component/records.d.ts +87 -0
- package/dist/component/records.d.ts.map +1 -0
- package/dist/component/records.js +51 -0
- package/dist/component/records.js.map +1 -0
- package/dist/component/schema.d.ts +138 -0
- package/dist/component/schema.d.ts.map +1 -0
- package/dist/component/schema.js +70 -0
- package/dist/component/schema.js.map +1 -0
- package/dist/component/sessions.d.ts +21 -0
- package/dist/component/sessions.d.ts.map +1 -0
- package/dist/component/sessions.js +59 -0
- package/dist/component/sessions.js.map +1 -0
- package/dist/component/validate.d.ts +15 -0
- package/dist/component/validate.d.ts.map +1 -0
- package/dist/component/validate.js +44 -0
- package/dist/component/validate.js.map +1 -0
- package/package.json +99 -0
- package/src/client/_generated/_ignore.ts +1 -0
- package/src/client/index.ts +199 -0
- package/src/component/_generated/api.ts +68 -0
- package/src/component/_generated/component.ts +430 -0
- package/src/component/_generated/dataModel.ts +60 -0
- package/src/component/_generated/server.ts +171 -0
- package/src/component/boxd.ts +188 -0
- package/src/component/convex.config.ts +9 -0
- package/src/component/errors.ts +105 -0
- package/src/component/exec.ts +134 -0
- package/src/component/executions.ts +115 -0
- package/src/component/files.ts +128 -0
- package/src/component/limits.ts +48 -0
- package/src/component/machines.ts +500 -0
- package/src/component/records.ts +71 -0
- package/src/component/schema.ts +77 -0
- package/src/component/sessions.ts +61 -0
- package/src/component/validate.ts +58 -0
- package/src/test.ts +28 -0
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* App-facing client for the boxd Convex component.
|
|
3
|
+
*
|
|
4
|
+
* Create one with `components.boxd` in your `convex/` directory and call it
|
|
5
|
+
* from your queries and actions. Reads (`get`, `list`, `listExecutions`,
|
|
6
|
+
* `getExecution`) run in queries and are reactive. Everything that talks to
|
|
7
|
+
* boxd runs in actions.
|
|
8
|
+
*
|
|
9
|
+
* The component can't see your users: `ctx.auth` doesn't reach into a
|
|
10
|
+
* component. Derive `ownerId` from your own auth and pass it on every call.
|
|
11
|
+
* Never take it from a client argument. A machine created with an `ownerId`
|
|
12
|
+
* is reachable only with that same `ownerId`.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { ConvexError, type Infer } from "convex/values";
|
|
16
|
+
import type {
|
|
17
|
+
FunctionArgs,
|
|
18
|
+
FunctionReference,
|
|
19
|
+
FunctionReturnType,
|
|
20
|
+
GenericActionCtx,
|
|
21
|
+
GenericDataModel,
|
|
22
|
+
GenericQueryCtx,
|
|
23
|
+
} from "convex/server";
|
|
24
|
+
import type { ComponentApi } from "../component/_generated/component.js";
|
|
25
|
+
import type { BoxdErrorData, errorCode } from "../component/errors.js";
|
|
26
|
+
|
|
27
|
+
type QueryCtx = Pick<GenericQueryCtx<GenericDataModel>, "runQuery">;
|
|
28
|
+
type ActionCtx = Pick<
|
|
29
|
+
GenericActionCtx<GenericDataModel>,
|
|
30
|
+
"runQuery" | "runMutation" | "runAction"
|
|
31
|
+
>;
|
|
32
|
+
|
|
33
|
+
type Machines = ComponentApi["machines"];
|
|
34
|
+
type Args<F extends FunctionReference<any, "internal">> = FunctionArgs<F>;
|
|
35
|
+
type Returns<F extends FunctionReference<any, "internal">> =
|
|
36
|
+
FunctionReturnType<F>;
|
|
37
|
+
|
|
38
|
+
/** A machine's row: boxd's last observed state plus the component's fields. */
|
|
39
|
+
export type MachineRecord = Returns<Machines["create"]>;
|
|
40
|
+
/** One `exec`, as stored in the component. */
|
|
41
|
+
export type ExecutionRecord = NonNullable<
|
|
42
|
+
Returns<ComponentApi["executions"]["get"]>
|
|
43
|
+
>;
|
|
44
|
+
export type ExecResult = Returns<ComponentApi["exec"]["run"]>;
|
|
45
|
+
export type DirListing = Returns<ComponentApi["files"]["listDir"]>;
|
|
46
|
+
|
|
47
|
+
export type CreateArgs = Args<Machines["create"]>;
|
|
48
|
+
export type ForkArgs = Args<Machines["fork"]>;
|
|
49
|
+
export type ExecArgs = Args<ComponentApi["exec"]["run"]>;
|
|
50
|
+
export type ExposeArgs = Args<Machines["expose"]>;
|
|
51
|
+
|
|
52
|
+
/** Addresses one machine: its boxd id, and the owner it belongs to. */
|
|
53
|
+
export type MachineRef = { machineId: string; ownerId?: string };
|
|
54
|
+
/** Addresses a machine that wakes up: optionally wait until it takes an exec. */
|
|
55
|
+
export type WakeArgs = Args<Machines["start"]>;
|
|
56
|
+
export type FileRef = MachineRef & { path: string };
|
|
57
|
+
|
|
58
|
+
export type BoxdErrorCode = Infer<typeof errorCode>;
|
|
59
|
+
export type { BoxdErrorData, ComponentApi };
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* True when `error` is a `ConvexError` this component threw, and, with
|
|
63
|
+
* `code`, carries that code:
|
|
64
|
+
*
|
|
65
|
+
* ```ts
|
|
66
|
+
* if (isBoxdError(error, "NOT_FOUND")) return null;
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export function isBoxdError(
|
|
70
|
+
error: unknown,
|
|
71
|
+
code?: BoxdErrorCode,
|
|
72
|
+
): error is ConvexError<BoxdErrorData> {
|
|
73
|
+
if (!(error instanceof ConvexError)) return false;
|
|
74
|
+
const data = error.data as Partial<BoxdErrorData> | null;
|
|
75
|
+
if (typeof data !== "object" || data === null) return false;
|
|
76
|
+
if (typeof data.code !== "string" || typeof data.message !== "string") {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
return code === undefined || data.code === code;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export class Boxd {
|
|
83
|
+
constructor(public readonly component: ComponentApi) {}
|
|
84
|
+
|
|
85
|
+
// ---- Reactive reads (component tables only, no boxd call) --------------
|
|
86
|
+
|
|
87
|
+
/** The machine's row, or null if it doesn't exist for this owner. */
|
|
88
|
+
async get(ctx: QueryCtx, args: MachineRef) {
|
|
89
|
+
return await ctx.runQuery(this.component.machines.get, args);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** The owner's machines, newest first, destroyed ones included. */
|
|
93
|
+
async list(ctx: QueryCtx, args: { ownerId?: string; limit?: number } = {}) {
|
|
94
|
+
return await ctx.runQuery(this.component.machines.list, args);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** A machine's executions, newest first. */
|
|
98
|
+
async listExecutions(ctx: QueryCtx, args: MachineRef & { limit?: number }) {
|
|
99
|
+
return await ctx.runQuery(this.component.executions.list, args);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** One execution by the id `exec` returned, or null. */
|
|
103
|
+
async getExecution(
|
|
104
|
+
ctx: QueryCtx,
|
|
105
|
+
args: { executionId: string; ownerId?: string },
|
|
106
|
+
) {
|
|
107
|
+
return await ctx.runQuery(this.component.executions.get, args);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// ---- Lifecycle -----------------------------------------------------------
|
|
111
|
+
|
|
112
|
+
/** Create a machine and, by default, wait until it accepts an exec. */
|
|
113
|
+
async create(ctx: ActionCtx, args: CreateArgs = {}) {
|
|
114
|
+
return await ctx.runAction(this.component.machines.create, args);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** Fork a machine, disk and memory, into a new one with the same owner. */
|
|
118
|
+
async fork(ctx: ActionCtx, args: ForkArgs) {
|
|
119
|
+
return await ctx.runAction(this.component.machines.fork, args);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** Re-read the machine from boxd into its row. */
|
|
123
|
+
async refresh(ctx: ActionCtx, args: MachineRef) {
|
|
124
|
+
return await ctx.runAction(this.component.machines.refresh, args);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** Boot a stopped machine. */
|
|
128
|
+
async start(ctx: ActionCtx, args: WakeArgs) {
|
|
129
|
+
return await ctx.runAction(this.component.machines.start, args);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** Shut the machine down. The disk is kept. */
|
|
133
|
+
async stop(ctx: ActionCtx, args: MachineRef) {
|
|
134
|
+
return await ctx.runAction(this.component.machines.stop, args);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** Suspend to RAM. An exec or an HTTPS request wakes it again. */
|
|
138
|
+
async pause(ctx: ActionCtx, args: MachineRef) {
|
|
139
|
+
return await ctx.runAction(this.component.machines.pause, args);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** Resume a paused machine. */
|
|
143
|
+
async resume(ctx: ActionCtx, args: WakeArgs) {
|
|
144
|
+
return await ctx.runAction(this.component.machines.resume, args);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** Suspend to disk, freeing the host's memory. */
|
|
148
|
+
async hibernate(ctx: ActionCtx, args: MachineRef) {
|
|
149
|
+
return await ctx.runAction(this.component.machines.hibernate, args);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** Restore a hibernated machine, memory included. */
|
|
153
|
+
async wake(ctx: ActionCtx, args: WakeArgs) {
|
|
154
|
+
return await ctx.runAction(this.component.machines.wake, args);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** Destroy the machine. Its row stays, with status "destroyed". */
|
|
158
|
+
async destroy(ctx: ActionCtx, args: MachineRef) {
|
|
159
|
+
return await ctx.runAction(this.component.machines.destroy, args);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Route public HTTPS to a port. Without `name`: the machine's default URL.
|
|
164
|
+
* With `name`: an extra `https://<name>.<machine>.<zone>`.
|
|
165
|
+
*/
|
|
166
|
+
async expose(ctx: ActionCtx, args: ExposeArgs) {
|
|
167
|
+
return await ctx.runAction(this.component.machines.expose, args);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// ---- Commands and files ------------------------------------------------
|
|
171
|
+
|
|
172
|
+
/** Run a command and wait for it to exit. Recorded in `executions`. */
|
|
173
|
+
async exec(ctx: ActionCtx, args: ExecArgs) {
|
|
174
|
+
return await ctx.runAction(this.component.exec.run, args);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** Read a file as UTF-8 text. */
|
|
178
|
+
async readFile(ctx: ActionCtx, args: FileRef) {
|
|
179
|
+
return await ctx.runAction(this.component.files.readFile, args);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** Read a file byte for byte. */
|
|
183
|
+
async readFileBytes(ctx: ActionCtx, args: FileRef) {
|
|
184
|
+
return await ctx.runAction(this.component.files.readFileBytes, args);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/** Create or replace a file from text or bytes. */
|
|
188
|
+
async writeFile(
|
|
189
|
+
ctx: ActionCtx,
|
|
190
|
+
args: FileRef & { content: string | ArrayBuffer },
|
|
191
|
+
) {
|
|
192
|
+
return await ctx.runAction(this.component.files.writeFile, args);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/** The immediate contents of a directory. */
|
|
196
|
+
async listDir(ctx: ActionCtx, args: FileRef) {
|
|
197
|
+
return await ctx.runAction(this.component.files.listDir, args);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/**
|
|
3
|
+
* Generated `api` utility.
|
|
4
|
+
*
|
|
5
|
+
* THIS CODE IS AUTOMATICALLY GENERATED.
|
|
6
|
+
*
|
|
7
|
+
* To regenerate, run `npx convex dev`.
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type * as boxd from "../boxd.js";
|
|
12
|
+
import type * as errors from "../errors.js";
|
|
13
|
+
import type * as exec from "../exec.js";
|
|
14
|
+
import type * as executions from "../executions.js";
|
|
15
|
+
import type * as files from "../files.js";
|
|
16
|
+
import type * as limits from "../limits.js";
|
|
17
|
+
import type * as machines from "../machines.js";
|
|
18
|
+
import type * as records from "../records.js";
|
|
19
|
+
import type * as sessions from "../sessions.js";
|
|
20
|
+
import type * as validate from "../validate.js";
|
|
21
|
+
|
|
22
|
+
import type {
|
|
23
|
+
ApiFromModules,
|
|
24
|
+
FilterApi,
|
|
25
|
+
FunctionReference,
|
|
26
|
+
} from "convex/server";
|
|
27
|
+
import { anyApi, componentsGeneric } from "convex/server";
|
|
28
|
+
|
|
29
|
+
const fullApi: ApiFromModules<{
|
|
30
|
+
boxd: typeof boxd;
|
|
31
|
+
errors: typeof errors;
|
|
32
|
+
exec: typeof exec;
|
|
33
|
+
executions: typeof executions;
|
|
34
|
+
files: typeof files;
|
|
35
|
+
limits: typeof limits;
|
|
36
|
+
machines: typeof machines;
|
|
37
|
+
records: typeof records;
|
|
38
|
+
sessions: typeof sessions;
|
|
39
|
+
validate: typeof validate;
|
|
40
|
+
}> = anyApi as any;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* A utility for referencing Convex functions in your app's public API.
|
|
44
|
+
*
|
|
45
|
+
* Usage:
|
|
46
|
+
* ```js
|
|
47
|
+
* const myFunctionReference = api.myModule.myFunction;
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export const api: FilterApi<
|
|
51
|
+
typeof fullApi,
|
|
52
|
+
FunctionReference<any, "public">
|
|
53
|
+
> = anyApi as any;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* A utility for referencing Convex functions in your app's internal API.
|
|
57
|
+
*
|
|
58
|
+
* Usage:
|
|
59
|
+
* ```js
|
|
60
|
+
* const myFunctionReference = internal.myModule.myFunction;
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export const internal: FilterApi<
|
|
64
|
+
typeof fullApi,
|
|
65
|
+
FunctionReference<any, "internal">
|
|
66
|
+
> = anyApi as any;
|
|
67
|
+
|
|
68
|
+
export const components = componentsGeneric() as unknown as {};
|
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/**
|
|
3
|
+
* Generated `ComponentApi` utility.
|
|
4
|
+
*
|
|
5
|
+
* THIS CODE IS AUTOMATICALLY GENERATED.
|
|
6
|
+
*
|
|
7
|
+
* To regenerate, run `npx convex dev`.
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { FunctionReference } from "convex/server";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A utility for referencing a Convex component's exposed API.
|
|
15
|
+
*
|
|
16
|
+
* Useful when expecting a parameter like `components.myComponent`.
|
|
17
|
+
* Usage:
|
|
18
|
+
* ```ts
|
|
19
|
+
* async function myFunction(ctx: QueryCtx, component: ComponentApi) {
|
|
20
|
+
* return ctx.runQuery(component.someFile.someQuery, { ...args });
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
25
|
+
{
|
|
26
|
+
exec: {
|
|
27
|
+
run: FunctionReference<
|
|
28
|
+
"action",
|
|
29
|
+
"internal",
|
|
30
|
+
{
|
|
31
|
+
command: string | Array<string>;
|
|
32
|
+
cwd?: string;
|
|
33
|
+
env?: Record<string, string>;
|
|
34
|
+
machineId: string;
|
|
35
|
+
ownerId?: string;
|
|
36
|
+
timeoutMs?: number;
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
executionId: string;
|
|
40
|
+
exitCode: number;
|
|
41
|
+
stderr: string;
|
|
42
|
+
stdout: string;
|
|
43
|
+
success: boolean;
|
|
44
|
+
},
|
|
45
|
+
Name
|
|
46
|
+
>;
|
|
47
|
+
};
|
|
48
|
+
executions: {
|
|
49
|
+
get: FunctionReference<
|
|
50
|
+
"query",
|
|
51
|
+
"internal",
|
|
52
|
+
{ executionId: string; ownerId?: string },
|
|
53
|
+
null | {
|
|
54
|
+
_creationTime: number;
|
|
55
|
+
_id: string;
|
|
56
|
+
command: string;
|
|
57
|
+
cwd?: string;
|
|
58
|
+
error?: string;
|
|
59
|
+
exitCode?: number;
|
|
60
|
+
finishedAt?: number;
|
|
61
|
+
machineId: string;
|
|
62
|
+
ownerId?: string;
|
|
63
|
+
startedAt: number;
|
|
64
|
+
status: "running" | "completed" | "failed";
|
|
65
|
+
stderr?: string;
|
|
66
|
+
stdout?: string;
|
|
67
|
+
},
|
|
68
|
+
Name
|
|
69
|
+
>;
|
|
70
|
+
list: FunctionReference<
|
|
71
|
+
"query",
|
|
72
|
+
"internal",
|
|
73
|
+
{ limit?: number; machineId: string; ownerId?: string },
|
|
74
|
+
Array<{
|
|
75
|
+
_creationTime: number;
|
|
76
|
+
_id: string;
|
|
77
|
+
command: string;
|
|
78
|
+
cwd?: string;
|
|
79
|
+
error?: string;
|
|
80
|
+
exitCode?: number;
|
|
81
|
+
finishedAt?: number;
|
|
82
|
+
machineId: string;
|
|
83
|
+
ownerId?: string;
|
|
84
|
+
startedAt: number;
|
|
85
|
+
status: "running" | "completed" | "failed";
|
|
86
|
+
stderr?: string;
|
|
87
|
+
stdout?: string;
|
|
88
|
+
}>,
|
|
89
|
+
Name
|
|
90
|
+
>;
|
|
91
|
+
};
|
|
92
|
+
files: {
|
|
93
|
+
listDir: FunctionReference<
|
|
94
|
+
"action",
|
|
95
|
+
"internal",
|
|
96
|
+
{ machineId: string; ownerId?: string; path: string },
|
|
97
|
+
{
|
|
98
|
+
entries: Array<{
|
|
99
|
+
isDir: boolean;
|
|
100
|
+
modifiedAt: number;
|
|
101
|
+
name: string;
|
|
102
|
+
permissions: string;
|
|
103
|
+
sizeBytes: number;
|
|
104
|
+
}>;
|
|
105
|
+
truncated: boolean;
|
|
106
|
+
},
|
|
107
|
+
Name
|
|
108
|
+
>;
|
|
109
|
+
readFile: FunctionReference<
|
|
110
|
+
"action",
|
|
111
|
+
"internal",
|
|
112
|
+
{ machineId: string; ownerId?: string; path: string },
|
|
113
|
+
string,
|
|
114
|
+
Name
|
|
115
|
+
>;
|
|
116
|
+
readFileBytes: FunctionReference<
|
|
117
|
+
"action",
|
|
118
|
+
"internal",
|
|
119
|
+
{ machineId: string; ownerId?: string; path: string },
|
|
120
|
+
ArrayBuffer,
|
|
121
|
+
Name
|
|
122
|
+
>;
|
|
123
|
+
writeFile: FunctionReference<
|
|
124
|
+
"action",
|
|
125
|
+
"internal",
|
|
126
|
+
{
|
|
127
|
+
content: string | ArrayBuffer;
|
|
128
|
+
machineId: string;
|
|
129
|
+
ownerId?: string;
|
|
130
|
+
path: string;
|
|
131
|
+
},
|
|
132
|
+
{ bytesWritten: number },
|
|
133
|
+
Name
|
|
134
|
+
>;
|
|
135
|
+
};
|
|
136
|
+
machines: {
|
|
137
|
+
create: FunctionReference<
|
|
138
|
+
"action",
|
|
139
|
+
"internal",
|
|
140
|
+
{
|
|
141
|
+
autoDestroySeconds?: number;
|
|
142
|
+
autoSuspendSeconds?: number;
|
|
143
|
+
env?: Record<string, string>;
|
|
144
|
+
image?: string;
|
|
145
|
+
isolated?: boolean;
|
|
146
|
+
memory?: string;
|
|
147
|
+
name?: string;
|
|
148
|
+
ownerId?: string;
|
|
149
|
+
readyTimeoutMs?: number;
|
|
150
|
+
vcpu?: number;
|
|
151
|
+
waitUntilReady?: boolean;
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
_creationTime: number;
|
|
155
|
+
_id: string;
|
|
156
|
+
forkedFrom?: string;
|
|
157
|
+
image?: string;
|
|
158
|
+
lastError?: string;
|
|
159
|
+
machineId: string;
|
|
160
|
+
memoryBytes?: number;
|
|
161
|
+
name: string;
|
|
162
|
+
ownerId?: string;
|
|
163
|
+
status: string;
|
|
164
|
+
updatedAt: number;
|
|
165
|
+
url?: string;
|
|
166
|
+
vcpu?: number;
|
|
167
|
+
},
|
|
168
|
+
Name
|
|
169
|
+
>;
|
|
170
|
+
destroy: FunctionReference<
|
|
171
|
+
"action",
|
|
172
|
+
"internal",
|
|
173
|
+
{ machineId: string; ownerId?: string },
|
|
174
|
+
{
|
|
175
|
+
_creationTime: number;
|
|
176
|
+
_id: string;
|
|
177
|
+
forkedFrom?: string;
|
|
178
|
+
image?: string;
|
|
179
|
+
lastError?: string;
|
|
180
|
+
machineId: string;
|
|
181
|
+
memoryBytes?: number;
|
|
182
|
+
name: string;
|
|
183
|
+
ownerId?: string;
|
|
184
|
+
status: string;
|
|
185
|
+
updatedAt: number;
|
|
186
|
+
url?: string;
|
|
187
|
+
vcpu?: number;
|
|
188
|
+
},
|
|
189
|
+
Name
|
|
190
|
+
>;
|
|
191
|
+
expose: FunctionReference<
|
|
192
|
+
"action",
|
|
193
|
+
"internal",
|
|
194
|
+
{ machineId: string; name?: string; ownerId?: string; port: number },
|
|
195
|
+
{ port: number; url: string },
|
|
196
|
+
Name
|
|
197
|
+
>;
|
|
198
|
+
fork: FunctionReference<
|
|
199
|
+
"action",
|
|
200
|
+
"internal",
|
|
201
|
+
{
|
|
202
|
+
machineId: string;
|
|
203
|
+
name?: string;
|
|
204
|
+
ownerId?: string;
|
|
205
|
+
readyTimeoutMs?: number;
|
|
206
|
+
waitUntilReady?: boolean;
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
_creationTime: number;
|
|
210
|
+
_id: string;
|
|
211
|
+
forkedFrom?: string;
|
|
212
|
+
image?: string;
|
|
213
|
+
lastError?: string;
|
|
214
|
+
machineId: string;
|
|
215
|
+
memoryBytes?: number;
|
|
216
|
+
name: string;
|
|
217
|
+
ownerId?: string;
|
|
218
|
+
status: string;
|
|
219
|
+
updatedAt: number;
|
|
220
|
+
url?: string;
|
|
221
|
+
vcpu?: number;
|
|
222
|
+
},
|
|
223
|
+
Name
|
|
224
|
+
>;
|
|
225
|
+
get: FunctionReference<
|
|
226
|
+
"query",
|
|
227
|
+
"internal",
|
|
228
|
+
{ machineId: string; ownerId?: string },
|
|
229
|
+
null | {
|
|
230
|
+
_creationTime: number;
|
|
231
|
+
_id: string;
|
|
232
|
+
forkedFrom?: string;
|
|
233
|
+
image?: string;
|
|
234
|
+
lastError?: string;
|
|
235
|
+
machineId: string;
|
|
236
|
+
memoryBytes?: number;
|
|
237
|
+
name: string;
|
|
238
|
+
ownerId?: string;
|
|
239
|
+
status: string;
|
|
240
|
+
updatedAt: number;
|
|
241
|
+
url?: string;
|
|
242
|
+
vcpu?: number;
|
|
243
|
+
},
|
|
244
|
+
Name
|
|
245
|
+
>;
|
|
246
|
+
hibernate: FunctionReference<
|
|
247
|
+
"action",
|
|
248
|
+
"internal",
|
|
249
|
+
{ machineId: string; ownerId?: string },
|
|
250
|
+
{
|
|
251
|
+
_creationTime: number;
|
|
252
|
+
_id: string;
|
|
253
|
+
forkedFrom?: string;
|
|
254
|
+
image?: string;
|
|
255
|
+
lastError?: string;
|
|
256
|
+
machineId: string;
|
|
257
|
+
memoryBytes?: number;
|
|
258
|
+
name: string;
|
|
259
|
+
ownerId?: string;
|
|
260
|
+
status: string;
|
|
261
|
+
updatedAt: number;
|
|
262
|
+
url?: string;
|
|
263
|
+
vcpu?: number;
|
|
264
|
+
},
|
|
265
|
+
Name
|
|
266
|
+
>;
|
|
267
|
+
list: FunctionReference<
|
|
268
|
+
"query",
|
|
269
|
+
"internal",
|
|
270
|
+
{ limit?: number; ownerId?: string },
|
|
271
|
+
Array<{
|
|
272
|
+
_creationTime: number;
|
|
273
|
+
_id: string;
|
|
274
|
+
forkedFrom?: string;
|
|
275
|
+
image?: string;
|
|
276
|
+
lastError?: string;
|
|
277
|
+
machineId: string;
|
|
278
|
+
memoryBytes?: number;
|
|
279
|
+
name: string;
|
|
280
|
+
ownerId?: string;
|
|
281
|
+
status: string;
|
|
282
|
+
updatedAt: number;
|
|
283
|
+
url?: string;
|
|
284
|
+
vcpu?: number;
|
|
285
|
+
}>,
|
|
286
|
+
Name
|
|
287
|
+
>;
|
|
288
|
+
pause: FunctionReference<
|
|
289
|
+
"action",
|
|
290
|
+
"internal",
|
|
291
|
+
{ machineId: string; ownerId?: string },
|
|
292
|
+
{
|
|
293
|
+
_creationTime: number;
|
|
294
|
+
_id: string;
|
|
295
|
+
forkedFrom?: string;
|
|
296
|
+
image?: string;
|
|
297
|
+
lastError?: string;
|
|
298
|
+
machineId: string;
|
|
299
|
+
memoryBytes?: number;
|
|
300
|
+
name: string;
|
|
301
|
+
ownerId?: string;
|
|
302
|
+
status: string;
|
|
303
|
+
updatedAt: number;
|
|
304
|
+
url?: string;
|
|
305
|
+
vcpu?: number;
|
|
306
|
+
},
|
|
307
|
+
Name
|
|
308
|
+
>;
|
|
309
|
+
refresh: FunctionReference<
|
|
310
|
+
"action",
|
|
311
|
+
"internal",
|
|
312
|
+
{ machineId: string; ownerId?: string },
|
|
313
|
+
{
|
|
314
|
+
_creationTime: number;
|
|
315
|
+
_id: string;
|
|
316
|
+
forkedFrom?: string;
|
|
317
|
+
image?: string;
|
|
318
|
+
lastError?: string;
|
|
319
|
+
machineId: string;
|
|
320
|
+
memoryBytes?: number;
|
|
321
|
+
name: string;
|
|
322
|
+
ownerId?: string;
|
|
323
|
+
status: string;
|
|
324
|
+
updatedAt: number;
|
|
325
|
+
url?: string;
|
|
326
|
+
vcpu?: number;
|
|
327
|
+
},
|
|
328
|
+
Name
|
|
329
|
+
>;
|
|
330
|
+
resume: FunctionReference<
|
|
331
|
+
"action",
|
|
332
|
+
"internal",
|
|
333
|
+
{
|
|
334
|
+
machineId: string;
|
|
335
|
+
ownerId?: string;
|
|
336
|
+
readyTimeoutMs?: number;
|
|
337
|
+
waitUntilReady?: boolean;
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
_creationTime: number;
|
|
341
|
+
_id: string;
|
|
342
|
+
forkedFrom?: string;
|
|
343
|
+
image?: string;
|
|
344
|
+
lastError?: string;
|
|
345
|
+
machineId: string;
|
|
346
|
+
memoryBytes?: number;
|
|
347
|
+
name: string;
|
|
348
|
+
ownerId?: string;
|
|
349
|
+
status: string;
|
|
350
|
+
updatedAt: number;
|
|
351
|
+
url?: string;
|
|
352
|
+
vcpu?: number;
|
|
353
|
+
},
|
|
354
|
+
Name
|
|
355
|
+
>;
|
|
356
|
+
start: FunctionReference<
|
|
357
|
+
"action",
|
|
358
|
+
"internal",
|
|
359
|
+
{
|
|
360
|
+
machineId: string;
|
|
361
|
+
ownerId?: string;
|
|
362
|
+
readyTimeoutMs?: number;
|
|
363
|
+
waitUntilReady?: boolean;
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
_creationTime: number;
|
|
367
|
+
_id: string;
|
|
368
|
+
forkedFrom?: string;
|
|
369
|
+
image?: string;
|
|
370
|
+
lastError?: string;
|
|
371
|
+
machineId: string;
|
|
372
|
+
memoryBytes?: number;
|
|
373
|
+
name: string;
|
|
374
|
+
ownerId?: string;
|
|
375
|
+
status: string;
|
|
376
|
+
updatedAt: number;
|
|
377
|
+
url?: string;
|
|
378
|
+
vcpu?: number;
|
|
379
|
+
},
|
|
380
|
+
Name
|
|
381
|
+
>;
|
|
382
|
+
stop: FunctionReference<
|
|
383
|
+
"action",
|
|
384
|
+
"internal",
|
|
385
|
+
{ machineId: string; ownerId?: string },
|
|
386
|
+
{
|
|
387
|
+
_creationTime: number;
|
|
388
|
+
_id: string;
|
|
389
|
+
forkedFrom?: string;
|
|
390
|
+
image?: string;
|
|
391
|
+
lastError?: string;
|
|
392
|
+
machineId: string;
|
|
393
|
+
memoryBytes?: number;
|
|
394
|
+
name: string;
|
|
395
|
+
ownerId?: string;
|
|
396
|
+
status: string;
|
|
397
|
+
updatedAt: number;
|
|
398
|
+
url?: string;
|
|
399
|
+
vcpu?: number;
|
|
400
|
+
},
|
|
401
|
+
Name
|
|
402
|
+
>;
|
|
403
|
+
wake: FunctionReference<
|
|
404
|
+
"action",
|
|
405
|
+
"internal",
|
|
406
|
+
{
|
|
407
|
+
machineId: string;
|
|
408
|
+
ownerId?: string;
|
|
409
|
+
readyTimeoutMs?: number;
|
|
410
|
+
waitUntilReady?: boolean;
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
_creationTime: number;
|
|
414
|
+
_id: string;
|
|
415
|
+
forkedFrom?: string;
|
|
416
|
+
image?: string;
|
|
417
|
+
lastError?: string;
|
|
418
|
+
machineId: string;
|
|
419
|
+
memoryBytes?: number;
|
|
420
|
+
name: string;
|
|
421
|
+
ownerId?: string;
|
|
422
|
+
status: string;
|
|
423
|
+
updatedAt: number;
|
|
424
|
+
url?: string;
|
|
425
|
+
vcpu?: number;
|
|
426
|
+
},
|
|
427
|
+
Name
|
|
428
|
+
>;
|
|
429
|
+
};
|
|
430
|
+
};
|