@miosa/sdk 1.2.5 → 1.2.7

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 (92) hide show
  1. package/README.md +107 -59
  2. package/dist/index.d.ts +513 -193
  3. package/dist/index.js +1266 -891
  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 -569
  11. package/src/resources/admin.ts +0 -348
  12. package/src/resources/analytics.ts +0 -60
  13. package/src/resources/api-keys.ts +0 -119
  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 -197
  37. package/src/resources/deployments.ts +0 -1208
  38. package/src/resources/desktop.ts +0 -134
  39. package/src/resources/devices.test.ts +0 -92
  40. package/src/resources/devices.ts +0 -291
  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/health-checks.ts +0 -165
  55. package/src/resources/integrations.ts +0 -183
  56. package/src/resources/mcp.ts +0 -70
  57. package/src/resources/models.ts +0 -45
  58. package/src/resources/network_policy.ts +0 -73
  59. package/src/resources/open-computers/agents.ts +0 -91
  60. package/src/resources/open-computers/apps.ts +0 -102
  61. package/src/resources/open-computers/clusters.ts +0 -88
  62. package/src/resources/open-computers/desktop.ts +0 -34
  63. package/src/resources/open-computers/files.ts +0 -97
  64. package/src/resources/open-computers/hosts.ts +0 -85
  65. package/src/resources/open-computers/index.ts +0 -98
  66. package/src/resources/open-computers/jobs.ts +0 -75
  67. package/src/resources/open-computers/open_computers.test.ts +0 -288
  68. package/src/resources/open-computers/secrets.ts +0 -115
  69. package/src/resources/open-computers/terminal.ts +0 -33
  70. package/src/resources/open-computers/tunnels.ts +0 -87
  71. package/src/resources/open-computers/types.ts +0 -343
  72. package/src/resources/open-computers/workspaces.ts +0 -135
  73. package/src/resources/org-invites.ts +0 -189
  74. package/src/resources/project-auth.ts +0 -142
  75. package/src/resources/project-integrations.ts +0 -133
  76. package/src/resources/provider-defaults.ts +0 -89
  77. package/src/resources/regions.ts +0 -94
  78. package/src/resources/sandbox-templates.ts +0 -195
  79. package/src/resources/sandboxes.live.test.ts +0 -92
  80. package/src/resources/sandboxes.test.ts +0 -655
  81. package/src/resources/sandboxes.ts +0 -1437
  82. package/src/resources/settings.ts +0 -143
  83. package/src/resources/snapshots-standalone.ts +0 -51
  84. package/src/resources/storage.ts +0 -221
  85. package/src/resources/tenant.ts +0 -66
  86. package/src/resources/usage.ts +0 -85
  87. package/src/resources/volumes.ts +0 -117
  88. package/src/resources/webhooks.ts +0 -239
  89. package/src/resources/workspace-invites.ts +0 -188
  90. package/src/resources/workspace-members.test.ts +0 -121
  91. package/src/resources/workspace-members.ts +0 -143
  92. package/src/types.ts +0 -463
