withruntime 1.0.0 → 1.1.1

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.
Files changed (97) hide show
  1. package/CHANGELOG.md +76 -0
  2. package/README.md +145 -0
  3. package/dist/generated/agentSessions.d.ts +218 -0
  4. package/dist/generated/agentSessions.js +154 -0
  5. package/dist/generated/agents.d.ts +193 -0
  6. package/dist/generated/agents.js +166 -0
  7. package/dist/generated/apps.d.ts +87 -28
  8. package/dist/generated/apps.js +153 -41
  9. package/dist/generated/audit.d.ts +2 -2
  10. package/dist/generated/audit.js +3 -3
  11. package/dist/generated/browsers.d.ts +87 -28
  12. package/dist/generated/browsers.js +153 -41
  13. package/dist/generated/builds.d.ts +87 -28
  14. package/dist/generated/builds.js +153 -41
  15. package/dist/generated/ci.d.ts +87 -28
  16. package/dist/generated/ci.js +153 -41
  17. package/dist/generated/containers.d.ts +87 -28
  18. package/dist/generated/containers.js +153 -41
  19. package/dist/generated/desktops.d.ts +89 -30
  20. package/dist/generated/desktops.js +155 -43
  21. package/dist/generated/domains.d.ts +52 -15
  22. package/dist/generated/domains.js +74 -14
  23. package/dist/generated/egressIps.d.ts +6 -6
  24. package/dist/generated/egressIps.js +4 -4
  25. package/dist/generated/events.d.ts +4 -2
  26. package/dist/generated/events.js +3 -3
  27. package/dist/generated/feedback.d.ts +1 -1
  28. package/dist/generated/feedback.js +3 -3
  29. package/dist/generated/functions.d.ts +87 -28
  30. package/dist/generated/functions.js +153 -41
  31. package/dist/generated/identities.d.ts +2 -2
  32. package/dist/generated/identities.js +5 -5
  33. package/dist/generated/images.d.ts +68 -14
  34. package/dist/generated/images.js +96 -15
  35. package/dist/generated/index.d.ts +9 -0
  36. package/dist/generated/index.js +12 -0
  37. package/dist/generated/jobRuns.d.ts +11 -4
  38. package/dist/generated/jobRuns.js +6 -6
  39. package/dist/generated/jobs.d.ts +58 -9
  40. package/dist/generated/jobs.js +98 -14
  41. package/dist/generated/keys.d.ts +8 -6
  42. package/dist/generated/keys.js +6 -6
  43. package/dist/generated/me.d.ts +2 -2
  44. package/dist/generated/me.js +3 -3
  45. package/dist/generated/messages.d.ts +67 -0
  46. package/dist/generated/messages.js +17 -0
  47. package/dist/generated/networks.d.ts +4 -4
  48. package/dist/generated/networks.js +4 -4
  49. package/dist/generated/notebooks.d.ts +87 -28
  50. package/dist/generated/notebooks.js +153 -41
  51. package/dist/generated/otel.d.ts +2 -2
  52. package/dist/generated/otel.js +5 -5
  53. package/dist/generated/ports.d.ts +11 -11
  54. package/dist/generated/ports.js +8 -8
  55. package/dist/generated/previews.d.ts +50 -15
  56. package/dist/generated/previews.js +70 -18
  57. package/dist/generated/projects.d.ts +30 -6
  58. package/dist/generated/projects.js +13 -9
  59. package/dist/generated/roles.d.ts +11 -2
  60. package/dist/generated/roles.js +9 -5
  61. package/dist/generated/routes.js +1 -1
  62. package/dist/generated/runtime.d.ts +15 -3
  63. package/dist/generated/runtime.js +31 -18
  64. package/dist/generated/sandboxes.d.ts +213 -66
  65. package/dist/generated/sandboxes.js +171 -43
  66. package/dist/generated/secrets.d.ts +45 -6
  67. package/dist/generated/secrets.js +69 -9
  68. package/dist/generated/sessions.d.ts +1 -1
  69. package/dist/generated/sessions.js +4 -4
  70. package/dist/generated/signing.js +3 -1
  71. package/dist/generated/sites.d.ts +87 -28
  72. package/dist/generated/sites.js +153 -41
  73. package/dist/generated/snapshots.d.ts +70 -5
  74. package/dist/generated/snapshots.js +107 -7
  75. package/dist/generated/tunnels.d.ts +8 -8
  76. package/dist/generated/tunnels.js +4 -4
  77. package/dist/generated/usage.d.ts +57 -6
  78. package/dist/generated/usage.js +4 -4
  79. package/dist/generated/volumes.d.ts +72 -7
  80. package/dist/generated/volumes.js +114 -10
  81. package/dist/generated/webhooks.d.ts +2 -2
  82. package/dist/generated/webhooks.js +5 -5
  83. package/dist/generated/workspaces.d.ts +87 -28
  84. package/dist/generated/workspaces.js +153 -41
  85. package/dist/v2/bin.d.ts +2 -0
  86. package/dist/v2/bin.js +15 -0
  87. package/dist/v2/cli.d.ts +15 -2
  88. package/dist/v2/cli.js +158 -53
  89. package/dist/v2/json.d.ts +9 -0
  90. package/dist/v2/json.js +5 -0
  91. package/dist/v2/mcp.js +14 -1
  92. package/dist/v2/openapi.json +7695 -4382
  93. package/dist/v2/shims/fly.js +49 -13
  94. package/dist/v2/shims/morph.js +1 -1
  95. package/dist/v2/table.d.ts +7 -4
  96. package/dist/v2/table.js +97 -34
  97. package/package.json +7 -5
