@miosa/sdk 1.2.2 → 1.2.4
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 +42 -0
- package/dist/index.d.ts +166 -26
- package/dist/index.js +384 -66
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +5 -0
- package/src/index.ts +15 -0
- package/src/resources/deployments.test.ts +139 -0
- package/src/resources/deployments.ts +254 -0
- package/src/resources/docker-deploy.test.ts +102 -0
- package/src/resources/docker-deploy.ts +183 -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/tenant-events.ts +32 -0
- package/src/resources/tenant.ts +101 -19
- package/src/resources/webhooks.ts +39 -54
- package/src/resources/workspaces.ts +285 -0
package/dist/index.js
CHANGED
|
@@ -3645,6 +3645,42 @@ function dockerDeployMetadata(metadata) {
|
|
|
3645
3645
|
deployment_product: "docker_deploy"
|
|
3646
3646
|
};
|
|
3647
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 dockerDeployApp(deployment) {
|
|
3656
|
+
const app = deployment.metadata?.["docker_deploy"];
|
|
3657
|
+
if (!app || typeof app !== "object" || Array.isArray(app)) return null;
|
|
3658
|
+
return app;
|
|
3659
|
+
}
|
|
3660
|
+
function dockerDeployAppPort(app) {
|
|
3661
|
+
const url = app?.["url"];
|
|
3662
|
+
if (typeof url !== "string") return null;
|
|
3663
|
+
try {
|
|
3664
|
+
const parsed = new URL(url);
|
|
3665
|
+
const port = Number.parseInt(parsed.port, 10);
|
|
3666
|
+
return Number.isInteger(port) ? port : null;
|
|
3667
|
+
} catch {
|
|
3668
|
+
return null;
|
|
3669
|
+
}
|
|
3670
|
+
}
|
|
3671
|
+
function addDoctorCheck(checks, name, ok, message, details) {
|
|
3672
|
+
checks.push({ name, ok, message, ...details ? { details } : {} });
|
|
3673
|
+
}
|
|
3674
|
+
function hostHealthy(host) {
|
|
3675
|
+
return Boolean(
|
|
3676
|
+
host && host.status === "active" && host.appliance_status === "healthy"
|
|
3677
|
+
);
|
|
3678
|
+
}
|
|
3679
|
+
function probeUrl(publicUrl, probePath) {
|
|
3680
|
+
const url = new URL(publicUrl);
|
|
3681
|
+
url.pathname = probePath.startsWith("/") ? probePath : `/${probePath}`;
|
|
3682
|
+
return url.toString();
|
|
3683
|
+
}
|
|
3648
3684
|
var DeploymentVersions = class {
|
|
3649
3685
|
constructor(http, deploymentId) {
|
|
3650
3686
|
this.http = http;
|
|
@@ -3838,6 +3874,136 @@ var Deployments = class {
|
|
|
3838
3874
|
metadata: dockerDeployMetadata(params.metadata)
|
|
3839
3875
|
});
|
|
3840
3876
|
}
|
|
3877
|
+
/**
|
|
3878
|
+
* Verify a Docker Deploy deployment before telling a user or agent it is
|
|
3879
|
+
* live. Checks product markers, appliance host health, route metadata, and
|
|
3880
|
+
* optionally probes the public URL.
|
|
3881
|
+
*/
|
|
3882
|
+
async doctorDockerDeploy(deploymentId, params = {}) {
|
|
3883
|
+
const checks = [];
|
|
3884
|
+
const deployment = await this.get(deploymentId);
|
|
3885
|
+
const metadata = deployment.metadata ?? {};
|
|
3886
|
+
const product = dockerDeployProduct(deployment);
|
|
3887
|
+
const hostId = dockerDeployHostId(deployment);
|
|
3888
|
+
addDoctorCheck(
|
|
3889
|
+
checks,
|
|
3890
|
+
"deployment_product",
|
|
3891
|
+
product === "docker_deploy",
|
|
3892
|
+
product === "docker_deploy" ? "Deployment is marked for Docker Deploy." : `Expected deployment_product=docker_deploy, got ${String(product ?? "missing")}.`,
|
|
3893
|
+
{ deployment_product: product ?? null }
|
|
3894
|
+
);
|
|
3895
|
+
addDoctorCheck(
|
|
3896
|
+
checks,
|
|
3897
|
+
"docker_deploy_host_id",
|
|
3898
|
+
Boolean(hostId),
|
|
3899
|
+
hostId ? "Deployment has a Docker Deploy host id." : "Deployment has no docker_deploy_host_id.",
|
|
3900
|
+
{ docker_deploy_host_id: hostId }
|
|
3901
|
+
);
|
|
3902
|
+
let host;
|
|
3903
|
+
if (hostId) {
|
|
3904
|
+
try {
|
|
3905
|
+
const rawHost = await this.http.get(
|
|
3906
|
+
`/docker-deploy/hosts/${hostId}`
|
|
3907
|
+
);
|
|
3908
|
+
host = unwrap23(rawHost);
|
|
3909
|
+
addDoctorCheck(
|
|
3910
|
+
checks,
|
|
3911
|
+
"docker_deploy_host_health",
|
|
3912
|
+
hostHealthy(host),
|
|
3913
|
+
hostHealthy(host) ? "Docker Deploy host is active and healthy." : `Docker Deploy host status=${host.status} appliance=${host.appliance_status}.`,
|
|
3914
|
+
{
|
|
3915
|
+
status: host.status,
|
|
3916
|
+
appliance_status: host.appliance_status
|
|
3917
|
+
}
|
|
3918
|
+
);
|
|
3919
|
+
} catch (error) {
|
|
3920
|
+
addDoctorCheck(
|
|
3921
|
+
checks,
|
|
3922
|
+
"docker_deploy_host_health",
|
|
3923
|
+
false,
|
|
3924
|
+
error instanceof Error ? error.message : String(error)
|
|
3925
|
+
);
|
|
3926
|
+
}
|
|
3927
|
+
}
|
|
3928
|
+
const app = dockerDeployApp(deployment);
|
|
3929
|
+
const appPort = dockerDeployAppPort(app);
|
|
3930
|
+
const appRunning = app?.["status"] === "running" && appPort !== null;
|
|
3931
|
+
addDoctorCheck(
|
|
3932
|
+
checks,
|
|
3933
|
+
"docker_deploy_app",
|
|
3934
|
+
appRunning,
|
|
3935
|
+
appRunning ? "Docker Deploy app metadata points at a running container." : "Deployment is missing running Docker Deploy app metadata.",
|
|
3936
|
+
app ? {
|
|
3937
|
+
app_id: app["app_id"],
|
|
3938
|
+
container_id: app["container_id"],
|
|
3939
|
+
status: app["status"],
|
|
3940
|
+
url: app["url"],
|
|
3941
|
+
expected_port: appPort
|
|
3942
|
+
} : void 0
|
|
3943
|
+
);
|
|
3944
|
+
const runtime = metadata["runtime"];
|
|
3945
|
+
const hasRuntimeRoute = typeof runtime === "object" && runtime !== null && typeof runtime["ip"] === "string" && typeof runtime["port"] === "number";
|
|
3946
|
+
const runtimeRecord = hasRuntimeRoute && typeof runtime === "object" ? runtime : void 0;
|
|
3947
|
+
const routeMatchesContainerPort = hasRuntimeRoute && (appPort === null || runtimeRecord?.["port"] === appPort);
|
|
3948
|
+
addDoctorCheck(
|
|
3949
|
+
checks,
|
|
3950
|
+
"runtime_route",
|
|
3951
|
+
hasRuntimeRoute && routeMatchesContainerPort,
|
|
3952
|
+
hasRuntimeRoute && routeMatchesContainerPort ? "Deployment route points at the Docker container host port." : hasRuntimeRoute && appPort !== null ? `Deployment route port ${String(runtimeRecord?.["port"])} does not match Docker container host port ${appPort}.` : "Deployment is missing appliance runtime route metadata.",
|
|
3953
|
+
runtimeRecord ? {
|
|
3954
|
+
...runtimeRecord,
|
|
3955
|
+
expected_port: appPort,
|
|
3956
|
+
docker_deploy_url: app?.["url"]
|
|
3957
|
+
} : void 0
|
|
3958
|
+
);
|
|
3959
|
+
let probe;
|
|
3960
|
+
const publicUrl = deployment.public_url;
|
|
3961
|
+
const path = params.probePath ?? params.probe_path ?? "/";
|
|
3962
|
+
if (publicUrl && typeof fetch === "function") {
|
|
3963
|
+
const url = probeUrl(publicUrl, path);
|
|
3964
|
+
const controller = new AbortController();
|
|
3965
|
+
const timeout = setTimeout(
|
|
3966
|
+
() => controller.abort(),
|
|
3967
|
+
params.timeoutMs ?? params.timeout_ms ?? 1e4
|
|
3968
|
+
);
|
|
3969
|
+
try {
|
|
3970
|
+
const response = await fetch(url, {
|
|
3971
|
+
method: "GET",
|
|
3972
|
+
signal: controller.signal
|
|
3973
|
+
});
|
|
3974
|
+
probe = { url, ok: response.ok, status: response.status };
|
|
3975
|
+
addDoctorCheck(
|
|
3976
|
+
checks,
|
|
3977
|
+
"public_url_probe",
|
|
3978
|
+
response.ok,
|
|
3979
|
+
response.ok ? `Public URL returned HTTP ${response.status}.` : `Public URL returned HTTP ${response.status}.`,
|
|
3980
|
+
{ url, status: response.status }
|
|
3981
|
+
);
|
|
3982
|
+
} catch (error) {
|
|
3983
|
+
probe = {
|
|
3984
|
+
url,
|
|
3985
|
+
ok: false,
|
|
3986
|
+
error: error instanceof Error ? error.message : String(error)
|
|
3987
|
+
};
|
|
3988
|
+
addDoctorCheck(
|
|
3989
|
+
checks,
|
|
3990
|
+
"public_url_probe",
|
|
3991
|
+
false,
|
|
3992
|
+
probe.error ?? "Public URL probe failed.",
|
|
3993
|
+
{ url }
|
|
3994
|
+
);
|
|
3995
|
+
} finally {
|
|
3996
|
+
clearTimeout(timeout);
|
|
3997
|
+
}
|
|
3998
|
+
}
|
|
3999
|
+
return {
|
|
4000
|
+
ok: checks.every((check) => check.ok),
|
|
4001
|
+
deployment,
|
|
4002
|
+
...host ? { host } : {},
|
|
4003
|
+
checks,
|
|
4004
|
+
...probe ? { probe } : {}
|
|
4005
|
+
};
|
|
4006
|
+
}
|
|
3841
4007
|
async update(deploymentId, params) {
|
|
3842
4008
|
const body = stripUndefined10({
|
|
3843
4009
|
name: params.name,
|
|
@@ -3954,6 +4120,90 @@ var Deployments = class {
|
|
|
3954
4120
|
}
|
|
3955
4121
|
};
|
|
3956
4122
|
|
|
4123
|
+
// src/resources/docker-deploy.ts
|
|
4124
|
+
function workspaceId(params) {
|
|
4125
|
+
return params?.workspace_id ?? params?.workspaceId;
|
|
4126
|
+
}
|
|
4127
|
+
function ensureBody(params) {
|
|
4128
|
+
const body = {};
|
|
4129
|
+
const id = params.workspace_id ?? params.workspaceId;
|
|
4130
|
+
const externalId = params.external_workspace_id ?? params.externalWorkspaceId;
|
|
4131
|
+
if (id) body.workspace_id = id;
|
|
4132
|
+
if (externalId) body.external_workspace_id = externalId;
|
|
4133
|
+
return body;
|
|
4134
|
+
}
|
|
4135
|
+
function unwrapHost(response) {
|
|
4136
|
+
const host = response.data ?? response.host;
|
|
4137
|
+
if (!host) {
|
|
4138
|
+
throw new Error("Docker Deploy host response was empty.");
|
|
4139
|
+
}
|
|
4140
|
+
return host;
|
|
4141
|
+
}
|
|
4142
|
+
function unwrapTemplates(response) {
|
|
4143
|
+
return response.data ?? response.templates ?? [];
|
|
4144
|
+
}
|
|
4145
|
+
function unwrapTemplate(response) {
|
|
4146
|
+
const template = response.data ?? response.template;
|
|
4147
|
+
if (!template) {
|
|
4148
|
+
throw new Error("Docker Deploy template response was empty.");
|
|
4149
|
+
}
|
|
4150
|
+
return template;
|
|
4151
|
+
}
|
|
4152
|
+
var DockerDeploy = class {
|
|
4153
|
+
constructor(http) {
|
|
4154
|
+
this.http = http;
|
|
4155
|
+
}
|
|
4156
|
+
http;
|
|
4157
|
+
/**
|
|
4158
|
+
* List Docker Deploy appliance hosts scoped to the current tenant.
|
|
4159
|
+
*
|
|
4160
|
+
* Pass a workspace ID to inspect the dedicated always-on appliance machine
|
|
4161
|
+
* for one white-label workspace.
|
|
4162
|
+
*/
|
|
4163
|
+
async listHosts(params = {}) {
|
|
4164
|
+
const res = await this.http.get(
|
|
4165
|
+
"/docker-deploy/hosts",
|
|
4166
|
+
{ workspace_id: workspaceId(params) }
|
|
4167
|
+
);
|
|
4168
|
+
return res.data ?? res.hosts ?? [];
|
|
4169
|
+
}
|
|
4170
|
+
/**
|
|
4171
|
+
* Ensure a workspace has its dedicated Docker Deploy appliance host.
|
|
4172
|
+
*
|
|
4173
|
+
* The host may still be `pending`, `provisioning`, or `bootstrapping` after
|
|
4174
|
+
* this call. Treat `status === "active"` and `appliance_status === "healthy"`
|
|
4175
|
+
* as the ready condition before sending app/container traffic to it.
|
|
4176
|
+
*/
|
|
4177
|
+
async ensureHost(params = {}) {
|
|
4178
|
+
const res = await this.http.post(
|
|
4179
|
+
"/docker-deploy/hosts/ensure",
|
|
4180
|
+
ensureBody(params)
|
|
4181
|
+
);
|
|
4182
|
+
return { host: unwrapHost(res), queued: res.queued ?? false };
|
|
4183
|
+
}
|
|
4184
|
+
/** Fetch one Docker Deploy host by ID. */
|
|
4185
|
+
async getHost(hostId) {
|
|
4186
|
+
const res = await this.http.get(
|
|
4187
|
+
`/docker-deploy/hosts/${hostId}`
|
|
4188
|
+
);
|
|
4189
|
+
return unwrapHost(res);
|
|
4190
|
+
}
|
|
4191
|
+
/** List Docker Deploy starter templates. */
|
|
4192
|
+
async listTemplates() {
|
|
4193
|
+
const res = await this.http.get(
|
|
4194
|
+
"/docker-deploy/templates"
|
|
4195
|
+
);
|
|
4196
|
+
return unwrapTemplates(res);
|
|
4197
|
+
}
|
|
4198
|
+
/** Fetch one Docker Deploy starter template by ID. */
|
|
4199
|
+
async getTemplate(templateId) {
|
|
4200
|
+
const res = await this.http.get(
|
|
4201
|
+
`/docker-deploy/templates/${encodeURIComponent(templateId)}`
|
|
4202
|
+
);
|
|
4203
|
+
return unwrapTemplate(res);
|
|
4204
|
+
}
|
|
4205
|
+
};
|
|
4206
|
+
|
|
3957
4207
|
// src/resources/email.ts
|
|
3958
4208
|
function unwrap24(data) {
|
|
3959
4209
|
if (data && typeof data === "object") {
|
|
@@ -5105,49 +5355,49 @@ var OcWorkspaces = class {
|
|
|
5105
5355
|
/**
|
|
5106
5356
|
* Fetch a single workspace.
|
|
5107
5357
|
*/
|
|
5108
|
-
async get(hostId,
|
|
5358
|
+
async get(hostId, workspaceId2) {
|
|
5109
5359
|
return this.http.get(
|
|
5110
|
-
`${this.base(hostId)}/${
|
|
5360
|
+
`${this.base(hostId)}/${workspaceId2}`
|
|
5111
5361
|
);
|
|
5112
5362
|
}
|
|
5113
5363
|
/**
|
|
5114
5364
|
* Update workspace metadata (name, branch).
|
|
5115
5365
|
*/
|
|
5116
|
-
async update(hostId,
|
|
5366
|
+
async update(hostId, workspaceId2, params) {
|
|
5117
5367
|
return this.http.patch(
|
|
5118
|
-
`${this.base(hostId)}/${
|
|
5368
|
+
`${this.base(hostId)}/${workspaceId2}`,
|
|
5119
5369
|
params
|
|
5120
5370
|
);
|
|
5121
5371
|
}
|
|
5122
5372
|
/**
|
|
5123
5373
|
* Delete a workspace.
|
|
5124
5374
|
*/
|
|
5125
|
-
async delete(hostId,
|
|
5126
|
-
return this.http.delete(`${this.base(hostId)}/${
|
|
5375
|
+
async delete(hostId, workspaceId2) {
|
|
5376
|
+
return this.http.delete(`${this.base(hostId)}/${workspaceId2}`);
|
|
5127
5377
|
}
|
|
5128
5378
|
/**
|
|
5129
5379
|
* Pull the latest changes from the remote repository.
|
|
5130
5380
|
*/
|
|
5131
|
-
async pull(hostId,
|
|
5381
|
+
async pull(hostId, workspaceId2) {
|
|
5132
5382
|
return this.http.post(
|
|
5133
|
-
`${this.base(hostId)}/${
|
|
5383
|
+
`${this.base(hostId)}/${workspaceId2}/pull`
|
|
5134
5384
|
);
|
|
5135
5385
|
}
|
|
5136
5386
|
/**
|
|
5137
5387
|
* Open a terminal session scoped to the workspace root directory.
|
|
5138
5388
|
* Returns a short-lived WebSocket ticket.
|
|
5139
5389
|
*/
|
|
5140
|
-
async openTerminal(hostId,
|
|
5390
|
+
async openTerminal(hostId, workspaceId2) {
|
|
5141
5391
|
return this.http.post(
|
|
5142
|
-
`${this.base(hostId)}/${
|
|
5392
|
+
`${this.base(hostId)}/${workspaceId2}/open-terminal`
|
|
5143
5393
|
);
|
|
5144
5394
|
}
|
|
5145
5395
|
/**
|
|
5146
5396
|
* Stream workspace setup / clone / install events.
|
|
5147
5397
|
*/
|
|
5148
|
-
events(hostId,
|
|
5398
|
+
events(hostId, workspaceId2) {
|
|
5149
5399
|
return this.http.stream(
|
|
5150
|
-
`${this.base(hostId)}/${
|
|
5400
|
+
`${this.base(hostId)}/${workspaceId2}/events`
|
|
5151
5401
|
);
|
|
5152
5402
|
}
|
|
5153
5403
|
};
|
|
@@ -6753,22 +7003,96 @@ var OrgInvites = class {
|
|
|
6753
7003
|
function unwrap41(payload) {
|
|
6754
7004
|
if (payload && typeof payload === "object") {
|
|
6755
7005
|
const p = payload;
|
|
6756
|
-
for (const k of ["data", "tenant", "items"]) {
|
|
7006
|
+
for (const k of ["data", "tenant", "branding", "items"]) {
|
|
6757
7007
|
if (k in p) return p[k];
|
|
6758
7008
|
}
|
|
6759
7009
|
}
|
|
6760
7010
|
return payload;
|
|
6761
7011
|
}
|
|
6762
|
-
var
|
|
7012
|
+
var PreviewDomain = class {
|
|
6763
7013
|
constructor(http) {
|
|
6764
7014
|
this.http = http;
|
|
6765
7015
|
}
|
|
6766
7016
|
http;
|
|
7017
|
+
/** Get the tenant's white-label preview domain settings. */
|
|
7018
|
+
async get() {
|
|
7019
|
+
const data = await this.http.get("/tenant/preview-domain");
|
|
7020
|
+
return unwrap41(data);
|
|
7021
|
+
}
|
|
7022
|
+
/** Set the tenant's white-label preview domain. */
|
|
7023
|
+
async set(domain) {
|
|
7024
|
+
const data = await this.http.put("/tenant/preview-domain", {
|
|
7025
|
+
preview_domain: domain
|
|
7026
|
+
});
|
|
7027
|
+
return unwrap41(data);
|
|
7028
|
+
}
|
|
7029
|
+
/** Re-run DNS verification for the configured preview domain. */
|
|
7030
|
+
async verify() {
|
|
7031
|
+
const data = await this.http.post(
|
|
7032
|
+
"/tenant/preview-domain/verify",
|
|
7033
|
+
{}
|
|
7034
|
+
);
|
|
7035
|
+
return unwrap41(data);
|
|
7036
|
+
}
|
|
7037
|
+
/** Remove the tenant's custom preview domain. */
|
|
7038
|
+
async delete() {
|
|
7039
|
+
await this.http.delete("/tenant/preview-domain");
|
|
7040
|
+
}
|
|
7041
|
+
};
|
|
7042
|
+
var Branding = class {
|
|
7043
|
+
constructor(http) {
|
|
7044
|
+
this.http = http;
|
|
7045
|
+
}
|
|
7046
|
+
http;
|
|
7047
|
+
/** Get tenant branding used by white-label hosted surfaces. */
|
|
7048
|
+
async get() {
|
|
7049
|
+
const data = await this.http.get("/tenant/branding");
|
|
7050
|
+
return unwrap41(data);
|
|
7051
|
+
}
|
|
7052
|
+
/** Update tenant branding used by white-label hosted surfaces. */
|
|
7053
|
+
async set(params) {
|
|
7054
|
+
const body = Object.fromEntries(
|
|
7055
|
+
Object.entries(params).filter(([, v]) => v !== void 0)
|
|
7056
|
+
);
|
|
7057
|
+
const data = await this.http.put("/tenant/branding", {
|
|
7058
|
+
branding: body
|
|
7059
|
+
});
|
|
7060
|
+
return unwrap41(data);
|
|
7061
|
+
}
|
|
7062
|
+
/** Reset tenant branding to platform defaults. */
|
|
7063
|
+
async delete() {
|
|
7064
|
+
await this.http.delete("/tenant/branding");
|
|
7065
|
+
}
|
|
7066
|
+
};
|
|
7067
|
+
var Tenant = class {
|
|
7068
|
+
http;
|
|
7069
|
+
preview_domain;
|
|
7070
|
+
branding;
|
|
7071
|
+
/** camelCase alias for SDK consumers that avoid snake_case properties. */
|
|
7072
|
+
previewDomain;
|
|
7073
|
+
constructor(http) {
|
|
7074
|
+
this.http = http;
|
|
7075
|
+
this.preview_domain = new PreviewDomain(http);
|
|
7076
|
+
this.previewDomain = this.preview_domain;
|
|
7077
|
+
this.branding = new Branding(http);
|
|
7078
|
+
}
|
|
6767
7079
|
/** Get the current tenant's plan, limits, and live usage counters. */
|
|
6768
7080
|
async current() {
|
|
6769
7081
|
const data = await this.http.get("/tenant/plan");
|
|
6770
7082
|
return unwrap41(data);
|
|
6771
7083
|
}
|
|
7084
|
+
/** Convenience alias for `tenant.branding.get()`. */
|
|
7085
|
+
async getBranding() {
|
|
7086
|
+
return this.branding.get();
|
|
7087
|
+
}
|
|
7088
|
+
/** Convenience alias for `tenant.branding.set(...)`. */
|
|
7089
|
+
async setBranding(params) {
|
|
7090
|
+
return this.branding.set(params);
|
|
7091
|
+
}
|
|
7092
|
+
/** Convenience alias for `tenant.branding.delete()`. */
|
|
7093
|
+
async deleteBranding() {
|
|
7094
|
+
await this.branding.delete();
|
|
7095
|
+
}
|
|
6772
7096
|
};
|
|
6773
7097
|
|
|
6774
7098
|
// src/resources/usage.ts
|
|
@@ -6890,43 +7214,35 @@ function stripUndefined25(input) {
|
|
|
6890
7214
|
function idempotencyKey10(key) {
|
|
6891
7215
|
return key ?? randomUUID();
|
|
6892
7216
|
}
|
|
6893
|
-
function
|
|
6894
|
-
|
|
6895
|
-
|
|
6896
|
-
|
|
6897
|
-
|
|
6898
|
-
|
|
6899
|
-
|
|
6900
|
-
|
|
6901
|
-
|
|
6902
|
-
|
|
6903
|
-
|
|
6904
|
-
|
|
6905
|
-
|
|
7217
|
+
function bodyBuffer(body) {
|
|
7218
|
+
if (Buffer.isBuffer(body)) return body;
|
|
7219
|
+
if (typeof body === "string") return Buffer.from(body, "utf8");
|
|
7220
|
+
return Buffer.from(body);
|
|
7221
|
+
}
|
|
7222
|
+
function verifySignature(body, header, secret, toleranceSec = 300) {
|
|
7223
|
+
const parts = Object.fromEntries(
|
|
7224
|
+
header.split(",").map((chunk) => chunk.split("=", 2)).filter(([key, value]) => key && value)
|
|
7225
|
+
);
|
|
7226
|
+
const timestamp = parts.t;
|
|
7227
|
+
const received = parts.v1;
|
|
7228
|
+
if (!timestamp || !received || !secret) return false;
|
|
7229
|
+
const unixSeconds = Number(timestamp);
|
|
7230
|
+
if (!Number.isFinite(unixSeconds)) return false;
|
|
7231
|
+
const ageSec = Math.abs(Date.now() / 1e3 - unixSeconds);
|
|
7232
|
+
if (ageSec > toleranceSec) {
|
|
7233
|
+
throw new Error("webhook timestamp too old");
|
|
7234
|
+
}
|
|
7235
|
+
const rawBody = bodyBuffer(body);
|
|
7236
|
+
const signed = Buffer.concat([Buffer.from(`${timestamp}.`), rawBody]);
|
|
7237
|
+
const expected = createHmac("sha256", secret).update(signed).digest("hex");
|
|
7238
|
+
try {
|
|
7239
|
+
return timingSafeEqual(
|
|
7240
|
+
Buffer.from(expected, "utf8"),
|
|
7241
|
+
Buffer.from(received, "utf8")
|
|
7242
|
+
);
|
|
7243
|
+
} catch {
|
|
7244
|
+
return false;
|
|
6906
7245
|
}
|
|
6907
|
-
if (timestamp == null || signatures.length === 0) return null;
|
|
6908
|
-
return { timestamp, signatures };
|
|
6909
|
-
}
|
|
6910
|
-
function verifySignature(body, header, secret, options = {}) {
|
|
6911
|
-
const parsed = parseSignatureHeader(header);
|
|
6912
|
-
if (!parsed) return false;
|
|
6913
|
-
const toleranceSeconds = options.toleranceSeconds ?? 300;
|
|
6914
|
-
const ageSeconds = Math.abs(Math.floor(Date.now() / 1e3) - parsed.timestamp);
|
|
6915
|
-
if (ageSeconds > toleranceSeconds) {
|
|
6916
|
-
throw new Error("Webhook signature timestamp is too old");
|
|
6917
|
-
}
|
|
6918
|
-
const bodyBuffer = Buffer.isBuffer(body) ? body : Buffer.from(body);
|
|
6919
|
-
const signedPayload = Buffer.concat([
|
|
6920
|
-
Buffer.from(`${parsed.timestamp}.`),
|
|
6921
|
-
bodyBuffer
|
|
6922
|
-
]);
|
|
6923
|
-
const expected = createHmac("sha256", secret).update(signedPayload).digest("hex");
|
|
6924
|
-
const expectedBuffer = Buffer.from(expected, "hex");
|
|
6925
|
-
return parsed.signatures.some((signature) => {
|
|
6926
|
-
const actualBuffer = Buffer.from(signature, "hex");
|
|
6927
|
-
if (actualBuffer.length !== expectedBuffer.length) return false;
|
|
6928
|
-
return timingSafeEqual(actualBuffer, expectedBuffer);
|
|
6929
|
-
});
|
|
6930
7246
|
}
|
|
6931
7247
|
var Webhooks = class {
|
|
6932
7248
|
constructor(http) {
|
|
@@ -6934,7 +7250,6 @@ var Webhooks = class {
|
|
|
6934
7250
|
}
|
|
6935
7251
|
http;
|
|
6936
7252
|
static verifySignature = verifySignature;
|
|
6937
|
-
static verify_signature = verifySignature;
|
|
6938
7253
|
async list(params = {}) {
|
|
6939
7254
|
const query = stripUndefined25({ ...params });
|
|
6940
7255
|
const data = await this.http.get("/webhooks", query);
|
|
@@ -6999,9 +7314,9 @@ var WorkspaceInvites = class {
|
|
|
6999
7314
|
*
|
|
7000
7315
|
* `POST /workspaces/:id/invites`
|
|
7001
7316
|
*/
|
|
7002
|
-
async create(
|
|
7317
|
+
async create(workspaceId2, params) {
|
|
7003
7318
|
return this.http.post(
|
|
7004
|
-
`/workspaces/${
|
|
7319
|
+
`/workspaces/${workspaceId2}/invites`,
|
|
7005
7320
|
params
|
|
7006
7321
|
);
|
|
7007
7322
|
}
|
|
@@ -7010,9 +7325,9 @@ var WorkspaceInvites = class {
|
|
|
7010
7325
|
*
|
|
7011
7326
|
* `GET /workspaces/:id/invites`
|
|
7012
7327
|
*/
|
|
7013
|
-
async list(
|
|
7328
|
+
async list(workspaceId2) {
|
|
7014
7329
|
const res = await this.http.get(
|
|
7015
|
-
`/workspaces/${
|
|
7330
|
+
`/workspaces/${workspaceId2}/invites`
|
|
7016
7331
|
);
|
|
7017
7332
|
return res.data ?? [];
|
|
7018
7333
|
}
|
|
@@ -7024,9 +7339,9 @@ var WorkspaceInvites = class {
|
|
|
7024
7339
|
*
|
|
7025
7340
|
* `DELETE /workspaces/:id/invites/:invite_id`
|
|
7026
7341
|
*/
|
|
7027
|
-
async revoke(
|
|
7342
|
+
async revoke(workspaceId2, inviteId) {
|
|
7028
7343
|
return this.http.delete(
|
|
7029
|
-
`/workspaces/${
|
|
7344
|
+
`/workspaces/${workspaceId2}/invites/${inviteId}`
|
|
7030
7345
|
);
|
|
7031
7346
|
}
|
|
7032
7347
|
/**
|
|
@@ -7080,9 +7395,9 @@ var WorkspaceMembers = class {
|
|
|
7080
7395
|
*
|
|
7081
7396
|
* `GET /workspaces/:id/members`
|
|
7082
7397
|
*/
|
|
7083
|
-
async list(
|
|
7398
|
+
async list(workspaceId2) {
|
|
7084
7399
|
const res = await this.http.get(
|
|
7085
|
-
`/workspaces/${
|
|
7400
|
+
`/workspaces/${workspaceId2}/members`
|
|
7086
7401
|
);
|
|
7087
7402
|
return res.data ?? res;
|
|
7088
7403
|
}
|
|
@@ -7098,9 +7413,9 @@ var WorkspaceMembers = class {
|
|
|
7098
7413
|
* @throws `MiosaError` with code `NOT_TENANT_MEMBER` if the user is not an
|
|
7099
7414
|
* org member.
|
|
7100
7415
|
*/
|
|
7101
|
-
async add(
|
|
7416
|
+
async add(workspaceId2, params) {
|
|
7102
7417
|
const res = await this.http.post(
|
|
7103
|
-
`/workspaces/${
|
|
7418
|
+
`/workspaces/${workspaceId2}/members`,
|
|
7104
7419
|
params
|
|
7105
7420
|
);
|
|
7106
7421
|
return res.data ?? res;
|
|
@@ -7110,9 +7425,9 @@ var WorkspaceMembers = class {
|
|
|
7110
7425
|
*
|
|
7111
7426
|
* `PATCH /workspaces/:id/members/:user_id`
|
|
7112
7427
|
*/
|
|
7113
|
-
async updateRole(
|
|
7428
|
+
async updateRole(workspaceId2, userId, params) {
|
|
7114
7429
|
const res = await this.http.patch(
|
|
7115
|
-
`/workspaces/${
|
|
7430
|
+
`/workspaces/${workspaceId2}/members/${userId}`,
|
|
7116
7431
|
params
|
|
7117
7432
|
);
|
|
7118
7433
|
return res.data ?? res;
|
|
@@ -7127,9 +7442,9 @@ var WorkspaceMembers = class {
|
|
|
7127
7442
|
*
|
|
7128
7443
|
* @throws `MiosaError` with code `LAST_OWNER` if the target is the sole owner.
|
|
7129
7444
|
*/
|
|
7130
|
-
async remove(
|
|
7445
|
+
async remove(workspaceId2, userId) {
|
|
7131
7446
|
return this.http.delete(
|
|
7132
|
-
`/workspaces/${
|
|
7447
|
+
`/workspaces/${workspaceId2}/members/${userId}`
|
|
7133
7448
|
);
|
|
7134
7449
|
}
|
|
7135
7450
|
};
|
|
@@ -7186,6 +7501,8 @@ var Miosa = class {
|
|
|
7186
7501
|
* Versions, releases, rollback, custom domains.
|
|
7187
7502
|
*/
|
|
7188
7503
|
deployments;
|
|
7504
|
+
/** Docker Deploy appliance hosts — one always-on workspace host, many apps. */
|
|
7505
|
+
dockerDeploy;
|
|
7189
7506
|
/** Credit balance and usage. */
|
|
7190
7507
|
credits;
|
|
7191
7508
|
/** Admin surface (`/api/v1/admin/*`) — requires an admin credential. */
|
|
@@ -7280,6 +7597,7 @@ var Miosa = class {
|
|
|
7280
7597
|
this.computers = new Computers(this.http);
|
|
7281
7598
|
this.sandboxes = new Sandboxes(this.http);
|
|
7282
7599
|
this.deployments = new Deployments(this.http);
|
|
7600
|
+
this.dockerDeploy = new DockerDeploy(this.http);
|
|
7283
7601
|
this.credits = new Credits(this.http);
|
|
7284
7602
|
this.admin = new Admin(this.http);
|
|
7285
7603
|
this.openComputers = new OpenComputers(this.http);
|
|
@@ -7309,6 +7627,6 @@ var Miosa = class {
|
|
|
7309
7627
|
}
|
|
7310
7628
|
};
|
|
7311
7629
|
|
|
7312
|
-
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, verifySignature };
|
|
7630
|
+
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 };
|
|
7313
7631
|
//# sourceMappingURL=index.js.map
|
|
7314
7632
|
//# sourceMappingURL=index.js.map
|