@miosa/sdk 1.2.4 → 1.2.6

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 (100) hide show
  1. package/README.md +75 -3
  2. package/dist/index.d.ts +323 -175
  3. package/dist/index.js +441 -386
  4. package/dist/index.js.map +1 -1
  5. package/package.json +1 -2
  6. package/src/client.ts +0 -293
  7. package/src/errors.ts +0 -136
  8. package/src/http.test.ts +0 -374
  9. package/src/http.ts +0 -390
  10. package/src/index.ts +0 -564
  11. package/src/resources/admin.ts +0 -359
  12. package/src/resources/analytics.ts +0 -60
  13. package/src/resources/api-keys.ts +0 -135
  14. package/src/resources/audit-log.ts +0 -64
  15. package/src/resources/benchmarks.ts +0 -104
  16. package/src/resources/builder-sessions.ts +0 -75
  17. package/src/resources/channels.ts +0 -143
  18. package/src/resources/checkpoints.ts +0 -225
  19. package/src/resources/command-center.ts +0 -73
  20. package/src/resources/community.ts +0 -103
  21. package/src/resources/completions.ts +0 -104
  22. package/src/resources/computer-auto-stop.ts +0 -43
  23. package/src/resources/computer-env.ts +0 -76
  24. package/src/resources/computer-logs.ts +0 -50
  25. package/src/resources/computer-osa.ts +0 -76
  26. package/src/resources/computer-ports.ts +0 -91
  27. package/src/resources/computer-terminal.ts +0 -61
  28. package/src/resources/computer-volumes.ts +0 -64
  29. package/src/resources/computer.ts +0 -551
  30. package/src/resources/computers.ts +0 -75
  31. package/src/resources/credits.ts +0 -43
  32. package/src/resources/cron-jobs.ts +0 -191
  33. package/src/resources/custom_domains.ts +0 -123
  34. package/src/resources/dashboard.ts +0 -49
  35. package/src/resources/databases.ts +0 -218
  36. package/src/resources/deployments.test.ts +0 -194
  37. package/src/resources/deployments.ts +0 -1060
  38. package/src/resources/desktop.ts +0 -134
  39. package/src/resources/docker-deploy.test.ts +0 -102
  40. package/src/resources/docker-deploy.ts +0 -183
  41. package/src/resources/egress.test.ts +0 -318
  42. package/src/resources/egressAudit.ts +0 -245
  43. package/src/resources/egressNetwork.ts +0 -450
  44. package/src/resources/egressSecrets.ts +0 -577
  45. package/src/resources/email.ts +0 -212
  46. package/src/resources/embeddings.ts +0 -36
  47. package/src/resources/events.ts +0 -296
  48. package/src/resources/exec.ts +0 -319
  49. package/src/resources/external-keys.ts +0 -79
  50. package/src/resources/files.test.ts +0 -339
  51. package/src/resources/files.ts +0 -220
  52. package/src/resources/flat-custom-domains.ts +0 -127
  53. package/src/resources/functions.ts +0 -178
  54. package/src/resources/governance.test.ts +0 -355
  55. package/src/resources/governance.ts +0 -528
  56. package/src/resources/health-checks.ts +0 -165
  57. package/src/resources/integrations.ts +0 -183
  58. package/src/resources/mcp.ts +0 -70
  59. package/src/resources/models.ts +0 -45
  60. package/src/resources/network_policy.ts +0 -73
  61. package/src/resources/open-computers/agents.ts +0 -91
  62. package/src/resources/open-computers/apps.ts +0 -102
  63. package/src/resources/open-computers/clusters.ts +0 -88
  64. package/src/resources/open-computers/desktop.ts +0 -34
  65. package/src/resources/open-computers/files.ts +0 -97
  66. package/src/resources/open-computers/hosts.ts +0 -85
  67. package/src/resources/open-computers/index.ts +0 -98
  68. package/src/resources/open-computers/jobs.ts +0 -75
  69. package/src/resources/open-computers/open_computers.test.ts +0 -288
  70. package/src/resources/open-computers/secrets.ts +0 -115
  71. package/src/resources/open-computers/terminal.ts +0 -33
  72. package/src/resources/open-computers/tunnels.ts +0 -87
  73. package/src/resources/open-computers/types.ts +0 -343
  74. package/src/resources/open-computers/workspaces.ts +0 -135
  75. package/src/resources/org-invites.ts +0 -189
  76. package/src/resources/phase1.test.ts +0 -187
  77. package/src/resources/project-auth.ts +0 -142
  78. package/src/resources/project-integrations.ts +0 -133
  79. package/src/resources/provider-defaults.ts +0 -89
  80. package/src/resources/quotas.ts +0 -77
  81. package/src/resources/regions.ts +0 -94
  82. package/src/resources/sandbox-processes.ts +0 -112
  83. package/src/resources/sandbox-shares.ts +0 -83
  84. package/src/resources/sandbox-templates.ts +0 -195
  85. package/src/resources/sandboxes.live.test.ts +0 -92
  86. package/src/resources/sandboxes.test.ts +0 -653
  87. package/src/resources/sandboxes.ts +0 -1433
  88. package/src/resources/settings.ts +0 -143
  89. package/src/resources/snapshots-standalone.ts +0 -51
  90. package/src/resources/storage.ts +0 -221
  91. package/src/resources/tenant-events.ts +0 -32
  92. package/src/resources/tenant.ts +0 -148
  93. package/src/resources/usage.ts +0 -85
  94. package/src/resources/volumes.ts +0 -117
  95. package/src/resources/webhooks.ts +0 -224
  96. package/src/resources/workspace-invites.ts +0 -188
  97. package/src/resources/workspace-members.test.ts +0 -121
  98. package/src/resources/workspace-members.ts +0 -143
  99. package/src/resources/workspaces.ts +0 -285
  100. package/src/types.ts +0 -463
