@buddy-works/sandbox-sdk 0.1.6-rc.0 → 0.1.6-rc.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.
- package/README.md +51 -0
- package/dist/index.d.mts +440 -1
- package/dist/index.mjs +539 -102
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -95,6 +95,57 @@ await Sandbox.create({
|
|
|
95
95
|
});
|
|
96
96
|
```
|
|
97
97
|
|
|
98
|
+
## Updating a sandbox
|
|
99
|
+
|
|
100
|
+
Use `sandbox.update()` to change configuration after creation - `timeout`, `apps`, `endpoints`, `variables`, `tags`, etc. The internal state is updated with the API's response.
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
const sandbox = await Sandbox.getByIdentifier("my-sandbox");
|
|
104
|
+
|
|
105
|
+
await sandbox.update({
|
|
106
|
+
timeout: 1200,
|
|
107
|
+
tags: ["staging", "feature-x"],
|
|
108
|
+
});
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Snapshots
|
|
112
|
+
|
|
113
|
+
Take point-in-time snapshots of a sandbox and restore from them later. Each snapshot is returned as a `Snapshot` instance with its own methods.
|
|
114
|
+
|
|
115
|
+
```typescript
|
|
116
|
+
const sandbox = await Sandbox.getByIdentifier("my-sandbox");
|
|
117
|
+
|
|
118
|
+
// Create a snapshot. Returns immediately with status "CREATING".
|
|
119
|
+
const snapshot = await sandbox.createSnapshot({ name: "before-deploy" });
|
|
120
|
+
|
|
121
|
+
// Wait until the snapshot is "CREATED" before using it.
|
|
122
|
+
await snapshot.waitUntilReady();
|
|
123
|
+
|
|
124
|
+
// Create a new sandbox from the snapshot.
|
|
125
|
+
const restored = await Sandbox.createFromSnapshot(snapshot.id, {
|
|
126
|
+
name: "restored-sandbox",
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
// List all snapshots for this sandbox.
|
|
130
|
+
const snapshots = await sandbox.listSnapshots();
|
|
131
|
+
|
|
132
|
+
// Delete a snapshot.
|
|
133
|
+
await snapshot.delete();
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
If you already have a snapshot ID from elsewhere (e.g. persisted in your own storage), get the entity directly:
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
const snapshot = await Sandbox.getSnapshotById(sandboxId, snapshotId);
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Equivalent convenience methods on `Sandbox` are available when you only have an ID and don't want to fetch the `Snapshot` first:
|
|
143
|
+
|
|
144
|
+
```typescript
|
|
145
|
+
await sandbox.waitForSnapshotReady(snapshotId);
|
|
146
|
+
await sandbox.deleteSnapshot(snapshotId);
|
|
147
|
+
```
|
|
148
|
+
|
|
98
149
|
## Regions
|
|
99
150
|
|
|
100
151
|
Configure the API region:
|
package/dist/index.d.mts
CHANGED
|
@@ -531,6 +531,17 @@ type SandboxContentItem = {
|
|
|
531
531
|
*/
|
|
532
532
|
size?: bigint;
|
|
533
533
|
};
|
|
534
|
+
type SandboxCommandsView = {
|
|
535
|
+
/**
|
|
536
|
+
* API endpoint to GET this object
|
|
537
|
+
*/
|
|
538
|
+
readonly url?: string;
|
|
539
|
+
/**
|
|
540
|
+
* Web URL to view this object in Buddy.works
|
|
541
|
+
*/
|
|
542
|
+
readonly html_url?: string;
|
|
543
|
+
commands?: Array<SandboxCommandView>;
|
|
544
|
+
};
|
|
534
545
|
type SandboxCommandView = {
|
|
535
546
|
/**
|
|
536
547
|
* API endpoint to GET this object
|
|
@@ -601,6 +612,50 @@ type SandboxAppLogsView = {
|
|
|
601
612
|
*/
|
|
602
613
|
logs?: Array<string>;
|
|
603
614
|
};
|
|
615
|
+
type SnapshotsView = {
|
|
616
|
+
/**
|
|
617
|
+
* API endpoint to GET this object
|
|
618
|
+
*/
|
|
619
|
+
readonly url?: string;
|
|
620
|
+
/**
|
|
621
|
+
* Web URL to view this object in Buddy.works
|
|
622
|
+
*/
|
|
623
|
+
readonly html_url?: string;
|
|
624
|
+
/**
|
|
625
|
+
* Collection of snapshots
|
|
626
|
+
*/
|
|
627
|
+
snapshots?: Array<ShortSnapshotView>;
|
|
628
|
+
};
|
|
629
|
+
type ShortSnapshotView = {
|
|
630
|
+
/**
|
|
631
|
+
* API endpoint to GET this object
|
|
632
|
+
*/
|
|
633
|
+
readonly url?: string;
|
|
634
|
+
/**
|
|
635
|
+
* Web URL to view this object in Buddy.works
|
|
636
|
+
*/
|
|
637
|
+
readonly html_url?: string;
|
|
638
|
+
/**
|
|
639
|
+
* The ID of the snapshot
|
|
640
|
+
*/
|
|
641
|
+
id?: string;
|
|
642
|
+
/**
|
|
643
|
+
* Snapshot name
|
|
644
|
+
*/
|
|
645
|
+
name?: string;
|
|
646
|
+
/**
|
|
647
|
+
* Snapshot size in GB
|
|
648
|
+
*/
|
|
649
|
+
size?: number;
|
|
650
|
+
/**
|
|
651
|
+
* Snapshot status
|
|
652
|
+
*/
|
|
653
|
+
status?: "CREATING" | "CREATED" | "DELETING" | "FAILED";
|
|
654
|
+
/**
|
|
655
|
+
* Snapshot creation date
|
|
656
|
+
*/
|
|
657
|
+
create_date?: Date;
|
|
658
|
+
};
|
|
604
659
|
type ExecuteSandboxCommandRequest = {
|
|
605
660
|
/**
|
|
606
661
|
* Command to execute in the sandbox
|
|
@@ -611,6 +666,43 @@ type ExecuteSandboxCommandRequest = {
|
|
|
611
666
|
*/
|
|
612
667
|
runtime?: "BASH" | "JAVASCRIPT" | "TYPESCRIPT" | "PYTHON";
|
|
613
668
|
};
|
|
669
|
+
type AddSnapshotRequest = {
|
|
670
|
+
/**
|
|
671
|
+
* Snapshot name
|
|
672
|
+
*/
|
|
673
|
+
name?: string;
|
|
674
|
+
};
|
|
675
|
+
type SnapshotView = {
|
|
676
|
+
/**
|
|
677
|
+
* API endpoint to GET this object
|
|
678
|
+
*/
|
|
679
|
+
readonly url?: string;
|
|
680
|
+
/**
|
|
681
|
+
* Web URL to view this object in Buddy.works
|
|
682
|
+
*/
|
|
683
|
+
readonly html_url?: string;
|
|
684
|
+
/**
|
|
685
|
+
* The ID of the snapshot
|
|
686
|
+
*/
|
|
687
|
+
id?: string;
|
|
688
|
+
/**
|
|
689
|
+
* Snapshot name
|
|
690
|
+
*/
|
|
691
|
+
name?: string;
|
|
692
|
+
/**
|
|
693
|
+
* Snapshot size in GB
|
|
694
|
+
*/
|
|
695
|
+
size?: number;
|
|
696
|
+
/**
|
|
697
|
+
* Snapshot status
|
|
698
|
+
*/
|
|
699
|
+
status?: "CREATING" | "CREATED" | "DELETING" | "FAILED";
|
|
700
|
+
/**
|
|
701
|
+
* Snapshot creation date
|
|
702
|
+
*/
|
|
703
|
+
create_date?: Date;
|
|
704
|
+
created_by?: MemberView;
|
|
705
|
+
};
|
|
614
706
|
type EnvironmentVariableView = {
|
|
615
707
|
/**
|
|
616
708
|
* The ID of the variable
|
|
@@ -795,6 +887,53 @@ type SandboxResponse = {
|
|
|
795
887
|
*/
|
|
796
888
|
variables?: Array<EnvironmentVariableView>;
|
|
797
889
|
};
|
|
890
|
+
type UpdateSandboxRequestWritable = {
|
|
891
|
+
/**
|
|
892
|
+
* The name of the sandbox
|
|
893
|
+
*/
|
|
894
|
+
name?: string;
|
|
895
|
+
/**
|
|
896
|
+
* A human-readable ID. Alphanumeric characters, underscores, and hyphens (hyphens cannot appear at the start or end).
|
|
897
|
+
*/
|
|
898
|
+
identifier?: string;
|
|
899
|
+
/**
|
|
900
|
+
* The resource configuration of the sandbox (CPU x RAM)
|
|
901
|
+
*/
|
|
902
|
+
resources?: "1x2" | "2x4" | "3x6" | "4x8" | "5x10" | "6x12" | "7x14" | "8x16" | "9x18" | "10x20" | "11x22" | "12x24" | "CUSTOM";
|
|
903
|
+
/**
|
|
904
|
+
* The commands to run during first boot of the sandbox
|
|
905
|
+
*/
|
|
906
|
+
first_boot_commands?: string;
|
|
907
|
+
/**
|
|
908
|
+
* The application directory of the sandbox
|
|
909
|
+
*/
|
|
910
|
+
app_dir?: string;
|
|
911
|
+
/**
|
|
912
|
+
* The list of apps (run commands) for the sandbox
|
|
913
|
+
*/
|
|
914
|
+
apps?: Array<SandboxAppView>;
|
|
915
|
+
/**
|
|
916
|
+
* The list of items (repositories and artifacts) to fetch into the sandbox
|
|
917
|
+
*/
|
|
918
|
+
fetch?: Array<SandboxFetchView>;
|
|
919
|
+
/**
|
|
920
|
+
* The timeout in seconds after which the sandbox will be automatically stopped
|
|
921
|
+
*/
|
|
922
|
+
timeout?: number;
|
|
923
|
+
/**
|
|
924
|
+
* The list of tags associated with the sandbox
|
|
925
|
+
*/
|
|
926
|
+
tags?: Array<string>;
|
|
927
|
+
/**
|
|
928
|
+
* The tunnel endpoints of the sandbox
|
|
929
|
+
*/
|
|
930
|
+
endpoints?: Array<TunnelViewWritable>;
|
|
931
|
+
/**
|
|
932
|
+
* The environment variables of the sandbox
|
|
933
|
+
*/
|
|
934
|
+
variables?: Array<AddVariableInObjectRequestWritable>;
|
|
935
|
+
permissions?: PermissionsView;
|
|
936
|
+
};
|
|
798
937
|
/**
|
|
799
938
|
* The environment variables of the sandbox
|
|
800
939
|
*/
|
|
@@ -1209,6 +1348,21 @@ type GetSandboxResponses = {
|
|
|
1209
1348
|
200: SandboxResponse;
|
|
1210
1349
|
};
|
|
1211
1350
|
type GetSandboxResponse = GetSandboxResponses[keyof GetSandboxResponses];
|
|
1351
|
+
type UpdateSandboxData = {
|
|
1352
|
+
body?: UpdateSandboxRequestWritable;
|
|
1353
|
+
path: {
|
|
1354
|
+
/**
|
|
1355
|
+
* The human-readable ID of the workspace
|
|
1356
|
+
*/
|
|
1357
|
+
workspace_domain: string;
|
|
1358
|
+
/**
|
|
1359
|
+
* The ID of the sandbox
|
|
1360
|
+
*/
|
|
1361
|
+
id: string;
|
|
1362
|
+
};
|
|
1363
|
+
query?: never;
|
|
1364
|
+
url: "/workspaces/{workspace_domain}/sandboxes/{id}";
|
|
1365
|
+
};
|
|
1212
1366
|
type GetSandboxAppLogsByIdData = {
|
|
1213
1367
|
body?: never;
|
|
1214
1368
|
path: {
|
|
@@ -1275,6 +1429,21 @@ type StopSandboxAppData = {
|
|
|
1275
1429
|
query?: never;
|
|
1276
1430
|
url: "/workspaces/{workspace_domain}/sandboxes/{sandbox_id}/apps/{app_id}/stop";
|
|
1277
1431
|
};
|
|
1432
|
+
type GetSandboxCommandsData = {
|
|
1433
|
+
body?: never;
|
|
1434
|
+
path: {
|
|
1435
|
+
/**
|
|
1436
|
+
* The human-readable ID of the workspace
|
|
1437
|
+
*/
|
|
1438
|
+
workspace_domain: string;
|
|
1439
|
+
/**
|
|
1440
|
+
* The ID of the sandbox
|
|
1441
|
+
*/
|
|
1442
|
+
sandbox_id: string;
|
|
1443
|
+
};
|
|
1444
|
+
query?: never;
|
|
1445
|
+
url: "/workspaces/{workspace_domain}/sandboxes/{sandbox_id}/commands";
|
|
1446
|
+
};
|
|
1278
1447
|
type ExecuteSandboxCommandData = {
|
|
1279
1448
|
body?: ExecuteSandboxCommandRequest;
|
|
1280
1449
|
path: {
|
|
@@ -1456,6 +1625,74 @@ type RestartSandboxData = {
|
|
|
1456
1625
|
query?: never;
|
|
1457
1626
|
url: "/workspaces/{workspace_domain}/sandboxes/{sandbox_id}/restart";
|
|
1458
1627
|
};
|
|
1628
|
+
type GetSandboxSnapshotsData = {
|
|
1629
|
+
body?: never;
|
|
1630
|
+
path: {
|
|
1631
|
+
/**
|
|
1632
|
+
* The human-readable ID of the workspace
|
|
1633
|
+
*/
|
|
1634
|
+
workspace_domain: string;
|
|
1635
|
+
/**
|
|
1636
|
+
* The ID of the sandbox
|
|
1637
|
+
*/
|
|
1638
|
+
sandbox_id: string;
|
|
1639
|
+
};
|
|
1640
|
+
query?: never;
|
|
1641
|
+
url: "/workspaces/{workspace_domain}/sandboxes/{sandbox_id}/snapshots";
|
|
1642
|
+
};
|
|
1643
|
+
type AddSandboxSnapshotData = {
|
|
1644
|
+
body?: AddSnapshotRequest;
|
|
1645
|
+
path: {
|
|
1646
|
+
/**
|
|
1647
|
+
* The human-readable ID of the workspace
|
|
1648
|
+
*/
|
|
1649
|
+
workspace_domain: string;
|
|
1650
|
+
/**
|
|
1651
|
+
* The ID of the sandbox
|
|
1652
|
+
*/
|
|
1653
|
+
sandbox_id: string;
|
|
1654
|
+
};
|
|
1655
|
+
query?: never;
|
|
1656
|
+
url: "/workspaces/{workspace_domain}/sandboxes/{sandbox_id}/snapshots";
|
|
1657
|
+
};
|
|
1658
|
+
type DeleteSandboxSnapshotData = {
|
|
1659
|
+
body?: never;
|
|
1660
|
+
path: {
|
|
1661
|
+
/**
|
|
1662
|
+
* The human-readable ID of the workspace
|
|
1663
|
+
*/
|
|
1664
|
+
workspace_domain: string;
|
|
1665
|
+
/**
|
|
1666
|
+
* The ID of the sandbox
|
|
1667
|
+
*/
|
|
1668
|
+
sandbox_id: string;
|
|
1669
|
+
/**
|
|
1670
|
+
* The ID of the snapshot
|
|
1671
|
+
*/
|
|
1672
|
+
id: string;
|
|
1673
|
+
};
|
|
1674
|
+
query?: never;
|
|
1675
|
+
url: "/workspaces/{workspace_domain}/sandboxes/{sandbox_id}/snapshots/{id}";
|
|
1676
|
+
};
|
|
1677
|
+
type GetSandboxSnapshotData = {
|
|
1678
|
+
body?: never;
|
|
1679
|
+
path: {
|
|
1680
|
+
/**
|
|
1681
|
+
* The human-readable ID of the workspace
|
|
1682
|
+
*/
|
|
1683
|
+
workspace_domain: string;
|
|
1684
|
+
/**
|
|
1685
|
+
* The ID of the sandbox
|
|
1686
|
+
*/
|
|
1687
|
+
sandbox_id: string;
|
|
1688
|
+
/**
|
|
1689
|
+
* The ID of the snapshot
|
|
1690
|
+
*/
|
|
1691
|
+
id: string;
|
|
1692
|
+
};
|
|
1693
|
+
query?: never;
|
|
1694
|
+
url: "/workspaces/{workspace_domain}/sandboxes/{sandbox_id}/snapshots/{id}";
|
|
1695
|
+
};
|
|
1459
1696
|
type StartSandboxData = {
|
|
1460
1697
|
body?: never;
|
|
1461
1698
|
path: {
|
|
@@ -1486,6 +1723,37 @@ type StopSandboxData = {
|
|
|
1486
1723
|
query?: never;
|
|
1487
1724
|
url: "/workspaces/{workspace_domain}/sandboxes/{sandbox_id}/stop";
|
|
1488
1725
|
};
|
|
1726
|
+
type GetProjectSnapshotsData = {
|
|
1727
|
+
body?: never;
|
|
1728
|
+
path: {
|
|
1729
|
+
/**
|
|
1730
|
+
* The human-readable ID of the workspace
|
|
1731
|
+
*/
|
|
1732
|
+
workspace_domain: string;
|
|
1733
|
+
};
|
|
1734
|
+
query: {
|
|
1735
|
+
/**
|
|
1736
|
+
* The human-readable ID of the project to filter sandboxes
|
|
1737
|
+
*/
|
|
1738
|
+
project_name: string;
|
|
1739
|
+
};
|
|
1740
|
+
url: "/workspaces/{workspace_domain}/sandboxes/snapshots";
|
|
1741
|
+
};
|
|
1742
|
+
type DeleteSnapshotData = {
|
|
1743
|
+
body?: never;
|
|
1744
|
+
path: {
|
|
1745
|
+
/**
|
|
1746
|
+
* The human-readable ID of the workspace
|
|
1747
|
+
*/
|
|
1748
|
+
workspace_domain: string;
|
|
1749
|
+
/**
|
|
1750
|
+
* The ID of the snapshot
|
|
1751
|
+
*/
|
|
1752
|
+
id: string;
|
|
1753
|
+
};
|
|
1754
|
+
query?: never;
|
|
1755
|
+
url: "/workspaces/{workspace_domain}/sandboxes/snapshots/{id}";
|
|
1756
|
+
};
|
|
1489
1757
|
//#endregion
|
|
1490
1758
|
//#region src/core/http-client.d.ts
|
|
1491
1759
|
/** Configuration options for creating an HttpClient instance */
|
|
@@ -1533,6 +1801,8 @@ declare class HttpClient {
|
|
|
1533
1801
|
post<T = unknown>(url: string, data?: unknown, config?: RequestConfig): Promise<HttpResponse<T>>;
|
|
1534
1802
|
/** Perform a DELETE request */
|
|
1535
1803
|
delete<T = unknown>(url: string, config?: RequestConfig): Promise<HttpResponse<T>>;
|
|
1804
|
+
/** Perform a PATCH request with optional body data */
|
|
1805
|
+
patch<T = unknown>(url: string, data?: unknown, config?: RequestConfig): Promise<HttpResponse<T>>;
|
|
1536
1806
|
/** Set the Bearer token for authenticated requests */
|
|
1537
1807
|
setAuthToken(token: string): void;
|
|
1538
1808
|
}
|
|
@@ -1584,12 +1854,31 @@ declare class BuddyApiClient extends HttpClient {
|
|
|
1584
1854
|
readonly project_name: BuddyApiConfig["project_name"];
|
|
1585
1855
|
/** Create a new sandbox */
|
|
1586
1856
|
addSandbox<const Data$1 extends AddSandboxData>(data: ClientData<Data$1>): Promise<SandboxResponse>;
|
|
1857
|
+
/** Update an existing sandbox's configuration (timeout, apps, endpoints, etc.) */
|
|
1858
|
+
updateSandbox<const Data$1 extends UpdateSandboxData>(data: ClientData<Data$1>): Promise<SandboxResponse>;
|
|
1859
|
+
/** List snapshots for a sandbox */
|
|
1860
|
+
getSandboxSnapshots<const Data$1 extends GetSandboxSnapshotsData>(data: ClientData<Data$1>): Promise<SnapshotsView>;
|
|
1861
|
+
/** List all snapshots in the project (across all sandboxes, including orphans) */
|
|
1862
|
+
getProjectSnapshots<const Data$1 extends GetProjectSnapshotsData>(data: ClientData<Data$1>): Promise<SnapshotsView>;
|
|
1863
|
+
/** Create a snapshot of a sandbox */
|
|
1864
|
+
addSandboxSnapshot<const Data$1 extends AddSandboxSnapshotData>(data: ClientData<Data$1>): Promise<SnapshotView>;
|
|
1865
|
+
/** Get a single sandbox snapshot by ID */
|
|
1866
|
+
getSandboxSnapshot<const Data$1 extends GetSandboxSnapshotData>(data: ClientData<Data$1>): Promise<SnapshotView>;
|
|
1867
|
+
/** Delete a sandbox snapshot by ID */
|
|
1868
|
+
deleteSandboxSnapshot<const Data$1 extends DeleteSandboxSnapshotData>(data: ClientData<Data$1>): Promise<void>;
|
|
1869
|
+
/**
|
|
1870
|
+
* Delete a snapshot by ID at the project level (works for snapshots whose
|
|
1871
|
+
* parent sandbox has been deleted).
|
|
1872
|
+
*/
|
|
1873
|
+
deleteSnapshot<const Data$1 extends DeleteSnapshotData>(data: ClientData<Data$1>): Promise<void>;
|
|
1587
1874
|
/** Get a specific sandbox by its ID */
|
|
1588
1875
|
getSandboxById<const Data$1 extends GetSandboxData>(data: ClientData<Data$1>): Promise<SandboxResponse>;
|
|
1589
1876
|
/** Get a specific sandbox by its ID */
|
|
1590
1877
|
getIdentifiers<const Data$1 extends GetIdentifiersData>(data: ClientData<Data$1>): Promise<IdsView>;
|
|
1591
1878
|
/** Execute a command in a sandbox */
|
|
1592
1879
|
executeCommand<const Data$1 extends ExecuteSandboxCommandData>(data: ClientData<Data$1>): Promise<SandboxCommandView>;
|
|
1880
|
+
/** List all command executions in a sandbox (history) */
|
|
1881
|
+
getSandboxCommands<const Data$1 extends GetSandboxCommandsData>(data: ClientData<Data$1>): Promise<SandboxCommandsView>;
|
|
1593
1882
|
/** Get a specific command execution details */
|
|
1594
1883
|
getCommandDetails<const Data$1 extends GetSandboxCommandData>(data: ClientData<Data$1>): Promise<SandboxCommandView>;
|
|
1595
1884
|
/** Terminate a running command in a sandbox */
|
|
@@ -1799,6 +2088,41 @@ declare class FileSystem {
|
|
|
1799
2088
|
uploadFile(source: Buffer | string, remotePath: string): Promise<void>;
|
|
1800
2089
|
}
|
|
1801
2090
|
//#endregion
|
|
2091
|
+
//#region src/entity/snapshot.d.ts
|
|
2092
|
+
declare class Snapshot {
|
|
2093
|
+
#private;
|
|
2094
|
+
/** The raw snapshot response data from the API */
|
|
2095
|
+
get data(): SnapshotView;
|
|
2096
|
+
/** The snapshot ID, throws if not present */
|
|
2097
|
+
get id(): NonNullable<SnapshotView["id"]>;
|
|
2098
|
+
/** ID of the sandbox this snapshot belongs to */
|
|
2099
|
+
get sandboxId(): string;
|
|
2100
|
+
/**
|
|
2101
|
+
* Refresh the snapshot data from the API
|
|
2102
|
+
* Updates the internal state with the latest snapshot information
|
|
2103
|
+
*/
|
|
2104
|
+
refresh(): Promise<void>;
|
|
2105
|
+
/**
|
|
2106
|
+
* Wait until the snapshot reaches CREATED state.
|
|
2107
|
+
*
|
|
2108
|
+
* `sandbox.createSnapshot()` returns immediately with `status: "CREATING"`.
|
|
2109
|
+
* The snapshot cannot be restored until it transitions to `"CREATED"`.
|
|
2110
|
+
*
|
|
2111
|
+
* @param pollIntervalMs - How often to check the status (default: 2000ms (2s))
|
|
2112
|
+
* @param maxWaitMs - Maximum time to wait before timing out (default: 180000ms (180s))
|
|
2113
|
+
*/
|
|
2114
|
+
waitUntilReady(pollIntervalMs?: number, maxWaitMs?: number): Promise<void>;
|
|
2115
|
+
/**
|
|
2116
|
+
* Delete this snapshot permanently
|
|
2117
|
+
*/
|
|
2118
|
+
delete(): Promise<void>;
|
|
2119
|
+
private constructor();
|
|
2120
|
+
/**
|
|
2121
|
+
* @internal Factory used by the Sandbox class to construct Snapshot instances.
|
|
2122
|
+
*/
|
|
2123
|
+
static _build(data: SnapshotView, client: BuddyApiClient, sandboxId: string): Snapshot;
|
|
2124
|
+
}
|
|
2125
|
+
//#endregion
|
|
1802
2126
|
//#region src/entity/sandbox.d.ts
|
|
1803
2127
|
/**
|
|
1804
2128
|
* Configuration for creating a new sandbox
|
|
@@ -1821,6 +2145,20 @@ interface ListSandboxesConfig {
|
|
|
1821
2145
|
/** Optional connection configuration to override defaults */
|
|
1822
2146
|
connection?: ConnectionConfig;
|
|
1823
2147
|
}
|
|
2148
|
+
/**
|
|
2149
|
+
* Configuration for creating a sandbox from an existing snapshot
|
|
2150
|
+
*/
|
|
2151
|
+
interface CreateFromSnapshotConfig extends Partial<Omit<CreateFromSnapshotRequestWritable, "snapshot_id">> {
|
|
2152
|
+
/** Optional connection configuration to override defaults */
|
|
2153
|
+
connection?: ConnectionConfig;
|
|
2154
|
+
}
|
|
2155
|
+
/**
|
|
2156
|
+
* Configuration for cloning an existing sandbox
|
|
2157
|
+
*/
|
|
2158
|
+
interface CloneSandboxConfig extends Partial<Omit<CloneSandboxRequest, "source_sandbox_id">> {
|
|
2159
|
+
/** Optional connection configuration to override defaults */
|
|
2160
|
+
connection?: ConnectionConfig;
|
|
2161
|
+
}
|
|
1824
2162
|
/**
|
|
1825
2163
|
* Options for running a command in the sandbox
|
|
1826
2164
|
*/
|
|
@@ -1849,6 +2187,25 @@ declare class Sandbox {
|
|
|
1849
2187
|
* @returns A ready-to-use Sandbox instance
|
|
1850
2188
|
*/
|
|
1851
2189
|
static create(config?: CreateSandboxConfig): Promise<Sandbox>;
|
|
2190
|
+
/**
|
|
2191
|
+
* Create a new sandbox from an existing snapshot
|
|
2192
|
+
*
|
|
2193
|
+
* @param snapshotId - ID of the snapshot to create from
|
|
2194
|
+
* @param config - Optional sandbox configuration overrides (name, identifier, …)
|
|
2195
|
+
* @returns A ready-to-use Sandbox instance restored from the snapshot
|
|
2196
|
+
*/
|
|
2197
|
+
static createFromSnapshot(snapshotId: string, config?: CreateFromSnapshotConfig): Promise<Sandbox>;
|
|
2198
|
+
/**
|
|
2199
|
+
* Clone an existing sandbox by ID into a new one.
|
|
2200
|
+
*
|
|
2201
|
+
* Differs from `createFromSnapshot` in that it copies the current state of
|
|
2202
|
+
* a live sandbox directly, without going through a snapshot.
|
|
2203
|
+
*
|
|
2204
|
+
* @param sourceSandboxId - ID of the sandbox to clone
|
|
2205
|
+
* @param config - Optional sandbox configuration overrides (name, identifier)
|
|
2206
|
+
* @returns A ready-to-use Sandbox instance cloned from the source
|
|
2207
|
+
*/
|
|
2208
|
+
static clone(sourceSandboxId: string, config?: CloneSandboxConfig): Promise<Sandbox>;
|
|
1852
2209
|
/**
|
|
1853
2210
|
* Get an existing sandbox by its identifier
|
|
1854
2211
|
* @param identifier - Identifier of the sandbox to retrieve
|
|
@@ -1874,11 +2231,93 @@ declare class Sandbox {
|
|
|
1874
2231
|
* @returns Array of simplified sandbox objects
|
|
1875
2232
|
*/
|
|
1876
2233
|
static list(config?: ListSandboxesConfig): Promise<SandboxIdView[]>;
|
|
2234
|
+
/**
|
|
2235
|
+
* Get a single snapshot by its sandbox + snapshot ID without first fetching
|
|
2236
|
+
* the parent sandbox. Useful when you already have both IDs (e.g. from a
|
|
2237
|
+
* persisted reference).
|
|
2238
|
+
*
|
|
2239
|
+
* @param sandboxId - ID of the sandbox the snapshot belongs to
|
|
2240
|
+
* @param snapshotId - ID of the snapshot to fetch
|
|
2241
|
+
* @param config - Optional configuration including connection settings
|
|
2242
|
+
*/
|
|
2243
|
+
static getSnapshotById(sandboxId: string, snapshotId: NonNullable<SnapshotView["id"]>, config?: GetSandboxConfig): Promise<Snapshot>;
|
|
1877
2244
|
/**
|
|
1878
2245
|
* Execute a command in the sandbox
|
|
1879
2246
|
* @returns Command instance (call wait() for blocking execution)
|
|
1880
2247
|
*/
|
|
1881
2248
|
runCommand(options: RunCommandOptions): Promise<Command>;
|
|
2249
|
+
/**
|
|
2250
|
+
* List all command executions in this sandbox (history).
|
|
2251
|
+
*
|
|
2252
|
+
* Returns one `Command` instance per past execution. Useful for inspecting
|
|
2253
|
+
* previous runs, fetching their logs, or killing still-running detached
|
|
2254
|
+
* commands.
|
|
2255
|
+
*/
|
|
2256
|
+
listCommands(): Promise<Command[]>;
|
|
2257
|
+
/**
|
|
2258
|
+
* Update the sandbox configuration in place
|
|
2259
|
+
*
|
|
2260
|
+
* Accepts a partial update of any mutable sandbox field (`timeout`, `apps`,
|
|
2261
|
+
* `endpoints`, `variables`, `tags`, `resources`, …). Updates the internal
|
|
2262
|
+
* state with the API's response.
|
|
2263
|
+
*
|
|
2264
|
+
* @remarks Changing `first_boot_commands` leaves the sandbox in
|
|
2265
|
+
* `setup_status: STALE` — the new commands only apply on first boot, so
|
|
2266
|
+
* the sandbox must be recreated to take effect.
|
|
2267
|
+
*/
|
|
2268
|
+
update(config: Partial<UpdateSandboxRequestWritable>): Promise<void>;
|
|
2269
|
+
/**
|
|
2270
|
+
* Create a snapshot of the current sandbox
|
|
2271
|
+
*
|
|
2272
|
+
* Returns immediately with a snapshot whose `status` is `"CREATING"`. Call
|
|
2273
|
+
* `snapshot.waitUntilReady()` (or `sandbox.waitForSnapshotReady(snapshot.id)`)
|
|
2274
|
+
* before restoring from it.
|
|
2275
|
+
*
|
|
2276
|
+
* @param config - Optional snapshot configuration (name, description, …)
|
|
2277
|
+
*/
|
|
2278
|
+
createSnapshot(config?: AddSnapshotRequest): Promise<Snapshot>;
|
|
2279
|
+
/**
|
|
2280
|
+
* List all snapshots in the project across every sandbox, including
|
|
2281
|
+
* snapshots whose parent sandbox has been deleted.
|
|
2282
|
+
*
|
|
2283
|
+
* Use `Sandbox.createFromSnapshot(snapshot.id, …)` to provision a new
|
|
2284
|
+
* sandbox from any item in the list.
|
|
2285
|
+
*
|
|
2286
|
+
* @param config - Optional configuration including connection settings
|
|
2287
|
+
*/
|
|
2288
|
+
static listSnapshots(config?: ListSandboxesConfig): Promise<ShortSnapshotView[]>;
|
|
2289
|
+
/**
|
|
2290
|
+
* List snapshots of this sandbox
|
|
2291
|
+
*/
|
|
2292
|
+
listSnapshots(): Promise<Snapshot[]>;
|
|
2293
|
+
/**
|
|
2294
|
+
* Get a single snapshot of this sandbox by ID
|
|
2295
|
+
*/
|
|
2296
|
+
getSnapshot(snapshotId: NonNullable<SnapshotView["id"]>): Promise<Snapshot>;
|
|
2297
|
+
/**
|
|
2298
|
+
* Delete a snapshot by ID without needing the parent sandbox. Useful for
|
|
2299
|
+
* cleaning up snapshots whose parent sandbox has already been deleted.
|
|
2300
|
+
*
|
|
2301
|
+
* @param snapshotId - ID of the snapshot to delete
|
|
2302
|
+
* @param config - Optional configuration including connection settings
|
|
2303
|
+
*/
|
|
2304
|
+
static deleteSnapshot(snapshotId: NonNullable<SnapshotView["id"]>, config?: GetSandboxConfig): Promise<void>;
|
|
2305
|
+
/**
|
|
2306
|
+
* Delete a snapshot of this sandbox by ID
|
|
2307
|
+
*/
|
|
2308
|
+
deleteSnapshot(snapshotId: NonNullable<SnapshotView["id"]>): Promise<void>;
|
|
2309
|
+
/**
|
|
2310
|
+
* Wait until a snapshot reaches CREATED state.
|
|
2311
|
+
*
|
|
2312
|
+
* `createSnapshot()` returns immediately with `status: "CREATING"`. The
|
|
2313
|
+
* snapshot cannot be used as input to `Sandbox.createFromSnapshot()` until
|
|
2314
|
+
* it transitions to `"CREATED"`. Use this method to block until it does.
|
|
2315
|
+
*
|
|
2316
|
+
* @param snapshotId - ID of the snapshot to wait for
|
|
2317
|
+
* @param pollIntervalMs - How often to check the status (default: 2000ms (2s))
|
|
2318
|
+
* @param maxWaitMs - Maximum time to wait before timing out (default: 180000ms (180s))
|
|
2319
|
+
*/
|
|
2320
|
+
waitForSnapshotReady(snapshotId: NonNullable<SnapshotView["id"]>, pollIntervalMs?: number, maxWaitMs?: number): Promise<void>;
|
|
1882
2321
|
/**
|
|
1883
2322
|
* Delete the sandbox permanently
|
|
1884
2323
|
*/
|
|
@@ -1971,4 +2410,4 @@ declare class BuddySDKError extends Error {
|
|
|
1971
2410
|
});
|
|
1972
2411
|
}
|
|
1973
2412
|
//#endregion
|
|
1974
|
-
export { API_URLS, BuddyApiClient, BuddySDKError, Command, type ConnectionConfig, type CreateSandboxConfig, ERROR_CODES, type ErrorCode, type FileInfo, FileSystem, type GetFileSystemConfig, type GetSandboxConfig, type ListSandboxesConfig, REGIONS, type Region, Sandbox, type SandboxAppView, type SandboxIdView };
|
|
2413
|
+
export { API_URLS, type AddSnapshotRequest, BuddyApiClient, BuddySDKError, type CloneSandboxConfig, type CloneSandboxRequest, Command, type ConnectionConfig, type CreateFromSnapshotConfig, type CreateSandboxConfig, ERROR_CODES, type ErrorCode, type FileInfo, FileSystem, type GetFileSystemConfig, type GetSandboxConfig, type ListSandboxesConfig, REGIONS, type Region, Sandbox, type SandboxAppView, type SandboxIdView, type ShortSnapshotView, Snapshot, type SnapshotView };
|