@miosa/sdk 1.2.1 → 1.2.3
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 +43 -1
- package/dist/index.d.ts +224 -8
- package/dist/index.js +398 -30
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +5 -0
- package/src/index.ts +24 -2
- package/src/resources/admin.ts +11 -0
- package/src/resources/api-keys.ts +16 -0
- package/src/resources/custom_domains.ts +1 -1
- package/src/resources/deployments.test.ts +121 -0
- package/src/resources/deployments.ts +231 -1
- package/src/resources/docker-deploy.test.ts +102 -0
- package/src/resources/docker-deploy.ts +183 -0
- package/src/resources/governance.test.ts +355 -0
- package/src/resources/governance.ts +528 -0
- package/src/resources/phase1.test.ts +187 -0
- package/src/resources/quotas.ts +77 -0
- package/src/resources/sandbox-processes.ts +112 -0
- package/src/resources/sandbox-shares.ts +83 -0
- package/src/resources/sandboxes.test.ts +26 -0
- package/src/resources/sandboxes.ts +31 -0
- package/src/resources/tenant-events.ts +32 -0
- package/src/resources/tenant.ts +111 -2
- package/src/resources/webhooks.ts +54 -1
- package/src/resources/workspaces.ts +285 -0
- package/src/types.ts +5 -5
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { randomUUID } from 'crypto';
|
|
1
|
+
import { createHmac, timingSafeEqual, randomUUID } from 'crypto';
|
|
2
2
|
import EventEmitter from 'events';
|
|
3
3
|
|
|
4
4
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
@@ -592,6 +592,13 @@ var Admin = class {
|
|
|
592
592
|
model_id: modelId
|
|
593
593
|
});
|
|
594
594
|
}
|
|
595
|
+
/** POST /api/v1/admin/impersonate — returns {token, expires_at}. */
|
|
596
|
+
impersonate(externalUserId, options = {}) {
|
|
597
|
+
return this.http.post("/admin/impersonate", {
|
|
598
|
+
external_user_id: externalUserId,
|
|
599
|
+
ttl_sec: options.ttlSec ?? 3600
|
|
600
|
+
});
|
|
601
|
+
}
|
|
595
602
|
};
|
|
596
603
|
|
|
597
604
|
// src/resources/analytics.ts
|
|
@@ -674,6 +681,17 @@ var ApiKeys = class {
|
|
|
674
681
|
});
|
|
675
682
|
return unwrap2(data);
|
|
676
683
|
}
|
|
684
|
+
/** POST /api/v1/api-keys/scoped — L2 delegation token bound to one external user. */
|
|
685
|
+
async createScoped(params) {
|
|
686
|
+
const body = stripUndefined2({
|
|
687
|
+
external_user_id: params.externalUserId,
|
|
688
|
+
scopes: params.scopes,
|
|
689
|
+
expires_at: params.expiresAt
|
|
690
|
+
});
|
|
691
|
+
return unwrap2(
|
|
692
|
+
await this.http.post("/api-keys/scoped", body)
|
|
693
|
+
);
|
|
694
|
+
}
|
|
677
695
|
async delete(keyId) {
|
|
678
696
|
await this.http.delete(`/api-keys/${keyId}`);
|
|
679
697
|
}
|
|
@@ -3621,6 +3639,32 @@ function stripUndefined10(input) {
|
|
|
3621
3639
|
Object.entries(input).filter(([, v]) => v !== void 0)
|
|
3622
3640
|
);
|
|
3623
3641
|
}
|
|
3642
|
+
function dockerDeployMetadata(metadata) {
|
|
3643
|
+
return {
|
|
3644
|
+
...metadata ?? {},
|
|
3645
|
+
deployment_product: "docker_deploy"
|
|
3646
|
+
};
|
|
3647
|
+
}
|
|
3648
|
+
function dockerDeployProduct(deployment) {
|
|
3649
|
+
return deployment.deployment_product ?? deployment.metadata?.["deployment_product"];
|
|
3650
|
+
}
|
|
3651
|
+
function dockerDeployHostId(deployment) {
|
|
3652
|
+
const metadataHost = deployment.metadata?.["docker_deploy_host_id"];
|
|
3653
|
+
return deployment.docker_deploy_host_id ?? (typeof metadataHost === "string" ? metadataHost : null);
|
|
3654
|
+
}
|
|
3655
|
+
function addDoctorCheck(checks, name, ok, message, details) {
|
|
3656
|
+
checks.push({ name, ok, message, ...details ? { details } : {} });
|
|
3657
|
+
}
|
|
3658
|
+
function hostHealthy(host) {
|
|
3659
|
+
return Boolean(
|
|
3660
|
+
host && host.status === "active" && host.appliance_status === "healthy"
|
|
3661
|
+
);
|
|
3662
|
+
}
|
|
3663
|
+
function probeUrl(publicUrl, probePath) {
|
|
3664
|
+
const url = new URL(publicUrl);
|
|
3665
|
+
url.pathname = probePath.startsWith("/") ? probePath : `/${probePath}`;
|
|
3666
|
+
return url.toString();
|
|
3667
|
+
}
|
|
3624
3668
|
var DeploymentVersions = class {
|
|
3625
3669
|
constructor(http, deploymentId) {
|
|
3626
3670
|
this.http = http;
|
|
@@ -3803,6 +3847,125 @@ var Deployments = class {
|
|
|
3803
3847
|
});
|
|
3804
3848
|
return unwrap23(data);
|
|
3805
3849
|
}
|
|
3850
|
+
/**
|
|
3851
|
+
* Create a deployment that runs on the workspace's dedicated Docker Deploy
|
|
3852
|
+
* runtime. It uses the same /deployments API as MIOSA Deploy, but marks the
|
|
3853
|
+
* deployment so the control plane attaches it to the workspace Docker host.
|
|
3854
|
+
*/
|
|
3855
|
+
async createDockerDeploy(params) {
|
|
3856
|
+
return this.create({
|
|
3857
|
+
...params,
|
|
3858
|
+
metadata: dockerDeployMetadata(params.metadata)
|
|
3859
|
+
});
|
|
3860
|
+
}
|
|
3861
|
+
/**
|
|
3862
|
+
* Verify a Docker Deploy deployment before telling a user or agent it is
|
|
3863
|
+
* live. Checks product markers, appliance host health, route metadata, and
|
|
3864
|
+
* optionally probes the public URL.
|
|
3865
|
+
*/
|
|
3866
|
+
async doctorDockerDeploy(deploymentId, params = {}) {
|
|
3867
|
+
const checks = [];
|
|
3868
|
+
const deployment = await this.get(deploymentId);
|
|
3869
|
+
const metadata = deployment.metadata ?? {};
|
|
3870
|
+
const product = dockerDeployProduct(deployment);
|
|
3871
|
+
const hostId = dockerDeployHostId(deployment);
|
|
3872
|
+
addDoctorCheck(
|
|
3873
|
+
checks,
|
|
3874
|
+
"deployment_product",
|
|
3875
|
+
product === "docker_deploy",
|
|
3876
|
+
product === "docker_deploy" ? "Deployment is marked for Docker Deploy." : `Expected deployment_product=docker_deploy, got ${String(product ?? "missing")}.`,
|
|
3877
|
+
{ deployment_product: product ?? null }
|
|
3878
|
+
);
|
|
3879
|
+
addDoctorCheck(
|
|
3880
|
+
checks,
|
|
3881
|
+
"docker_deploy_host_id",
|
|
3882
|
+
Boolean(hostId),
|
|
3883
|
+
hostId ? "Deployment has a Docker Deploy host id." : "Deployment has no docker_deploy_host_id.",
|
|
3884
|
+
{ docker_deploy_host_id: hostId }
|
|
3885
|
+
);
|
|
3886
|
+
let host;
|
|
3887
|
+
if (hostId) {
|
|
3888
|
+
try {
|
|
3889
|
+
const rawHost = await this.http.get(
|
|
3890
|
+
`/docker-deploy/hosts/${hostId}`
|
|
3891
|
+
);
|
|
3892
|
+
host = unwrap23(rawHost);
|
|
3893
|
+
addDoctorCheck(
|
|
3894
|
+
checks,
|
|
3895
|
+
"docker_deploy_host_health",
|
|
3896
|
+
hostHealthy(host),
|
|
3897
|
+
hostHealthy(host) ? "Docker Deploy host is active and healthy." : `Docker Deploy host status=${host.status} appliance=${host.appliance_status}.`,
|
|
3898
|
+
{
|
|
3899
|
+
status: host.status,
|
|
3900
|
+
appliance_status: host.appliance_status
|
|
3901
|
+
}
|
|
3902
|
+
);
|
|
3903
|
+
} catch (error) {
|
|
3904
|
+
addDoctorCheck(
|
|
3905
|
+
checks,
|
|
3906
|
+
"docker_deploy_host_health",
|
|
3907
|
+
false,
|
|
3908
|
+
error instanceof Error ? error.message : String(error)
|
|
3909
|
+
);
|
|
3910
|
+
}
|
|
3911
|
+
}
|
|
3912
|
+
const runtime = metadata["runtime"];
|
|
3913
|
+
const hasRuntimeRoute = typeof runtime === "object" && runtime !== null && typeof runtime["ip"] === "string" && typeof runtime["port"] === "number";
|
|
3914
|
+
addDoctorCheck(
|
|
3915
|
+
checks,
|
|
3916
|
+
"runtime_route",
|
|
3917
|
+
hasRuntimeRoute,
|
|
3918
|
+
hasRuntimeRoute ? "Deployment has appliance runtime route metadata." : "Deployment is missing appliance runtime route metadata.",
|
|
3919
|
+
typeof runtime === "object" && runtime !== null ? runtime : void 0
|
|
3920
|
+
);
|
|
3921
|
+
let probe;
|
|
3922
|
+
const publicUrl = deployment.public_url;
|
|
3923
|
+
const path = params.probePath ?? params.probe_path ?? "/";
|
|
3924
|
+
if (publicUrl && typeof fetch === "function") {
|
|
3925
|
+
const url = probeUrl(publicUrl, path);
|
|
3926
|
+
const controller = new AbortController();
|
|
3927
|
+
const timeout = setTimeout(
|
|
3928
|
+
() => controller.abort(),
|
|
3929
|
+
params.timeoutMs ?? params.timeout_ms ?? 1e4
|
|
3930
|
+
);
|
|
3931
|
+
try {
|
|
3932
|
+
const response = await fetch(url, {
|
|
3933
|
+
method: "GET",
|
|
3934
|
+
signal: controller.signal
|
|
3935
|
+
});
|
|
3936
|
+
probe = { url, ok: response.ok, status: response.status };
|
|
3937
|
+
addDoctorCheck(
|
|
3938
|
+
checks,
|
|
3939
|
+
"public_url_probe",
|
|
3940
|
+
response.ok,
|
|
3941
|
+
response.ok ? `Public URL returned HTTP ${response.status}.` : `Public URL returned HTTP ${response.status}.`,
|
|
3942
|
+
{ url, status: response.status }
|
|
3943
|
+
);
|
|
3944
|
+
} catch (error) {
|
|
3945
|
+
probe = {
|
|
3946
|
+
url,
|
|
3947
|
+
ok: false,
|
|
3948
|
+
error: error instanceof Error ? error.message : String(error)
|
|
3949
|
+
};
|
|
3950
|
+
addDoctorCheck(
|
|
3951
|
+
checks,
|
|
3952
|
+
"public_url_probe",
|
|
3953
|
+
false,
|
|
3954
|
+
probe.error ?? "Public URL probe failed.",
|
|
3955
|
+
{ url }
|
|
3956
|
+
);
|
|
3957
|
+
} finally {
|
|
3958
|
+
clearTimeout(timeout);
|
|
3959
|
+
}
|
|
3960
|
+
}
|
|
3961
|
+
return {
|
|
3962
|
+
ok: checks.every((check) => check.ok),
|
|
3963
|
+
deployment,
|
|
3964
|
+
...host ? { host } : {},
|
|
3965
|
+
checks,
|
|
3966
|
+
...probe ? { probe } : {}
|
|
3967
|
+
};
|
|
3968
|
+
}
|
|
3806
3969
|
async update(deploymentId, params) {
|
|
3807
3970
|
const body = stripUndefined10({
|
|
3808
3971
|
name: params.name,
|
|
@@ -3919,6 +4082,90 @@ var Deployments = class {
|
|
|
3919
4082
|
}
|
|
3920
4083
|
};
|
|
3921
4084
|
|
|
4085
|
+
// src/resources/docker-deploy.ts
|
|
4086
|
+
function workspaceId(params) {
|
|
4087
|
+
return params?.workspace_id ?? params?.workspaceId;
|
|
4088
|
+
}
|
|
4089
|
+
function ensureBody(params) {
|
|
4090
|
+
const body = {};
|
|
4091
|
+
const id = params.workspace_id ?? params.workspaceId;
|
|
4092
|
+
const externalId = params.external_workspace_id ?? params.externalWorkspaceId;
|
|
4093
|
+
if (id) body.workspace_id = id;
|
|
4094
|
+
if (externalId) body.external_workspace_id = externalId;
|
|
4095
|
+
return body;
|
|
4096
|
+
}
|
|
4097
|
+
function unwrapHost(response) {
|
|
4098
|
+
const host = response.data ?? response.host;
|
|
4099
|
+
if (!host) {
|
|
4100
|
+
throw new Error("Docker Deploy host response was empty.");
|
|
4101
|
+
}
|
|
4102
|
+
return host;
|
|
4103
|
+
}
|
|
4104
|
+
function unwrapTemplates(response) {
|
|
4105
|
+
return response.data ?? response.templates ?? [];
|
|
4106
|
+
}
|
|
4107
|
+
function unwrapTemplate(response) {
|
|
4108
|
+
const template = response.data ?? response.template;
|
|
4109
|
+
if (!template) {
|
|
4110
|
+
throw new Error("Docker Deploy template response was empty.");
|
|
4111
|
+
}
|
|
4112
|
+
return template;
|
|
4113
|
+
}
|
|
4114
|
+
var DockerDeploy = class {
|
|
4115
|
+
constructor(http) {
|
|
4116
|
+
this.http = http;
|
|
4117
|
+
}
|
|
4118
|
+
http;
|
|
4119
|
+
/**
|
|
4120
|
+
* List Docker Deploy appliance hosts scoped to the current tenant.
|
|
4121
|
+
*
|
|
4122
|
+
* Pass a workspace ID to inspect the dedicated always-on appliance machine
|
|
4123
|
+
* for one white-label workspace.
|
|
4124
|
+
*/
|
|
4125
|
+
async listHosts(params = {}) {
|
|
4126
|
+
const res = await this.http.get(
|
|
4127
|
+
"/docker-deploy/hosts",
|
|
4128
|
+
{ workspace_id: workspaceId(params) }
|
|
4129
|
+
);
|
|
4130
|
+
return res.data ?? res.hosts ?? [];
|
|
4131
|
+
}
|
|
4132
|
+
/**
|
|
4133
|
+
* Ensure a workspace has its dedicated Docker Deploy appliance host.
|
|
4134
|
+
*
|
|
4135
|
+
* The host may still be `pending`, `provisioning`, or `bootstrapping` after
|
|
4136
|
+
* this call. Treat `status === "active"` and `appliance_status === "healthy"`
|
|
4137
|
+
* as the ready condition before sending app/container traffic to it.
|
|
4138
|
+
*/
|
|
4139
|
+
async ensureHost(params = {}) {
|
|
4140
|
+
const res = await this.http.post(
|
|
4141
|
+
"/docker-deploy/hosts/ensure",
|
|
4142
|
+
ensureBody(params)
|
|
4143
|
+
);
|
|
4144
|
+
return { host: unwrapHost(res), queued: res.queued ?? false };
|
|
4145
|
+
}
|
|
4146
|
+
/** Fetch one Docker Deploy host by ID. */
|
|
4147
|
+
async getHost(hostId) {
|
|
4148
|
+
const res = await this.http.get(
|
|
4149
|
+
`/docker-deploy/hosts/${hostId}`
|
|
4150
|
+
);
|
|
4151
|
+
return unwrapHost(res);
|
|
4152
|
+
}
|
|
4153
|
+
/** List Docker Deploy starter templates. */
|
|
4154
|
+
async listTemplates() {
|
|
4155
|
+
const res = await this.http.get(
|
|
4156
|
+
"/docker-deploy/templates"
|
|
4157
|
+
);
|
|
4158
|
+
return unwrapTemplates(res);
|
|
4159
|
+
}
|
|
4160
|
+
/** Fetch one Docker Deploy starter template by ID. */
|
|
4161
|
+
async getTemplate(templateId) {
|
|
4162
|
+
const res = await this.http.get(
|
|
4163
|
+
`/docker-deploy/templates/${encodeURIComponent(templateId)}`
|
|
4164
|
+
);
|
|
4165
|
+
return unwrapTemplate(res);
|
|
4166
|
+
}
|
|
4167
|
+
};
|
|
4168
|
+
|
|
3922
4169
|
// src/resources/email.ts
|
|
3923
4170
|
function unwrap24(data) {
|
|
3924
4171
|
if (data && typeof data === "object") {
|
|
@@ -5070,49 +5317,49 @@ var OcWorkspaces = class {
|
|
|
5070
5317
|
/**
|
|
5071
5318
|
* Fetch a single workspace.
|
|
5072
5319
|
*/
|
|
5073
|
-
async get(hostId,
|
|
5320
|
+
async get(hostId, workspaceId2) {
|
|
5074
5321
|
return this.http.get(
|
|
5075
|
-
`${this.base(hostId)}/${
|
|
5322
|
+
`${this.base(hostId)}/${workspaceId2}`
|
|
5076
5323
|
);
|
|
5077
5324
|
}
|
|
5078
5325
|
/**
|
|
5079
5326
|
* Update workspace metadata (name, branch).
|
|
5080
5327
|
*/
|
|
5081
|
-
async update(hostId,
|
|
5328
|
+
async update(hostId, workspaceId2, params) {
|
|
5082
5329
|
return this.http.patch(
|
|
5083
|
-
`${this.base(hostId)}/${
|
|
5330
|
+
`${this.base(hostId)}/${workspaceId2}`,
|
|
5084
5331
|
params
|
|
5085
5332
|
);
|
|
5086
5333
|
}
|
|
5087
5334
|
/**
|
|
5088
5335
|
* Delete a workspace.
|
|
5089
5336
|
*/
|
|
5090
|
-
async delete(hostId,
|
|
5091
|
-
return this.http.delete(`${this.base(hostId)}/${
|
|
5337
|
+
async delete(hostId, workspaceId2) {
|
|
5338
|
+
return this.http.delete(`${this.base(hostId)}/${workspaceId2}`);
|
|
5092
5339
|
}
|
|
5093
5340
|
/**
|
|
5094
5341
|
* Pull the latest changes from the remote repository.
|
|
5095
5342
|
*/
|
|
5096
|
-
async pull(hostId,
|
|
5343
|
+
async pull(hostId, workspaceId2) {
|
|
5097
5344
|
return this.http.post(
|
|
5098
|
-
`${this.base(hostId)}/${
|
|
5345
|
+
`${this.base(hostId)}/${workspaceId2}/pull`
|
|
5099
5346
|
);
|
|
5100
5347
|
}
|
|
5101
5348
|
/**
|
|
5102
5349
|
* Open a terminal session scoped to the workspace root directory.
|
|
5103
5350
|
* Returns a short-lived WebSocket ticket.
|
|
5104
5351
|
*/
|
|
5105
|
-
async openTerminal(hostId,
|
|
5352
|
+
async openTerminal(hostId, workspaceId2) {
|
|
5106
5353
|
return this.http.post(
|
|
5107
|
-
`${this.base(hostId)}/${
|
|
5354
|
+
`${this.base(hostId)}/${workspaceId2}/open-terminal`
|
|
5108
5355
|
);
|
|
5109
5356
|
}
|
|
5110
5357
|
/**
|
|
5111
5358
|
* Stream workspace setup / clone / install events.
|
|
5112
5359
|
*/
|
|
5113
|
-
events(hostId,
|
|
5360
|
+
events(hostId, workspaceId2) {
|
|
5114
5361
|
return this.http.stream(
|
|
5115
|
-
`${this.base(hostId)}/${
|
|
5362
|
+
`${this.base(hostId)}/${workspaceId2}/events`
|
|
5116
5363
|
);
|
|
5117
5364
|
}
|
|
5118
5365
|
};
|
|
@@ -6033,6 +6280,16 @@ var Sandbox = class _Sandbox {
|
|
|
6033
6280
|
output_path: params.outputPath ?? params.output_path ?? params.path ?? params.sourcePath ?? params.source_path,
|
|
6034
6281
|
source_snapshot_path: params.sourceSnapshotPath ?? params.source_snapshot_path,
|
|
6035
6282
|
entrypoint: params.entrypoint,
|
|
6283
|
+
build_command: params.buildCommand ?? params.build_command,
|
|
6284
|
+
run_command: params.runCommand ?? params.run_command,
|
|
6285
|
+
start_command: params.startCommand ?? params.start_command,
|
|
6286
|
+
port: params.port,
|
|
6287
|
+
health_check_path: params.healthCheckPath ?? params.health_check_path,
|
|
6288
|
+
deployment_type: params.deploymentType ?? params.deployment_type,
|
|
6289
|
+
type: params.type,
|
|
6290
|
+
mode: params.mode,
|
|
6291
|
+
database: params.database,
|
|
6292
|
+
resources: params.resources,
|
|
6036
6293
|
domain: params.domain,
|
|
6037
6294
|
custom_domain: params.customDomain ?? params.custom_domain
|
|
6038
6295
|
})
|
|
@@ -6047,6 +6304,9 @@ var Sandbox = class _Sandbox {
|
|
|
6047
6304
|
)
|
|
6048
6305
|
);
|
|
6049
6306
|
}
|
|
6307
|
+
async deployDocker(params = {}) {
|
|
6308
|
+
return this.deploy({ ...params, deploymentType: "docker_deploy" });
|
|
6309
|
+
}
|
|
6050
6310
|
/** Check readiness of the sandbox (GET /sandboxes/:id/readiness). */
|
|
6051
6311
|
async readiness() {
|
|
6052
6312
|
return unwrap36(
|
|
@@ -6705,22 +6965,96 @@ var OrgInvites = class {
|
|
|
6705
6965
|
function unwrap41(payload) {
|
|
6706
6966
|
if (payload && typeof payload === "object") {
|
|
6707
6967
|
const p = payload;
|
|
6708
|
-
for (const k of ["data", "tenant", "items"]) {
|
|
6968
|
+
for (const k of ["data", "tenant", "branding", "items"]) {
|
|
6709
6969
|
if (k in p) return p[k];
|
|
6710
6970
|
}
|
|
6711
6971
|
}
|
|
6712
6972
|
return payload;
|
|
6713
6973
|
}
|
|
6714
|
-
var
|
|
6974
|
+
var PreviewDomain = class {
|
|
6715
6975
|
constructor(http) {
|
|
6716
6976
|
this.http = http;
|
|
6717
6977
|
}
|
|
6718
6978
|
http;
|
|
6979
|
+
/** Get the tenant's white-label preview domain settings. */
|
|
6980
|
+
async get() {
|
|
6981
|
+
const data = await this.http.get("/tenant/preview-domain");
|
|
6982
|
+
return unwrap41(data);
|
|
6983
|
+
}
|
|
6984
|
+
/** Set the tenant's white-label preview domain. */
|
|
6985
|
+
async set(domain) {
|
|
6986
|
+
const data = await this.http.put("/tenant/preview-domain", {
|
|
6987
|
+
preview_domain: domain
|
|
6988
|
+
});
|
|
6989
|
+
return unwrap41(data);
|
|
6990
|
+
}
|
|
6991
|
+
/** Re-run DNS verification for the configured preview domain. */
|
|
6992
|
+
async verify() {
|
|
6993
|
+
const data = await this.http.post(
|
|
6994
|
+
"/tenant/preview-domain/verify",
|
|
6995
|
+
{}
|
|
6996
|
+
);
|
|
6997
|
+
return unwrap41(data);
|
|
6998
|
+
}
|
|
6999
|
+
/** Remove the tenant's custom preview domain. */
|
|
7000
|
+
async delete() {
|
|
7001
|
+
await this.http.delete("/tenant/preview-domain");
|
|
7002
|
+
}
|
|
7003
|
+
};
|
|
7004
|
+
var Branding = class {
|
|
7005
|
+
constructor(http) {
|
|
7006
|
+
this.http = http;
|
|
7007
|
+
}
|
|
7008
|
+
http;
|
|
7009
|
+
/** Get tenant branding used by white-label hosted surfaces. */
|
|
7010
|
+
async get() {
|
|
7011
|
+
const data = await this.http.get("/tenant/branding");
|
|
7012
|
+
return unwrap41(data);
|
|
7013
|
+
}
|
|
7014
|
+
/** Update tenant branding used by white-label hosted surfaces. */
|
|
7015
|
+
async set(params) {
|
|
7016
|
+
const body = Object.fromEntries(
|
|
7017
|
+
Object.entries(params).filter(([, v]) => v !== void 0)
|
|
7018
|
+
);
|
|
7019
|
+
const data = await this.http.put("/tenant/branding", {
|
|
7020
|
+
branding: body
|
|
7021
|
+
});
|
|
7022
|
+
return unwrap41(data);
|
|
7023
|
+
}
|
|
7024
|
+
/** Reset tenant branding to platform defaults. */
|
|
7025
|
+
async delete() {
|
|
7026
|
+
await this.http.delete("/tenant/branding");
|
|
7027
|
+
}
|
|
7028
|
+
};
|
|
7029
|
+
var Tenant = class {
|
|
7030
|
+
http;
|
|
7031
|
+
preview_domain;
|
|
7032
|
+
branding;
|
|
7033
|
+
/** camelCase alias for SDK consumers that avoid snake_case properties. */
|
|
7034
|
+
previewDomain;
|
|
7035
|
+
constructor(http) {
|
|
7036
|
+
this.http = http;
|
|
7037
|
+
this.preview_domain = new PreviewDomain(http);
|
|
7038
|
+
this.previewDomain = this.preview_domain;
|
|
7039
|
+
this.branding = new Branding(http);
|
|
7040
|
+
}
|
|
6719
7041
|
/** Get the current tenant's plan, limits, and live usage counters. */
|
|
6720
7042
|
async current() {
|
|
6721
7043
|
const data = await this.http.get("/tenant/plan");
|
|
6722
7044
|
return unwrap41(data);
|
|
6723
7045
|
}
|
|
7046
|
+
/** Convenience alias for `tenant.branding.get()`. */
|
|
7047
|
+
async getBranding() {
|
|
7048
|
+
return this.branding.get();
|
|
7049
|
+
}
|
|
7050
|
+
/** Convenience alias for `tenant.branding.set(...)`. */
|
|
7051
|
+
async setBranding(params) {
|
|
7052
|
+
return this.branding.set(params);
|
|
7053
|
+
}
|
|
7054
|
+
/** Convenience alias for `tenant.branding.delete()`. */
|
|
7055
|
+
async deleteBranding() {
|
|
7056
|
+
await this.branding.delete();
|
|
7057
|
+
}
|
|
6724
7058
|
};
|
|
6725
7059
|
|
|
6726
7060
|
// src/resources/usage.ts
|
|
@@ -6842,11 +7176,42 @@ function stripUndefined25(input) {
|
|
|
6842
7176
|
function idempotencyKey10(key) {
|
|
6843
7177
|
return key ?? randomUUID();
|
|
6844
7178
|
}
|
|
7179
|
+
function bodyBuffer(body) {
|
|
7180
|
+
if (Buffer.isBuffer(body)) return body;
|
|
7181
|
+
if (typeof body === "string") return Buffer.from(body, "utf8");
|
|
7182
|
+
return Buffer.from(body);
|
|
7183
|
+
}
|
|
7184
|
+
function verifySignature(body, header, secret, toleranceSec = 300) {
|
|
7185
|
+
const parts = Object.fromEntries(
|
|
7186
|
+
header.split(",").map((chunk) => chunk.split("=", 2)).filter(([key, value]) => key && value)
|
|
7187
|
+
);
|
|
7188
|
+
const timestamp = parts.t;
|
|
7189
|
+
const received = parts.v1;
|
|
7190
|
+
if (!timestamp || !received || !secret) return false;
|
|
7191
|
+
const unixSeconds = Number(timestamp);
|
|
7192
|
+
if (!Number.isFinite(unixSeconds)) return false;
|
|
7193
|
+
const ageSec = Math.abs(Date.now() / 1e3 - unixSeconds);
|
|
7194
|
+
if (ageSec > toleranceSec) {
|
|
7195
|
+
throw new Error("webhook timestamp too old");
|
|
7196
|
+
}
|
|
7197
|
+
const rawBody = bodyBuffer(body);
|
|
7198
|
+
const signed = Buffer.concat([Buffer.from(`${timestamp}.`), rawBody]);
|
|
7199
|
+
const expected = createHmac("sha256", secret).update(signed).digest("hex");
|
|
7200
|
+
try {
|
|
7201
|
+
return timingSafeEqual(
|
|
7202
|
+
Buffer.from(expected, "utf8"),
|
|
7203
|
+
Buffer.from(received, "utf8")
|
|
7204
|
+
);
|
|
7205
|
+
} catch {
|
|
7206
|
+
return false;
|
|
7207
|
+
}
|
|
7208
|
+
}
|
|
6845
7209
|
var Webhooks = class {
|
|
6846
7210
|
constructor(http) {
|
|
6847
7211
|
this.http = http;
|
|
6848
7212
|
}
|
|
6849
7213
|
http;
|
|
7214
|
+
static verifySignature = verifySignature;
|
|
6850
7215
|
async list(params = {}) {
|
|
6851
7216
|
const query = stripUndefined25({ ...params });
|
|
6852
7217
|
const data = await this.http.get("/webhooks", query);
|
|
@@ -6911,9 +7276,9 @@ var WorkspaceInvites = class {
|
|
|
6911
7276
|
*
|
|
6912
7277
|
* `POST /workspaces/:id/invites`
|
|
6913
7278
|
*/
|
|
6914
|
-
async create(
|
|
7279
|
+
async create(workspaceId2, params) {
|
|
6915
7280
|
return this.http.post(
|
|
6916
|
-
`/workspaces/${
|
|
7281
|
+
`/workspaces/${workspaceId2}/invites`,
|
|
6917
7282
|
params
|
|
6918
7283
|
);
|
|
6919
7284
|
}
|
|
@@ -6922,9 +7287,9 @@ var WorkspaceInvites = class {
|
|
|
6922
7287
|
*
|
|
6923
7288
|
* `GET /workspaces/:id/invites`
|
|
6924
7289
|
*/
|
|
6925
|
-
async list(
|
|
7290
|
+
async list(workspaceId2) {
|
|
6926
7291
|
const res = await this.http.get(
|
|
6927
|
-
`/workspaces/${
|
|
7292
|
+
`/workspaces/${workspaceId2}/invites`
|
|
6928
7293
|
);
|
|
6929
7294
|
return res.data ?? [];
|
|
6930
7295
|
}
|
|
@@ -6936,9 +7301,9 @@ var WorkspaceInvites = class {
|
|
|
6936
7301
|
*
|
|
6937
7302
|
* `DELETE /workspaces/:id/invites/:invite_id`
|
|
6938
7303
|
*/
|
|
6939
|
-
async revoke(
|
|
7304
|
+
async revoke(workspaceId2, inviteId) {
|
|
6940
7305
|
return this.http.delete(
|
|
6941
|
-
`/workspaces/${
|
|
7306
|
+
`/workspaces/${workspaceId2}/invites/${inviteId}`
|
|
6942
7307
|
);
|
|
6943
7308
|
}
|
|
6944
7309
|
/**
|
|
@@ -6992,9 +7357,9 @@ var WorkspaceMembers = class {
|
|
|
6992
7357
|
*
|
|
6993
7358
|
* `GET /workspaces/:id/members`
|
|
6994
7359
|
*/
|
|
6995
|
-
async list(
|
|
7360
|
+
async list(workspaceId2) {
|
|
6996
7361
|
const res = await this.http.get(
|
|
6997
|
-
`/workspaces/${
|
|
7362
|
+
`/workspaces/${workspaceId2}/members`
|
|
6998
7363
|
);
|
|
6999
7364
|
return res.data ?? res;
|
|
7000
7365
|
}
|
|
@@ -7010,9 +7375,9 @@ var WorkspaceMembers = class {
|
|
|
7010
7375
|
* @throws `MiosaError` with code `NOT_TENANT_MEMBER` if the user is not an
|
|
7011
7376
|
* org member.
|
|
7012
7377
|
*/
|
|
7013
|
-
async add(
|
|
7378
|
+
async add(workspaceId2, params) {
|
|
7014
7379
|
const res = await this.http.post(
|
|
7015
|
-
`/workspaces/${
|
|
7380
|
+
`/workspaces/${workspaceId2}/members`,
|
|
7016
7381
|
params
|
|
7017
7382
|
);
|
|
7018
7383
|
return res.data ?? res;
|
|
@@ -7022,9 +7387,9 @@ var WorkspaceMembers = class {
|
|
|
7022
7387
|
*
|
|
7023
7388
|
* `PATCH /workspaces/:id/members/:user_id`
|
|
7024
7389
|
*/
|
|
7025
|
-
async updateRole(
|
|
7390
|
+
async updateRole(workspaceId2, userId, params) {
|
|
7026
7391
|
const res = await this.http.patch(
|
|
7027
|
-
`/workspaces/${
|
|
7392
|
+
`/workspaces/${workspaceId2}/members/${userId}`,
|
|
7028
7393
|
params
|
|
7029
7394
|
);
|
|
7030
7395
|
return res.data ?? res;
|
|
@@ -7039,9 +7404,9 @@ var WorkspaceMembers = class {
|
|
|
7039
7404
|
*
|
|
7040
7405
|
* @throws `MiosaError` with code `LAST_OWNER` if the target is the sole owner.
|
|
7041
7406
|
*/
|
|
7042
|
-
async remove(
|
|
7407
|
+
async remove(workspaceId2, userId) {
|
|
7043
7408
|
return this.http.delete(
|
|
7044
|
-
`/workspaces/${
|
|
7409
|
+
`/workspaces/${workspaceId2}/members/${userId}`
|
|
7045
7410
|
);
|
|
7046
7411
|
}
|
|
7047
7412
|
};
|
|
@@ -7098,6 +7463,8 @@ var Miosa = class {
|
|
|
7098
7463
|
* Versions, releases, rollback, custom domains.
|
|
7099
7464
|
*/
|
|
7100
7465
|
deployments;
|
|
7466
|
+
/** Docker Deploy appliance hosts — one always-on workspace host, many apps. */
|
|
7467
|
+
dockerDeploy;
|
|
7101
7468
|
/** Credit balance and usage. */
|
|
7102
7469
|
credits;
|
|
7103
7470
|
/** Admin surface (`/api/v1/admin/*`) — requires an admin credential. */
|
|
@@ -7192,6 +7559,7 @@ var Miosa = class {
|
|
|
7192
7559
|
this.computers = new Computers(this.http);
|
|
7193
7560
|
this.sandboxes = new Sandboxes(this.http);
|
|
7194
7561
|
this.deployments = new Deployments(this.http);
|
|
7562
|
+
this.dockerDeploy = new DockerDeploy(this.http);
|
|
7195
7563
|
this.credits = new Credits(this.http);
|
|
7196
7564
|
this.admin = new Admin(this.http);
|
|
7197
7565
|
this.openComputers = new OpenComputers(this.http);
|
|
@@ -7221,6 +7589,6 @@ var Miosa = class {
|
|
|
7221
7589
|
}
|
|
7222
7590
|
};
|
|
7223
7591
|
|
|
7224
|
-
export { Admin, Analytics, ApiKeys, AuditLog, AuthError, Benchmarks, BuilderSessions, Channels, Checkpoints, CommandCenter, Community, Completions, Computer, ComputerAudit, ComputerAutoStop, ComputerEnv, ComputerInbox, ComputerLogs, ComputerNetwork, ComputerOsa, ComputerPorts, ComputerSecrets, ComputerTerminal, ComputerVolumes, Computers, Credits, CronJobs, Dashboard, Databases, DeploymentDomains, DeploymentReleases, DeploymentRuntimeInstances, DeploymentVersions, Deployments, Desktop, EgressAudit, EgressNetwork, EgressSecrets, Email, EmailCampaigns, EmailInbox, EmailTemplates, Embeddings, Exec, ExternalKeys, Files, FlatCustomDomains, Functions, HealthChecks, InsufficientCreditsError, Integrations, Mcp, Miosa, MiosaError, Models, NetworkError, NetworkPolicy, NotFoundError, OAuthFlow, OpenComputers, OrgInvites, ProjectAuth, ProjectIntegrations, ProviderDefaults, RateLimitError, Regions, SANDBOX_TEMPLATE, Sandbox, SandboxArtifacts, SandboxAudit, SandboxCommands, SandboxEnv, SandboxEvents, SandboxFiles, SandboxNetwork, SandboxPreview, SandboxPreviews, SandboxSecrets, SandboxTags, SandboxTemplates, SandboxTerminal, Sandboxes, ScopedFs, Settings, SnapshotsStandalone, Storage, Tenant, TimeoutError, Usage, ValidationError, Volumes, Webhooks, WorkspaceInvites, WorkspaceMembers };
|
|
7592
|
+
export { Admin, Analytics, ApiKeys, AuditLog, AuthError, Benchmarks, BuilderSessions, Channels, Checkpoints, CommandCenter, Community, Completions, Computer, ComputerAudit, ComputerAutoStop, ComputerEnv, ComputerInbox, ComputerLogs, ComputerNetwork, ComputerOsa, ComputerPorts, ComputerSecrets, ComputerTerminal, ComputerVolumes, Computers, Credits, CronJobs, Dashboard, Databases, DeploymentDomains, DeploymentReleases, DeploymentRuntimeInstances, DeploymentVersions, Deployments, Desktop, DockerDeploy, EgressAudit, EgressNetwork, EgressSecrets, Email, EmailCampaigns, EmailInbox, EmailTemplates, Embeddings, Exec, ExternalKeys, Files, FlatCustomDomains, Functions, HealthChecks, InsufficientCreditsError, Integrations, Mcp, Miosa, MiosaError, Models, NetworkError, NetworkPolicy, NotFoundError, OAuthFlow, OpenComputers, OrgInvites, ProjectAuth, ProjectIntegrations, ProviderDefaults, RateLimitError, Regions, SANDBOX_TEMPLATE, Sandbox, SandboxArtifacts, SandboxAudit, SandboxCommands, SandboxEnv, SandboxEvents, SandboxFiles, SandboxNetwork, SandboxPreview, SandboxPreviews, SandboxSecrets, SandboxTags, SandboxTemplates, SandboxTerminal, Sandboxes, ScopedFs, Settings, SnapshotsStandalone, Storage, Tenant, TimeoutError, Usage, ValidationError, Volumes, Webhooks, WorkspaceInvites, WorkspaceMembers, verifySignature };
|
|
7225
7593
|
//# sourceMappingURL=index.js.map
|
|
7226
7594
|
//# sourceMappingURL=index.js.map
|