@@ -1,134 +0,0 @@
1
- import { HttpClient } from "../http.js";
2
- import type {
3
- ClickParams,
4
- CursorInfo,
5
- DesktopActionResult,
6
- DoubleClickParams,
7
- DragParams,
8
- KeyParams,
9
- LaunchParams,
10
- ScrollParams,
11
- TypeParams,
12
- WaitParams,
13
- WindowFocusParams,
14
- WindowInfo,
15
- } from "../types.js";
16
-
17
- export class Desktop {
18
- private readonly http: HttpClient;
19
- private readonly computerId: string;
20
-
21
- constructor(http: HttpClient, computerId: string) {
22
- this.http = http;
23
- this.computerId = computerId;
24
- }
25
-
26
- private base(): string {
27
- return `/computers/${this.computerId}/desktop`;
28
- }
29
-
30
- /** Capture a screenshot of the desktop. Returns raw PNG bytes. */
31
- async screenshot(): Promise<Uint8Array> {
32
- return this.http.getBinary(`${this.base()}/screenshot`);
33
- }
34
-
35
- /** Click at the given coordinates. */
36
- async click(
37
- x: number,
38
- y: number,
39
- button: ClickParams["button"] = "left",
40
- ): Promise<DesktopActionResult> {
41
- return this.http.post<DesktopActionResult>(`${this.base()}/click`, {
42
- x,
43
- y,
44
- button,
45
- });
46
- }
47
-
48
- /** Double-click at the given coordinates. */
49
- async doubleClick(x: number, y: number): Promise<DesktopActionResult> {
50
- const params: DoubleClickParams = { x, y };
51
- return this.http.post<DesktopActionResult>(
52
- `${this.base()}/double-click`,
53
- params,
54
- );
55
- }
56
-
57
- /** Type text into the currently focused element. */
58
- async type(text: string, delay?: number): Promise<DesktopActionResult> {
59
- const params: TypeParams = { text, ...(delay !== undefined && { delay }) };
60
- return this.http.post<DesktopActionResult>(`${this.base()}/type`, params);
61
- }
62
-
63
- /** Send a key or key combination (e.g. "Enter", "ctrl+c"). */
64
- async key(key: string): Promise<DesktopActionResult> {
65
- const params: KeyParams = { key };
66
- return this.http.post<DesktopActionResult>(`${this.base()}/key`, params);
67
- }
68
-
69
- /** Scroll in a direction at an optional position. */
70
- async scroll(
71
- direction: ScrollParams["direction"],
72
- clicks: number = 3,
73
- x?: number,
74
- y?: number,
75
- ): Promise<DesktopActionResult> {
76
- const params: ScrollParams = {
77
- direction,
78
- clicks,
79
- ...(x !== undefined && { x }),
80
- ...(y !== undefined && { y }),
81
- };
82
- return this.http.post<DesktopActionResult>(`${this.base()}/scroll`, params);
83
- }
84
-
85
- /** Click and drag from one coordinate to another. */
86
- async drag(
87
- fromX: number,
88
- fromY: number,
89
- toX: number,
90
- toY: number,
91
- ): Promise<DesktopActionResult> {
92
- const params: DragParams = {
93
- from_x: fromX,
94
- from_y: fromY,
95
- to_x: toX,
96
- to_y: toY,
97
- };
98
- return this.http.post<DesktopActionResult>(`${this.base()}/drag`, params);
99
- }
100
-
101
- /** Wait for the given number of seconds. */
102
- async wait(seconds: number): Promise<DesktopActionResult> {
103
- const params: WaitParams = { seconds };
104
- return this.http.post<DesktopActionResult>(`${this.base()}/wait`, params);
105
- }
106
-
107
- /** List all open windows on the desktop. */
108
- async windows(): Promise<WindowInfo[]> {
109
- const result = await this.http.get<{ windows: WindowInfo[] }>(
110
- `${this.base()}/windows`,
111
- );
112
- return result.windows;
113
- }
114
-
115
- /** Get the current cursor position. */
116
- async cursor(): Promise<CursorInfo> {
117
- return this.http.get<CursorInfo>(`${this.base()}/cursor`);
118
- }
119
-
120
- /** Bring the given window into focus. */
121
- async focusWindow(windowId: string): Promise<DesktopActionResult> {
122
- const params: WindowFocusParams = { window_id: windowId };
123
- return this.http.post<DesktopActionResult>(
124
- `${this.base()}/window/focus`,
125
- params,
126
- );
127
- }
128
-
129
- /** Launch an application by name. */
130
- async launch(appName: string): Promise<DesktopActionResult> {
131
- const params: LaunchParams = { app_name: appName };
132
- return this.http.post<DesktopActionResult>(`${this.base()}/launch`, params);
133
- }
134
- }
@@ -1,102 +0,0 @@
1
- import { beforeEach, describe, expect, it, vi } from "vitest";
2
- import type { HttpClient } from "../http.js";
3
- import { DockerDeploy } from "./docker-deploy.js";
4
-
5
- const mockGet = vi.fn();
6
- const mockPost = vi.fn();
7
-
8
- function makeHttp(): HttpClient {
9
- const http = {} as HttpClient;
10
- http.get = mockGet;
11
- http.post = mockPost;
12
- return http;
13
- }
14
-
15
- beforeEach(() => {
16
- vi.clearAllMocks();
17
- });
18
-
19
- describe("DockerDeploy", () => {
20
- it("lists Docker Deploy hosts by workspace", async () => {
21
- mockGet.mockResolvedValue({
22
- data: [
23
- {
24
- id: "ddh_123",
25
- tenant_id: "ten_123",
26
- workspace_id: "ws_123",
27
- status: "bootstrapping",
28
- appliance_status: "starting",
29
- size: "medium",
30
- region: "us",
31
- },
32
- ],
33
- });
34
-
35
- const hosts = await new DockerDeploy(makeHttp()).listHosts({
36
- workspaceId: "ws_123",
37
- });
38
-
39
- expect(mockGet).toHaveBeenCalledWith("/docker-deploy/hosts", {
40
- workspace_id: "ws_123",
41
- });
42
- expect(hosts[0]?.id).toBe("ddh_123");
43
- });
44
-
45
- it("ensures a workspace Docker Deploy host", async () => {
46
- mockPost.mockResolvedValue({
47
- host: {
48
- id: "ddh_123",
49
- tenant_id: "ten_123",
50
- workspace_id: "ws_123",
51
- status: "pending",
52
- appliance_status: "not_installed",
53
- size: "medium",
54
- region: "us",
55
- },
56
- queued: true,
57
- });
58
-
59
- const result = await new DockerDeploy(makeHttp()).ensureHost({
60
- workspaceId: "ws_123",
61
- });
62
-
63
- expect(mockPost).toHaveBeenCalledWith("/docker-deploy/hosts/ensure", {
64
- workspace_id: "ws_123",
65
- });
66
- expect(result.queued).toBe(true);
67
- expect(result.host.status).toBe("pending");
68
- });
69
-
70
- it("lists Docker Deploy templates", async () => {
71
- mockGet.mockResolvedValue({
72
- data: [
73
- {
74
- id: "nextjs-app",
75
- name: "Next.js app",
76
- description: "App router starter",
77
- },
78
- ],
79
- });
80
-
81
- const templates = await new DockerDeploy(makeHttp()).listTemplates();
82
-
83
- expect(mockGet).toHaveBeenCalledWith("/docker-deploy/templates");
84
- expect(templates[0]?.id).toBe("nextjs-app");
85
- });
86
-
87
- it("gets a Docker Deploy template", async () => {
88
- mockGet.mockResolvedValue({
89
- template: {
90
- id: "compose-full-stack",
91
- name: "Compose full stack",
92
- },
93
- });
94
-
95
- const template = await new DockerDeploy(makeHttp()).getTemplate("compose-full-stack");
96
-
97
- expect(mockGet).toHaveBeenCalledWith(
98
- "/docker-deploy/templates/compose-full-stack",
99
- );
100
- expect(template.id).toBe("compose-full-stack");
101
- });
102
- });
@@ -1,183 +0,0 @@
1
- import type { HttpClient } from "../http.js";
2
-
3
- export type DockerDeployHostId = string & {
4
- readonly __brand: "DockerDeployHostId";
5
- };
6
-
7
- export type DockerDeployHostStatus =
8
- | "pending"
9
- | "provisioning"
10
- | "bootstrapping"
11
- | "active"
12
- | "degraded"
13
- | "suspended"
14
- | "retired"
15
- | "error";
16
-
17
- export type DockerDeployApplianceStatus =
18
- | "not_installed"
19
- | "installing"
20
- | "starting"
21
- | "healthy"
22
- | "unhealthy"
23
- | "unknown";
24
-
25
- export interface DockerDeployHostData {
26
- id: DockerDeployHostId;
27
- tenant_id: string;
28
- workspace_id: string;
29
- external_workspace_id?: string | null;
30
- computer_id?: string | null;
31
- fleet_node_id?: string | null;
32
- status: DockerDeployHostStatus;
33
- size: string;
34
- region: string;
35
- portal_domain?: string | null;
36
- runtime_base_url?: string | null;
37
- agent_base_url?: string | null;
38
- appliance_image?: string | null;
39
- appliance_version?: string | null;
40
- appliance_status: DockerDeployApplianceStatus;
41
- agent_last_seen_at?: string | null;
42
- metadata?: Record<string, unknown>;
43
- created_at?: string;
44
- updated_at?: string;
45
- }
46
-
47
- export interface DockerDeployHostListParams {
48
- workspace_id?: string;
49
- workspaceId?: string;
50
- }
51
-
52
- export interface DockerDeployHostEnsureParams {
53
- workspace_id?: string;
54
- workspaceId?: string;
55
- external_workspace_id?: string;
56
- externalWorkspaceId?: string;
57
- }
58
-
59
- export interface DockerDeployHostListResponse {
60
- data?: DockerDeployHostData[];
61
- hosts?: DockerDeployHostData[];
62
- }
63
-
64
- export interface DockerDeployHostResponse {
65
- data?: DockerDeployHostData;
66
- host?: DockerDeployHostData;
67
- queued?: boolean;
68
- }
69
-
70
- export interface DockerDeployTemplate {
71
- id: string;
72
- name: string;
73
- description?: string;
74
- category?: string;
75
- runtime?: string;
76
- tags?: string[];
77
- metadata?: Record<string, unknown>;
78
- [key: string]: unknown;
79
- }
80
-
81
- export interface DockerDeployTemplateListResponse {
82
- data?: DockerDeployTemplate[];
83
- templates?: DockerDeployTemplate[];
84
- }
85
-
86
- export interface DockerDeployTemplateResponse {
87
- data?: DockerDeployTemplate;
88
- template?: DockerDeployTemplate;
89
- }
90
-
91
- function workspaceId(params?: DockerDeployHostListParams): string | undefined {
92
- return params?.workspace_id ?? params?.workspaceId;
93
- }
94
-
95
- function ensureBody(params: DockerDeployHostEnsureParams): Record<string, string> {
96
- const body: Record<string, string> = {};
97
- const id = params.workspace_id ?? params.workspaceId;
98
- const externalId = params.external_workspace_id ?? params.externalWorkspaceId;
99
- if (id) body.workspace_id = id;
100
- if (externalId) body.external_workspace_id = externalId;
101
- return body;
102
- }
103
-
104
- function unwrapHost(response: DockerDeployHostResponse): DockerDeployHostData {
105
- const host = response.data ?? response.host;
106
- if (!host) {
107
- throw new Error("Docker Deploy host response was empty.");
108
- }
109
- return host;
110
- }
111
-
112
- function unwrapTemplates(response: DockerDeployTemplateListResponse): DockerDeployTemplate[] {
113
- return response.data ?? response.templates ?? [];
114
- }
115
-
116
- function unwrapTemplate(response: DockerDeployTemplateResponse): DockerDeployTemplate {
117
- const template = response.data ?? response.template;
118
- if (!template) {
119
- throw new Error("Docker Deploy template response was empty.");
120
- }
121
- return template;
122
- }
123
-
124
- export class DockerDeploy {
125
- constructor(private readonly http: HttpClient) {}
126
-
127
- /**
128
- * List Docker Deploy appliance hosts scoped to the current tenant.
129
- *
130
- * Pass a workspace ID to inspect the dedicated always-on appliance machine
131
- * for one white-label workspace.
132
- */
133
- async listHosts(
134
- params: DockerDeployHostListParams = {},
135
- ): Promise<DockerDeployHostData[]> {
136
- const res = await this.http.get<DockerDeployHostListResponse>(
137
- "/docker-deploy/hosts",
138
- { workspace_id: workspaceId(params) },
139
- );
140
- return res.data ?? res.hosts ?? [];
141
- }
142
-
143
- /**
144
- * Ensure a workspace has its dedicated Docker Deploy appliance host.
145
- *
146
- * The host may still be `pending`, `provisioning`, or `bootstrapping` after
147
- * this call. Treat `status === "active"` and `appliance_status === "healthy"`
148
- * as the ready condition before sending app/container traffic to it.
149
- */
150
- async ensureHost(
151
- params: DockerDeployHostEnsureParams = {},
152
- ): Promise<{ host: DockerDeployHostData; queued: boolean }> {
153
- const res = await this.http.post<DockerDeployHostResponse>(
154
- "/docker-deploy/hosts/ensure",
155
- ensureBody(params),
156
- );
157
- return { host: unwrapHost(res), queued: res.queued ?? false };
158
- }
159
-
160
- /** Fetch one Docker Deploy host by ID. */
161
- async getHost(hostId: string): Promise<DockerDeployHostData> {
162
- const res = await this.http.get<DockerDeployHostResponse>(
163
- `/docker-deploy/hosts/${hostId}`,
164
- );
165
- return unwrapHost(res);
166
- }
167
-
168
- /** List Docker Deploy starter templates. */
169
- async listTemplates(): Promise<DockerDeployTemplate[]> {
170
- const res = await this.http.get<DockerDeployTemplateListResponse>(
171
- "/docker-deploy/templates",
172
- );
173
- return unwrapTemplates(res);
174
- }
175
-
176
- /** Fetch one Docker Deploy starter template by ID. */
177
- async getTemplate(templateId: string): Promise<DockerDeployTemplate> {
178
- const res = await this.http.get<DockerDeployTemplateResponse>(
179
- `/docker-deploy/templates/${encodeURIComponent(templateId)}`,
180
- );
181
- return unwrapTemplate(res);
182
- }
183
- }