@@ -1,6 +1,13 @@
1
1
  import type { RequestOptions, Transport } from "./runtime.js";
2
2
  import { Paginated } from "./runtime.js";
3
3
  import type { Stored } from "./sandboxes.js";
4
+ /** A change to a snapshot, an image version or a volume: each field left out stays as it is. */
5
+ export interface StoredUpdate {
6
+ /** Seconds from now until Runtime deletes it, as its delete does: final, and it can't be undone. Sent again before then, it renews it; 0 takes its end off (kept until deleted). At least 0. At most 315360000. */
7
+ deleteAfterSeconds?: number;
8
+ /** true refuses its delete (409 `delete_protected`) until an update sends false. Not while it has a `deleteAt`, unless the same update sends `deleteAfterSeconds` 0. */
9
+ deleteProtection?: boolean;
10
+ }
4
11
  /** What list takes in its query. */
5
12
  export type SnapshotListQuery = {
6
13
  /** Only those of this name. */
@@ -9,19 +16,77 @@ export type SnapshotListQuery = {
9
16
  state?: string;
10
17
  /** Only those with every label given (repeat it for several): key:value, or a key for any value. */
11
18
  label?: string[];
12
- /** Only those taken of this sandbox (or other machine), by its ID; a deleted one's snapshots too. */
19
+ /** Only those taken of this machine, by its ID; a deleted one's snapshots too. */
13
20
  sandbox?: string;
14
21
  /** The most items the page holds. At least 1. At most 200. Default: 50. */
15
22
  limit?: number;
16
23
  };
17
- /** A sandbox's memory and disk as they were, kept to start new sandboxes from. */
18
- export declare class Snapshots {
24
+ /** What get takes in its query. */
25
+ export type SnapshotGetQuery = {
26
+ /** Seconds to wait, at most 60, for its state to differ from `ifState`; it answers once it does, or as it is when the wait ends. At least 0. At most 60. */
27
+ wait?: number;
28
+ /** The state the caller last read, which `wait` waits for it to leave. */
29
+ ifState?: string;
30
+ };
31
+ /** One of snapshots: A machine's memory and disk as they were, kept to start new machines from. */
32
+ export declare class Snapshot {
19
33
  #private;
34
+ /** What it was when last read. */
35
+ info: Stored;
36
+ constructor(client: Snapshots, info: Stored);
37
+ /** Its id. */
38
+ get id(): string;
39
+ /** Its kind: `snapshot`, `image` or `volume`. */
40
+ get object(): "snapshot" | "image" | "volume" | (string & {});
41
+ /** Its name, unique in its project among its kind. */
42
+ get name(): string | undefined;
43
+ /** Where it is. */
44
+ get state(): "making" | "ready" | "failed" | "deleted" | (string & {});
45
+ /** Its labels. */
46
+ get labels(): Record<string, string>;
47
+ /** What it was made to hold, in bytes. */
48
+ get sizeBytes(): number;
49
+ /** What it holds now, in bytes. */
50
+ get storedBytes(): number;
51
+ /** What it was made from (a snapshot's machine, an image's base), if anything. */
52
+ get parentId(): string | undefined;
53
+ /** The machine it is attached to now, if any. */
54
+ get attachedTo(): string | undefined;
55
+ /** When it was made. */
56
+ get createdAt(): string | undefined;
57
+ /** An image's version of its name: each build or keep of a name is its next. */
58
+ get version(): number | undefined;
59
+ /** An image's tags, each `name:tag`. */
60
+ get tags(): string[] | undefined;
61
+ /** Why an image's build failed. */
62
+ get error(): string | undefined;
63
+ /** When it was deleted: a delete's answer, its state `deleted`. */
64
+ get deletedAt(): string | undefined;
65
+ /** When Runtime deletes it (`deleteAfterSeconds`), finally: it can't be undone, as its delete can't; none: kept until deleted. */
66
+ get deleteAt(): string | undefined;
67
+ /** Once `deleteAt` has passed, what its delete waits for: the App that boots this image, or the machine this volume is attached to, by its ID. It is deleted as soon as that one no longer does. */
68
+ get deleteWaitsFor(): string | undefined;
69
+ /** Whether its delete is refused (409 `delete_protected`) until an update turns this off. */
70
+ get deleteProtection(): boolean | undefined;
71
+ /** Returns a snapshot. */
72
+ refresh(query?: SnapshotGetQuery & RequestOptions, options?: RequestOptions): Promise<this>;
73
+ /** Deletes a snapshot, its memory and its disk. */
74
+ delete(options?: RequestOptions): Promise<Stored>;
75
+ /** Changes its lifetime (`deleteAfterSeconds`) or delete protection (`deleteProtection`). A lifetime sent again before its end moves the end to that many seconds from now; 0 takes it off. At its end Runtime deletes it as its delete does: final, and it can't be undone. A lifetime and protection are never set together (409 `delete_protected`). Each field left out stays as it is. */
76
+ update(input?: StoredUpdate, options?: RequestOptions): Promise<this>;
77
+ /** Deletes it when the `await using` block that holds it ends. */
78
+ [Symbol.asyncDispose](): Promise<void>;
79
+ }
80
+ /** A machine's memory and disk as they were, kept to start new machines from. */
81
+ export declare class Snapshots {
82
+ readonly transport: Transport;
20
83
  constructor(transport: Transport);
21
84
  /** Lists the project's snapshots, newest first. */
22
- list(query?: SnapshotListQuery, options?: RequestOptions): Paginated<Stored>;
85
+ list(query?: SnapshotListQuery & RequestOptions, options?: RequestOptions): Paginated<Stored>;
23
86
  /** Returns a snapshot. */
24
- get(id: string, options?: RequestOptions): Promise<Stored>;
87
+ get(id: string, query?: SnapshotGetQuery & RequestOptions, options?: RequestOptions): Promise<Snapshot>;
25
88
  /** Deletes a snapshot, its memory and its disk. */
26
89
  delete(id: string, options?: RequestOptions): Promise<Stored>;
90
+ /** Changes its lifetime (`deleteAfterSeconds`) or delete protection (`deleteProtection`). A lifetime sent again before its end moves the end to that many seconds from now; 0 takes it off. At its end Runtime deletes it as its delete does: final, and it can't be undone. A lifetime and protection are never set together (409 `delete_protected`). Each field left out stays as it is. */
91
+ update(id: string, input?: StoredUpdate, options?: RequestOptions): Promise<Stored>;
27
92
  }
@@ -1,22 +1,122 @@
1
1
  // Generated by spec-gen from engines/front/crates/spec. Do not edit:
2
2
  // change the spec and run `cargo run -p runtime-front-spec-gen -- write`.
3
3
  import { Paginated } from "./runtime.js";
4
- /** A sandbox's memory and disk as they were, kept to start new sandboxes from. */
4
+ /** One of snapshots: A machine's memory and disk as they were, kept to start new machines from. */
5
+ export class Snapshot {
6
+ #c;
7
+ /** What it was when last read. */
8
+ info;
9
+ constructor(client, info) {
10
+ this.#c = client;
11
+ this.info = info;
12
+ }
13
+ /** Its id. */
14
+ get id() {
15
+ return this.info.id;
16
+ }
17
+ /** Its kind: `snapshot`, `image` or `volume`. */
18
+ get object() {
19
+ return this.info.object;
20
+ }
21
+ /** Its name, unique in its project among its kind. */
22
+ get name() {
23
+ return this.info.name;
24
+ }
25
+ /** Where it is. */
26
+ get state() {
27
+ return this.info.state;
28
+ }
29
+ /** Its labels. */
30
+ get labels() {
31
+ return this.info.labels;
32
+ }
33
+ /** What it was made to hold, in bytes. */
34
+ get sizeBytes() {
35
+ return this.info.sizeBytes;
36
+ }
37
+ /** What it holds now, in bytes. */
38
+ get storedBytes() {
39
+ return this.info.storedBytes;
40
+ }
41
+ /** What it was made from (a snapshot's machine, an image's base), if anything. */
42
+ get parentId() {
43
+ return this.info.parentId;
44
+ }
45
+ /** The machine it is attached to now, if any. */
46
+ get attachedTo() {
47
+ return this.info.attachedTo;
48
+ }
49
+ /** When it was made. */
50
+ get createdAt() {
51
+ return this.info.createdAt;
52
+ }
53
+ /** An image's version of its name: each build or keep of a name is its next. */
54
+ get version() {
55
+ return this.info.version;
56
+ }
57
+ /** An image's tags, each `name:tag`. */
58
+ get tags() {
59
+ return this.info.tags;
60
+ }
61
+ /** Why an image's build failed. */
62
+ get error() {
63
+ return this.info.error;
64
+ }
65
+ /** When it was deleted: a delete's answer, its state `deleted`. */
66
+ get deletedAt() {
67
+ return this.info.deletedAt;
68
+ }
69
+ /** When Runtime deletes it (`deleteAfterSeconds`), finally: it can't be undone, as its delete can't; none: kept until deleted. */
70
+ get deleteAt() {
71
+ return this.info.deleteAt;
72
+ }
73
+ /** Once `deleteAt` has passed, what its delete waits for: the App that boots this image, or the machine this volume is attached to, by its ID. It is deleted as soon as that one no longer does. */
74
+ get deleteWaitsFor() {
75
+ return this.info.deleteWaitsFor;
76
+ }
77
+ /** Whether its delete is refused (409 `delete_protected`) until an update turns this off. */
78
+ get deleteProtection() {
79
+ return this.info.deleteProtection;
80
+ }
81
+ /** Returns a snapshot. */
82
+ async refresh(query = {}, options) {
83
+ this.info = (await this.#c.get(this.id, query, options)).info;
84
+ return this;
85
+ }
86
+ /** Deletes a snapshot, its memory and its disk. */
87
+ delete(options) {
88
+ return this.#c.delete(this.id, options);
89
+ }
90
+ /** Changes its lifetime (`deleteAfterSeconds`) or delete protection (`deleteProtection`). A lifetime sent again before its end moves the end to that many seconds from now; 0 takes it off. At its end Runtime deletes it as its delete does: final, and it can't be undone. A lifetime and protection are never set together (409 `delete_protected`). Each field left out stays as it is. */
91
+ async update(input = {}, options) {
92
+ this.info = await this.#c.update(this.id, input, options);
93
+ return this;
94
+ }
95
+ /** Deletes it when the `await using` block that holds it ends. */
96
+ async [Symbol.asyncDispose]() {
97
+ await this.delete();
98
+ }
99
+ }
100
+ /** A machine's memory and disk as they were, kept to start new machines from. */
5
101
  export class Snapshots {
6
- #t;
102
+ transport;
7
103
  constructor(transport) {
8
- this.#t = transport;
104
+ this.transport = transport;
9
105
  }
10
106
  /** Lists the project's snapshots, newest first. */
11
107
  list(query = {}, options) {
12
- return new Paginated((cursor) => this.#t.request("GET", `/v2/snapshots`, { query: { ...query, cursor }, options, idempotent: true }));
108
+ return new Paginated((cursor) => this.transport.request("GET", `/v2/snapshots`, { query: { ...query, cursor }, options, idempotent: true }));
13
109
  }
14
110
  /** Returns a snapshot. */
15
- get(id, options) {
16
- return this.#t.request("GET", `/v2/snapshots/${encodeURIComponent(id)}`, { options, idempotent: true });
111
+ async get(id, query = {}, options) {
112
+ return new Snapshot(this, await this.transport.request("GET", `/v2/snapshots/${encodeURIComponent(id)}`, { query: { ...query }, options, idempotent: true }));
17
113
  }
18
114
  /** Deletes a snapshot, its memory and its disk. */
19
115
  delete(id, options) {
20
- return this.#t.request("DELETE", `/v2/snapshots/${encodeURIComponent(id)}`, { options });
116
+ return this.transport.request("DELETE", `/v2/snapshots/${encodeURIComponent(id)}`, { options });
117
+ }
118
+ /** Changes its lifetime (`deleteAfterSeconds`) or delete protection (`deleteProtection`). A lifetime sent again before its end moves the end to that many seconds from now; 0 takes it off. At its end Runtime deletes it as its delete does: final, and it can't be undone. A lifetime and protection are never set together (409 `delete_protected`). Each field left out stays as it is. */
119
+ update(id, input = {}, options) {
120
+ return this.transport.request("POST", `/v2/snapshots/${encodeURIComponent(id)}:update`, { body: input, options, idempotent: true });
21
121
  }
22
122
  }
@@ -10,16 +10,16 @@ export interface TunnelPeer {
10
10
  publicKey: string;
11
11
  /** Its address in the tunnel's subnet. */
12
12
  address: string;
13
- /** The org's own ranges behind it that sandboxes may reach. */
13
+ /** The org's own ranges behind it that machines may reach. */
14
14
  routes: string[];
15
15
  /** When it was added. */
16
16
  createdAt: string;
17
17
  /** When its key was last replaced. */
18
18
  rotatedAt?: string;
19
19
  }
20
- /** A sandbox's address in a tunnel's subnet. */
20
+ /** A machine's address in a tunnel's subnet. */
21
21
  export interface TunnelMember {
22
- /** The sandbox. */
22
+ /** The machine. */
23
23
  sandboxId: string;
24
24
  /** Its address in the subnet. */
25
25
  address: string;
@@ -38,10 +38,10 @@ export interface TunnelSettings {
38
38
  rate: string;
39
39
  /** The org's machines and routers on it. */
40
40
  peers: TunnelPeer[];
41
- /** Each sandbox's address in the subnet. */
41
+ /** Each machine's address in the subnet. */
42
42
  members: TunnelMember[];
43
43
  }
44
- /** A WireGuard tunnel from the org's own network into its sandboxes. */
44
+ /** A WireGuard tunnel from the org's own network into its machines. */
45
45
  export interface Tunnel extends TunnelSettings {
46
46
  /** Its ID. */
47
47
  id: string;
@@ -59,10 +59,10 @@ export type TunnelListQuery = {
59
59
  /** The most items the page holds. At least 1. At most 200. Default: 50. */
60
60
  limit?: number;
61
61
  };
62
- /** A WireGuard tunnel from your own network into your sandboxes. */
62
+ /** A WireGuard tunnel from your own network into your machines. */
63
63
  export declare class Tunnels {
64
- #private;
64
+ readonly transport: Transport;
65
65
  constructor(transport: Transport);
66
66
  /** Lists the org's WireGuard tunnels. */
67
- list(query?: TunnelListQuery, options?: RequestOptions): Paginated<Tunnel>;
67
+ list(query?: TunnelListQuery & RequestOptions, options?: RequestOptions): Paginated<Tunnel>;
68
68
  }
@@ -1,14 +1,14 @@
1
1
  // Generated by spec-gen from engines/front/crates/spec. Do not edit:
2
2
  // change the spec and run `cargo run -p runtime-front-spec-gen -- write`.
3
3
  import { Paginated } from "./runtime.js";
4
- /** A WireGuard tunnel from your own network into your sandboxes. */
4
+ /** A WireGuard tunnel from your own network into your machines. */
5
5
  export class Tunnels {
6
- #t;
6
+ transport;
7
7
  constructor(transport) {
8
- this.#t = transport;
8
+ this.transport = transport;
9
9
  }
10
10
  /** Lists the org's WireGuard tunnels. */
11
11
  list(query = {}, options) {
12
- return new Paginated((cursor) => this.#t.request("GET", `/v2/tunnels`, { query: { ...query, cursor }, options, idempotent: true }));
12
+ return new Paginated((cursor) => this.transport.request("GET", `/v2/tunnels`, { query: { ...query, cursor }, options, idempotent: true }));
13
13
  }
14
14
  }
@@ -42,7 +42,7 @@ export interface KeyUsage {
42
42
  }
43
43
  /** The spend cap a key's creates are held to, and what is left under it. */
44
44
  export interface KeySpendCap {
45
- /** The most its holder's sandboxes may spend over windowSeconds, in US dollars. */
45
+ /** The most its holder's machines may spend over windowSeconds, in US dollars. */
46
46
  cap: string;
47
47
  /** What they spent over the window, in US dollars, as the cap counts it. */
48
48
  spent: string;
@@ -51,6 +51,49 @@ export interface KeySpendCap {
51
51
  /** The rolling window the cap counts over, in seconds. */
52
52
  windowSeconds: number;
53
53
  }
54
+ /** One product's use in one hour, at the card's prices. */
55
+ export interface UsageHour {
56
+ /** The hour's first moment (UTC). */
57
+ at: string;
58
+ /** What it was used by: the machine's kind (`sandbox`, `app`, `function`, `ci`, ...), what is kept on disk (`disk`, `volume`, `snapshot`, `image`), or `traffic`, what was sent out; `machine` or `storage` when what used it was deleted too long ago to name. */
59
+ product: string;
60
+ /** What it costs on the price card, before any credit, in US dollars. */
61
+ charged: string;
62
+ }
63
+ /** One meter's part of one product's month: a quantity at the card's rate. */
64
+ export interface ProductLine {
65
+ /** What it was used by, as `hours` names it (`sandbox`, `disk`, `traffic`, ...). */
66
+ product: string;
67
+ /** The card's meter (`cpu`, `memory`, `traffic-out`, ...). */
68
+ meter: string;
69
+ /** The meter's name on the card (`CPU`, `Memory`), from `names::METERS`. */
70
+ name: string;
71
+ /** Used this month, in `unit`, as a decimal in text. */
72
+ quantity: string;
73
+ /** What `quantity` counts: `active vCPU-hours`, `GiB-hours`, `GiB-months`, `GB`, ... */
74
+ unit: string;
75
+ /** The card's price for one of `unit`, as the card writes it (`$0.03 per active vCPU-hour`). */
76
+ rate: string;
77
+ /** What it costs on the price card, before any credit, in US dollars. */
78
+ charged: string;
79
+ }
80
+ /** What one key, or what was made with no key, used this month. */
81
+ export interface KeySpend {
82
+ /** The key the machines and storage were made with. Omitted for what was made with no key (signed in to the console), and for `others`. */
83
+ keyId?: string;
84
+ /** The key's name. */
85
+ name?: string;
86
+ /** The person the key acts for, or who made it signed in to the console. */
87
+ accountId?: string;
88
+ /** That person's email address. */
89
+ email?: string;
90
+ /** The agent or CI pipeline the key acts as. */
91
+ agentId?: string;
92
+ /** `key`: one key's. `console`: made signed in, with no key. `others`: keys the caller may not see, together. `unknown`: made by something deleted too long ago to name. */
93
+ source: string;
94
+ /** Charged this month at the card's rates, in US dollars. */
95
+ charged: string;
96
+ }
54
97
  /** What the org has used and has left, at the card's prices. */
55
98
  export interface Usage {
56
99
  /** The organization. */
@@ -77,6 +120,12 @@ export interface Usage {
77
120
  key?: KeyUsage;
78
121
  /** The spend cap this key's creates are held to: the tightest of its own, those of the keys it was made with, and its holder's grants'. Omitted when none holds it. */
79
122
  keySpendCap?: KeySpendCap;
123
+ /** With `by=hour`: what each product used each hour, since the month began or 7 days ago, whichever is earlier, oldest first. Only hours that cost something. */
124
+ hours?: UsageHour[];
125
+ /** With `by=hour`: what each product's month is made of, a line for each meter it used, its quantity at the card's rate. A product's lines sum to its hours since the month began. */
126
+ lines?: ProductLine[];
127
+ /** With `by=key`: what each key's machines and storage used this month, most first. A key the caller may not see is counted under `others`. */
128
+ keys?: KeySpend[];
80
129
  }
81
130
  /** One meter of one machine's, disk's or address's hour, as measured, at the card's price. */
82
131
  export interface UsageLine {
@@ -84,7 +133,7 @@ export interface UsageLine {
84
133
  id: string;
85
134
  /** The resource it was used by: a machine, a disk or an address. */
86
135
  subjectId: string;
87
- /** The ID its product names it by (a sandbox's own ID). */
136
+ /** The ID its product names it by (a machine's own ID). */
88
137
  resourceId: string;
89
138
  /** Its project. */
90
139
  projectId: string;
@@ -128,6 +177,8 @@ export interface UsageExport {
128
177
  export type UsageGetQuery = {
129
178
  /** One key's spend too, by its ID: a key the caller may see (its own holder's, or any for an owner or admin); any other is 404. */
130
179
  key?: string;
180
+ /** Splits too (repeat it for both): `hour`, what each product used each hour (`hours`); `key`, what each key used this month (`keys`). */
181
+ by?: string[];
131
182
  };
132
183
  /** What export takes in its query. */
133
184
  export type UsageExportQuery = {
@@ -137,7 +188,7 @@ export type UsageExportQuery = {
137
188
  until: string;
138
189
  /** What the range selects lines by: `hour`, each line's hour's start, or `settled`, its settledAt (its hour's end), of hours that have ended. Ranges by `settled`, each from the last one's end to no later than `finalThrough`, read every line once, final. Default: "hour". */
139
190
  by?: string;
140
- /** Only the usage of these resources (repeat it for several, up to 100): each line's `resourceId`, such as a sandbox's ID. */
191
+ /** Only the usage of these resources (repeat it for several, up to 100): each line's `resourceId`, such as a machine's ID. */
141
192
  resourceId?: string[];
142
193
  /** Where the page starts: a page's `next`. */
143
194
  cursor?: string;
@@ -146,10 +197,10 @@ export type UsageExportQuery = {
146
197
  };
147
198
  /** What the organization has used and has left at the price card's rates, and every limit it is held to. */
148
199
  export declare class UsageClient {
149
- #private;
200
+ readonly transport: Transport;
150
201
  constructor(transport: Transport);
151
202
  /** Returns the organization's credit and charges (everything credited and spent, what is left, and this month's use and charges by meter), its plan, and every limit it is held to with what it uses of each now; with key, that key's spend. */
152
- get(query?: UsageGetQuery, options?: RequestOptions): Promise<Usage>;
203
+ get(query?: UsageGetQuery & RequestOptions, options?: RequestOptions): Promise<Usage>;
153
204
  /** Returns the organization's measured usage in a time range, of every resource or only those named: each meter of each machine's, disk's or address's hour, what it used and its price at the card, oldest first, paginated. Each line settles at its hour's end and is final once finalThrough reaches it, so closed hours can be read while resources run. */
154
- export(query: UsageExportQuery, options?: RequestOptions): Promise<UsageExport>;
205
+ export(query: UsageExportQuery & RequestOptions, options?: RequestOptions): Promise<UsageExport>;
155
206
  }
@@ -2,16 +2,16 @@
2
2
  // change the spec and run `cargo run -p runtime-front-spec-gen -- write`.
3
3
  /** What the organization has used and has left at the price card's rates, and every limit it is held to. */
4
4
  export class UsageClient {
5
- #t;
5
+ transport;
6
6
  constructor(transport) {
7
- this.#t = transport;
7
+ this.transport = transport;
8
8
  }
9
9
  /** Returns the organization's credit and charges (everything credited and spent, what is left, and this month's use and charges by meter), its plan, and every limit it is held to with what it uses of each now; with key, that key's spend. */
10
10
  get(query = {}, options) {
11
- return this.#t.request("GET", `/v2/usage`, { query: { ...query }, options, idempotent: true });
11
+ return this.transport.request("GET", `/v2/usage`, { query: { ...query }, options, idempotent: true });
12
12
  }
13
13
  /** Returns the organization's measured usage in a time range, of every resource or only those named: each meter of each machine's, disk's or address's hour, what it used and its price at the card, oldest first, paginated. Each line settles at its hour's end and is final once finalThrough reaches it, so closed hours can be read while resources run. */
14
14
  export(query, options) {
15
- return this.#t.request("GET", `/v2/usage/export`, { query: { ...query }, options, idempotent: true });
15
+ return this.transport.request("GET", `/v2/usage/export`, { query: { ...query }, options, idempotent: true });
16
16
  }
17
17
  }
@@ -1,6 +1,7 @@
1
- import type { RequestOptions, Transport } from "./runtime.js";
2
- import { Paginated } from "./runtime.js";
1
+ import type { RequestOptions, ClientOptions } from "./runtime.js";
2
+ import { Paginated, Transport } from "./runtime.js";
3
3
  import type { Stored } from "./sandboxes.js";
4
+ import type { StoredUpdate } from "./snapshots.js";
4
5
  /** A volume to create: an empty disk, formatted ext4 at its first mount. */
5
6
  export interface VolumeCreate {
6
7
  /** Its name, unique in its project among volumes. */
@@ -9,6 +10,10 @@ export interface VolumeCreate {
9
10
  labels?: Record<string, string>;
10
11
  /** Its size in MiB, 64 to 409600 (400 GiB). */
11
12
  sizeMiB: number;
13
+ /** Seconds until Runtime deletes it and what it holds, as its delete does: final, and it can't be undone; one attached to a machine is deleted once that machine ends. 0 or omitted: kept until deleted. At least 0. At most 315360000. */
14
+ deleteAfterSeconds?: number;
15
+ /** Whether its delete is refused (409 `delete_protected`) until an update turns this off; false when omitted. Not with `deleteAfterSeconds`. */
16
+ deleteProtection?: boolean;
12
17
  }
13
18
  /** What list takes in its query. */
14
19
  export type VolumeListQuery = {
@@ -21,16 +26,76 @@ export type VolumeListQuery = {
21
26
  /** The most items the page holds. At least 1. At most 200. Default: 50. */
22
27
  limit?: number;
23
28
  };
29
+ /** What get takes in its query. */
30
+ export type VolumeGetQuery = {
31
+ /** Seconds to wait, at most 60, for its state to differ from `ifState`; it answers once it does, or as it is when the wait ends. At least 0. At most 60. */
32
+ wait?: number;
33
+ /** The state the caller last read, which `wait` waits for it to leave. */
34
+ ifState?: string;
35
+ };
36
+ /** One of volumes: A disk that outlives the machines it is attached to. */
37
+ export declare class Volume {
38
+ #private;
39
+ /** What it was when last read. */
40
+ info: Stored;
41
+ constructor(client: Volumes, info: Stored);
42
+ /** Its id. */
43
+ get id(): string;
44
+ /** Its kind: `snapshot`, `image` or `volume`. */
45
+ get object(): "snapshot" | "image" | "volume" | (string & {});
46
+ /** Its name, unique in its project among its kind. */
47
+ get name(): string | undefined;
48
+ /** Where it is. */
49
+ get state(): "making" | "ready" | "failed" | "deleted" | (string & {});
50
+ /** Its labels. */
51
+ get labels(): Record<string, string>;
52
+ /** What it was made to hold, in bytes. */
53
+ get sizeBytes(): number;
54
+ /** What it holds now, in bytes. */
55
+ get storedBytes(): number;
56
+ /** What it was made from (a snapshot's machine, an image's base), if anything. */
57
+ get parentId(): string | undefined;
58
+ /** The machine it is attached to now, if any. */
59
+ get attachedTo(): string | undefined;
60
+ /** When it was made. */
61
+ get createdAt(): string | undefined;
62
+ /** An image's version of its name: each build or keep of a name is its next. */
63
+ get version(): number | undefined;
64
+ /** An image's tags, each `name:tag`. */
65
+ get tags(): string[] | undefined;
66
+ /** Why an image's build failed. */
67
+ get error(): string | undefined;
68
+ /** When it was deleted: a delete's answer, its state `deleted`. */
69
+ get deletedAt(): string | undefined;
70
+ /** When Runtime deletes it (`deleteAfterSeconds`), finally: it can't be undone, as its delete can't; none: kept until deleted. */
71
+ get deleteAt(): string | undefined;
72
+ /** Once `deleteAt` has passed, what its delete waits for: the App that boots this image, or the machine this volume is attached to, by its ID. It is deleted as soon as that one no longer does. */
73
+ get deleteWaitsFor(): string | undefined;
74
+ /** Whether its delete is refused (409 `delete_protected`) until an update turns this off. */
75
+ get deleteProtection(): boolean | undefined;
76
+ /** Makes one and returns it, as `new Runtime().volumes.create()` does, with a client of its own: `RUNTIME_API_KEY`, or the key `options` names. */
77
+ static create(input: VolumeCreate, options?: ClientOptions & RequestOptions): Promise<Volume>;
78
+ /** Returns a volume. */
79
+ refresh(query?: VolumeGetQuery & RequestOptions, options?: RequestOptions): Promise<this>;
80
+ /** Deletes a volume and what it holds. One attached to a machine is refused: delete the machine first. */
81
+ delete(options?: RequestOptions): Promise<Stored>;
82
+ /** Changes its lifetime (`deleteAfterSeconds`) or delete protection (`deleteProtection`). A lifetime sent again before its end moves the end to that many seconds from now; 0 takes it off. At its end Runtime deletes it as its delete does: final, and it can't be undone. A lifetime and protection are never set together (409 `delete_protected`). Each field left out stays as it is. */
83
+ update(input?: StoredUpdate, options?: RequestOptions): Promise<this>;
84
+ /** Deletes it when the `await using` block that holds it ends. */
85
+ [Symbol.asyncDispose](): Promise<void>;
86
+ }
24
87
  /** A disk that outlives the machines it is attached to. */
25
88
  export declare class Volumes {
26
- #private;
89
+ readonly transport: Transport;
27
90
  constructor(transport: Transport);
28
91
  /** Creates an empty volume. Asked again with the same Idempotency-Key, it returns the same one. */
29
- create(input: VolumeCreate, options?: RequestOptions): Promise<Stored>;
92
+ create(input: VolumeCreate, options?: RequestOptions): Promise<Volume>;
30
93
  /** Lists the project's volumes, newest first. */
31
- list(query?: VolumeListQuery, options?: RequestOptions): Paginated<Stored>;
94
+ list(query?: VolumeListQuery & RequestOptions, options?: RequestOptions): Paginated<Stored>;
32
95
  /** Returns a volume. */
33
- get(id: string, options?: RequestOptions): Promise<Stored>;
34
- /** Deletes a volume and what it holds. One attached to a sandbox is refused: delete the sandbox first. */
96
+ get(id: string, query?: VolumeGetQuery & RequestOptions, options?: RequestOptions): Promise<Volume>;
97
+ /** Deletes a volume and what it holds. One attached to a machine is refused: delete the machine first. */
35
98
  delete(id: string, options?: RequestOptions): Promise<Stored>;
99
+ /** Changes its lifetime (`deleteAfterSeconds`) or delete protection (`deleteProtection`). A lifetime sent again before its end moves the end to that many seconds from now; 0 takes it off. At its end Runtime deletes it as its delete does: final, and it can't be undone. A lifetime and protection are never set together (409 `delete_protected`). Each field left out stays as it is. */
100
+ update(id: string, input?: StoredUpdate, options?: RequestOptions): Promise<Stored>;
36
101
  }