@@ -1,197 +0,0 @@
1
- import { beforeEach, describe, expect, it, vi } from "vitest";
2
- import type { HttpClient } from "../http.js";
3
- import { Deployments } from "./deployments.js";
4
-
5
- const mockRequest = vi.fn();
6
- const mockGet = vi.fn();
7
-
8
- function makeHttp(): HttpClient {
9
- const http = {} as HttpClient;
10
- http.request = mockRequest;
11
- http.get = mockGet;
12
- return http;
13
- }
14
-
15
- beforeEach(() => {
16
- vi.clearAllMocks();
17
- });
18
-
19
- describe("Deployments", () => {
20
- it("createDockerDeploy() marks the deployment for Docker Deploy", async () => {
21
- mockRequest.mockResolvedValue({
22
- data: {
23
- id: "dep_123",
24
- tenant_id: "ten_123",
25
- name: "Clinic Intake",
26
- slug: "clinic-intake",
27
- state: "pending",
28
- deployment_product: "docker_deploy",
29
- docker_deploy_host_id: "ddh_123",
30
- metadata: { deployment_product: "docker_deploy", client: "clinic-iq" },
31
- },
32
- });
33
-
34
- const deployment = await new Deployments(makeHttp()).createDockerDeploy({
35
- name: "Clinic Intake",
36
- repoUrl: "https://github.com/clinic-iq/intake",
37
- externalWorkspaceId: "dr-smith",
38
- externalProjectId: "lead-magnet",
39
- metadata: { client: "clinic-iq" },
40
- idempotencyKey: "idem-123",
41
- });
42
-
43
- expect(mockRequest).toHaveBeenCalledWith("/deployments", {
44
- method: "POST",
45
- body: {
46
- name: "Clinic Intake",
47
- repo_url: "https://github.com/clinic-iq/intake",
48
- metadata: { client: "clinic-iq", deployment_product: "docker_deploy" },
49
- external_workspace_id: "dr-smith",
50
- external_project_id: "lead-magnet",
51
- },
52
- headers: { "Idempotency-Key": "idem-123" },
53
- });
54
- expect(deployment.deployment_product).toBe("docker_deploy");
55
- expect(deployment.docker_deploy_host_id).toBe("ddh_123");
56
- });
57
-
58
- it("lists Docker Deploy templates", async () => {
59
- mockGet.mockResolvedValue({
60
- data: {
61
- templates: [
62
- {
63
- id: "nextjs-app",
64
- name: "Next.js App",
65
- runtime: "node",
66
- framework: "nextjs",
67
- design_md: "# Design",
68
- design_reference_presets: [
69
- {
70
- id: "fintech-control",
71
- name: "Fintech Control",
72
- summary: "Metrics-heavy finance app.",
73
- best_for: ["billing portals"],
74
- },
75
- ],
76
- },
77
- ],
78
- },
79
- });
80
-
81
- const templates = await new Deployments(
82
- makeHttp(),
83
- ).listDockerDeployTemplates({
84
- framework: "nextjs",
85
- includePreview: true,
86
- });
87
-
88
- expect(mockGet).toHaveBeenCalledWith("/docker-deploy/templates", {
89
- framework: "nextjs",
90
- include_preview: true,
91
- });
92
- expect(templates[0]?.id).toBe("nextjs-app");
93
- expect(templates[0]?.design_reference_presets?.[0]?.id).toBe(
94
- "fintech-control",
95
- );
96
- });
97
-
98
- it("gets one Docker Deploy template", async () => {
99
- mockGet.mockResolvedValue({
100
- data: {
101
- id: "compose-full-stack",
102
- name: "Compose Full Stack",
103
- runtime: "docker-compose",
104
- },
105
- });
106
-
107
- const template = await new Deployments(makeHttp()).getDockerDeployTemplate(
108
- "compose-full-stack",
109
- );
110
-
111
- expect(mockGet).toHaveBeenCalledWith(
112
- "/docker-deploy/templates/compose-full-stack",
113
- );
114
- expect(template.runtime).toBe("docker-compose");
115
- });
116
-
117
- it("doctorDockerDeploy() proves appliance metadata and public URL", async () => {
118
- mockGet
119
- .mockResolvedValueOnce({
120
- data: {
121
- id: "dep_123",
122
- tenant_id: "ten_123",
123
- name: "Clinic Intake",
124
- slug: "clinic-intake",
125
- state: "running",
126
- deployment_product: "docker_deploy",
127
- docker_deploy_host_id: "ddh_123",
128
- public_url: "https://clinic.osa.miosa.app",
129
- metadata: {
130
- deployment_product: "docker_deploy",
131
- runtime: { ip: "172.16.74.246", port: 23906 },
132
- },
133
- },
134
- })
135
- .mockResolvedValueOnce({
136
- data: {
137
- id: "ddh_123",
138
- status: "active",
139
- appliance_status: "healthy",
140
- },
141
- });
142
- const fetchImpl = vi.fn().mockResolvedValue({
143
- ok: true,
144
- status: 200,
145
- text: async () => JSON.stringify({ ok: true, product: "clinic" }),
146
- });
147
-
148
- const result = await new Deployments(makeHttp()).doctorDockerDeploy(
149
- "dep_123",
150
- { probePath: "/health", fetchImpl },
151
- );
152
-
153
- expect(mockGet).toHaveBeenNthCalledWith(1, "/deployments/dep_123");
154
- expect(mockGet).toHaveBeenNthCalledWith(2, "/docker-deploy/hosts/ddh_123");
155
- expect(fetchImpl).toHaveBeenCalledWith(
156
- "https://clinic.osa.miosa.app/health",
157
- expect.objectContaining({ headers: { Accept: "*/*" } }),
158
- );
159
- expect(result.ok).toBe(true);
160
- expect(result.host?.id).toBe("ddh_123");
161
- expect(result.probe?.status).toBe(200);
162
- });
163
-
164
- it("doctorDockerDeploy() flags gateway JSON as not the user app", async () => {
165
- mockGet
166
- .mockResolvedValueOnce({
167
- data: {
168
- id: "dep_123",
169
- tenant_id: "ten_123",
170
- name: "Clinic Intake",
171
- slug: "clinic-intake",
172
- state: "running",
173
- deployment_product: "docker_deploy",
174
- docker_deploy_host_id: "ddh_123",
175
- public_url: "https://clinic.osa.miosa.app",
176
- metadata: { runtime: { ip: "172.16.74.246", port: 23906 } },
177
- },
178
- })
179
- .mockResolvedValueOnce({ data: { id: "ddh_123", status: "active" } });
180
- const fetchImpl = vi.fn().mockResolvedValue({
181
- ok: true,
182
- status: 200,
183
- text: async () => JSON.stringify({ ok: true, run_id: "ciq-123" }),
184
- });
185
-
186
- const result = await new Deployments(makeHttp()).doctorDockerDeploy(
187
- "dep_123",
188
- { fetchImpl },
189
- );
190
-
191
- expect(result.ok).toBe(false);
192
- expect(result.probe?.gatewayJson).toBe(true);
193
- expect(
194
- result.checks.find((check) => check.name === "public_url_probe")?.message,
195
- ).toContain("gateway JSON");
196
- });
197
- });