@gjermundgaraba/clankerbox-sdk 0.15.5 → 0.16.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/dist/{client-C2Z7F3Tu.mjs → client-CLemHDCl.mjs} +202 -217
- package/dist/client-DgDb-TR7.d.mts +958 -0
- package/dist/index.d.mts +80 -357
- package/dist/index.mjs +129 -116
- package/dist/node.d.mts +2 -2
- package/dist/node.mjs +5 -5
- package/package.json +7 -6
- package/dist/client-Cn1bj4It.d.mts +0 -328
|
@@ -1,328 +0,0 @@
|
|
|
1
|
-
import { Context, Duration, Effect, Schema } from "effect";
|
|
2
|
-
import { HttpClient } from "effect/http";
|
|
3
|
-
//#region src/errors.d.ts
|
|
4
|
-
declare const Invalid_base: Schema.Class<Invalid, Schema.TaggedStruct<"Invalid", {
|
|
5
|
-
readonly message: Schema.String;
|
|
6
|
-
}>, import("effect/Cause").YieldableError>;
|
|
7
|
-
/** The request is malformed: a bad ID or name, an undeclared field, a value out of range. */
|
|
8
|
-
declare class Invalid extends Invalid_base {
|
|
9
|
-
get retryable(): boolean;
|
|
10
|
-
}
|
|
11
|
-
declare const NotFound_base: Schema.Class<NotFound, Schema.TaggedStruct<"NotFound", {
|
|
12
|
-
readonly message: Schema.String;
|
|
13
|
-
}>, import("effect/Cause").YieldableError>;
|
|
14
|
-
/** The machine or checkpoint doesn't exist. A `delete` that meets it is done. */
|
|
15
|
-
declare class NotFound extends NotFound_base {
|
|
16
|
-
get retryable(): boolean;
|
|
17
|
-
}
|
|
18
|
-
declare const ConflictKind: Schema.Literals<readonly ["exists", "busy"]>;
|
|
19
|
-
type ConflictKind = typeof ConflictKind.Type;
|
|
20
|
-
declare const Conflict_base: Schema.Class<Conflict, Schema.TaggedStruct<"Conflict", {
|
|
21
|
-
readonly message: Schema.String;
|
|
22
|
-
readonly kind: Schema.Literals<readonly ["exists", "busy"]>;
|
|
23
|
-
}>, import("effect/Cause").YieldableError>;
|
|
24
|
-
/** The name is taken (`exists`), or another action holds the resource (`busy`). */
|
|
25
|
-
declare class Conflict extends Conflict_base {
|
|
26
|
-
get retryable(): boolean;
|
|
27
|
-
}
|
|
28
|
-
declare const Precondition_base: Schema.Class<Precondition, Schema.TaggedStruct<"Precondition", {
|
|
29
|
-
readonly message: Schema.String;
|
|
30
|
-
}>, import("effect/Cause").YieldableError>;
|
|
31
|
-
/** The resource's state doesn't allow the action, or no host offers the requested base. */
|
|
32
|
-
declare class Precondition extends Precondition_base {
|
|
33
|
-
get retryable(): boolean;
|
|
34
|
-
}
|
|
35
|
-
declare const Capacity_base: Schema.Class<Capacity, Schema.TaggedStruct<"Capacity", {
|
|
36
|
-
readonly message: Schema.String;
|
|
37
|
-
}>, import("effect/Cause").YieldableError>;
|
|
38
|
-
/** The host has no room now; room can free up, so a later call may succeed. */
|
|
39
|
-
declare class Capacity extends Capacity_base {
|
|
40
|
-
get retryable(): boolean;
|
|
41
|
-
}
|
|
42
|
-
declare const Unavailable_base: Schema.Class<Unavailable, Schema.TaggedStruct<"Unavailable", {
|
|
43
|
-
readonly message: Schema.String;
|
|
44
|
-
readonly readOnly: Schema.Boolean;
|
|
45
|
-
}>, import("effect/Cause").YieldableError>;
|
|
46
|
-
/**
|
|
47
|
-
* The client couldn't reach the host, or lost its reply. Only the client library produces
|
|
48
|
-
* it. `readOnly` is that of the action that met it: a mutation's request may have reached
|
|
49
|
-
* the host and run, so it is never retryable.
|
|
50
|
-
*/
|
|
51
|
-
declare class Unavailable extends Unavailable_base {
|
|
52
|
-
get retryable(): boolean;
|
|
53
|
-
}
|
|
54
|
-
declare const Internal_base: Schema.Class<Internal, Schema.TaggedStruct<"Internal", {
|
|
55
|
-
readonly message: Schema.String;
|
|
56
|
-
}>, import("effect/Cause").YieldableError>;
|
|
57
|
-
declare class Internal extends Internal_base {
|
|
58
|
-
get retryable(): boolean;
|
|
59
|
-
}
|
|
60
|
-
/** What a host answers with; every action declares these. */
|
|
61
|
-
declare const hostErrors: readonly [typeof Invalid, typeof NotFound, typeof Conflict, typeof Precondition, typeof Capacity, typeof Internal];
|
|
62
|
-
type HostError = InstanceType<(typeof hostErrors)[number]>;
|
|
63
|
-
/** What a call through the client library fails with. */
|
|
64
|
-
type ClankerboxError = HostError | Unavailable;
|
|
65
|
-
/** The tag a host records on a failed action: always one of the errors it answers with. */
|
|
66
|
-
declare const HostErrorTag: Schema.Literals<("Capacity" | "Conflict" | "Internal" | "Invalid" | "NotFound" | "Precondition")[]>;
|
|
67
|
-
type HostErrorTag = typeof HostErrorTag.Type;
|
|
68
|
-
/** The tag of any error a call through the client library can fail with. */
|
|
69
|
-
declare const ErrorTag: Schema.Literals<readonly [...("Capacity" | "Conflict" | "Internal" | "Invalid" | "NotFound" | "Precondition")[], "Unavailable"]>;
|
|
70
|
-
type ErrorTag = typeof ErrorTag.Type;
|
|
71
|
-
//#endregion
|
|
72
|
-
//#region src/resources.d.ts
|
|
73
|
-
declare const Runtime: Schema.Literals<readonly ["smolvm", "tart", "boat"]>;
|
|
74
|
-
type Runtime = typeof Runtime.Type;
|
|
75
|
-
/** The mutations that record themselves on a resource's `action`. */
|
|
76
|
-
declare const ActionName: Schema.Literals<readonly ["create", "start", "stop", "delete", "fork", "restore", "capture"]>;
|
|
77
|
-
type ActionName = typeof ActionName.Type;
|
|
78
|
-
/**
|
|
79
|
-
* A resource's last action: `running` while it holds the row, `failed` with its error
|
|
80
|
-
* after a native failure, `done` after a success. The next action replaces it.
|
|
81
|
-
*/
|
|
82
|
-
declare const ActionRecord: Schema.Struct<{
|
|
83
|
-
readonly name: Schema.Literals<readonly ["create", "start", "stop", "delete", "fork", "restore", "capture"]>;
|
|
84
|
-
readonly status: Schema.Literals<readonly ["running", "failed", "done"]>;
|
|
85
|
-
readonly error: Schema.optionalKey<Schema.Struct<{
|
|
86
|
-
readonly tag: Schema.Literals<("Capacity" | "Conflict" | "Internal" | "Invalid" | "NotFound" | "Precondition")[]>;
|
|
87
|
-
readonly message: Schema.String;
|
|
88
|
-
}>>;
|
|
89
|
-
}>;
|
|
90
|
-
type ActionRecord = typeof ActionRecord.Type;
|
|
91
|
-
/** Where a machine's guest port 22 is reached. */
|
|
92
|
-
declare const SshEndpoint: Schema.Struct<{
|
|
93
|
-
readonly host: Schema.String;
|
|
94
|
-
readonly port: Schema.Int;
|
|
95
|
-
}>;
|
|
96
|
-
type SshEndpoint = typeof SshEndpoint.Type;
|
|
97
|
-
/** Where a running machine's SSH is reached, and the guest user its runtime's logins are for. */
|
|
98
|
-
declare const SshLogin: Schema.Struct<{
|
|
99
|
-
readonly host: Schema.String;
|
|
100
|
-
readonly port: Schema.Int;
|
|
101
|
-
readonly user: Schema.String;
|
|
102
|
-
}>;
|
|
103
|
-
type SshLogin = typeof SshLogin.Type;
|
|
104
|
-
declare const Machine: Schema.Struct<{
|
|
105
|
-
readonly id: Schema.String;
|
|
106
|
-
readonly runtime: Schema.Literals<readonly ["smolvm", "tart", "boat"]>;
|
|
107
|
-
readonly createdAt: Schema.DateTimeUtcFromString;
|
|
108
|
-
readonly base: Schema.String;
|
|
109
|
-
/** The label the client passed at create, normally its profile's name. */
|
|
110
|
-
readonly profile: Schema.optionalKey<Schema.String>;
|
|
111
|
-
readonly cpu: Schema.Int;
|
|
112
|
-
readonly ramMib: Schema.Int;
|
|
113
|
-
readonly diskGib: Schema.Int;
|
|
114
|
-
/**
|
|
115
|
-
* Read from the runtime, never stored: `missing` when the runtime doesn't have the machine,
|
|
116
|
-
* `unknown` when it couldn't be read.
|
|
117
|
-
*/
|
|
118
|
-
readonly state: Schema.Literals<readonly ["running", "stopped", "missing", "unknown"]>;
|
|
119
|
-
/**
|
|
120
|
-
* Whether its create, fork or restore has made it. One that isn't made, because that action
|
|
121
|
-
* still runs or failed, can only be read, stopped or deleted.
|
|
122
|
-
*/
|
|
123
|
-
readonly made: Schema.Boolean;
|
|
124
|
-
readonly action: Schema.Struct<{
|
|
125
|
-
readonly name: Schema.Literals<readonly ["create", "start", "stop", "delete", "fork", "restore", "capture"]>;
|
|
126
|
-
readonly status: Schema.Literals<readonly ["running", "failed", "done"]>;
|
|
127
|
-
readonly error: Schema.optionalKey<Schema.Struct<{
|
|
128
|
-
readonly tag: Schema.Literals<("Capacity" | "Conflict" | "Internal" | "Invalid" | "NotFound" | "Precondition")[]>;
|
|
129
|
-
readonly message: Schema.String;
|
|
130
|
-
}>>;
|
|
131
|
-
}>;
|
|
132
|
-
/** Only on a running machine whose runtime gives it an endpoint. */
|
|
133
|
-
readonly ssh: Schema.optionalKey<Schema.Struct<{
|
|
134
|
-
readonly host: Schema.String;
|
|
135
|
-
readonly port: Schema.Int;
|
|
136
|
-
readonly user: Schema.String;
|
|
137
|
-
}>>;
|
|
138
|
-
/** The guest's SSH host public key, as `<type> <base64>`, once preparation has recorded it. */
|
|
139
|
-
readonly hostKey: Schema.optionalKey<Schema.String>;
|
|
140
|
-
}>;
|
|
141
|
-
type Machine = typeof Machine.Type;
|
|
142
|
-
declare const Checkpoint: Schema.Struct<{
|
|
143
|
-
readonly id: Schema.String;
|
|
144
|
-
readonly createdAt: Schema.DateTimeUtcFromString;
|
|
145
|
-
/** The ID of the machine it was captured from. */
|
|
146
|
-
readonly machine: Schema.String;
|
|
147
|
-
/** What it holds, by runtime: `ram` (RAM and disks) on smolvm, `disk` on Tart and boat. */
|
|
148
|
-
readonly kind: Schema.Literals<readonly ["ram", "disk"]>;
|
|
149
|
-
readonly base: Schema.String;
|
|
150
|
-
readonly profile: Schema.optionalKey<Schema.String>;
|
|
151
|
-
readonly cpu: Schema.Int;
|
|
152
|
-
readonly ramMib: Schema.Int;
|
|
153
|
-
readonly diskGib: Schema.Int;
|
|
154
|
-
readonly action: Schema.Struct<{
|
|
155
|
-
readonly name: Schema.Literals<readonly ["create", "start", "stop", "delete", "fork", "restore", "capture"]>;
|
|
156
|
-
readonly status: Schema.Literals<readonly ["running", "failed", "done"]>;
|
|
157
|
-
readonly error: Schema.optionalKey<Schema.Struct<{
|
|
158
|
-
readonly tag: Schema.Literals<("Capacity" | "Conflict" | "Internal" | "Invalid" | "NotFound" | "Precondition")[]>;
|
|
159
|
-
readonly message: Schema.String;
|
|
160
|
-
}>>;
|
|
161
|
-
}>;
|
|
162
|
-
}>;
|
|
163
|
-
type Checkpoint = typeof Checkpoint.Type;
|
|
164
|
-
/** The SDK's version, which is also the version of the clankerbox binaries it ships with. */
|
|
165
|
-
declare const version: string;
|
|
166
|
-
/** A version's major.minor: releases that share it speak the same API. */
|
|
167
|
-
declare const release: (of: string) => string;
|
|
168
|
-
declare const Host: Schema.Struct<{
|
|
169
|
-
readonly id: Schema.String;
|
|
170
|
-
readonly runtime: Schema.Literals<readonly ["smolvm", "tart", "boat"]>;
|
|
171
|
-
/** The clankerbox version the host runs. */
|
|
172
|
-
readonly version: Schema.String;
|
|
173
|
-
/** The runtime's version; for boat, its API version. */
|
|
174
|
-
readonly runtimeVersion: Schema.String;
|
|
175
|
-
readonly bases: Schema.$Array<Schema.String>;
|
|
176
|
-
}>;
|
|
177
|
-
type Host = typeof Host.Type;
|
|
178
|
-
/**
|
|
179
|
-
* One limit a host's `Capacity` refusals come from, and how much of it is in use, counted as
|
|
180
|
-
* the refusal counts it, so `used` needn't match the host's own machines. Read from the runtime,
|
|
181
|
-
* never stored.
|
|
182
|
-
*/
|
|
183
|
-
declare const Limit: Schema.Struct<{
|
|
184
|
-
readonly host: Schema.String;
|
|
185
|
-
/**
|
|
186
|
-
* `ramMib`: smolvm's RAM budget. `runningVms`: Tart's, Apple's two VMs per Mac.
|
|
187
|
-
* `activeSandboxes` and the `starts` of each rolling window: the boat account's.
|
|
188
|
-
*/
|
|
189
|
-
readonly resource: Schema.Literals<readonly ["ramMib", "runningVms", "activeSandboxes", "startsPerMinute", "startsPerHour", "startsPerDay"]>;
|
|
190
|
-
readonly limit: Schema.Int;
|
|
191
|
-
readonly used: Schema.Int;
|
|
192
|
-
}>;
|
|
193
|
-
type Limit = typeof Limit.Type;
|
|
194
|
-
/**
|
|
195
|
-
* A setup script and how long it may run, the host's default when it doesn't say. Nothing logs
|
|
196
|
-
* the script: it can carry secrets.
|
|
197
|
-
*/
|
|
198
|
-
declare const Setup: Schema.Struct<{
|
|
199
|
-
readonly script: Schema.String;
|
|
200
|
-
readonly timeoutSeconds: Schema.optionalKey<Schema.Int>;
|
|
201
|
-
}>;
|
|
202
|
-
type Setup = typeof Setup.Type;
|
|
203
|
-
/**
|
|
204
|
-
* What a new machine is made from: a base, its sizes, an optional setup script with its
|
|
205
|
-
* timeout, and an optional `profile` label. A profile file fills these in; the host never
|
|
206
|
-
* sees the profile itself.
|
|
207
|
-
*/
|
|
208
|
-
declare const MachineSpec: Schema.Struct<{
|
|
209
|
-
base: Schema.String;
|
|
210
|
-
cpu: Schema.Int;
|
|
211
|
-
ramMib: Schema.Int;
|
|
212
|
-
diskGib: Schema.Int;
|
|
213
|
-
setup: Schema.optionalKey<Schema.Struct<{
|
|
214
|
-
readonly script: Schema.String;
|
|
215
|
-
readonly timeoutSeconds: Schema.optionalKey<Schema.Int>;
|
|
216
|
-
}>>;
|
|
217
|
-
profile: Schema.optionalKey<Schema.String>;
|
|
218
|
-
}>;
|
|
219
|
-
type MachineSpec = typeof MachineSpec.Type;
|
|
220
|
-
/**
|
|
221
|
-
* `machine.create`'s input: the spec and the new machine's full ID. The host checks that the ID
|
|
222
|
-
* names it, so a create never lands under another host's ID.
|
|
223
|
-
*/
|
|
224
|
-
declare const CreateRequest: Schema.Struct<{
|
|
225
|
-
readonly base: Schema.String;
|
|
226
|
-
readonly cpu: Schema.Int;
|
|
227
|
-
readonly ramMib: Schema.Int;
|
|
228
|
-
readonly diskGib: Schema.Int;
|
|
229
|
-
readonly setup: Schema.optionalKey<Schema.Struct<{
|
|
230
|
-
readonly script: Schema.String;
|
|
231
|
-
readonly timeoutSeconds: Schema.optionalKey<Schema.Int>;
|
|
232
|
-
}>>;
|
|
233
|
-
readonly profile: Schema.optionalKey<Schema.String>;
|
|
234
|
-
readonly id: Schema.String;
|
|
235
|
-
}>;
|
|
236
|
-
type CreateRequest = typeof CreateRequest.Type;
|
|
237
|
-
/**
|
|
238
|
-
* A profile file: a client-side file that fills in a create request. `setup.path` is a script
|
|
239
|
-
* file or a recipe directory, relative to the profile file; without a `timeoutSeconds` the host's
|
|
240
|
-
* default applies. `host` places the create on that host instead of by base.
|
|
241
|
-
*/
|
|
242
|
-
declare const Profile: Schema.Struct<{
|
|
243
|
-
readonly base: Schema.String;
|
|
244
|
-
readonly cpu: Schema.Int;
|
|
245
|
-
readonly ramMib: Schema.Int;
|
|
246
|
-
readonly diskGib: Schema.Int;
|
|
247
|
-
readonly setup: Schema.optionalKey<Schema.Struct<{
|
|
248
|
-
readonly path: Schema.String;
|
|
249
|
-
readonly timeoutSeconds: Schema.optionalKey<Schema.Int>;
|
|
250
|
-
}>>;
|
|
251
|
-
readonly host: Schema.optionalKey<Schema.String>;
|
|
252
|
-
}>;
|
|
253
|
-
type Profile = typeof Profile.Type;
|
|
254
|
-
declare namespace client_d_exports {
|
|
255
|
-
export { Client, CreateOptions, Gathered, HostEntry, Interface, Options, Unreachable, make };
|
|
256
|
-
}
|
|
257
|
-
/** One host a client talks to. `id` is the host part of every ID it holds. */
|
|
258
|
-
declare const HostEntry: Schema.Struct<{
|
|
259
|
-
readonly id: Schema.String;
|
|
260
|
-
readonly url: Schema.String;
|
|
261
|
-
}>;
|
|
262
|
-
type HostEntry = typeof HostEntry.Type;
|
|
263
|
-
/** A host that didn't answer a fan-out, and why. */
|
|
264
|
-
interface Unreachable {
|
|
265
|
-
readonly host: string;
|
|
266
|
-
readonly error: ClankerboxError;
|
|
267
|
-
}
|
|
268
|
-
/** What a fan-out gathered: every reachable host's answers, and the hosts that didn't answer. */
|
|
269
|
-
interface Gathered<A> {
|
|
270
|
-
readonly answers: ReadonlyArray<A>;
|
|
271
|
-
readonly unreachable: ReadonlyArray<Unreachable>;
|
|
272
|
-
}
|
|
273
|
-
interface Options {
|
|
274
|
-
/**
|
|
275
|
-
* How long to wait for a mutation's reply, unbounded by default: a create with a long setup
|
|
276
|
-
* runs for as long as it takes. It only stops the wait, and a mutation that outlasts it fails
|
|
277
|
-
* like a lost reply.
|
|
278
|
-
*/
|
|
279
|
-
readonly timeout?: Duration.Duration | undefined;
|
|
280
|
-
/**
|
|
281
|
-
* How long to wait for a read's reply, `readTimeout` (10 s) by default. A fan-out bounds each
|
|
282
|
-
* host's request on its own, so a host that doesn't answer in time is named among the
|
|
283
|
-
* unreachable.
|
|
284
|
-
*/
|
|
285
|
-
readonly readTimeout?: Duration.Duration | undefined;
|
|
286
|
-
}
|
|
287
|
-
interface CreateOptions {
|
|
288
|
-
/** The host to create on instead of placing by base: a `--host` flag or a profile's `host`. */
|
|
289
|
-
readonly host?: string | undefined;
|
|
290
|
-
}
|
|
291
|
-
interface Interface {
|
|
292
|
-
/** Every host, with its bases. */
|
|
293
|
-
readonly hosts: Effect.Effect<Gathered<Host>>;
|
|
294
|
-
readonly machines: Effect.Effect<Gathered<Machine>>;
|
|
295
|
-
readonly checkpoints: Effect.Effect<Gathered<Checkpoint>>;
|
|
296
|
-
/** Every host's limits; a host whose runtime couldn't be read is among the unreachable. */
|
|
297
|
-
readonly capacity: Effect.Effect<Gathered<Limit>>;
|
|
298
|
-
readonly machine: (id: string) => Effect.Effect<Machine, ClankerboxError>;
|
|
299
|
-
readonly checkpoint: (id: string) => Effect.Effect<Checkpoint, ClankerboxError>;
|
|
300
|
-
/**
|
|
301
|
-
* The host a create of `base` goes to: the options' host, or else the first host in the list
|
|
302
|
-
* that offers the base. It is read either way, so a caller knows its runtime before it creates.
|
|
303
|
-
*/
|
|
304
|
-
readonly place: (base: string, options?: CreateOptions) => Effect.Effect<Host, ClankerboxError>;
|
|
305
|
-
/**
|
|
306
|
-
* Creates a machine named `name` on the options' host, or else on the first host in the
|
|
307
|
-
* list that offers the spec's base.
|
|
308
|
-
*/
|
|
309
|
-
readonly create: (name: string, spec: MachineSpec, options?: CreateOptions) => Effect.Effect<Machine, ClankerboxError>;
|
|
310
|
-
readonly start: (id: string) => Effect.Effect<Machine, ClankerboxError>;
|
|
311
|
-
readonly stop: (id: string) => Effect.Effect<Machine, ClankerboxError>;
|
|
312
|
-
readonly delete: (id: string) => Effect.Effect<void, ClankerboxError>;
|
|
313
|
-
/** Copies a machine to a new name on its host. */
|
|
314
|
-
readonly fork: (machine: string, name: string) => Effect.Effect<Machine, ClankerboxError>;
|
|
315
|
-
/** Creates a machine named `name` from a checkpoint, on the checkpoint's host. */
|
|
316
|
-
readonly restore: (checkpoint: string, name: string) => Effect.Effect<Machine, ClankerboxError>;
|
|
317
|
-
readonly capture: (machine: string, name: string) => Effect.Effect<Checkpoint, ClankerboxError>;
|
|
318
|
-
readonly deleteCheckpoint: (id: string) => Effect.Effect<void, ClankerboxError>;
|
|
319
|
-
}
|
|
320
|
-
declare const Client_base: Context.ServiceClass<Client, "@gjermundgaraba/clankerbox-sdk/Client", Interface>;
|
|
321
|
-
declare class Client extends Client_base {}
|
|
322
|
-
/**
|
|
323
|
-
* Builds a client over `hosts`, in placement order. Making it sends nothing. An empty list
|
|
324
|
-
* is Invalid, and so is a malformed entry or a host ID that appears twice: IDs route by it.
|
|
325
|
-
*/
|
|
326
|
-
declare const make: (hosts: ReadonlyArray<HostEntry>, options?: Options) => Effect.Effect<Interface, Invalid, HttpClient.HttpClient>;
|
|
327
|
-
//#endregion
|
|
328
|
-
export { Invalid as A, ClankerboxError as C, HostError as D, ErrorTag as E, Precondition as M, Unavailable as N, HostErrorTag as O, hostErrors as P, Capacity as S, ConflictKind as T, Setup as _, Options as a, release as b, ActionRecord as c, Host as d, Limit as f, Runtime as g, Profile as h, Interface as i, NotFound as j, Internal as k, Checkpoint as l, MachineSpec as m, CreateOptions as n, client_d_exports as o, Machine as p, HostEntry as r, ActionName as s, Client as t, CreateRequest as u, SshEndpoint as v, Conflict as w, version as x, SshLogin as y };
|