@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,143 +0,0 @@
1
- /**
2
- * Workspace Members — per-workspace user roster.
3
- *
4
- * Endpoints:
5
- * GET /workspaces/:id/members
6
- * POST /workspaces/:id/members
7
- * PATCH /workspaces/:id/members/:user_id
8
- * DELETE /workspaces/:id/members/:user_id
9
- */
10
-
11
- import type { HttpClient } from "../http.js";
12
-
13
- // ── Resource shapes ──────────────────────────────────────────────────────────
14
-
15
- /** Role a user can hold within a workspace. */
16
- export type WorkspaceRole = "owner" | "admin" | "member" | "viewer";
17
-
18
- /**
19
- * Workspace member as returned by `list` — includes denormalised user fields
20
- * for display.
21
- */
22
- export interface WorkspaceMember {
23
- user_id: string;
24
- email: string | null;
25
- name: string | null;
26
- avatar_url: string | null;
27
- role: WorkspaceRole;
28
- joined_at: string | null;
29
- added_by: string | null;
30
- }
31
-
32
- /** Raw workspace_members row returned after add/update operations. */
33
- export interface WorkspaceMemberRecord {
34
- user_id: string;
35
- workspace_id: string;
36
- role: WorkspaceRole;
37
- joined_at: string | null;
38
- added_by: string | null;
39
- }
40
-
41
- // ── Request payloads ─────────────────────────────────────────────────────────
42
-
43
- export interface AddWorkspaceMemberParams {
44
- /** UUID of the tenant user to add. Must already be an org member. */
45
- user_id: string;
46
- /** Role to assign; defaults to `"member"`. */
47
- role?: WorkspaceRole;
48
- }
49
-
50
- export interface UpdateWorkspaceMemberRoleParams {
51
- role: WorkspaceRole;
52
- }
53
-
54
- // ── Response envelopes ───────────────────────────────────────────────────────
55
-
56
- export interface WorkspaceMemberListResponse {
57
- data: WorkspaceMember[];
58
- }
59
-
60
- export interface WorkspaceMemberRecordResponse {
61
- data: WorkspaceMemberRecord;
62
- }
63
-
64
- export interface WorkspaceMemberDeleteResponse {
65
- deleted: boolean;
66
- }
67
-
68
- // ── Main resource ─────────────────────────────────────────────────────────────
69
-
70
- export class WorkspaceMembers {
71
- constructor(private readonly http: HttpClient) {}
72
-
73
- /**
74
- * List all members of a workspace.
75
- *
76
- * `GET /workspaces/:id/members`
77
- */
78
- async list(workspaceId: string): Promise<WorkspaceMember[]> {
79
- const res = await this.http.get<WorkspaceMemberListResponse>(
80
- `/workspaces/${workspaceId}/members`,
81
- );
82
- return res.data ?? (res as unknown as WorkspaceMember[]);
83
- }
84
-
85
- /**
86
- * Add an existing tenant user to a workspace.
87
- *
88
- * The `user_id` must already hold a `tenant_members` row for the parent org.
89
- * Use {@link WorkspaceInvites.create} to invite someone who is not yet an org
90
- * member.
91
- *
92
- * `POST /workspaces/:id/members`
93
- *
94
- * @throws `MiosaError` with code `NOT_TENANT_MEMBER` if the user is not an
95
- * org member.
96
- */
97
- async add(
98
- workspaceId: string,
99
- params: AddWorkspaceMemberParams,
100
- ): Promise<WorkspaceMemberRecord> {
101
- const res = await this.http.post<WorkspaceMemberRecordResponse>(
102
- `/workspaces/${workspaceId}/members`,
103
- params,
104
- );
105
- return res.data ?? (res as unknown as WorkspaceMemberRecord);
106
- }
107
-
108
- /**
109
- * Change a workspace member's role.
110
- *
111
- * `PATCH /workspaces/:id/members/:user_id`
112
- */
113
- async updateRole(
114
- workspaceId: string,
115
- userId: string,
116
- params: UpdateWorkspaceMemberRoleParams,
117
- ): Promise<WorkspaceMemberRecord> {
118
- const res = await this.http.patch<WorkspaceMemberRecordResponse>(
119
- `/workspaces/${workspaceId}/members/${userId}`,
120
- params,
121
- );
122
- return res.data ?? (res as unknown as WorkspaceMemberRecord);
123
- }
124
-
125
- /**
126
- * Remove a user from a workspace.
127
- *
128
- * The last `owner` of a workspace cannot be removed. Promote another member
129
- * to `owner` first using {@link updateRole}.
130
- *
131
- * `DELETE /workspaces/:id/members/:user_id`
132
- *
133
- * @throws `MiosaError` with code `LAST_OWNER` if the target is the sole owner.
134
- */
135
- async remove(
136
- workspaceId: string,
137
- userId: string,
138
- ): Promise<WorkspaceMemberDeleteResponse> {
139
- return this.http.delete<WorkspaceMemberDeleteResponse>(
140
- `/workspaces/${workspaceId}/members/${userId}`,
141
- );
142
- }
143
- }
@@ -1,285 +0,0 @@
1
- /**
2
- * Workspaces resource — top-level tenant workspaces grouping computers.
3
- *
4
- * A workspace is a logical bucket of computers (handy for teams / projects).
5
- * Accessed via `miosa.workspaces` on the top-level client.
6
- *
7
- * @example
8
- * ```ts
9
- * const ws = await miosa.workspaces.create({ name: "prod" });
10
- * const computers = await miosa.workspaces.listComputers(ws.id);
11
- * ```
12
- */
13
-
14
- import type { HttpClient } from "../http.js";
15
- import type { ComputerData } from "../types.js";
16
- import { Computer } from "./computer.js";
17
-
18
- // ── Branded IDs ──────────────────────────────────────────────────────────────
19
-
20
- export type WorkspaceId = string & { readonly __brand: "WorkspaceId" };
21
-
22
- // ── Resource shapes ──────────────────────────────────────────────────────────
23
-
24
- export interface WorkspaceData {
25
- id: WorkspaceId;
26
- tenant_id: string;
27
- name: string;
28
- slug?: string | null;
29
- description?: string | null;
30
- metadata?: Record<string, unknown> | null;
31
- settings?: Record<string, unknown> | null;
32
- created_at?: string;
33
- updated_at?: string;
34
- [key: string]: unknown;
35
- }
36
-
37
- // ── Request payloads ─────────────────────────────────────────────────────────
38
-
39
- export interface WorkspaceCreateParams {
40
- name: string;
41
- slug?: string;
42
- description?: string;
43
- metadata?: Record<string, unknown>;
44
- }
45
-
46
- export interface WorkspaceUpdateParams {
47
- name?: string;
48
- description?: string;
49
- metadata?: Record<string, unknown>;
50
- }
51
-
52
- export interface WorkspaceComputerTemplateCreateParams {
53
- name: string;
54
- templateType?: string;
55
- template_type?: string;
56
- description?: string;
57
- [key: string]: unknown;
58
- }
59
-
60
- // ── Helpers ───────────────────────────────────────────────────────────────────
61
-
62
- function unwrap<T>(payload: unknown): T {
63
- if (payload && typeof payload === "object" && "data" in (payload as object)) {
64
- return (payload as { data: T }).data;
65
- }
66
- return payload as T;
67
- }
68
-
69
- function listItems<T>(
70
- payload: unknown,
71
- candidateKeys: string[] = ["data", "items"],
72
- ): T[] {
73
- if (Array.isArray(payload)) return payload;
74
- if (!payload || typeof payload !== "object") return [];
75
- const p = payload as Record<string, unknown>;
76
- if (Array.isArray(p.data)) return p.data as T[];
77
- for (const key of candidateKeys) {
78
- if (Array.isArray(p[key])) return p[key] as T[];
79
- }
80
- return [];
81
- }
82
-
83
- // ── Workspaces resource ───────────────────────────────────────────────────────
84
-
85
- export class Workspaces {
86
- private readonly http: HttpClient;
87
-
88
- constructor(http: HttpClient) {
89
- this.http = http;
90
- }
91
-
92
- /**
93
- * Create a new workspace.
94
- */
95
- async create(params: WorkspaceCreateParams): Promise<WorkspaceData> {
96
- const payload = await this.http.post<unknown>("/workspaces", params);
97
- return unwrap<WorkspaceData>(payload);
98
- }
99
-
100
- /**
101
- * List all workspaces visible to the current credential.
102
- */
103
- async list(): Promise<WorkspaceData[]> {
104
- const payload = await this.http.get<unknown>("/workspaces");
105
- if (
106
- payload &&
107
- typeof payload === "object" &&
108
- "workspaces" in (payload as object)
109
- ) {
110
- const p = payload as Record<string, unknown>;
111
- return (p["workspaces"] as WorkspaceData[]) ?? [];
112
- }
113
- return listItems<WorkspaceData>(payload, ["data", "workspaces", "items"]);
114
- }
115
-
116
- /**
117
- * Get a single workspace by ID.
118
- */
119
- async get(id: WorkspaceId | string): Promise<WorkspaceData> {
120
- const payload = await this.http.get<unknown>(`/workspaces/${id}`);
121
- return unwrap<WorkspaceData>(payload);
122
- }
123
-
124
- /**
125
- * Update a workspace's metadata.
126
- */
127
- async update(
128
- id: WorkspaceId | string,
129
- params: WorkspaceUpdateParams,
130
- ): Promise<WorkspaceData> {
131
- const payload = await this.http.patch<unknown>(`/workspaces/${id}`, params);
132
- return unwrap<WorkspaceData>(payload);
133
- }
134
-
135
- /**
136
- * Delete a workspace. Does not delete member computers.
137
- */
138
- async delete(id: WorkspaceId | string): Promise<void> {
139
- await this.http.delete<void>(`/workspaces/${id}`);
140
- }
141
-
142
- /**
143
- * Update workspace-level settings.
144
- */
145
- async updateSettings(
146
- id: WorkspaceId | string,
147
- settings: Record<string, unknown>,
148
- ): Promise<WorkspaceData> {
149
- const payload = await this.http.put<unknown>(
150
- `/workspaces/${id}/settings`,
151
- settings,
152
- );
153
- return unwrap<WorkspaceData>(payload);
154
- }
155
-
156
- /**
157
- * List all computers that belong to the given workspace.
158
- */
159
- async listComputers(id: WorkspaceId | string): Promise<Computer[]> {
160
- const payload = await this.http.get<unknown>(`/workspaces/${id}/computers`);
161
- const items = listItems<ComputerData>(payload, [
162
- "data",
163
- "computers",
164
- "items",
165
- ]);
166
- return items.map((d) => new Computer(this.http, d));
167
- }
168
-
169
- /**
170
- * List all sandboxes that belong to this workspace.
171
- */
172
- async listSandboxes(
173
- id: WorkspaceId | string,
174
- ): Promise<Record<string, unknown>[]> {
175
- const payload = await this.http.get<unknown>(`/workspaces/${id}/sandboxes`);
176
- return listItems<Record<string, unknown>>(payload, [
177
- "data",
178
- "sandboxes",
179
- "items",
180
- ]);
181
- }
182
-
183
- /**
184
- * List all deployments that belong to this workspace.
185
- */
186
- async listDeployments(
187
- id: WorkspaceId | string,
188
- ): Promise<Record<string, unknown>[]> {
189
- const payload = await this.http.get<unknown>(
190
- `/workspaces/${id}/deployments`,
191
- );
192
- return listItems<Record<string, unknown>>(payload, [
193
- "data",
194
- "deployments",
195
- "items",
196
- ]);
197
- }
198
-
199
- /**
200
- * List all managed databases that belong to this workspace.
201
- */
202
- async listDatabases(
203
- id: WorkspaceId | string,
204
- ): Promise<Record<string, unknown>[]> {
205
- const payload = await this.http.get<unknown>(`/workspaces/${id}/databases`);
206
- return listItems<Record<string, unknown>>(payload, [
207
- "data",
208
- "databases",
209
- "items",
210
- ]);
211
- }
212
-
213
- /**
214
- * List all projects that belong to this workspace.
215
- */
216
- async listProjects(
217
- id: WorkspaceId | string,
218
- ): Promise<Record<string, unknown>[]> {
219
- const payload = await this.http.get<unknown>(`/workspaces/${id}/projects`);
220
- return listItems<Record<string, unknown>>(payload, [
221
- "data",
222
- "projects",
223
- "items",
224
- ]);
225
- }
226
-
227
- /**
228
- * Return aggregate resource stats for this workspace.
229
- */
230
- async stats(id: WorkspaceId | string): Promise<Record<string, unknown>> {
231
- const payload = await this.http.get<unknown>(`/workspaces/${id}/stats`);
232
- return unwrap<Record<string, unknown>>(payload);
233
- }
234
-
235
- /**
236
- * Return metered usage data for this workspace.
237
- */
238
- async usage(id: WorkspaceId | string): Promise<Record<string, unknown>> {
239
- const payload = await this.http.get<unknown>(`/workspaces/${id}/usage`);
240
- return unwrap<Record<string, unknown>>(payload);
241
- }
242
-
243
- /**
244
- * Return activity feed for this workspace.
245
- */
246
- async activity(id: WorkspaceId | string): Promise<Record<string, unknown>[]> {
247
- const payload = await this.http.get<unknown>(`/workspaces/${id}/activity`);
248
- return listItems<Record<string, unknown>>(payload, [
249
- "data",
250
- "activity",
251
- "events",
252
- "items",
253
- ]);
254
- }
255
-
256
- /**
257
- * List computer templates available in this workspace.
258
- */
259
- async listComputerTemplates(
260
- id: WorkspaceId | string,
261
- ): Promise<Record<string, unknown>[]> {
262
- const payload = await this.http.get<unknown>(
263
- `/workspaces/${id}/computer-templates`,
264
- );
265
- return listItems<Record<string, unknown>>(payload, [
266
- "data",
267
- "templates",
268
- "items",
269
- ]);
270
- }
271
-
272
- /**
273
- * Create a computer template scoped to this workspace.
274
- */
275
- async createComputerTemplate(
276
- id: WorkspaceId | string,
277
- params: WorkspaceComputerTemplateCreateParams,
278
- ): Promise<Record<string, unknown>> {
279
- const payload = await this.http.post<unknown>(
280
- `/workspaces/${id}/computer-templates`,
281
- params,
282
- );
283
- return unwrap<Record<string, unknown>>(payload);
284
- }
285
- }