@miosa/sdk 1.2.5 → 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.
- package/README.md +107 -59
- package/dist/index.d.ts +331 -202
- package/dist/index.js +572 -603
- package/dist/index.js.map +1 -1
- package/package.json +1 -2
- package/src/client.ts +0 -293
- package/src/errors.ts +0 -136
- package/src/http.test.ts +0 -374
- package/src/http.ts +0 -390
- package/src/index.ts +0 -569
- package/src/resources/admin.ts +0 -348
- package/src/resources/analytics.ts +0 -60
- package/src/resources/api-keys.ts +0 -119
- package/src/resources/audit-log.ts +0 -64
- package/src/resources/benchmarks.ts +0 -104
- package/src/resources/builder-sessions.ts +0 -75
- package/src/resources/channels.ts +0 -143
- package/src/resources/checkpoints.ts +0 -225
- package/src/resources/command-center.ts +0 -73
- package/src/resources/community.ts +0 -103
- package/src/resources/completions.ts +0 -104
- package/src/resources/computer-auto-stop.ts +0 -43
- package/src/resources/computer-env.ts +0 -76
- package/src/resources/computer-logs.ts +0 -50
- package/src/resources/computer-osa.ts +0 -76
- package/src/resources/computer-ports.ts +0 -91
- package/src/resources/computer-terminal.ts +0 -61
- package/src/resources/computer-volumes.ts +0 -64
- package/src/resources/computer.ts +0 -551
- package/src/resources/computers.ts +0 -75
- package/src/resources/credits.ts +0 -43
- package/src/resources/cron-jobs.ts +0 -191
- package/src/resources/custom_domains.ts +0 -123
- package/src/resources/dashboard.ts +0 -49
- package/src/resources/databases.ts +0 -218
- package/src/resources/deployments.test.ts +0 -197
- package/src/resources/deployments.ts +0 -1208
- package/src/resources/desktop.ts +0 -134
- package/src/resources/devices.test.ts +0 -92
- package/src/resources/devices.ts +0 -291
- package/src/resources/egress.test.ts +0 -318
- package/src/resources/egressAudit.ts +0 -245
- package/src/resources/egressNetwork.ts +0 -450
- package/src/resources/egressSecrets.ts +0 -577
- package/src/resources/email.ts +0 -212
- package/src/resources/embeddings.ts +0 -36
- package/src/resources/events.ts +0 -296
- package/src/resources/exec.ts +0 -319
- package/src/resources/external-keys.ts +0 -79
- package/src/resources/files.test.ts +0 -339
- package/src/resources/files.ts +0 -220
- package/src/resources/flat-custom-domains.ts +0 -127
- package/src/resources/functions.ts +0 -178
- package/src/resources/health-checks.ts +0 -165
- package/src/resources/integrations.ts +0 -183
- package/src/resources/mcp.ts +0 -70
- package/src/resources/models.ts +0 -45
- package/src/resources/network_policy.ts +0 -73
- package/src/resources/open-computers/agents.ts +0 -91
- package/src/resources/open-computers/apps.ts +0 -102
- package/src/resources/open-computers/clusters.ts +0 -88
- package/src/resources/open-computers/desktop.ts +0 -34
- package/src/resources/open-computers/files.ts +0 -97
- package/src/resources/open-computers/hosts.ts +0 -85
- package/src/resources/open-computers/index.ts +0 -98
- package/src/resources/open-computers/jobs.ts +0 -75
- package/src/resources/open-computers/open_computers.test.ts +0 -288
- package/src/resources/open-computers/secrets.ts +0 -115
- package/src/resources/open-computers/terminal.ts +0 -33
- package/src/resources/open-computers/tunnels.ts +0 -87
- package/src/resources/open-computers/types.ts +0 -343
- package/src/resources/open-computers/workspaces.ts +0 -135
- package/src/resources/org-invites.ts +0 -189
- package/src/resources/project-auth.ts +0 -142
- package/src/resources/project-integrations.ts +0 -133
- package/src/resources/provider-defaults.ts +0 -89
- package/src/resources/regions.ts +0 -94
- package/src/resources/sandbox-templates.ts +0 -195
- package/src/resources/sandboxes.live.test.ts +0 -92
- package/src/resources/sandboxes.test.ts +0 -655
- package/src/resources/sandboxes.ts +0 -1437
- package/src/resources/settings.ts +0 -143
- package/src/resources/snapshots-standalone.ts +0 -51
- package/src/resources/storage.ts +0 -221
- package/src/resources/tenant.ts +0 -66
- package/src/resources/usage.ts +0 -85
- package/src/resources/volumes.ts +0 -117
- package/src/resources/webhooks.ts +0 -239
- package/src/resources/workspace-invites.ts +0 -188
- package/src/resources/workspace-members.test.ts +0 -121
- package/src/resources/workspace-members.ts +0 -143
- package/src/types.ts +0 -463
|
@@ -1,1208 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Deployments resource — sandbox→production publishing surface.
|
|
3
|
-
*
|
|
4
|
-
* Backend phase status:
|
|
5
|
-
* - list / get / create / update / delete / env: repo deployment surface.
|
|
6
|
-
* - publish / versions.* / releases.* / rollback / domains.*: live release surface.
|
|
7
|
-
* - runtimeInstances.*: dynamic runtime status/log inspection.
|
|
8
|
-
* - publishFromSandbox: direct sandbox -> deployment bridge.
|
|
9
|
-
*
|
|
10
|
-
* See docs/deploy/* for the conceptual model.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import { randomUUID } from "node:crypto";
|
|
14
|
-
|
|
15
|
-
import type { HttpClient } from "../http.js";
|
|
16
|
-
|
|
17
|
-
// ── Branded IDs ─────────────────────────────────────────────────────────────
|
|
18
|
-
|
|
19
|
-
export type DeploymentId = string & { readonly __brand: "DeploymentId" };
|
|
20
|
-
export type DeploymentVersionId = string & {
|
|
21
|
-
readonly __brand: "DeploymentVersionId";
|
|
22
|
-
};
|
|
23
|
-
export type DeploymentReleaseId = string & {
|
|
24
|
-
readonly __brand: "DeploymentReleaseId";
|
|
25
|
-
};
|
|
26
|
-
export type DeploymentServiceId = string & {
|
|
27
|
-
readonly __brand: "DeploymentServiceId";
|
|
28
|
-
};
|
|
29
|
-
export type RuntimeInstanceId = string & {
|
|
30
|
-
readonly __brand: "RuntimeInstanceId";
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
// ── States / enums ──────────────────────────────────────────────────────────
|
|
34
|
-
|
|
35
|
-
export type DeploymentState =
|
|
36
|
-
| "pending"
|
|
37
|
-
| "building"
|
|
38
|
-
| "running"
|
|
39
|
-
| "stopped"
|
|
40
|
-
| "failed";
|
|
41
|
-
|
|
42
|
-
export type DeploymentVersionKind = "static" | "dynamic" | "sandbox_backed";
|
|
43
|
-
|
|
44
|
-
export type DeploymentVersionState =
|
|
45
|
-
| "created"
|
|
46
|
-
| "building"
|
|
47
|
-
| "ready"
|
|
48
|
-
| "failed"
|
|
49
|
-
| "archived";
|
|
50
|
-
|
|
51
|
-
export type DeploymentSourceType = "repo" | "sandbox" | "upload";
|
|
52
|
-
|
|
53
|
-
export type DeploymentProduct = "miosa_deploy" | "docker_deploy";
|
|
54
|
-
|
|
55
|
-
export type DeploymentServiceType =
|
|
56
|
-
| "static_web"
|
|
57
|
-
| "web"
|
|
58
|
-
| "api"
|
|
59
|
-
| "function"
|
|
60
|
-
| "worker"
|
|
61
|
-
| "cron"
|
|
62
|
-
| "postgres"
|
|
63
|
-
| "redis"
|
|
64
|
-
| "bucket"
|
|
65
|
-
| "volume";
|
|
66
|
-
|
|
67
|
-
export type RuntimeInstanceState =
|
|
68
|
-
| "provisioning"
|
|
69
|
-
| "starting"
|
|
70
|
-
| "healthy"
|
|
71
|
-
| "unhealthy"
|
|
72
|
-
| "error"
|
|
73
|
-
| "stopped"
|
|
74
|
-
| "destroyed";
|
|
75
|
-
|
|
76
|
-
// ── Shared attribution ──────────────────────────────────────────────────────
|
|
77
|
-
|
|
78
|
-
export interface ExternalAttribution {
|
|
79
|
-
externalWorkspaceId?: string;
|
|
80
|
-
external_workspace_id?: string;
|
|
81
|
-
externalUserId?: string;
|
|
82
|
-
external_user_id?: string;
|
|
83
|
-
externalProjectId?: string;
|
|
84
|
-
external_project_id?: string;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// ── Resource shapes ─────────────────────────────────────────────────────────
|
|
88
|
-
|
|
89
|
-
export interface DeploymentData {
|
|
90
|
-
id: DeploymentId;
|
|
91
|
-
tenant_id: string;
|
|
92
|
-
owner_id?: string;
|
|
93
|
-
name: string;
|
|
94
|
-
slug: string;
|
|
95
|
-
/**
|
|
96
|
-
* @deprecated — repo-based model. New deployments use source_type: "sandbox"
|
|
97
|
-
* with `source_sandbox_id` on the version row. Will become nullable.
|
|
98
|
-
*/
|
|
99
|
-
repo_url?: string;
|
|
100
|
-
repo_provider?: "github";
|
|
101
|
-
branch?: string;
|
|
102
|
-
build_command?: string | null;
|
|
103
|
-
run_command?: string | null;
|
|
104
|
-
runtime_image?: string | null;
|
|
105
|
-
current_build_id?: string | null;
|
|
106
|
-
active_version_id?: string | null;
|
|
107
|
-
source_type?: DeploymentSourceType;
|
|
108
|
-
state: DeploymentState;
|
|
109
|
-
auto_deploy?: boolean;
|
|
110
|
-
custom_domain_id?: string | null;
|
|
111
|
-
linked_database_id?: string | null;
|
|
112
|
-
deployment_product?: DeploymentProduct | string | null;
|
|
113
|
-
docker_deploy_host_id?: string | null;
|
|
114
|
-
metadata?: Record<string, unknown>;
|
|
115
|
-
external_workspace_id?: string | null;
|
|
116
|
-
external_user_id?: string | null;
|
|
117
|
-
external_project_id?: string | null;
|
|
118
|
-
public_url?: string | null;
|
|
119
|
-
created_at?: string;
|
|
120
|
-
updated_at?: string;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export type DeploymentDatabaseRequest =
|
|
124
|
-
| boolean
|
|
125
|
-
| {
|
|
126
|
-
engine?: "postgresql" | "mysql" | "redis" | "qdrant";
|
|
127
|
-
size?: "xs" | "small" | "medium" | "large";
|
|
128
|
-
storage_mb?: number;
|
|
129
|
-
region?: string;
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
export interface DeploymentVersionData {
|
|
133
|
-
id: DeploymentVersionId;
|
|
134
|
-
deployment_id: DeploymentId;
|
|
135
|
-
tenant_id: string;
|
|
136
|
-
created_by?: string | null;
|
|
137
|
-
source_sandbox_id?: string | null;
|
|
138
|
-
build_id?: string | null;
|
|
139
|
-
version_number: number;
|
|
140
|
-
kind: DeploymentVersionKind;
|
|
141
|
-
state: DeploymentVersionState;
|
|
142
|
-
artifact_uri?: string | null;
|
|
143
|
-
artifact_manifest?: Record<string, unknown>;
|
|
144
|
-
artifact_sha256?: string | null;
|
|
145
|
-
runtime_image?: string | null;
|
|
146
|
-
runtime_command?: string | null;
|
|
147
|
-
runtime_port?: number | null;
|
|
148
|
-
health_check_path?: string | null;
|
|
149
|
-
build_log_uri?: string | null;
|
|
150
|
-
metadata?: Record<string, unknown>;
|
|
151
|
-
promoted_at?: string | null;
|
|
152
|
-
archived_at?: string | null;
|
|
153
|
-
external_workspace_id?: string | null;
|
|
154
|
-
external_user_id?: string | null;
|
|
155
|
-
external_project_id?: string | null;
|
|
156
|
-
created_at?: string;
|
|
157
|
-
updated_at?: string;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
export interface DeploymentReleaseData {
|
|
161
|
-
id: DeploymentReleaseId;
|
|
162
|
-
deployment_id?: DeploymentId;
|
|
163
|
-
environment_id?: string | null;
|
|
164
|
-
deployment_version_id: DeploymentVersionId;
|
|
165
|
-
service_id?: DeploymentServiceId | null;
|
|
166
|
-
tenant_id: string;
|
|
167
|
-
external_workspace_id?: string | null;
|
|
168
|
-
external_user_id?: string | null;
|
|
169
|
-
external_project_id?: string | null;
|
|
170
|
-
source_sandbox_id?: string | null;
|
|
171
|
-
build_id?: string | null;
|
|
172
|
-
kind: "static" | "oci" | "rootfs" | string;
|
|
173
|
-
state?: string;
|
|
174
|
-
artifact_uri?: string | null;
|
|
175
|
-
artifact_sha256?: string | null;
|
|
176
|
-
artifact_manifest?: Record<string, unknown>;
|
|
177
|
-
storage_backend?: string | null;
|
|
178
|
-
storage_uri?: string;
|
|
179
|
-
sha256?: string;
|
|
180
|
-
size_bytes?: number;
|
|
181
|
-
start_command?: string | null;
|
|
182
|
-
port?: number | null;
|
|
183
|
-
health_check_path?: string | null;
|
|
184
|
-
build_log_uri?: string | null;
|
|
185
|
-
metadata?: Record<string, unknown>;
|
|
186
|
-
ready_at?: string | null;
|
|
187
|
-
archived_at?: string | null;
|
|
188
|
-
created_at?: string;
|
|
189
|
-
updated_at?: string;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
export interface DeploymentServiceData {
|
|
193
|
-
id: DeploymentServiceId;
|
|
194
|
-
deployment_id: DeploymentId;
|
|
195
|
-
environment_id?: string | null;
|
|
196
|
-
tenant_id: string;
|
|
197
|
-
type: DeploymentServiceType;
|
|
198
|
-
name?: string | null;
|
|
199
|
-
desired_replicas?: number;
|
|
200
|
-
state: string;
|
|
201
|
-
metadata?: Record<string, unknown>;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
export interface RuntimeInstanceData {
|
|
205
|
-
id: RuntimeInstanceId;
|
|
206
|
-
deployment_id?: DeploymentId;
|
|
207
|
-
environment_id?: string | null;
|
|
208
|
-
service_id?: DeploymentServiceId | null;
|
|
209
|
-
release_id?: DeploymentReleaseId;
|
|
210
|
-
tenant_id: string;
|
|
211
|
-
external_workspace_id?: string | null;
|
|
212
|
-
external_user_id?: string | null;
|
|
213
|
-
external_project_id?: string | null;
|
|
214
|
-
host_id?: string | null;
|
|
215
|
-
node_id?: string | null;
|
|
216
|
-
vm_id?: string | null;
|
|
217
|
-
desired_state?: string | null;
|
|
218
|
-
state: RuntimeInstanceState;
|
|
219
|
-
ip_address?: string | null;
|
|
220
|
-
port?: number | null;
|
|
221
|
-
health_check_path?: string | null;
|
|
222
|
-
last_health_check_at?: string | null;
|
|
223
|
-
last_heartbeat_at?: string | null;
|
|
224
|
-
started_at?: string | null;
|
|
225
|
-
stopped_at?: string | null;
|
|
226
|
-
error_message?: string | null;
|
|
227
|
-
restart_count?: number;
|
|
228
|
-
cpu_limit_millicores?: number | null;
|
|
229
|
-
memory_limit_mb?: number | null;
|
|
230
|
-
runtime_log_path?: string | null;
|
|
231
|
-
metadata?: Record<string, unknown>;
|
|
232
|
-
created_at?: string;
|
|
233
|
-
updated_at?: string;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
export interface DeploymentBuildData {
|
|
237
|
-
id: string;
|
|
238
|
-
deployment_id: DeploymentId;
|
|
239
|
-
commit_sha?: string | null;
|
|
240
|
-
commit_message?: string | null;
|
|
241
|
-
triggered_by?: string;
|
|
242
|
-
state: string;
|
|
243
|
-
started_at?: string | null;
|
|
244
|
-
finished_at?: string | null;
|
|
245
|
-
duration_ms?: number | null;
|
|
246
|
-
log_url?: string | null;
|
|
247
|
-
image_digest?: string | null;
|
|
248
|
-
error_message?: string | null;
|
|
249
|
-
external_workspace_id?: string | null;
|
|
250
|
-
external_user_id?: string | null;
|
|
251
|
-
external_project_id?: string | null;
|
|
252
|
-
created_at?: string;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
// ── Request / response payloads ─────────────────────────────────────────────
|
|
256
|
-
|
|
257
|
-
export interface DeploymentListParams extends ExternalAttribution {
|
|
258
|
-
project_id?: string;
|
|
259
|
-
projectId?: string;
|
|
260
|
-
state?: DeploymentState | string;
|
|
261
|
-
limit?: number;
|
|
262
|
-
cursor?: string;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
export interface DeploymentCreateParams extends ExternalAttribution {
|
|
266
|
-
name: string;
|
|
267
|
-
/** Current backend create route is repo-backed; project IDs are attribution, not route ownership. */
|
|
268
|
-
project_id?: string;
|
|
269
|
-
projectId?: string;
|
|
270
|
-
/** @deprecated Ignored by the backend create route. Use sandbox.deploy() for sandbox-backed deployments. */
|
|
271
|
-
source_type?: DeploymentSourceType;
|
|
272
|
-
/** @deprecated Ignored by the backend create route. Use sandbox.deploy() for sandbox-backed deployments. */
|
|
273
|
-
sourceType?: DeploymentSourceType;
|
|
274
|
-
repo_url?: string;
|
|
275
|
-
repoUrl?: string;
|
|
276
|
-
branch?: string;
|
|
277
|
-
build_command?: string;
|
|
278
|
-
buildCommand?: string;
|
|
279
|
-
run_command?: string;
|
|
280
|
-
runCommand?: string;
|
|
281
|
-
auto_deploy?: boolean;
|
|
282
|
-
autoDeploy?: boolean;
|
|
283
|
-
database?: DeploymentDatabaseRequest;
|
|
284
|
-
docker_deploy_template_id?: string;
|
|
285
|
-
dockerDeployTemplateId?: string;
|
|
286
|
-
metadata?: Record<string, unknown>;
|
|
287
|
-
idempotencyKey?: string;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
export interface DockerDeployCreateParams extends DeploymentCreateParams {}
|
|
291
|
-
|
|
292
|
-
export interface DockerDeployHostData {
|
|
293
|
-
id: string;
|
|
294
|
-
tenant_id?: string;
|
|
295
|
-
workspace_id?: string | null;
|
|
296
|
-
computer_id?: string | null;
|
|
297
|
-
fleet_node_id?: string | null;
|
|
298
|
-
runtime_base_url?: string | null;
|
|
299
|
-
status?: string;
|
|
300
|
-
appliance_status?: string | null;
|
|
301
|
-
appliance_version?: string | null;
|
|
302
|
-
appliance_image?: string | null;
|
|
303
|
-
agent_configured?: boolean;
|
|
304
|
-
last_health_check_at?: string | null;
|
|
305
|
-
created_at?: string;
|
|
306
|
-
updated_at?: string;
|
|
307
|
-
metadata?: Record<string, unknown>;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
export interface DockerDeployHostListParams {
|
|
311
|
-
workspace_id?: string;
|
|
312
|
-
workspaceId?: string;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
export interface DockerDeployHostEnsureParams {
|
|
316
|
-
workspace_id: string;
|
|
317
|
-
workspaceId?: string;
|
|
318
|
-
region?: string;
|
|
319
|
-
size?: string;
|
|
320
|
-
appliance_image?: string;
|
|
321
|
-
applianceImage?: string;
|
|
322
|
-
metadata?: Record<string, unknown>;
|
|
323
|
-
idempotencyKey?: string;
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
export interface DockerDeployTemplateData {
|
|
327
|
-
id: string;
|
|
328
|
-
name: string;
|
|
329
|
-
summary?: string;
|
|
330
|
-
description?: string;
|
|
331
|
-
category?: string;
|
|
332
|
-
runtime?: string;
|
|
333
|
-
framework?: string;
|
|
334
|
-
build_command?: string | null;
|
|
335
|
-
run_command?: string | null;
|
|
336
|
-
ports?: number[];
|
|
337
|
-
env?: Record<string, string>;
|
|
338
|
-
files?: Record<string, string>;
|
|
339
|
-
design_md?: string | null;
|
|
340
|
-
design_source_url?: string | null;
|
|
341
|
-
design_sources?: string[];
|
|
342
|
-
design_reference_presets?: DockerDeployDesignReferencePreset[];
|
|
343
|
-
metadata?: Record<string, unknown>;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
export interface DockerDeployDesignReferencePreset {
|
|
347
|
-
id: string;
|
|
348
|
-
name: string;
|
|
349
|
-
summary: string;
|
|
350
|
-
best_for?: string[];
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
export interface DockerDeployTemplateListParams {
|
|
354
|
-
category?: string;
|
|
355
|
-
runtime?: string;
|
|
356
|
-
framework?: string;
|
|
357
|
-
includePreview?: boolean;
|
|
358
|
-
include_preview?: boolean;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
export interface DockerDeployDoctorParams {
|
|
362
|
-
/** Probe the deployment public URL after checking control-plane metadata. Default: true. */
|
|
363
|
-
probe?: boolean;
|
|
364
|
-
/** Path to request on the public URL. Default: "/". */
|
|
365
|
-
probePath?: string;
|
|
366
|
-
/** Public URL probe timeout in milliseconds. Default: 20_000. */
|
|
367
|
-
timeoutMs?: number;
|
|
368
|
-
/** Test hook or custom runtime fetch implementation. */
|
|
369
|
-
fetchImpl?: typeof fetch;
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
export interface DockerDeployDoctorCheck {
|
|
373
|
-
name: string;
|
|
374
|
-
ok: boolean;
|
|
375
|
-
message: string;
|
|
376
|
-
data?: Record<string, unknown>;
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
export interface DockerDeployDoctorProbe {
|
|
380
|
-
url: string;
|
|
381
|
-
status: number | null;
|
|
382
|
-
ok: boolean;
|
|
383
|
-
responseSnippet: string;
|
|
384
|
-
gatewayJson?: boolean;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
export interface DockerDeployDoctorResult {
|
|
388
|
-
ok: boolean;
|
|
389
|
-
deployment: DeploymentData;
|
|
390
|
-
host?: DockerDeployHostData;
|
|
391
|
-
publicUrl?: string | null;
|
|
392
|
-
checks: DockerDeployDoctorCheck[];
|
|
393
|
-
probe?: DockerDeployDoctorProbe;
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
export interface DeploymentUpdateParams {
|
|
397
|
-
name?: string;
|
|
398
|
-
branch?: string;
|
|
399
|
-
build_command?: string;
|
|
400
|
-
buildCommand?: string;
|
|
401
|
-
run_command?: string;
|
|
402
|
-
runCommand?: string;
|
|
403
|
-
auto_deploy?: boolean;
|
|
404
|
-
autoDeploy?: boolean;
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
export interface PublishParams extends ExternalAttribution {
|
|
408
|
-
sourceSandboxId: string;
|
|
409
|
-
source_sandbox_id?: string;
|
|
410
|
-
name?: string;
|
|
411
|
-
deploymentId?: string;
|
|
412
|
-
deployment_id?: string;
|
|
413
|
-
/** @deprecated Reserved for dynamic runtime publish; ignored by current static publish route. */
|
|
414
|
-
kind?: "auto" | "static" | "dynamic";
|
|
415
|
-
/** @deprecated Reserved for deployment environments; ignored by current static publish route. */
|
|
416
|
-
environment?: "production" | "staging" | string;
|
|
417
|
-
outputPath?: string;
|
|
418
|
-
output_path?: string;
|
|
419
|
-
/** @deprecated Current /deployments/:id/publish snapshots /workspace internally. */
|
|
420
|
-
sourceSnapshotPath?: string;
|
|
421
|
-
/** @deprecated Current /deployments/:id/publish snapshots /workspace internally. */
|
|
422
|
-
source_snapshot_path?: string;
|
|
423
|
-
entrypoint?: string;
|
|
424
|
-
promote?: boolean;
|
|
425
|
-
domain?: string;
|
|
426
|
-
customDomain?: string;
|
|
427
|
-
custom_domain?: string;
|
|
428
|
-
/** @deprecated Reserved for dynamic runtime publish. */
|
|
429
|
-
buildCommand?: string;
|
|
430
|
-
/** @deprecated Reserved for dynamic runtime publish. */
|
|
431
|
-
build_command?: string;
|
|
432
|
-
/** @deprecated Reserved for dynamic runtime publish. */
|
|
433
|
-
runCommand?: string;
|
|
434
|
-
/** @deprecated Reserved for dynamic runtime publish. */
|
|
435
|
-
run_command?: string;
|
|
436
|
-
/** @deprecated Reserved for dynamic runtime publish. */
|
|
437
|
-
port?: number;
|
|
438
|
-
/** @deprecated Reserved for dynamic runtime publish. */
|
|
439
|
-
healthCheckPath?: string;
|
|
440
|
-
/** @deprecated Reserved for dynamic runtime publish. */
|
|
441
|
-
health_check_path?: string;
|
|
442
|
-
deploymentType?: DeploymentProduct | string;
|
|
443
|
-
deployment_type?: DeploymentProduct | string;
|
|
444
|
-
dockerDeployTemplateId?: string;
|
|
445
|
-
docker_deploy_template_id?: string;
|
|
446
|
-
/** @deprecated Reserved for managed data-service binding. */
|
|
447
|
-
dataServices?: string[];
|
|
448
|
-
/** @deprecated Reserved for managed data-service binding. */
|
|
449
|
-
data_services?: string[];
|
|
450
|
-
idempotencyKey?: string;
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
export interface PublishResult {
|
|
454
|
-
deployment: DeploymentData;
|
|
455
|
-
version: DeploymentVersionData;
|
|
456
|
-
release?: DeploymentReleaseData;
|
|
457
|
-
services?: DeploymentServiceData[];
|
|
458
|
-
promoted: boolean;
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
export type PublishFromSandboxParams = Omit<
|
|
462
|
-
PublishParams,
|
|
463
|
-
"sourceSandboxId" | "source_sandbox_id"
|
|
464
|
-
> & {
|
|
465
|
-
sourceSandboxId?: string;
|
|
466
|
-
source_sandbox_id?: string;
|
|
467
|
-
};
|
|
468
|
-
|
|
469
|
-
export interface RollbackParams {
|
|
470
|
-
versionId?: string;
|
|
471
|
-
version_id?: string;
|
|
472
|
-
idempotencyKey?: string;
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
export interface VersionListParams extends ExternalAttribution {
|
|
476
|
-
state?: DeploymentVersionState | string;
|
|
477
|
-
limit?: number;
|
|
478
|
-
cursor?: string;
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
export interface RuntimeLogsResult {
|
|
482
|
-
runtime_instance_id?: string;
|
|
483
|
-
deployment_id?: string;
|
|
484
|
-
log_path?: string;
|
|
485
|
-
logs: string;
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
export interface AddDomainParams extends ExternalAttribution {
|
|
489
|
-
redirectPolicy?: "none" | "www_to_apex" | "apex_to_www";
|
|
490
|
-
redirect_policy?: "none" | "www_to_apex" | "apex_to_www";
|
|
491
|
-
idempotencyKey?: string;
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
// ── Helpers ────────────────────────────────────────────────────────────────
|
|
495
|
-
|
|
496
|
-
function attributionBody(p: ExternalAttribution): Record<string, unknown> {
|
|
497
|
-
const out: Record<string, unknown> = {};
|
|
498
|
-
const ws = p.externalWorkspaceId ?? p.external_workspace_id;
|
|
499
|
-
const usr = p.externalUserId ?? p.external_user_id;
|
|
500
|
-
const proj = p.externalProjectId ?? p.external_project_id;
|
|
501
|
-
if (ws !== undefined) out.external_workspace_id = ws;
|
|
502
|
-
if (usr !== undefined) out.external_user_id = usr;
|
|
503
|
-
if (proj !== undefined) out.external_project_id = proj;
|
|
504
|
-
return out;
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
function idempotencyKey(key?: string): string {
|
|
508
|
-
return key ?? randomUUID();
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
function unwrap<T>(payload: { data?: T } | T): T {
|
|
512
|
-
if (payload && typeof payload === "object" && "data" in (payload as object)) {
|
|
513
|
-
return (payload as { data: T }).data;
|
|
514
|
-
}
|
|
515
|
-
return payload as T;
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
function listItems<T>(
|
|
519
|
-
payload: { data?: T[] } | { items?: T[] } | T[] | unknown,
|
|
520
|
-
candidateKeys: string[] = ["items", "deployments", "versions", "domains"],
|
|
521
|
-
): T[] {
|
|
522
|
-
if (Array.isArray(payload)) return payload;
|
|
523
|
-
if (!payload || typeof payload !== "object") return [];
|
|
524
|
-
const p = payload as Record<string, unknown>;
|
|
525
|
-
if (Array.isArray(p.data)) return p.data as T[];
|
|
526
|
-
for (const key of candidateKeys) {
|
|
527
|
-
if (Array.isArray(p[key])) return p[key] as T[];
|
|
528
|
-
}
|
|
529
|
-
return [];
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
function stripUndefined(
|
|
533
|
-
input: Record<string, unknown>,
|
|
534
|
-
): Record<string, unknown> {
|
|
535
|
-
return Object.fromEntries(
|
|
536
|
-
Object.entries(input).filter(([, v]) => v !== undefined),
|
|
537
|
-
);
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
function dockerDeployMetadata(
|
|
541
|
-
metadata: Record<string, unknown> | undefined,
|
|
542
|
-
templateId?: string,
|
|
543
|
-
): Record<string, unknown> {
|
|
544
|
-
return stripUndefined({
|
|
545
|
-
...(metadata ?? {}),
|
|
546
|
-
deployment_product: "docker_deploy",
|
|
547
|
-
docker_deploy_template_id: templateId,
|
|
548
|
-
});
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
552
|
-
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
function stringValue(value: unknown): string | undefined {
|
|
556
|
-
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
function runtimeMetadata(
|
|
560
|
-
metadata: Record<string, unknown>,
|
|
561
|
-
): Record<string, unknown> | undefined {
|
|
562
|
-
const runtime = metadata.runtime;
|
|
563
|
-
return isRecord(runtime) ? runtime : undefined;
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
function publicProbeUrl(publicUrl: string, probePath: string): string {
|
|
567
|
-
const url = new URL(publicUrl);
|
|
568
|
-
const normalizedPath = probePath.startsWith("/") ? probePath : `/${probePath}`;
|
|
569
|
-
url.pathname = normalizedPath;
|
|
570
|
-
return url.toString();
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
function looksLikeMiosaGatewayJson(body: string): boolean {
|
|
574
|
-
try {
|
|
575
|
-
const parsed = JSON.parse(body) as unknown;
|
|
576
|
-
return (
|
|
577
|
-
isRecord(parsed) &&
|
|
578
|
-
parsed.ok === true &&
|
|
579
|
-
typeof parsed.run_id === "string" &&
|
|
580
|
-
Object.keys(parsed).every((key) => ["ok", "run_id"].includes(key))
|
|
581
|
-
);
|
|
582
|
-
} catch {
|
|
583
|
-
return false;
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
function addDoctorCheck(
|
|
588
|
-
checks: DockerDeployDoctorCheck[],
|
|
589
|
-
name: string,
|
|
590
|
-
ok: boolean,
|
|
591
|
-
message: string,
|
|
592
|
-
data?: Record<string, unknown>,
|
|
593
|
-
): void {
|
|
594
|
-
const check: DockerDeployDoctorCheck = { name, ok, message };
|
|
595
|
-
if (data !== undefined) check.data = data;
|
|
596
|
-
checks.push(check);
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
// ── Sub-resources ──────────────────────────────────────────────────────────
|
|
600
|
-
|
|
601
|
-
export class DeploymentVersions {
|
|
602
|
-
constructor(
|
|
603
|
-
private readonly http: HttpClient,
|
|
604
|
-
private readonly deploymentId: string,
|
|
605
|
-
) {}
|
|
606
|
-
|
|
607
|
-
async list(params: VersionListParams = {}): Promise<DeploymentVersionData[]> {
|
|
608
|
-
const query = stripUndefined({
|
|
609
|
-
state: params.state,
|
|
610
|
-
limit: params.limit,
|
|
611
|
-
cursor: params.cursor,
|
|
612
|
-
...attributionBody(params),
|
|
613
|
-
});
|
|
614
|
-
const data = await this.http.get<unknown>(
|
|
615
|
-
`/deployments/${this.deploymentId}/versions`,
|
|
616
|
-
query as Record<string, string | number | boolean | undefined>,
|
|
617
|
-
);
|
|
618
|
-
return listItems<DeploymentVersionData>(data);
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
async get(versionId: string): Promise<DeploymentVersionData> {
|
|
622
|
-
const data = await this.http.get<unknown>(
|
|
623
|
-
`/deployments/${this.deploymentId}/versions/${versionId}`,
|
|
624
|
-
);
|
|
625
|
-
return unwrap(data) as DeploymentVersionData;
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
async promote(
|
|
629
|
-
versionId: string,
|
|
630
|
-
opts: { environment?: string; idempotencyKey?: string } = {},
|
|
631
|
-
): Promise<DeploymentData> {
|
|
632
|
-
const body = stripUndefined({ environment: opts.environment });
|
|
633
|
-
const data = await this.http.request<unknown>(
|
|
634
|
-
`/deployments/${this.deploymentId}/versions/${versionId}/promote`,
|
|
635
|
-
{
|
|
636
|
-
method: "POST",
|
|
637
|
-
body,
|
|
638
|
-
headers: { "Idempotency-Key": idempotencyKey(opts.idempotencyKey) },
|
|
639
|
-
},
|
|
640
|
-
);
|
|
641
|
-
return unwrap(data) as DeploymentData;
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
export class DeploymentReleases {
|
|
646
|
-
constructor(
|
|
647
|
-
private readonly http: HttpClient,
|
|
648
|
-
private readonly deploymentId: string,
|
|
649
|
-
) {}
|
|
650
|
-
|
|
651
|
-
async list(): Promise<DeploymentReleaseData[]> {
|
|
652
|
-
const data = await this.http.get<unknown>(
|
|
653
|
-
`/deployments/${this.deploymentId}/releases`,
|
|
654
|
-
);
|
|
655
|
-
return listItems<DeploymentReleaseData>(data, ["releases"]);
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
async get(releaseId: string): Promise<DeploymentReleaseData> {
|
|
659
|
-
const data = await this.http.get<unknown>(
|
|
660
|
-
`/deployments/${this.deploymentId}/releases/${releaseId}`,
|
|
661
|
-
);
|
|
662
|
-
return unwrap(data) as DeploymentReleaseData;
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
export class DeploymentRuntimeInstances {
|
|
667
|
-
constructor(
|
|
668
|
-
private readonly http: HttpClient,
|
|
669
|
-
private readonly deploymentId: string,
|
|
670
|
-
) {}
|
|
671
|
-
|
|
672
|
-
async list(): Promise<RuntimeInstanceData[]> {
|
|
673
|
-
const data = await this.http.get<unknown>(
|
|
674
|
-
`/deployments/${this.deploymentId}/runtime-instances`,
|
|
675
|
-
);
|
|
676
|
-
return listItems<RuntimeInstanceData>(data, ["runtime_instances"]);
|
|
677
|
-
}
|
|
678
|
-
|
|
679
|
-
async get(instanceId: string): Promise<RuntimeInstanceData> {
|
|
680
|
-
const data = await this.http.get<unknown>(
|
|
681
|
-
`/deployments/${this.deploymentId}/runtime-instances/${instanceId}`,
|
|
682
|
-
);
|
|
683
|
-
return unwrap(data) as RuntimeInstanceData;
|
|
684
|
-
}
|
|
685
|
-
|
|
686
|
-
async logs(instanceId: string, lines = 100): Promise<RuntimeLogsResult> {
|
|
687
|
-
const data = await this.http.get<unknown>(
|
|
688
|
-
`/deployments/${this.deploymentId}/runtime-instances/${instanceId}/logs`,
|
|
689
|
-
{ lines },
|
|
690
|
-
);
|
|
691
|
-
const unwrapped = unwrap(data) as Record<string, unknown>;
|
|
692
|
-
const result: RuntimeLogsResult = { logs: String(unwrapped.logs ?? "") };
|
|
693
|
-
if (typeof unwrapped.runtime_instance_id === "string") {
|
|
694
|
-
result.runtime_instance_id = unwrapped.runtime_instance_id;
|
|
695
|
-
}
|
|
696
|
-
if (typeof unwrapped.deployment_id === "string") {
|
|
697
|
-
result.deployment_id = unwrapped.deployment_id;
|
|
698
|
-
}
|
|
699
|
-
if (typeof unwrapped.log_path === "string") {
|
|
700
|
-
result.log_path = unwrapped.log_path;
|
|
701
|
-
}
|
|
702
|
-
return result;
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
export class DeploymentDomains {
|
|
707
|
-
constructor(
|
|
708
|
-
private readonly http: HttpClient,
|
|
709
|
-
private readonly deploymentId: string,
|
|
710
|
-
) {}
|
|
711
|
-
|
|
712
|
-
async add(
|
|
713
|
-
domain: string,
|
|
714
|
-
params: AddDomainParams = {},
|
|
715
|
-
): Promise<Record<string, unknown>> {
|
|
716
|
-
const body = {
|
|
717
|
-
domain,
|
|
718
|
-
redirect_policy: params.redirectPolicy ?? params.redirect_policy,
|
|
719
|
-
...attributionBody(params),
|
|
720
|
-
};
|
|
721
|
-
const data = await this.http.request<unknown>(
|
|
722
|
-
`/deployments/${this.deploymentId}/domains`,
|
|
723
|
-
{
|
|
724
|
-
method: "POST",
|
|
725
|
-
body: stripUndefined(body),
|
|
726
|
-
headers: { "Idempotency-Key": idempotencyKey(params.idempotencyKey) },
|
|
727
|
-
},
|
|
728
|
-
);
|
|
729
|
-
return unwrap(data) as Record<string, unknown>;
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
async list(
|
|
733
|
-
filters: ExternalAttribution = {},
|
|
734
|
-
): Promise<Record<string, unknown>[]> {
|
|
735
|
-
const data = await this.http.get<unknown>(
|
|
736
|
-
`/deployments/${this.deploymentId}/domains`,
|
|
737
|
-
attributionBody(filters) as Record<
|
|
738
|
-
string,
|
|
739
|
-
string | number | boolean | undefined
|
|
740
|
-
>,
|
|
741
|
-
);
|
|
742
|
-
return listItems<Record<string, unknown>>(data);
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
async verify(domainId: string): Promise<Record<string, unknown>> {
|
|
746
|
-
const data = await this.http.post<unknown>(
|
|
747
|
-
`/deployments/${this.deploymentId}/domains/${domainId}/verify`,
|
|
748
|
-
);
|
|
749
|
-
return unwrap(data) as Record<string, unknown>;
|
|
750
|
-
}
|
|
751
|
-
|
|
752
|
-
async delete(domainId: string): Promise<void> {
|
|
753
|
-
await this.http.delete<unknown>(
|
|
754
|
-
`/deployments/${this.deploymentId}/domains/${domainId}`,
|
|
755
|
-
);
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
// ── Main resource ──────────────────────────────────────────────────────────
|
|
760
|
-
|
|
761
|
-
export class Deployments {
|
|
762
|
-
constructor(private readonly http: HttpClient) {}
|
|
763
|
-
|
|
764
|
-
async list(params: DeploymentListParams = {}): Promise<DeploymentData[]> {
|
|
765
|
-
const projectId = params.projectId ?? params.project_id;
|
|
766
|
-
const query = stripUndefined({
|
|
767
|
-
project_id: projectId,
|
|
768
|
-
state: params.state,
|
|
769
|
-
limit: params.limit,
|
|
770
|
-
cursor: params.cursor,
|
|
771
|
-
...attributionBody(params),
|
|
772
|
-
});
|
|
773
|
-
const data = await this.http.get<unknown>(
|
|
774
|
-
"/deployments",
|
|
775
|
-
query as Record<string, string | number | boolean | undefined>,
|
|
776
|
-
);
|
|
777
|
-
return listItems<DeploymentData>(data);
|
|
778
|
-
}
|
|
779
|
-
|
|
780
|
-
async get(deploymentId: string): Promise<DeploymentData> {
|
|
781
|
-
const data = await this.http.get<unknown>(`/deployments/${deploymentId}`);
|
|
782
|
-
return unwrap(data) as DeploymentData;
|
|
783
|
-
}
|
|
784
|
-
|
|
785
|
-
async create(params: DeploymentCreateParams): Promise<DeploymentData> {
|
|
786
|
-
const body = stripUndefined({
|
|
787
|
-
name: params.name,
|
|
788
|
-
repo_url: params.repoUrl ?? params.repo_url,
|
|
789
|
-
branch: params.branch,
|
|
790
|
-
build_command: params.buildCommand ?? params.build_command,
|
|
791
|
-
run_command: params.runCommand ?? params.run_command,
|
|
792
|
-
auto_deploy: params.autoDeploy ?? params.auto_deploy,
|
|
793
|
-
database: params.database,
|
|
794
|
-
docker_deploy_template_id:
|
|
795
|
-
params.dockerDeployTemplateId ?? params.docker_deploy_template_id,
|
|
796
|
-
metadata: params.metadata,
|
|
797
|
-
...attributionBody(params),
|
|
798
|
-
});
|
|
799
|
-
const data = await this.http.request<unknown>("/deployments", {
|
|
800
|
-
method: "POST",
|
|
801
|
-
body,
|
|
802
|
-
headers: { "Idempotency-Key": idempotencyKey(params.idempotencyKey) },
|
|
803
|
-
});
|
|
804
|
-
return unwrap(data) as DeploymentData;
|
|
805
|
-
}
|
|
806
|
-
|
|
807
|
-
/**
|
|
808
|
-
* Create a deployment that runs on the workspace's dedicated Docker Deploy
|
|
809
|
-
* runtime. It uses the same /deployments API as MIOSA Deploy, but marks the
|
|
810
|
-
* deployment so the control plane attaches it to the workspace Docker host.
|
|
811
|
-
*/
|
|
812
|
-
async createDockerDeploy(
|
|
813
|
-
params: DockerDeployCreateParams,
|
|
814
|
-
): Promise<DeploymentData> {
|
|
815
|
-
const templateId =
|
|
816
|
-
params.dockerDeployTemplateId ?? params.docker_deploy_template_id;
|
|
817
|
-
return this.create({
|
|
818
|
-
...params,
|
|
819
|
-
metadata: dockerDeployMetadata(params.metadata, templateId),
|
|
820
|
-
});
|
|
821
|
-
}
|
|
822
|
-
|
|
823
|
-
async listDockerDeployHosts(
|
|
824
|
-
params: DockerDeployHostListParams = {},
|
|
825
|
-
): Promise<DockerDeployHostData[]> {
|
|
826
|
-
const data = await this.http.get<unknown>(
|
|
827
|
-
"/docker-deploy/hosts",
|
|
828
|
-
stripUndefined({
|
|
829
|
-
workspace_id: params.workspaceId ?? params.workspace_id,
|
|
830
|
-
}) as Record<string, string | number | boolean | undefined>,
|
|
831
|
-
);
|
|
832
|
-
return listItems<DockerDeployHostData>(data, ["hosts", "items"]);
|
|
833
|
-
}
|
|
834
|
-
|
|
835
|
-
async ensureDockerDeployHost(
|
|
836
|
-
params: DockerDeployHostEnsureParams,
|
|
837
|
-
): Promise<DockerDeployHostData> {
|
|
838
|
-
const data = await this.http.request<unknown>("/docker-deploy/hosts/ensure", {
|
|
839
|
-
method: "POST",
|
|
840
|
-
body: stripUndefined({
|
|
841
|
-
workspace_id: params.workspaceId ?? params.workspace_id,
|
|
842
|
-
region: params.region,
|
|
843
|
-
size: params.size,
|
|
844
|
-
appliance_image: params.applianceImage ?? params.appliance_image,
|
|
845
|
-
metadata: params.metadata,
|
|
846
|
-
}),
|
|
847
|
-
headers: { "Idempotency-Key": idempotencyKey(params.idempotencyKey) },
|
|
848
|
-
});
|
|
849
|
-
return unwrap(data) as DockerDeployHostData;
|
|
850
|
-
}
|
|
851
|
-
|
|
852
|
-
async getDockerDeployHost(hostId: string): Promise<DockerDeployHostData> {
|
|
853
|
-
const data = await this.http.get<unknown>(`/docker-deploy/hosts/${hostId}`);
|
|
854
|
-
return unwrap(data) as DockerDeployHostData;
|
|
855
|
-
}
|
|
856
|
-
|
|
857
|
-
/**
|
|
858
|
-
* Verify a Docker Deploy deployment end-to-end.
|
|
859
|
-
*
|
|
860
|
-
* This checks the deployment product marker, Docker Deploy host linkage,
|
|
861
|
-
* appliance health, route runtime metadata, and optionally the public URL.
|
|
862
|
-
* It is intentionally agent-friendly: use this after sandbox.deployDocker()
|
|
863
|
-
* or createDockerDeploy() before telling a user the app is live.
|
|
864
|
-
*/
|
|
865
|
-
async doctorDockerDeploy(
|
|
866
|
-
deploymentId: string,
|
|
867
|
-
params: DockerDeployDoctorParams = {},
|
|
868
|
-
): Promise<DockerDeployDoctorResult> {
|
|
869
|
-
const checks: DockerDeployDoctorCheck[] = [];
|
|
870
|
-
const deployment = await this.get(deploymentId);
|
|
871
|
-
const metadata = isRecord(deployment.metadata) ? deployment.metadata : {};
|
|
872
|
-
const product =
|
|
873
|
-
stringValue(deployment.deployment_product) ??
|
|
874
|
-
stringValue(metadata.deployment_product);
|
|
875
|
-
const hostId =
|
|
876
|
-
stringValue(deployment.docker_deploy_host_id) ??
|
|
877
|
-
stringValue(metadata.docker_deploy_host_id);
|
|
878
|
-
|
|
879
|
-
addDoctorCheck(
|
|
880
|
-
checks,
|
|
881
|
-
"deployment_product",
|
|
882
|
-
product === "docker_deploy",
|
|
883
|
-
product === "docker_deploy"
|
|
884
|
-
? "Deployment is marked as Docker Deploy."
|
|
885
|
-
: `Expected deployment_product=docker_deploy, got ${product ?? "missing"}.`,
|
|
886
|
-
{ product: product ?? null },
|
|
887
|
-
);
|
|
888
|
-
|
|
889
|
-
addDoctorCheck(
|
|
890
|
-
checks,
|
|
891
|
-
"docker_deploy_host_id",
|
|
892
|
-
!!hostId,
|
|
893
|
-
hostId
|
|
894
|
-
? "Deployment is linked to a Docker Deploy appliance host."
|
|
895
|
-
: "Deployment has no docker_deploy_host_id.",
|
|
896
|
-
{ docker_deploy_host_id: hostId ?? null },
|
|
897
|
-
);
|
|
898
|
-
|
|
899
|
-
let host: DockerDeployHostData | undefined;
|
|
900
|
-
if (hostId) {
|
|
901
|
-
try {
|
|
902
|
-
host = await this.getDockerDeployHost(hostId);
|
|
903
|
-
const status = host.status ?? null;
|
|
904
|
-
const applianceStatus = host.appliance_status ?? null;
|
|
905
|
-
const badHostStates = new Set(["failed", "error", "destroyed"]);
|
|
906
|
-
const badApplianceStates = new Set(["failed", "error", "unhealthy"]);
|
|
907
|
-
const ok =
|
|
908
|
-
!badHostStates.has(String(status)) &&
|
|
909
|
-
!badApplianceStates.has(String(applianceStatus));
|
|
910
|
-
addDoctorCheck(
|
|
911
|
-
checks,
|
|
912
|
-
"docker_deploy_host_health",
|
|
913
|
-
ok,
|
|
914
|
-
ok
|
|
915
|
-
? "Docker Deploy host is not reporting a failed state."
|
|
916
|
-
: `Docker Deploy host is unhealthy: status=${status}, appliance_status=${applianceStatus}.`,
|
|
917
|
-
{ status, appliance_status: applianceStatus },
|
|
918
|
-
);
|
|
919
|
-
} catch (err) {
|
|
920
|
-
addDoctorCheck(
|
|
921
|
-
checks,
|
|
922
|
-
"docker_deploy_host_health",
|
|
923
|
-
false,
|
|
924
|
-
`Could not fetch Docker Deploy host ${hostId}: ${
|
|
925
|
-
err instanceof Error ? err.message : String(err)
|
|
926
|
-
}`,
|
|
927
|
-
);
|
|
928
|
-
}
|
|
929
|
-
}
|
|
930
|
-
|
|
931
|
-
const runtime = runtimeMetadata(metadata);
|
|
932
|
-
const runtimeIp = runtime
|
|
933
|
-
? stringValue(runtime.ip) ?? stringValue(runtime.ip_address)
|
|
934
|
-
: undefined;
|
|
935
|
-
const runtimePort = runtime?.port;
|
|
936
|
-
addDoctorCheck(
|
|
937
|
-
checks,
|
|
938
|
-
"route_runtime",
|
|
939
|
-
!!runtimeIp && runtimePort !== undefined && runtimePort !== null,
|
|
940
|
-
runtimeIp && runtimePort !== undefined && runtimePort !== null
|
|
941
|
-
? "Deployment route metadata points at a runtime target."
|
|
942
|
-
: "Deployment metadata has no runtime ip/port target.",
|
|
943
|
-
{ ip: runtimeIp ?? null, port: runtimePort ?? null },
|
|
944
|
-
);
|
|
945
|
-
|
|
946
|
-
const publicUrl =
|
|
947
|
-
stringValue(deployment.public_url) ?? stringValue(metadata.public_url);
|
|
948
|
-
addDoctorCheck(
|
|
949
|
-
checks,
|
|
950
|
-
"public_url",
|
|
951
|
-
!!publicUrl,
|
|
952
|
-
publicUrl
|
|
953
|
-
? "Deployment has a public URL."
|
|
954
|
-
: "Deployment has no public URL to probe.",
|
|
955
|
-
{ public_url: publicUrl ?? null },
|
|
956
|
-
);
|
|
957
|
-
|
|
958
|
-
let probe: DockerDeployDoctorProbe | undefined;
|
|
959
|
-
if (params.probe !== false && publicUrl) {
|
|
960
|
-
const fetchImpl = params.fetchImpl ?? fetch;
|
|
961
|
-
const url = publicProbeUrl(publicUrl, params.probePath ?? "/");
|
|
962
|
-
const controller = new AbortController();
|
|
963
|
-
const timer = setTimeout(() => controller.abort(), params.timeoutMs ?? 20_000);
|
|
964
|
-
try {
|
|
965
|
-
const response = await fetchImpl(url, {
|
|
966
|
-
headers: { Accept: "*/*" },
|
|
967
|
-
signal: controller.signal,
|
|
968
|
-
});
|
|
969
|
-
const text = await response.text();
|
|
970
|
-
const gatewayJson = looksLikeMiosaGatewayJson(text);
|
|
971
|
-
const ok = response.ok && !gatewayJson;
|
|
972
|
-
probe = {
|
|
973
|
-
url,
|
|
974
|
-
status: response.status,
|
|
975
|
-
ok,
|
|
976
|
-
responseSnippet: text.slice(0, 500),
|
|
977
|
-
};
|
|
978
|
-
if (gatewayJson) probe.gatewayJson = true;
|
|
979
|
-
addDoctorCheck(
|
|
980
|
-
checks,
|
|
981
|
-
"public_url_probe",
|
|
982
|
-
ok,
|
|
983
|
-
ok
|
|
984
|
-
? `Public URL returned HTTP ${response.status}.`
|
|
985
|
-
: gatewayJson
|
|
986
|
-
? "Public URL returned MIOSA gateway JSON instead of the app."
|
|
987
|
-
: `Public URL returned HTTP ${response.status}.`,
|
|
988
|
-
{ status: response.status, gateway_json: gatewayJson },
|
|
989
|
-
);
|
|
990
|
-
} catch (err) {
|
|
991
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
992
|
-
probe = { url, status: null, ok: false, responseSnippet: message };
|
|
993
|
-
addDoctorCheck(
|
|
994
|
-
checks,
|
|
995
|
-
"public_url_probe",
|
|
996
|
-
false,
|
|
997
|
-
`Public URL probe failed: ${message}`,
|
|
998
|
-
);
|
|
999
|
-
} finally {
|
|
1000
|
-
clearTimeout(timer);
|
|
1001
|
-
}
|
|
1002
|
-
}
|
|
1003
|
-
|
|
1004
|
-
const result: DockerDeployDoctorResult = {
|
|
1005
|
-
ok: checks.every((check) => check.ok),
|
|
1006
|
-
deployment,
|
|
1007
|
-
checks,
|
|
1008
|
-
};
|
|
1009
|
-
if (host) result.host = host;
|
|
1010
|
-
if (publicUrl !== undefined) result.publicUrl = publicUrl;
|
|
1011
|
-
if (probe) result.probe = probe;
|
|
1012
|
-
return result;
|
|
1013
|
-
}
|
|
1014
|
-
|
|
1015
|
-
async listDockerDeployTemplates(
|
|
1016
|
-
params: DockerDeployTemplateListParams = {},
|
|
1017
|
-
): Promise<DockerDeployTemplateData[]> {
|
|
1018
|
-
const query: Record<string, string | number | boolean | undefined> = {
|
|
1019
|
-
category: params.category,
|
|
1020
|
-
runtime: params.runtime,
|
|
1021
|
-
framework: params.framework,
|
|
1022
|
-
include_preview: params.includePreview ?? params.include_preview,
|
|
1023
|
-
};
|
|
1024
|
-
const data = await this.http.get<unknown>(
|
|
1025
|
-
"/docker-deploy/templates",
|
|
1026
|
-
stripUndefined(query) as Record<string, string | number | boolean | undefined>,
|
|
1027
|
-
);
|
|
1028
|
-
const templates = unwrap<any>(data);
|
|
1029
|
-
if (Array.isArray(templates)) return templates as DockerDeployTemplateData[];
|
|
1030
|
-
return ((templates?.templates ?? templates?.items ?? templates?.data ?? []) ||
|
|
1031
|
-
[]) as DockerDeployTemplateData[];
|
|
1032
|
-
}
|
|
1033
|
-
|
|
1034
|
-
async getDockerDeployTemplate(
|
|
1035
|
-
templateId: string,
|
|
1036
|
-
): Promise<DockerDeployTemplateData> {
|
|
1037
|
-
const data = await this.http.get<unknown>(
|
|
1038
|
-
`/docker-deploy/templates/${templateId}`,
|
|
1039
|
-
);
|
|
1040
|
-
return unwrap(data) as DockerDeployTemplateData;
|
|
1041
|
-
}
|
|
1042
|
-
|
|
1043
|
-
async update(
|
|
1044
|
-
deploymentId: string,
|
|
1045
|
-
params: DeploymentUpdateParams,
|
|
1046
|
-
): Promise<DeploymentData> {
|
|
1047
|
-
const body = stripUndefined({
|
|
1048
|
-
name: params.name,
|
|
1049
|
-
branch: params.branch,
|
|
1050
|
-
build_command: params.buildCommand ?? params.build_command,
|
|
1051
|
-
run_command: params.runCommand ?? params.run_command,
|
|
1052
|
-
auto_deploy: params.autoDeploy ?? params.auto_deploy,
|
|
1053
|
-
});
|
|
1054
|
-
const data = await this.http.patch<unknown>(
|
|
1055
|
-
`/deployments/${deploymentId}`,
|
|
1056
|
-
body,
|
|
1057
|
-
);
|
|
1058
|
-
return unwrap(data) as DeploymentData;
|
|
1059
|
-
}
|
|
1060
|
-
|
|
1061
|
-
async delete(deploymentId: string): Promise<void> {
|
|
1062
|
-
await this.http.delete<unknown>(`/deployments/${deploymentId}`);
|
|
1063
|
-
}
|
|
1064
|
-
|
|
1065
|
-
async publish(
|
|
1066
|
-
deploymentId: string,
|
|
1067
|
-
params: PublishParams,
|
|
1068
|
-
): Promise<PublishResult> {
|
|
1069
|
-
const body = stripUndefined({
|
|
1070
|
-
source_sandbox_id: params.sourceSandboxId ?? params.source_sandbox_id,
|
|
1071
|
-
output_path: params.outputPath ?? params.output_path,
|
|
1072
|
-
entrypoint: params.entrypoint,
|
|
1073
|
-
promote: params.promote,
|
|
1074
|
-
build_command: params.buildCommand ?? params.build_command,
|
|
1075
|
-
run_command: params.runCommand ?? params.run_command,
|
|
1076
|
-
port: params.port,
|
|
1077
|
-
health_check_path: params.healthCheckPath ?? params.health_check_path,
|
|
1078
|
-
deployment_type: params.deploymentType ?? params.deployment_type,
|
|
1079
|
-
docker_deploy_template_id:
|
|
1080
|
-
params.dockerDeployTemplateId ?? params.docker_deploy_template_id,
|
|
1081
|
-
data_services: params.dataServices ?? params.data_services,
|
|
1082
|
-
...attributionBody(params),
|
|
1083
|
-
});
|
|
1084
|
-
const data = await this.http.request<unknown>(
|
|
1085
|
-
`/deployments/${deploymentId}/publish`,
|
|
1086
|
-
{
|
|
1087
|
-
method: "POST",
|
|
1088
|
-
body,
|
|
1089
|
-
headers: { "Idempotency-Key": idempotencyKey(params.idempotencyKey) },
|
|
1090
|
-
},
|
|
1091
|
-
);
|
|
1092
|
-
return unwrap(data) as PublishResult;
|
|
1093
|
-
}
|
|
1094
|
-
|
|
1095
|
-
/**
|
|
1096
|
-
* Backward-compatible bridge: POST /sandboxes/:id/deploy. Works today;
|
|
1097
|
-
* returns either release-backed or sandbox-backed depending on backend
|
|
1098
|
-
* phase. Prefer `publish()` once Phase 2B/3 lands.
|
|
1099
|
-
*/
|
|
1100
|
-
async publishFromSandbox(
|
|
1101
|
-
sandboxId: string,
|
|
1102
|
-
params: PublishFromSandboxParams = {},
|
|
1103
|
-
): Promise<Record<string, unknown>> {
|
|
1104
|
-
const body = stripUndefined({
|
|
1105
|
-
name: params.name,
|
|
1106
|
-
deployment_id: params.deploymentId ?? params.deployment_id,
|
|
1107
|
-
output_path: params.outputPath ?? params.output_path,
|
|
1108
|
-
source_snapshot_path:
|
|
1109
|
-
params.sourceSnapshotPath ?? params.source_snapshot_path,
|
|
1110
|
-
entrypoint: params.entrypoint,
|
|
1111
|
-
domain: params.domain,
|
|
1112
|
-
custom_domain: params.customDomain ?? params.custom_domain,
|
|
1113
|
-
build_command: params.buildCommand ?? params.build_command,
|
|
1114
|
-
run_command: params.runCommand ?? params.run_command,
|
|
1115
|
-
port: params.port,
|
|
1116
|
-
health_check_path: params.healthCheckPath ?? params.health_check_path,
|
|
1117
|
-
deployment_type: params.deploymentType ?? params.deployment_type,
|
|
1118
|
-
docker_deploy_template_id:
|
|
1119
|
-
params.dockerDeployTemplateId ?? params.docker_deploy_template_id,
|
|
1120
|
-
data_services: params.dataServices ?? params.data_services,
|
|
1121
|
-
...attributionBody(params),
|
|
1122
|
-
});
|
|
1123
|
-
const data = await this.http.request<unknown>(
|
|
1124
|
-
`/sandboxes/${sandboxId}/deploy`,
|
|
1125
|
-
{
|
|
1126
|
-
method: "POST",
|
|
1127
|
-
body,
|
|
1128
|
-
headers: { "Idempotency-Key": idempotencyKey(params.idempotencyKey) },
|
|
1129
|
-
},
|
|
1130
|
-
);
|
|
1131
|
-
return unwrap(data) as Record<string, unknown>;
|
|
1132
|
-
}
|
|
1133
|
-
|
|
1134
|
-
async rollback(
|
|
1135
|
-
deploymentId: string,
|
|
1136
|
-
params: RollbackParams = {},
|
|
1137
|
-
): Promise<DeploymentData> {
|
|
1138
|
-
const body = stripUndefined({
|
|
1139
|
-
version_id: params.versionId ?? params.version_id,
|
|
1140
|
-
});
|
|
1141
|
-
const data = await this.http.request<unknown>(
|
|
1142
|
-
`/deployments/${deploymentId}/rollback`,
|
|
1143
|
-
{
|
|
1144
|
-
method: "POST",
|
|
1145
|
-
body,
|
|
1146
|
-
headers: { "Idempotency-Key": idempotencyKey(params.idempotencyKey) },
|
|
1147
|
-
},
|
|
1148
|
-
);
|
|
1149
|
-
return unwrap(data) as DeploymentData;
|
|
1150
|
-
}
|
|
1151
|
-
|
|
1152
|
-
async listBuilds(deploymentId: string): Promise<DeploymentBuildData[]> {
|
|
1153
|
-
const data = await this.http.get<unknown>(
|
|
1154
|
-
`/deployments/${deploymentId}/builds`,
|
|
1155
|
-
);
|
|
1156
|
-
return listItems<DeploymentBuildData>(data);
|
|
1157
|
-
}
|
|
1158
|
-
|
|
1159
|
-
async getBuild(
|
|
1160
|
-
deploymentId: string,
|
|
1161
|
-
buildId: string,
|
|
1162
|
-
): Promise<DeploymentBuildData> {
|
|
1163
|
-
const data = await this.http.get<unknown>(
|
|
1164
|
-
`/deployments/${deploymentId}/builds/${buildId}`,
|
|
1165
|
-
);
|
|
1166
|
-
return unwrap(data) as DeploymentBuildData;
|
|
1167
|
-
}
|
|
1168
|
-
|
|
1169
|
-
async listEnv(deploymentId: string): Promise<Record<string, unknown>[]> {
|
|
1170
|
-
const data = await this.http.get<unknown>(
|
|
1171
|
-
`/deployments/${deploymentId}/env`,
|
|
1172
|
-
);
|
|
1173
|
-
return listItems<Record<string, unknown>>(data);
|
|
1174
|
-
}
|
|
1175
|
-
|
|
1176
|
-
async setEnv(
|
|
1177
|
-
deploymentId: string,
|
|
1178
|
-
vars: Record<string, string>,
|
|
1179
|
-
opts: { environment?: string } = {},
|
|
1180
|
-
): Promise<Record<string, unknown>[]> {
|
|
1181
|
-
const body = stripUndefined({ env: vars, environment: opts.environment });
|
|
1182
|
-
const data = await this.http.post<unknown>(
|
|
1183
|
-
`/deployments/${deploymentId}/env`,
|
|
1184
|
-
body,
|
|
1185
|
-
);
|
|
1186
|
-
return listItems<Record<string, unknown>>(data);
|
|
1187
|
-
}
|
|
1188
|
-
|
|
1189
|
-
versions(deploymentId: string): DeploymentVersions {
|
|
1190
|
-
return new DeploymentVersions(this.http, deploymentId);
|
|
1191
|
-
}
|
|
1192
|
-
|
|
1193
|
-
releases(deploymentId: string): DeploymentReleases {
|
|
1194
|
-
return new DeploymentReleases(this.http, deploymentId);
|
|
1195
|
-
}
|
|
1196
|
-
|
|
1197
|
-
runtimeInstances(deploymentId: string): DeploymentRuntimeInstances {
|
|
1198
|
-
return new DeploymentRuntimeInstances(this.http, deploymentId);
|
|
1199
|
-
}
|
|
1200
|
-
|
|
1201
|
-
runtime_instances(deploymentId: string): DeploymentRuntimeInstances {
|
|
1202
|
-
return this.runtimeInstances(deploymentId);
|
|
1203
|
-
}
|
|
1204
|
-
|
|
1205
|
-
domains(deploymentId: string): DeploymentDomains {
|
|
1206
|
-
return new DeploymentDomains(this.http, deploymentId);
|
|
1207
|
-
}
|
|
1208
|
-
}
|