@miosa/sdk 1.0.0 → 1.2.0
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/dist/index.d.ts +968 -6
- package/dist/index.js +1341 -236
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +39 -0
- package/src/index.ts +90 -0
- package/src/resources/admin.ts +11 -0
- package/src/resources/api-keys.ts +16 -0
- package/src/resources/computer.ts +16 -0
- package/src/resources/egress.test.ts +318 -0
- package/src/resources/egressAudit.ts +245 -0
- package/src/resources/egressNetwork.ts +450 -0
- package/src/resources/egressSecrets.ts +577 -0
- package/src/resources/governance.test.ts +355 -0
- package/src/resources/governance.ts +528 -0
- package/src/resources/org-invites.ts +189 -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.ts +239 -10
- package/src/resources/tenant-events.ts +32 -0
- package/src/resources/workspace-invites.ts +188 -0
- package/src/resources/workspace-members.test.ts +121 -0
- package/src/resources/workspace-members.ts +143 -0
- package/src/resources/workspaces.ts +285 -0
package/dist/index.js
CHANGED
|
@@ -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
|
}
|
|
@@ -1695,6 +1713,690 @@ var Desktop = class {
|
|
|
1695
1713
|
return this.http.post(`${this.base()}/launch`, params);
|
|
1696
1714
|
}
|
|
1697
1715
|
};
|
|
1716
|
+
|
|
1717
|
+
// src/resources/egressAudit.ts
|
|
1718
|
+
function unwrap17(payload) {
|
|
1719
|
+
if (payload && typeof payload === "object") {
|
|
1720
|
+
const p = payload;
|
|
1721
|
+
for (const k of ["data", "event", "items"]) {
|
|
1722
|
+
if (k in p) return p[k];
|
|
1723
|
+
}
|
|
1724
|
+
}
|
|
1725
|
+
return payload;
|
|
1726
|
+
}
|
|
1727
|
+
function unwrapList8(payload) {
|
|
1728
|
+
if (Array.isArray(payload)) return payload;
|
|
1729
|
+
if (payload && typeof payload === "object") {
|
|
1730
|
+
const p = payload;
|
|
1731
|
+
for (const k of ["data", "events", "audit", "items"]) {
|
|
1732
|
+
if (Array.isArray(p[k])) return p[k];
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1735
|
+
return [];
|
|
1736
|
+
}
|
|
1737
|
+
function stripUndefined5(input) {
|
|
1738
|
+
return Object.fromEntries(
|
|
1739
|
+
Object.entries(input).filter(([, v]) => v !== void 0)
|
|
1740
|
+
);
|
|
1741
|
+
}
|
|
1742
|
+
function pickFirst(...values) {
|
|
1743
|
+
for (const v of values) if (v !== void 0) return v;
|
|
1744
|
+
return void 0;
|
|
1745
|
+
}
|
|
1746
|
+
function listQuery(params) {
|
|
1747
|
+
return stripUndefined5({
|
|
1748
|
+
resource_id: pickFirst(params.resourceId, params.resource_id),
|
|
1749
|
+
resource_type: pickFirst(params.resourceType, params.resource_type),
|
|
1750
|
+
host: params.host,
|
|
1751
|
+
action: params.action,
|
|
1752
|
+
since: params.since,
|
|
1753
|
+
until: params.until,
|
|
1754
|
+
limit: params.limit,
|
|
1755
|
+
cursor: params.cursor,
|
|
1756
|
+
external_user_id: pickFirst(params.externalUserId, params.external_user_id),
|
|
1757
|
+
external_workspace_id: pickFirst(
|
|
1758
|
+
params.externalWorkspaceId,
|
|
1759
|
+
params.external_workspace_id
|
|
1760
|
+
)
|
|
1761
|
+
});
|
|
1762
|
+
}
|
|
1763
|
+
function sleep2(ms) {
|
|
1764
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
1765
|
+
}
|
|
1766
|
+
var EgressAudit = class {
|
|
1767
|
+
constructor(http) {
|
|
1768
|
+
this.http = http;
|
|
1769
|
+
}
|
|
1770
|
+
http;
|
|
1771
|
+
/** List audit events with optional filters. */
|
|
1772
|
+
async list(params = {}) {
|
|
1773
|
+
const data = await this.http.get(
|
|
1774
|
+
"/egress/audit",
|
|
1775
|
+
listQuery(params)
|
|
1776
|
+
);
|
|
1777
|
+
return unwrapList8(data);
|
|
1778
|
+
}
|
|
1779
|
+
/** Get a single audit event by id. */
|
|
1780
|
+
async get(id) {
|
|
1781
|
+
const data = await this.http.get(
|
|
1782
|
+
`/egress/audit/${id}`
|
|
1783
|
+
);
|
|
1784
|
+
return unwrap17(data);
|
|
1785
|
+
}
|
|
1786
|
+
/**
|
|
1787
|
+
* Long-poll the audit endpoint and yield new events as they appear.
|
|
1788
|
+
*
|
|
1789
|
+
* Tenant-wide `client.audit.tail()` is REST-based long polling. A
|
|
1790
|
+
* live WebSocket / SSE tail is only available for the sandbox-scoped
|
|
1791
|
+
* variant — see {@link SandboxAudit.tail}.
|
|
1792
|
+
*/
|
|
1793
|
+
async *tail(params = {}) {
|
|
1794
|
+
const pollMs = params.pollIntervalMs ?? 2e3;
|
|
1795
|
+
let since = params.since;
|
|
1796
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1797
|
+
while (true) {
|
|
1798
|
+
const queryParams = { ...params };
|
|
1799
|
+
if (since !== void 0) queryParams.since = since;
|
|
1800
|
+
const data = await this.http.get(
|
|
1801
|
+
"/egress/audit",
|
|
1802
|
+
listQuery(queryParams)
|
|
1803
|
+
);
|
|
1804
|
+
const events = unwrapList8(data);
|
|
1805
|
+
for (const event of events) {
|
|
1806
|
+
if (event.id && seen.has(event.id)) continue;
|
|
1807
|
+
if (event.id) seen.add(event.id);
|
|
1808
|
+
yield event;
|
|
1809
|
+
const ts = event.inserted_at ?? event.timestamp;
|
|
1810
|
+
if (typeof ts === "string") since = ts;
|
|
1811
|
+
}
|
|
1812
|
+
await sleep2(pollMs);
|
|
1813
|
+
}
|
|
1814
|
+
}
|
|
1815
|
+
};
|
|
1816
|
+
var SandboxAudit = class {
|
|
1817
|
+
constructor(http, resourceId) {
|
|
1818
|
+
this.http = http;
|
|
1819
|
+
this.resourceId = resourceId;
|
|
1820
|
+
this.delegate = new EgressAudit(http);
|
|
1821
|
+
}
|
|
1822
|
+
http;
|
|
1823
|
+
resourceId;
|
|
1824
|
+
resourceType = "sandbox";
|
|
1825
|
+
delegate;
|
|
1826
|
+
list(params = {}) {
|
|
1827
|
+
return this.delegate.list({
|
|
1828
|
+
...params,
|
|
1829
|
+
resource_id: params.resourceId ?? params.resource_id ?? this.resourceId,
|
|
1830
|
+
resource_type: params.resourceType ?? params.resource_type ?? this.resourceType
|
|
1831
|
+
});
|
|
1832
|
+
}
|
|
1833
|
+
get(id) {
|
|
1834
|
+
return this.delegate.get(id);
|
|
1835
|
+
}
|
|
1836
|
+
/** SSE tail of the sandbox-scoped audit stream. */
|
|
1837
|
+
async *tail(params = {}) {
|
|
1838
|
+
const streamPath = this.resourceType === "sandbox" ? `/sandboxes/${this.resourceId}/audit/stream` : `/computers/${this.resourceId}/audit/stream`;
|
|
1839
|
+
try {
|
|
1840
|
+
const stream = this.http.stream(streamPath, {
|
|
1841
|
+
method: "GET"
|
|
1842
|
+
});
|
|
1843
|
+
for await (const event of stream) {
|
|
1844
|
+
yield event;
|
|
1845
|
+
}
|
|
1846
|
+
} catch {
|
|
1847
|
+
yield* this.delegate.tail({
|
|
1848
|
+
...params,
|
|
1849
|
+
resource_id: this.resourceId,
|
|
1850
|
+
resource_type: this.resourceType
|
|
1851
|
+
});
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1854
|
+
};
|
|
1855
|
+
var ComputerAudit = class extends SandboxAudit {
|
|
1856
|
+
resourceType = "computer";
|
|
1857
|
+
};
|
|
1858
|
+
|
|
1859
|
+
// src/resources/egressNetwork.ts
|
|
1860
|
+
function unwrap18(payload) {
|
|
1861
|
+
if (payload && typeof payload === "object") {
|
|
1862
|
+
const p = payload;
|
|
1863
|
+
for (const k of ["data", "policy", "rule", "items"]) {
|
|
1864
|
+
if (k in p) return p[k];
|
|
1865
|
+
}
|
|
1866
|
+
}
|
|
1867
|
+
return payload;
|
|
1868
|
+
}
|
|
1869
|
+
function unwrapList9(payload) {
|
|
1870
|
+
if (Array.isArray(payload)) return payload;
|
|
1871
|
+
if (payload && typeof payload === "object") {
|
|
1872
|
+
const p = payload;
|
|
1873
|
+
for (const k of [
|
|
1874
|
+
"data",
|
|
1875
|
+
"policies",
|
|
1876
|
+
"rules",
|
|
1877
|
+
"allowlist",
|
|
1878
|
+
"suggestions",
|
|
1879
|
+
"items"
|
|
1880
|
+
]) {
|
|
1881
|
+
if (Array.isArray(p[k])) return p[k];
|
|
1882
|
+
}
|
|
1883
|
+
}
|
|
1884
|
+
return [];
|
|
1885
|
+
}
|
|
1886
|
+
function stripUndefined6(input) {
|
|
1887
|
+
return Object.fromEntries(
|
|
1888
|
+
Object.entries(input).filter(([, v]) => v !== void 0)
|
|
1889
|
+
);
|
|
1890
|
+
}
|
|
1891
|
+
function pickFirst2(...values) {
|
|
1892
|
+
for (const v of values) if (v !== void 0) return v;
|
|
1893
|
+
return void 0;
|
|
1894
|
+
}
|
|
1895
|
+
function ruleBody(host, params, effect) {
|
|
1896
|
+
return stripUndefined6({
|
|
1897
|
+
host,
|
|
1898
|
+
effect,
|
|
1899
|
+
methods: params.methods,
|
|
1900
|
+
path_glob: pickFirst2(params.pathGlob, params.path_glob),
|
|
1901
|
+
policy_id: pickFirst2(params.policyId, params.policy_id),
|
|
1902
|
+
resource_id: pickFirst2(params.resourceId, params.resource_id),
|
|
1903
|
+
resource_type: pickFirst2(params.resourceType, params.resource_type),
|
|
1904
|
+
note: params.note
|
|
1905
|
+
});
|
|
1906
|
+
}
|
|
1907
|
+
var EgressNetwork = class {
|
|
1908
|
+
constructor(http) {
|
|
1909
|
+
this.http = http;
|
|
1910
|
+
}
|
|
1911
|
+
http;
|
|
1912
|
+
// ── allowlist ─────────────────────────────────────────────────────────────
|
|
1913
|
+
/** Add an `allow` rule for `host` to the allowlist. */
|
|
1914
|
+
async allow(host, params = {}) {
|
|
1915
|
+
const data = await this.http.post(
|
|
1916
|
+
"/egress/allowlist",
|
|
1917
|
+
ruleBody(host, params, "allow")
|
|
1918
|
+
);
|
|
1919
|
+
return unwrap18(data);
|
|
1920
|
+
}
|
|
1921
|
+
/** Add a `deny` rule for `host` to the allowlist. */
|
|
1922
|
+
async deny(host, params = {}) {
|
|
1923
|
+
const data = await this.http.post(
|
|
1924
|
+
"/egress/allowlist",
|
|
1925
|
+
ruleBody(host, params, "deny")
|
|
1926
|
+
);
|
|
1927
|
+
return unwrap18(data);
|
|
1928
|
+
}
|
|
1929
|
+
/** List allowlist rules. */
|
|
1930
|
+
async rules(params = {}) {
|
|
1931
|
+
const query = stripUndefined6({
|
|
1932
|
+
policy_id: pickFirst2(params.policyId, params.policy_id),
|
|
1933
|
+
resource_id: pickFirst2(params.resourceId, params.resource_id),
|
|
1934
|
+
resource_type: pickFirst2(params.resourceType, params.resource_type)
|
|
1935
|
+
});
|
|
1936
|
+
const data = await this.http.get("/egress/allowlist", query);
|
|
1937
|
+
return unwrapList9(data);
|
|
1938
|
+
}
|
|
1939
|
+
/** Delete an allowlist rule by id. */
|
|
1940
|
+
async removeRule(ruleId) {
|
|
1941
|
+
await this.http.delete(`/egress/allowlist/${ruleId}`);
|
|
1942
|
+
}
|
|
1943
|
+
// ── policies ──────────────────────────────────────────────────────────────
|
|
1944
|
+
/** List egress policies. */
|
|
1945
|
+
async policies(params = {}) {
|
|
1946
|
+
const query = stripUndefined6({
|
|
1947
|
+
resource_id: pickFirst2(params.resourceId, params.resource_id),
|
|
1948
|
+
resource_type: pickFirst2(params.resourceType, params.resource_type)
|
|
1949
|
+
});
|
|
1950
|
+
const data = await this.http.get("/egress/policies", query);
|
|
1951
|
+
return unwrapList9(data);
|
|
1952
|
+
}
|
|
1953
|
+
/** Create an egress policy. */
|
|
1954
|
+
async createPolicy(params) {
|
|
1955
|
+
const body = stripUndefined6({
|
|
1956
|
+
name: params.name,
|
|
1957
|
+
mode: params.mode ?? "enforce",
|
|
1958
|
+
default_effect: pickFirst2(
|
|
1959
|
+
params.defaultEffect,
|
|
1960
|
+
params.default_effect,
|
|
1961
|
+
"deny"
|
|
1962
|
+
),
|
|
1963
|
+
resource_id: pickFirst2(params.resourceId, params.resource_id),
|
|
1964
|
+
resource_type: pickFirst2(params.resourceType, params.resource_type),
|
|
1965
|
+
description: params.description
|
|
1966
|
+
});
|
|
1967
|
+
const data = await this.http.post(
|
|
1968
|
+
"/egress/policies",
|
|
1969
|
+
body
|
|
1970
|
+
);
|
|
1971
|
+
return unwrap18(data);
|
|
1972
|
+
}
|
|
1973
|
+
/** Update an egress policy by id. */
|
|
1974
|
+
async updatePolicy(policyId, params) {
|
|
1975
|
+
const body = stripUndefined6({
|
|
1976
|
+
mode: params.mode,
|
|
1977
|
+
default_effect: pickFirst2(params.defaultEffect, params.default_effect),
|
|
1978
|
+
name: params.name,
|
|
1979
|
+
description: params.description
|
|
1980
|
+
});
|
|
1981
|
+
const data = await this.http.patch(
|
|
1982
|
+
`/egress/policies/${policyId}`,
|
|
1983
|
+
body
|
|
1984
|
+
);
|
|
1985
|
+
return unwrap18(data);
|
|
1986
|
+
}
|
|
1987
|
+
// ── mode helpers ──────────────────────────────────────────────────────────
|
|
1988
|
+
/** Set the policy to `mode="enforce"` — denied egress is blocked. */
|
|
1989
|
+
async lockdown(params = {}) {
|
|
1990
|
+
return this.setMode("enforce", params);
|
|
1991
|
+
}
|
|
1992
|
+
/** Set the policy to `mode="audit_only"` — log but do not block. */
|
|
1993
|
+
async observe(params = {}) {
|
|
1994
|
+
return this.setMode("audit_only", params);
|
|
1995
|
+
}
|
|
1996
|
+
async setMode(mode, params) {
|
|
1997
|
+
const policyId = pickFirst2(params.policyId, params.policy_id);
|
|
1998
|
+
const resourceId = pickFirst2(params.resourceId, params.resource_id);
|
|
1999
|
+
const resourceType = pickFirst2(params.resourceType, params.resource_type);
|
|
2000
|
+
if (policyId) {
|
|
2001
|
+
return this.updatePolicy(policyId, { mode });
|
|
2002
|
+
}
|
|
2003
|
+
const body = resourceId !== void 0 && resourceType !== void 0 ? stripUndefined6({
|
|
2004
|
+
mode,
|
|
2005
|
+
resource_id: resourceId,
|
|
2006
|
+
resource_type: resourceType
|
|
2007
|
+
}) : { mode };
|
|
2008
|
+
const data = await this.http.patch(
|
|
2009
|
+
"/egress/policies",
|
|
2010
|
+
body
|
|
2011
|
+
);
|
|
2012
|
+
return unwrap18(data);
|
|
2013
|
+
}
|
|
2014
|
+
// ── suggestions ───────────────────────────────────────────────────────────
|
|
2015
|
+
/** AI-generated allowlist suggestions from recent denied egress. */
|
|
2016
|
+
async suggestions(params = {}) {
|
|
2017
|
+
const query = stripUndefined6({
|
|
2018
|
+
resource_id: pickFirst2(params.resourceId, params.resource_id),
|
|
2019
|
+
resource_type: pickFirst2(params.resourceType, params.resource_type),
|
|
2020
|
+
since: params.since ?? "7d"
|
|
2021
|
+
});
|
|
2022
|
+
const data = await this.http.get(
|
|
2023
|
+
"/egress/audit/suggestions",
|
|
2024
|
+
query
|
|
2025
|
+
);
|
|
2026
|
+
return unwrapList9(data);
|
|
2027
|
+
}
|
|
2028
|
+
};
|
|
2029
|
+
var SandboxNetwork = class {
|
|
2030
|
+
constructor(http, resourceId) {
|
|
2031
|
+
this.resourceId = resourceId;
|
|
2032
|
+
this.delegate = new EgressNetwork(http);
|
|
2033
|
+
}
|
|
2034
|
+
resourceId;
|
|
2035
|
+
resourceType = "sandbox";
|
|
2036
|
+
delegate;
|
|
2037
|
+
resolvedResourceId(params) {
|
|
2038
|
+
return params.resourceId ?? params.resource_id ?? this.resourceId;
|
|
2039
|
+
}
|
|
2040
|
+
resolvedResourceType(params) {
|
|
2041
|
+
return params.resourceType ?? params.resource_type ?? this.resourceType;
|
|
2042
|
+
}
|
|
2043
|
+
allow(host, params = {}) {
|
|
2044
|
+
return this.delegate.allow(host, {
|
|
2045
|
+
...params,
|
|
2046
|
+
resource_id: this.resolvedResourceId(params),
|
|
2047
|
+
resource_type: this.resolvedResourceType(params)
|
|
2048
|
+
});
|
|
2049
|
+
}
|
|
2050
|
+
deny(host, params = {}) {
|
|
2051
|
+
return this.delegate.deny(host, {
|
|
2052
|
+
...params,
|
|
2053
|
+
resource_id: this.resolvedResourceId(params),
|
|
2054
|
+
resource_type: this.resolvedResourceType(params)
|
|
2055
|
+
});
|
|
2056
|
+
}
|
|
2057
|
+
rules(params = {}) {
|
|
2058
|
+
return this.delegate.rules({
|
|
2059
|
+
...params,
|
|
2060
|
+
resource_id: this.resolvedResourceId(params),
|
|
2061
|
+
resource_type: this.resolvedResourceType(params)
|
|
2062
|
+
});
|
|
2063
|
+
}
|
|
2064
|
+
removeRule(ruleId) {
|
|
2065
|
+
return this.delegate.removeRule(ruleId);
|
|
2066
|
+
}
|
|
2067
|
+
lockdown(params = {}) {
|
|
2068
|
+
const body = {
|
|
2069
|
+
resource_id: this.resourceId,
|
|
2070
|
+
resource_type: this.resourceType
|
|
2071
|
+
};
|
|
2072
|
+
if (params.policyId !== void 0) body.policyId = params.policyId;
|
|
2073
|
+
return this.delegate.lockdown(body);
|
|
2074
|
+
}
|
|
2075
|
+
observe(params = {}) {
|
|
2076
|
+
const body = {
|
|
2077
|
+
resource_id: this.resourceId,
|
|
2078
|
+
resource_type: this.resourceType
|
|
2079
|
+
};
|
|
2080
|
+
if (params.policyId !== void 0) body.policyId = params.policyId;
|
|
2081
|
+
return this.delegate.observe(body);
|
|
2082
|
+
}
|
|
2083
|
+
suggestions(params = {}) {
|
|
2084
|
+
const body = {
|
|
2085
|
+
resource_id: this.resourceId,
|
|
2086
|
+
resource_type: this.resourceType
|
|
2087
|
+
};
|
|
2088
|
+
if (params.since !== void 0) body.since = params.since;
|
|
2089
|
+
return this.delegate.suggestions(body);
|
|
2090
|
+
}
|
|
2091
|
+
policies() {
|
|
2092
|
+
return this.delegate.policies({
|
|
2093
|
+
resource_id: this.resourceId,
|
|
2094
|
+
resource_type: this.resourceType
|
|
2095
|
+
});
|
|
2096
|
+
}
|
|
2097
|
+
};
|
|
2098
|
+
var ComputerNetwork = class extends SandboxNetwork {
|
|
2099
|
+
resourceType = "computer";
|
|
2100
|
+
};
|
|
2101
|
+
|
|
2102
|
+
// src/resources/egressSecrets.ts
|
|
2103
|
+
function unwrap19(payload) {
|
|
2104
|
+
if (payload && typeof payload === "object") {
|
|
2105
|
+
const p = payload;
|
|
2106
|
+
for (const k of ["data", "secret", "binding", "items"]) {
|
|
2107
|
+
if (k in p) return p[k];
|
|
2108
|
+
}
|
|
2109
|
+
}
|
|
2110
|
+
return payload;
|
|
2111
|
+
}
|
|
2112
|
+
function unwrapList10(payload) {
|
|
2113
|
+
if (Array.isArray(payload)) return payload;
|
|
2114
|
+
if (payload && typeof payload === "object") {
|
|
2115
|
+
const p = payload;
|
|
2116
|
+
for (const k of ["data", "secrets", "bindings", "providers", "items"]) {
|
|
2117
|
+
if (Array.isArray(p[k])) return p[k];
|
|
2118
|
+
}
|
|
2119
|
+
}
|
|
2120
|
+
return [];
|
|
2121
|
+
}
|
|
2122
|
+
function stripUndefined7(input) {
|
|
2123
|
+
return Object.fromEntries(
|
|
2124
|
+
Object.entries(input).filter(([, v]) => v !== void 0)
|
|
2125
|
+
);
|
|
2126
|
+
}
|
|
2127
|
+
function pickFirst3(...values) {
|
|
2128
|
+
for (const v of values) if (v !== void 0) return v;
|
|
2129
|
+
return void 0;
|
|
2130
|
+
}
|
|
2131
|
+
function setBody(params) {
|
|
2132
|
+
return stripUndefined7({
|
|
2133
|
+
name: params.name,
|
|
2134
|
+
value: params.value,
|
|
2135
|
+
type: params.type ?? "api_key",
|
|
2136
|
+
scope: params.scope ?? "user",
|
|
2137
|
+
expose_as_env: pickFirst3(params.exposeAsEnv, params.expose_as_env),
|
|
2138
|
+
workspace_id: pickFirst3(params.workspaceId, params.workspace_id),
|
|
2139
|
+
owner_user_id: pickFirst3(params.ownerUserId, params.owner_user_id),
|
|
2140
|
+
external_user_id: pickFirst3(params.externalUserId, params.external_user_id),
|
|
2141
|
+
external_workspace_id: pickFirst3(
|
|
2142
|
+
params.externalWorkspaceId,
|
|
2143
|
+
params.external_workspace_id
|
|
2144
|
+
),
|
|
2145
|
+
resource_id: pickFirst3(params.resourceId, params.resource_id),
|
|
2146
|
+
resource_type: pickFirst3(params.resourceType, params.resource_type),
|
|
2147
|
+
refresh_token: pickFirst3(params.refreshToken, params.refresh_token),
|
|
2148
|
+
expires_at: pickFirst3(params.expiresAt, params.expires_at),
|
|
2149
|
+
metadata: params.metadata
|
|
2150
|
+
});
|
|
2151
|
+
}
|
|
2152
|
+
function listQuery2(params) {
|
|
2153
|
+
return stripUndefined7({
|
|
2154
|
+
scope: params.scope,
|
|
2155
|
+
type: params.type,
|
|
2156
|
+
workspace_id: pickFirst3(params.workspaceId, params.workspace_id),
|
|
2157
|
+
owner_user_id: pickFirst3(params.ownerUserId, params.owner_user_id),
|
|
2158
|
+
external_user_id: pickFirst3(params.externalUserId, params.external_user_id),
|
|
2159
|
+
external_workspace_id: pickFirst3(
|
|
2160
|
+
params.externalWorkspaceId,
|
|
2161
|
+
params.external_workspace_id
|
|
2162
|
+
),
|
|
2163
|
+
resource_id: pickFirst3(params.resourceId, params.resource_id),
|
|
2164
|
+
resource_type: pickFirst3(params.resourceType, params.resource_type)
|
|
2165
|
+
});
|
|
2166
|
+
}
|
|
2167
|
+
function rotateBody(params) {
|
|
2168
|
+
return stripUndefined7({
|
|
2169
|
+
value: pickFirst3(params.newValue, params.new_value, params.value),
|
|
2170
|
+
refresh_token: pickFirst3(params.refreshToken, params.refresh_token),
|
|
2171
|
+
expires_at: pickFirst3(params.expiresAt, params.expires_at)
|
|
2172
|
+
});
|
|
2173
|
+
}
|
|
2174
|
+
function bindingBody(params) {
|
|
2175
|
+
return stripUndefined7({
|
|
2176
|
+
secret_id: pickFirst3(params.secretId, params.secret_id),
|
|
2177
|
+
resource_id: pickFirst3(params.resourceId, params.resource_id),
|
|
2178
|
+
resource_type: pickFirst3(params.resourceType, params.resource_type),
|
|
2179
|
+
expose_as_env: pickFirst3(params.exposeAsEnv, params.expose_as_env)
|
|
2180
|
+
});
|
|
2181
|
+
}
|
|
2182
|
+
function bindingQuery(params) {
|
|
2183
|
+
return stripUndefined7({
|
|
2184
|
+
resource_id: pickFirst3(params.resourceId, params.resource_id),
|
|
2185
|
+
resource_type: pickFirst3(params.resourceType, params.resource_type),
|
|
2186
|
+
secret_id: pickFirst3(params.secretId, params.secret_id)
|
|
2187
|
+
});
|
|
2188
|
+
}
|
|
2189
|
+
function oauthBody(params) {
|
|
2190
|
+
return stripUndefined7({
|
|
2191
|
+
provider: params.provider,
|
|
2192
|
+
expose_as_env: pickFirst3(params.exposeAsEnv, params.expose_as_env),
|
|
2193
|
+
scope: params.scope,
|
|
2194
|
+
owner_user_id: pickFirst3(params.ownerUserId, params.owner_user_id),
|
|
2195
|
+
external_user_id: pickFirst3(params.externalUserId, params.external_user_id),
|
|
2196
|
+
external_workspace_id: pickFirst3(
|
|
2197
|
+
params.externalWorkspaceId,
|
|
2198
|
+
params.external_workspace_id
|
|
2199
|
+
),
|
|
2200
|
+
resource_id: pickFirst3(params.resourceId, params.resource_id),
|
|
2201
|
+
resource_type: pickFirst3(params.resourceType, params.resource_type),
|
|
2202
|
+
redirect_uri: pickFirst3(params.redirectUri, params.redirect_uri)
|
|
2203
|
+
});
|
|
2204
|
+
}
|
|
2205
|
+
function sleep3(ms) {
|
|
2206
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
2207
|
+
}
|
|
2208
|
+
var OAuthFlow = class {
|
|
2209
|
+
authorizeUrl;
|
|
2210
|
+
state;
|
|
2211
|
+
provider;
|
|
2212
|
+
data;
|
|
2213
|
+
http;
|
|
2214
|
+
constructor(http, payload, provider) {
|
|
2215
|
+
this.http = http;
|
|
2216
|
+
this.authorizeUrl = payload.authorize_url ?? payload.authorizeUrl ?? "";
|
|
2217
|
+
this.state = payload.state ?? "";
|
|
2218
|
+
if (provider !== void 0) {
|
|
2219
|
+
this.provider = provider;
|
|
2220
|
+
}
|
|
2221
|
+
this.data = payload;
|
|
2222
|
+
}
|
|
2223
|
+
/**
|
|
2224
|
+
* Poll `GET /egress/oauth/status?state=...` until the flow completes.
|
|
2225
|
+
*
|
|
2226
|
+
* Returns the status payload once the upstream provider issues
|
|
2227
|
+
* tokens. Rejects with a `TimeoutError`-style Error if the flow does
|
|
2228
|
+
* not complete within `timeoutSec` seconds, or if the upstream
|
|
2229
|
+
* returns a failed status.
|
|
2230
|
+
*/
|
|
2231
|
+
async waitForCompletion(options = {}) {
|
|
2232
|
+
const timeoutSec = options.timeoutSec ?? 300;
|
|
2233
|
+
const pollMs = options.pollIntervalMs ?? 2e3;
|
|
2234
|
+
const deadline = Date.now() + timeoutSec * 1e3;
|
|
2235
|
+
while (Date.now() < deadline) {
|
|
2236
|
+
const data = await this.http.get("/egress/oauth/status", {
|
|
2237
|
+
state: this.state
|
|
2238
|
+
});
|
|
2239
|
+
const payload = unwrap19(data) ?? {};
|
|
2240
|
+
const status = payload.status;
|
|
2241
|
+
if (status === "completed" || status === "ready" || status === "succeeded") {
|
|
2242
|
+
return payload;
|
|
2243
|
+
}
|
|
2244
|
+
if (status === "failed" || status === "error" || status === "denied") {
|
|
2245
|
+
throw new Error(
|
|
2246
|
+
`OAuth flow ${this.state} ended in status=${status}: ${payload.error ?? payload.message ?? "no detail"}`
|
|
2247
|
+
);
|
|
2248
|
+
}
|
|
2249
|
+
await sleep3(pollMs);
|
|
2250
|
+
}
|
|
2251
|
+
throw new Error(
|
|
2252
|
+
`OAuth flow ${this.state} did not complete within ${timeoutSec}s`
|
|
2253
|
+
);
|
|
2254
|
+
}
|
|
2255
|
+
};
|
|
2256
|
+
var EgressSecrets = class {
|
|
2257
|
+
constructor(http) {
|
|
2258
|
+
this.http = http;
|
|
2259
|
+
}
|
|
2260
|
+
http;
|
|
2261
|
+
/**
|
|
2262
|
+
* Create a secret. When `exposeAsEnv` is provided together with
|
|
2263
|
+
* `resourceId` the backend also creates a binding so the value is
|
|
2264
|
+
* injected as an env-var on that resource.
|
|
2265
|
+
*/
|
|
2266
|
+
async set(params) {
|
|
2267
|
+
const data = await this.http.post(
|
|
2268
|
+
"/egress/secrets",
|
|
2269
|
+
setBody(params)
|
|
2270
|
+
);
|
|
2271
|
+
return unwrap19(data);
|
|
2272
|
+
}
|
|
2273
|
+
/** List secrets. */
|
|
2274
|
+
async list(params = {}) {
|
|
2275
|
+
const data = await this.http.get(
|
|
2276
|
+
"/egress/secrets",
|
|
2277
|
+
listQuery2(params)
|
|
2278
|
+
);
|
|
2279
|
+
return unwrapList10(data);
|
|
2280
|
+
}
|
|
2281
|
+
/** Get a single secret by id. */
|
|
2282
|
+
async get(id) {
|
|
2283
|
+
const data = await this.http.get(
|
|
2284
|
+
`/egress/secrets/${id}`
|
|
2285
|
+
);
|
|
2286
|
+
return unwrap19(data);
|
|
2287
|
+
}
|
|
2288
|
+
/** Rotate the secret's value. */
|
|
2289
|
+
async rotate(id, params) {
|
|
2290
|
+
const body = typeof params === "string" ? rotateBody({ newValue: params }) : rotateBody(params);
|
|
2291
|
+
const data = await this.http.patch(
|
|
2292
|
+
`/egress/secrets/${id}`,
|
|
2293
|
+
body
|
|
2294
|
+
);
|
|
2295
|
+
return unwrap19(data);
|
|
2296
|
+
}
|
|
2297
|
+
/** Delete a secret. */
|
|
2298
|
+
async delete(id) {
|
|
2299
|
+
await this.http.delete(`/egress/secrets/${id}`);
|
|
2300
|
+
}
|
|
2301
|
+
// ── bindings ───────────────────────────────────────────────────────────────
|
|
2302
|
+
/** Bind a secret to a resource as an env var. */
|
|
2303
|
+
async createBinding(params) {
|
|
2304
|
+
const data = await this.http.post(
|
|
2305
|
+
"/egress/bindings",
|
|
2306
|
+
bindingBody(params)
|
|
2307
|
+
);
|
|
2308
|
+
return unwrap19(data);
|
|
2309
|
+
}
|
|
2310
|
+
/** List secret bindings. */
|
|
2311
|
+
async listBindings(params = {}) {
|
|
2312
|
+
const data = await this.http.get(
|
|
2313
|
+
"/egress/bindings",
|
|
2314
|
+
bindingQuery(params)
|
|
2315
|
+
);
|
|
2316
|
+
return unwrapList10(data);
|
|
2317
|
+
}
|
|
2318
|
+
/** Delete a binding. */
|
|
2319
|
+
async deleteBinding(id) {
|
|
2320
|
+
await this.http.delete(`/egress/bindings/${id}`);
|
|
2321
|
+
}
|
|
2322
|
+
// ── OAuth Connect ──────────────────────────────────────────────────────────
|
|
2323
|
+
/** List OAuth providers visible to the current tenant. */
|
|
2324
|
+
async providers() {
|
|
2325
|
+
const data = await this.http.get("/egress/oauth/providers");
|
|
2326
|
+
return unwrapList10(data);
|
|
2327
|
+
}
|
|
2328
|
+
/**
|
|
2329
|
+
* Start an OAuth Connect flow.
|
|
2330
|
+
*
|
|
2331
|
+
* Returns an {@link OAuthFlow} — the caller must surface
|
|
2332
|
+
* `flow.authorizeUrl` to the end user (the SDK does NOT open the
|
|
2333
|
+
* browser) and then call `flow.waitForCompletion()` to receive the
|
|
2334
|
+
* resulting secret id.
|
|
2335
|
+
*/
|
|
2336
|
+
async connect(params) {
|
|
2337
|
+
const data = await this.http.post(
|
|
2338
|
+
"/egress/oauth/start",
|
|
2339
|
+
oauthBody(params)
|
|
2340
|
+
);
|
|
2341
|
+
const payload = unwrap19(data) ?? {};
|
|
2342
|
+
return new OAuthFlow(this.http, payload, params.provider);
|
|
2343
|
+
}
|
|
2344
|
+
};
|
|
2345
|
+
var SandboxSecrets = class {
|
|
2346
|
+
constructor(http, resourceId) {
|
|
2347
|
+
this.resourceId = resourceId;
|
|
2348
|
+
this.delegate = new EgressSecrets(http);
|
|
2349
|
+
}
|
|
2350
|
+
resourceId;
|
|
2351
|
+
resourceType = "sandbox";
|
|
2352
|
+
delegate;
|
|
2353
|
+
resolvedResourceId(params) {
|
|
2354
|
+
return params.resourceId ?? params.resource_id ?? this.resourceId;
|
|
2355
|
+
}
|
|
2356
|
+
resolvedResourceType(params) {
|
|
2357
|
+
return params.resourceType ?? params.resource_type ?? this.resourceType;
|
|
2358
|
+
}
|
|
2359
|
+
set(params) {
|
|
2360
|
+
return this.delegate.set({
|
|
2361
|
+
...params,
|
|
2362
|
+
resource_id: this.resolvedResourceId(params),
|
|
2363
|
+
resource_type: this.resolvedResourceType(params)
|
|
2364
|
+
});
|
|
2365
|
+
}
|
|
2366
|
+
list(params = {}) {
|
|
2367
|
+
return this.delegate.list({
|
|
2368
|
+
...params,
|
|
2369
|
+
resource_id: this.resolvedResourceId(params),
|
|
2370
|
+
resource_type: this.resolvedResourceType(params)
|
|
2371
|
+
});
|
|
2372
|
+
}
|
|
2373
|
+
get(id) {
|
|
2374
|
+
return this.delegate.get(id);
|
|
2375
|
+
}
|
|
2376
|
+
rotate(id, params) {
|
|
2377
|
+
return this.delegate.rotate(id, params);
|
|
2378
|
+
}
|
|
2379
|
+
delete(id) {
|
|
2380
|
+
return this.delegate.delete(id);
|
|
2381
|
+
}
|
|
2382
|
+
connect(params) {
|
|
2383
|
+
return this.delegate.connect({
|
|
2384
|
+
...params,
|
|
2385
|
+
resource_id: this.resolvedResourceId(params),
|
|
2386
|
+
resource_type: this.resolvedResourceType(params)
|
|
2387
|
+
});
|
|
2388
|
+
}
|
|
2389
|
+
listBindings(params = {}) {
|
|
2390
|
+
return this.delegate.listBindings({
|
|
2391
|
+
...params,
|
|
2392
|
+
resource_id: this.resolvedResourceId(params),
|
|
2393
|
+
resource_type: this.resolvedResourceType(params)
|
|
2394
|
+
});
|
|
2395
|
+
}
|
|
2396
|
+
};
|
|
2397
|
+
var ComputerSecrets = class extends SandboxSecrets {
|
|
2398
|
+
resourceType = "computer";
|
|
2399
|
+
};
|
|
1698
2400
|
var EventStream = class extends EventEmitter {
|
|
1699
2401
|
ws = null;
|
|
1700
2402
|
closed = false;
|
|
@@ -2252,6 +2954,12 @@ var Computer = class _Computer {
|
|
|
2252
2954
|
ports;
|
|
2253
2955
|
/** Volume attachment — list, attach, detach. */
|
|
2254
2956
|
volumes;
|
|
2957
|
+
/** Encrypted secrets + OAuth credentials scoped to this computer. */
|
|
2958
|
+
secrets;
|
|
2959
|
+
/** Egress allowlist + policies scoped to this computer. */
|
|
2960
|
+
network;
|
|
2961
|
+
/** Egress audit log + live tail scoped to this computer. */
|
|
2962
|
+
audit;
|
|
2255
2963
|
http;
|
|
2256
2964
|
constructor(http, data) {
|
|
2257
2965
|
this.http = http;
|
|
@@ -2272,6 +2980,9 @@ var Computer = class _Computer {
|
|
|
2272
2980
|
this.logs = new ComputerLogs(http, id);
|
|
2273
2981
|
this.ports = new ComputerPorts(http, id);
|
|
2274
2982
|
this.volumes = new ComputerVolumes(http, id);
|
|
2983
|
+
this.secrets = new ComputerSecrets(http, id);
|
|
2984
|
+
this.network = new ComputerNetwork(http, id);
|
|
2985
|
+
this.audit = new ComputerAudit(http, id);
|
|
2275
2986
|
}
|
|
2276
2987
|
get id() {
|
|
2277
2988
|
return this.data.id;
|
|
@@ -2668,7 +3379,7 @@ var Credits = class {
|
|
|
2668
3379
|
return this.http.get("/credits/usage");
|
|
2669
3380
|
}
|
|
2670
3381
|
};
|
|
2671
|
-
function
|
|
3382
|
+
function unwrap20(payload) {
|
|
2672
3383
|
if (payload && typeof payload === "object" && "data" in payload) {
|
|
2673
3384
|
return payload.data;
|
|
2674
3385
|
}
|
|
@@ -2684,7 +3395,7 @@ function listItems2(payload, candidateKeys = ["data", "cron_jobs", "executions",
|
|
|
2684
3395
|
}
|
|
2685
3396
|
return [];
|
|
2686
3397
|
}
|
|
2687
|
-
function
|
|
3398
|
+
function stripUndefined8(input) {
|
|
2688
3399
|
return Object.fromEntries(
|
|
2689
3400
|
Object.entries(input).filter(([, v]) => v !== void 0)
|
|
2690
3401
|
);
|
|
@@ -2698,28 +3409,28 @@ var CronJobs = class {
|
|
|
2698
3409
|
}
|
|
2699
3410
|
http;
|
|
2700
3411
|
async list(params = {}) {
|
|
2701
|
-
const query =
|
|
3412
|
+
const query = stripUndefined8({ ...params });
|
|
2702
3413
|
const data = await this.http.get("/cron-jobs", query);
|
|
2703
3414
|
return listItems2(data);
|
|
2704
3415
|
}
|
|
2705
3416
|
async get(jobId) {
|
|
2706
3417
|
const data = await this.http.get(`/cron-jobs/${jobId}`);
|
|
2707
|
-
return
|
|
3418
|
+
return unwrap20(data);
|
|
2708
3419
|
}
|
|
2709
3420
|
async create(params) {
|
|
2710
3421
|
const { idempotencyKey: ikey, ...rest } = params;
|
|
2711
|
-
const body =
|
|
3422
|
+
const body = stripUndefined8(rest);
|
|
2712
3423
|
const data = await this.http.request("/cron-jobs", {
|
|
2713
3424
|
method: "POST",
|
|
2714
3425
|
body,
|
|
2715
3426
|
headers: { "Idempotency-Key": idempotencyKey2(ikey) }
|
|
2716
3427
|
});
|
|
2717
|
-
return
|
|
3428
|
+
return unwrap20(data);
|
|
2718
3429
|
}
|
|
2719
3430
|
async update(jobId, params) {
|
|
2720
|
-
const body =
|
|
3431
|
+
const body = stripUndefined8(params);
|
|
2721
3432
|
const data = await this.http.patch(`/cron-jobs/${jobId}`, body);
|
|
2722
|
-
return
|
|
3433
|
+
return unwrap20(data);
|
|
2723
3434
|
}
|
|
2724
3435
|
async delete(jobId) {
|
|
2725
3436
|
await this.http.delete(`/cron-jobs/${jobId}`);
|
|
@@ -2727,11 +3438,11 @@ var CronJobs = class {
|
|
|
2727
3438
|
// ── Control ────────────────────────────────────────────────────────────────
|
|
2728
3439
|
async pause(jobId) {
|
|
2729
3440
|
const data = await this.http.post(`/cron-jobs/${jobId}/pause`);
|
|
2730
|
-
return
|
|
3441
|
+
return unwrap20(data);
|
|
2731
3442
|
}
|
|
2732
3443
|
async resume(jobId) {
|
|
2733
3444
|
const data = await this.http.post(`/cron-jobs/${jobId}/resume`);
|
|
2734
|
-
return
|
|
3445
|
+
return unwrap20(data);
|
|
2735
3446
|
}
|
|
2736
3447
|
async runNow(jobId, opts = {}) {
|
|
2737
3448
|
const data = await this.http.request(
|
|
@@ -2741,7 +3452,7 @@ var CronJobs = class {
|
|
|
2741
3452
|
headers: { "Idempotency-Key": idempotencyKey2(opts.idempotencyKey) }
|
|
2742
3453
|
}
|
|
2743
3454
|
);
|
|
2744
|
-
return
|
|
3455
|
+
return unwrap20(data);
|
|
2745
3456
|
}
|
|
2746
3457
|
// ── Execution history ──────────────────────────────────────────────────────
|
|
2747
3458
|
async listExecutions(jobId) {
|
|
@@ -2756,12 +3467,12 @@ var CronJobs = class {
|
|
|
2756
3467
|
const data = await this.http.get(
|
|
2757
3468
|
`/cron-jobs/${jobId}/executions/${executionId}`
|
|
2758
3469
|
);
|
|
2759
|
-
return
|
|
3470
|
+
return unwrap20(data);
|
|
2760
3471
|
}
|
|
2761
3472
|
};
|
|
2762
3473
|
|
|
2763
3474
|
// src/resources/dashboard.ts
|
|
2764
|
-
function
|
|
3475
|
+
function unwrap21(payload) {
|
|
2765
3476
|
if (payload && typeof payload === "object") {
|
|
2766
3477
|
const p = payload;
|
|
2767
3478
|
for (const k of ["data", "dashboard", "overview", "items"]) {
|
|
@@ -2778,15 +3489,15 @@ var Dashboard = class {
|
|
|
2778
3489
|
/** Aggregated user dashboard payload. */
|
|
2779
3490
|
async summary() {
|
|
2780
3491
|
const data = await this.http.get("/dashboard");
|
|
2781
|
-
return
|
|
3492
|
+
return unwrap21(data);
|
|
2782
3493
|
}
|
|
2783
3494
|
/** Status / health overview (public endpoint). */
|
|
2784
3495
|
async overview() {
|
|
2785
3496
|
const data = await this.http.get("/overview");
|
|
2786
|
-
return
|
|
3497
|
+
return unwrap21(data);
|
|
2787
3498
|
}
|
|
2788
3499
|
};
|
|
2789
|
-
function
|
|
3500
|
+
function unwrap22(payload) {
|
|
2790
3501
|
if (payload && typeof payload === "object" && "data" in payload) {
|
|
2791
3502
|
return payload.data;
|
|
2792
3503
|
}
|
|
@@ -2802,7 +3513,7 @@ function listItems3(payload, candidateKeys = ["data", "databases", "items"]) {
|
|
|
2802
3513
|
}
|
|
2803
3514
|
return [];
|
|
2804
3515
|
}
|
|
2805
|
-
function
|
|
3516
|
+
function stripUndefined9(input) {
|
|
2806
3517
|
return Object.fromEntries(
|
|
2807
3518
|
Object.entries(input).filter(([, v]) => v !== void 0)
|
|
2808
3519
|
);
|
|
@@ -2816,13 +3527,13 @@ var Databases = class {
|
|
|
2816
3527
|
}
|
|
2817
3528
|
http;
|
|
2818
3529
|
async list(params = {}) {
|
|
2819
|
-
const query =
|
|
3530
|
+
const query = stripUndefined9({ ...params });
|
|
2820
3531
|
const data = await this.http.get("/databases", query);
|
|
2821
3532
|
return listItems3(data);
|
|
2822
3533
|
}
|
|
2823
3534
|
async get(databaseId) {
|
|
2824
3535
|
const data = await this.http.get(`/databases/${databaseId}`);
|
|
2825
|
-
return
|
|
3536
|
+
return unwrap22(data);
|
|
2826
3537
|
}
|
|
2827
3538
|
async create(params) {
|
|
2828
3539
|
const {
|
|
@@ -2833,7 +3544,7 @@ var Databases = class {
|
|
|
2833
3544
|
size: _deprecatedSize,
|
|
2834
3545
|
...rest
|
|
2835
3546
|
} = params;
|
|
2836
|
-
const body =
|
|
3547
|
+
const body = stripUndefined9({
|
|
2837
3548
|
...rest,
|
|
2838
3549
|
engine_version: engine_version ?? version
|
|
2839
3550
|
});
|
|
@@ -2846,7 +3557,7 @@ var Databases = class {
|
|
|
2846
3557
|
)
|
|
2847
3558
|
}
|
|
2848
3559
|
});
|
|
2849
|
-
return
|
|
3560
|
+
return unwrap22(data);
|
|
2850
3561
|
}
|
|
2851
3562
|
async delete(databaseId) {
|
|
2852
3563
|
await this.http.delete(`/databases/${databaseId}`);
|
|
@@ -2856,27 +3567,27 @@ var Databases = class {
|
|
|
2856
3567
|
const data = await this.http.post(
|
|
2857
3568
|
`/databases/${databaseId}/start`
|
|
2858
3569
|
);
|
|
2859
|
-
return
|
|
3570
|
+
return unwrap22(data);
|
|
2860
3571
|
}
|
|
2861
3572
|
async stop(databaseId) {
|
|
2862
3573
|
const data = await this.http.post(`/databases/${databaseId}/stop`);
|
|
2863
|
-
return
|
|
3574
|
+
return unwrap22(data);
|
|
2864
3575
|
}
|
|
2865
3576
|
async restart(databaseId) {
|
|
2866
3577
|
const data = await this.http.post(
|
|
2867
3578
|
`/databases/${databaseId}/restart`
|
|
2868
3579
|
);
|
|
2869
|
-
return
|
|
3580
|
+
return unwrap22(data);
|
|
2870
3581
|
}
|
|
2871
3582
|
// ── Credentials + logs ────────────────────────────────────────────────────
|
|
2872
3583
|
async credentials(databaseId) {
|
|
2873
3584
|
const data = await this.http.get(
|
|
2874
3585
|
`/databases/${databaseId}/credentials`
|
|
2875
3586
|
);
|
|
2876
|
-
return
|
|
3587
|
+
return unwrap22(data);
|
|
2877
3588
|
}
|
|
2878
3589
|
async logs(databaseId, params = {}) {
|
|
2879
|
-
const query =
|
|
3590
|
+
const query = stripUndefined9({
|
|
2880
3591
|
lines: params.lines,
|
|
2881
3592
|
since: params.since
|
|
2882
3593
|
});
|
|
@@ -2903,7 +3614,7 @@ function attributionBody(p) {
|
|
|
2903
3614
|
function idempotencyKey4(key) {
|
|
2904
3615
|
return key ?? randomUUID();
|
|
2905
3616
|
}
|
|
2906
|
-
function
|
|
3617
|
+
function unwrap23(payload) {
|
|
2907
3618
|
if (payload && typeof payload === "object" && "data" in payload) {
|
|
2908
3619
|
return payload.data;
|
|
2909
3620
|
}
|
|
@@ -2919,7 +3630,7 @@ function listItems4(payload, candidateKeys = ["items", "deployments", "versions"
|
|
|
2919
3630
|
}
|
|
2920
3631
|
return [];
|
|
2921
3632
|
}
|
|
2922
|
-
function
|
|
3633
|
+
function stripUndefined10(input) {
|
|
2923
3634
|
return Object.fromEntries(
|
|
2924
3635
|
Object.entries(input).filter(([, v]) => v !== void 0)
|
|
2925
3636
|
);
|
|
@@ -2932,7 +3643,7 @@ var DeploymentVersions = class {
|
|
|
2932
3643
|
http;
|
|
2933
3644
|
deploymentId;
|
|
2934
3645
|
async list(params = {}) {
|
|
2935
|
-
const query =
|
|
3646
|
+
const query = stripUndefined10({
|
|
2936
3647
|
state: params.state,
|
|
2937
3648
|
limit: params.limit,
|
|
2938
3649
|
cursor: params.cursor,
|
|
@@ -2948,10 +3659,10 @@ var DeploymentVersions = class {
|
|
|
2948
3659
|
const data = await this.http.get(
|
|
2949
3660
|
`/deployments/${this.deploymentId}/versions/${versionId}`
|
|
2950
3661
|
);
|
|
2951
|
-
return
|
|
3662
|
+
return unwrap23(data);
|
|
2952
3663
|
}
|
|
2953
3664
|
async promote(versionId, opts = {}) {
|
|
2954
|
-
const body =
|
|
3665
|
+
const body = stripUndefined10({ environment: opts.environment });
|
|
2955
3666
|
const data = await this.http.request(
|
|
2956
3667
|
`/deployments/${this.deploymentId}/versions/${versionId}/promote`,
|
|
2957
3668
|
{
|
|
@@ -2960,7 +3671,7 @@ var DeploymentVersions = class {
|
|
|
2960
3671
|
headers: { "Idempotency-Key": idempotencyKey4(opts.idempotencyKey) }
|
|
2961
3672
|
}
|
|
2962
3673
|
);
|
|
2963
|
-
return
|
|
3674
|
+
return unwrap23(data);
|
|
2964
3675
|
}
|
|
2965
3676
|
};
|
|
2966
3677
|
var DeploymentReleases = class {
|
|
@@ -2980,7 +3691,7 @@ var DeploymentReleases = class {
|
|
|
2980
3691
|
const data = await this.http.get(
|
|
2981
3692
|
`/deployments/${this.deploymentId}/releases/${releaseId}`
|
|
2982
3693
|
);
|
|
2983
|
-
return
|
|
3694
|
+
return unwrap23(data);
|
|
2984
3695
|
}
|
|
2985
3696
|
};
|
|
2986
3697
|
var DeploymentRuntimeInstances = class {
|
|
@@ -3000,14 +3711,14 @@ var DeploymentRuntimeInstances = class {
|
|
|
3000
3711
|
const data = await this.http.get(
|
|
3001
3712
|
`/deployments/${this.deploymentId}/runtime-instances/${instanceId}`
|
|
3002
3713
|
);
|
|
3003
|
-
return
|
|
3714
|
+
return unwrap23(data);
|
|
3004
3715
|
}
|
|
3005
3716
|
async logs(instanceId, lines = 100) {
|
|
3006
3717
|
const data = await this.http.get(
|
|
3007
3718
|
`/deployments/${this.deploymentId}/runtime-instances/${instanceId}/logs`,
|
|
3008
3719
|
{ lines }
|
|
3009
3720
|
);
|
|
3010
|
-
const unwrapped =
|
|
3721
|
+
const unwrapped = unwrap23(data);
|
|
3011
3722
|
const result = { logs: String(unwrapped.logs ?? "") };
|
|
3012
3723
|
if (typeof unwrapped.runtime_instance_id === "string") {
|
|
3013
3724
|
result.runtime_instance_id = unwrapped.runtime_instance_id;
|
|
@@ -3038,11 +3749,11 @@ var DeploymentDomains = class {
|
|
|
3038
3749
|
`/deployments/${this.deploymentId}/domains`,
|
|
3039
3750
|
{
|
|
3040
3751
|
method: "POST",
|
|
3041
|
-
body:
|
|
3752
|
+
body: stripUndefined10(body),
|
|
3042
3753
|
headers: { "Idempotency-Key": idempotencyKey4(params.idempotencyKey) }
|
|
3043
3754
|
}
|
|
3044
3755
|
);
|
|
3045
|
-
return
|
|
3756
|
+
return unwrap23(data);
|
|
3046
3757
|
}
|
|
3047
3758
|
async list(filters = {}) {
|
|
3048
3759
|
const data = await this.http.get(
|
|
@@ -3055,7 +3766,7 @@ var DeploymentDomains = class {
|
|
|
3055
3766
|
const data = await this.http.post(
|
|
3056
3767
|
`/deployments/${this.deploymentId}/domains/${domainId}/verify`
|
|
3057
3768
|
);
|
|
3058
|
-
return
|
|
3769
|
+
return unwrap23(data);
|
|
3059
3770
|
}
|
|
3060
3771
|
async delete(domainId) {
|
|
3061
3772
|
await this.http.delete(
|
|
@@ -3070,7 +3781,7 @@ var Deployments = class {
|
|
|
3070
3781
|
http;
|
|
3071
3782
|
async list(params = {}) {
|
|
3072
3783
|
const projectId = params.projectId ?? params.project_id;
|
|
3073
|
-
const query =
|
|
3784
|
+
const query = stripUndefined10({
|
|
3074
3785
|
project_id: projectId,
|
|
3075
3786
|
state: params.state,
|
|
3076
3787
|
limit: params.limit,
|
|
@@ -3085,10 +3796,10 @@ var Deployments = class {
|
|
|
3085
3796
|
}
|
|
3086
3797
|
async get(deploymentId) {
|
|
3087
3798
|
const data = await this.http.get(`/deployments/${deploymentId}`);
|
|
3088
|
-
return
|
|
3799
|
+
return unwrap23(data);
|
|
3089
3800
|
}
|
|
3090
3801
|
async create(params) {
|
|
3091
|
-
const body =
|
|
3802
|
+
const body = stripUndefined10({
|
|
3092
3803
|
name: params.name,
|
|
3093
3804
|
repo_url: params.repoUrl ?? params.repo_url,
|
|
3094
3805
|
branch: params.branch,
|
|
@@ -3104,10 +3815,10 @@ var Deployments = class {
|
|
|
3104
3815
|
body,
|
|
3105
3816
|
headers: { "Idempotency-Key": idempotencyKey4(params.idempotencyKey) }
|
|
3106
3817
|
});
|
|
3107
|
-
return
|
|
3818
|
+
return unwrap23(data);
|
|
3108
3819
|
}
|
|
3109
3820
|
async update(deploymentId, params) {
|
|
3110
|
-
const body =
|
|
3821
|
+
const body = stripUndefined10({
|
|
3111
3822
|
name: params.name,
|
|
3112
3823
|
branch: params.branch,
|
|
3113
3824
|
build_command: params.buildCommand ?? params.build_command,
|
|
@@ -3118,13 +3829,13 @@ var Deployments = class {
|
|
|
3118
3829
|
`/deployments/${deploymentId}`,
|
|
3119
3830
|
body
|
|
3120
3831
|
);
|
|
3121
|
-
return
|
|
3832
|
+
return unwrap23(data);
|
|
3122
3833
|
}
|
|
3123
3834
|
async delete(deploymentId) {
|
|
3124
3835
|
await this.http.delete(`/deployments/${deploymentId}`);
|
|
3125
3836
|
}
|
|
3126
3837
|
async publish(deploymentId, params) {
|
|
3127
|
-
const body =
|
|
3838
|
+
const body = stripUndefined10({
|
|
3128
3839
|
source_sandbox_id: params.sourceSandboxId ?? params.source_sandbox_id,
|
|
3129
3840
|
output_path: params.outputPath ?? params.output_path,
|
|
3130
3841
|
entrypoint: params.entrypoint,
|
|
@@ -3138,7 +3849,7 @@ var Deployments = class {
|
|
|
3138
3849
|
headers: { "Idempotency-Key": idempotencyKey4(params.idempotencyKey) }
|
|
3139
3850
|
}
|
|
3140
3851
|
);
|
|
3141
|
-
return
|
|
3852
|
+
return unwrap23(data);
|
|
3142
3853
|
}
|
|
3143
3854
|
/**
|
|
3144
3855
|
* Backward-compatible bridge: POST /sandboxes/:id/deploy. Works today;
|
|
@@ -3146,7 +3857,7 @@ var Deployments = class {
|
|
|
3146
3857
|
* phase. Prefer `publish()` once Phase 2B/3 lands.
|
|
3147
3858
|
*/
|
|
3148
3859
|
async publishFromSandbox(sandboxId, params = {}) {
|
|
3149
|
-
const body =
|
|
3860
|
+
const body = stripUndefined10({
|
|
3150
3861
|
name: params.name,
|
|
3151
3862
|
deployment_id: params.deploymentId ?? params.deployment_id,
|
|
3152
3863
|
output_path: params.outputPath ?? params.output_path,
|
|
@@ -3163,10 +3874,10 @@ var Deployments = class {
|
|
|
3163
3874
|
headers: { "Idempotency-Key": idempotencyKey4(params.idempotencyKey) }
|
|
3164
3875
|
}
|
|
3165
3876
|
);
|
|
3166
|
-
return
|
|
3877
|
+
return unwrap23(data);
|
|
3167
3878
|
}
|
|
3168
3879
|
async rollback(deploymentId, params = {}) {
|
|
3169
|
-
const body =
|
|
3880
|
+
const body = stripUndefined10({
|
|
3170
3881
|
version_id: params.versionId ?? params.version_id
|
|
3171
3882
|
});
|
|
3172
3883
|
const data = await this.http.request(
|
|
@@ -3177,7 +3888,7 @@ var Deployments = class {
|
|
|
3177
3888
|
headers: { "Idempotency-Key": idempotencyKey4(params.idempotencyKey) }
|
|
3178
3889
|
}
|
|
3179
3890
|
);
|
|
3180
|
-
return
|
|
3891
|
+
return unwrap23(data);
|
|
3181
3892
|
}
|
|
3182
3893
|
async listBuilds(deploymentId) {
|
|
3183
3894
|
const data = await this.http.get(
|
|
@@ -3189,7 +3900,7 @@ var Deployments = class {
|
|
|
3189
3900
|
const data = await this.http.get(
|
|
3190
3901
|
`/deployments/${deploymentId}/builds/${buildId}`
|
|
3191
3902
|
);
|
|
3192
|
-
return
|
|
3903
|
+
return unwrap23(data);
|
|
3193
3904
|
}
|
|
3194
3905
|
async listEnv(deploymentId) {
|
|
3195
3906
|
const data = await this.http.get(
|
|
@@ -3198,7 +3909,7 @@ var Deployments = class {
|
|
|
3198
3909
|
return listItems4(data);
|
|
3199
3910
|
}
|
|
3200
3911
|
async setEnv(deploymentId, vars, opts = {}) {
|
|
3201
|
-
const body =
|
|
3912
|
+
const body = stripUndefined10({ env: vars, environment: opts.environment });
|
|
3202
3913
|
const data = await this.http.post(
|
|
3203
3914
|
`/deployments/${deploymentId}/env`,
|
|
3204
3915
|
body
|
|
@@ -3223,7 +3934,7 @@ var Deployments = class {
|
|
|
3223
3934
|
};
|
|
3224
3935
|
|
|
3225
3936
|
// src/resources/email.ts
|
|
3226
|
-
function
|
|
3937
|
+
function unwrap24(data) {
|
|
3227
3938
|
if (data && typeof data === "object") {
|
|
3228
3939
|
const d = data;
|
|
3229
3940
|
for (const k of [
|
|
@@ -3239,7 +3950,7 @@ function unwrap21(data) {
|
|
|
3239
3950
|
}
|
|
3240
3951
|
return data;
|
|
3241
3952
|
}
|
|
3242
|
-
function
|
|
3953
|
+
function unwrapList11(data) {
|
|
3243
3954
|
if (Array.isArray(data)) return data;
|
|
3244
3955
|
if (data && typeof data === "object") {
|
|
3245
3956
|
const d = data;
|
|
@@ -3267,7 +3978,7 @@ var EmailCampaigns = class {
|
|
|
3267
3978
|
}
|
|
3268
3979
|
http;
|
|
3269
3980
|
async list(filters = {}) {
|
|
3270
|
-
return
|
|
3981
|
+
return unwrapList11(
|
|
3271
3982
|
await this.http.get(
|
|
3272
3983
|
"/admin/email-campaigns",
|
|
3273
3984
|
filters
|
|
@@ -3275,12 +3986,12 @@ var EmailCampaigns = class {
|
|
|
3275
3986
|
);
|
|
3276
3987
|
}
|
|
3277
3988
|
async create(attrs) {
|
|
3278
|
-
return
|
|
3989
|
+
return unwrap24(
|
|
3279
3990
|
await this.http.post("/admin/email-campaigns", strip(attrs))
|
|
3280
3991
|
);
|
|
3281
3992
|
}
|
|
3282
3993
|
async recipientCount(filters = {}) {
|
|
3283
|
-
return
|
|
3994
|
+
return unwrap24(
|
|
3284
3995
|
await this.http.get(
|
|
3285
3996
|
"/admin/email-campaigns/recipient-count",
|
|
3286
3997
|
filters
|
|
@@ -3288,7 +3999,7 @@ var EmailCampaigns = class {
|
|
|
3288
3999
|
);
|
|
3289
4000
|
}
|
|
3290
4001
|
async send(campaignId, opts = {}) {
|
|
3291
|
-
return
|
|
4002
|
+
return unwrap24(
|
|
3292
4003
|
await this.http.post(
|
|
3293
4004
|
`/admin/email-campaigns/${campaignId}/send`,
|
|
3294
4005
|
strip(opts)
|
|
@@ -3296,14 +4007,14 @@ var EmailCampaigns = class {
|
|
|
3296
4007
|
);
|
|
3297
4008
|
}
|
|
3298
4009
|
async cancel(campaignId) {
|
|
3299
|
-
return
|
|
4010
|
+
return unwrap24(
|
|
3300
4011
|
await this.http.post(
|
|
3301
4012
|
`/admin/email-campaigns/${campaignId}/cancel`
|
|
3302
4013
|
)
|
|
3303
4014
|
);
|
|
3304
4015
|
}
|
|
3305
4016
|
async deliveries(campaignId, filters = {}) {
|
|
3306
|
-
return
|
|
4017
|
+
return unwrapList11(
|
|
3307
4018
|
await this.http.get(
|
|
3308
4019
|
`/admin/email-campaigns/${campaignId}/deliveries`,
|
|
3309
4020
|
filters
|
|
@@ -3317,12 +4028,12 @@ var EmailTemplates = class {
|
|
|
3317
4028
|
}
|
|
3318
4029
|
http;
|
|
3319
4030
|
async list(filters = {}) {
|
|
3320
|
-
return
|
|
4031
|
+
return unwrapList11(
|
|
3321
4032
|
await this.http.get("/admin/email-templates", filters)
|
|
3322
4033
|
);
|
|
3323
4034
|
}
|
|
3324
4035
|
async create(key, attrs = {}) {
|
|
3325
|
-
return
|
|
4036
|
+
return unwrap24(
|
|
3326
4037
|
await this.http.post("/admin/email-templates", {
|
|
3327
4038
|
key,
|
|
3328
4039
|
...strip(attrs)
|
|
@@ -3330,7 +4041,7 @@ var EmailTemplates = class {
|
|
|
3330
4041
|
);
|
|
3331
4042
|
}
|
|
3332
4043
|
async update(key, attrs) {
|
|
3333
|
-
return
|
|
4044
|
+
return unwrap24(
|
|
3334
4045
|
await this.http.put(
|
|
3335
4046
|
`/admin/email-templates/${key}`,
|
|
3336
4047
|
strip(attrs)
|
|
@@ -3338,7 +4049,7 @@ var EmailTemplates = class {
|
|
|
3338
4049
|
);
|
|
3339
4050
|
}
|
|
3340
4051
|
async reset(key) {
|
|
3341
|
-
return
|
|
4052
|
+
return unwrap24(
|
|
3342
4053
|
await this.http.post(`/admin/email-templates/${key}/reset`)
|
|
3343
4054
|
);
|
|
3344
4055
|
}
|
|
@@ -3349,22 +4060,22 @@ var EmailInbox = class {
|
|
|
3349
4060
|
}
|
|
3350
4061
|
http;
|
|
3351
4062
|
async list(filters = {}) {
|
|
3352
|
-
return
|
|
4063
|
+
return unwrapList11(
|
|
3353
4064
|
await this.http.get("/admin/email-inbox", filters)
|
|
3354
4065
|
);
|
|
3355
4066
|
}
|
|
3356
4067
|
async send(attrs) {
|
|
3357
|
-
return
|
|
4068
|
+
return unwrap24(
|
|
3358
4069
|
await this.http.post("/admin/email-inbox/send", strip(attrs))
|
|
3359
4070
|
);
|
|
3360
4071
|
}
|
|
3361
4072
|
async markRead(messageId) {
|
|
3362
|
-
return
|
|
4073
|
+
return unwrap24(
|
|
3363
4074
|
await this.http.post(`/admin/email-inbox/${messageId}/read`)
|
|
3364
4075
|
);
|
|
3365
4076
|
}
|
|
3366
4077
|
async archive(messageId) {
|
|
3367
|
-
return
|
|
4078
|
+
return unwrap24(
|
|
3368
4079
|
await this.http.post(`/admin/email-inbox/${messageId}/archive`)
|
|
3369
4080
|
);
|
|
3370
4081
|
}
|
|
@@ -3404,7 +4115,7 @@ var Embeddings = class {
|
|
|
3404
4115
|
};
|
|
3405
4116
|
|
|
3406
4117
|
// src/resources/external-keys.ts
|
|
3407
|
-
function
|
|
4118
|
+
function unwrap25(payload) {
|
|
3408
4119
|
if (payload && typeof payload === "object") {
|
|
3409
4120
|
const p = payload;
|
|
3410
4121
|
for (const k of ["data", "external_keys", "items"]) {
|
|
@@ -3413,7 +4124,7 @@ function unwrap22(payload) {
|
|
|
3413
4124
|
}
|
|
3414
4125
|
return payload;
|
|
3415
4126
|
}
|
|
3416
|
-
function
|
|
4127
|
+
function stripUndefined11(input) {
|
|
3417
4128
|
return Object.fromEntries(
|
|
3418
4129
|
Object.entries(input).filter(([, v]) => v !== void 0)
|
|
3419
4130
|
);
|
|
@@ -3426,22 +4137,22 @@ var ExternalKeys = class {
|
|
|
3426
4137
|
/** List configured external keys. */
|
|
3427
4138
|
async list() {
|
|
3428
4139
|
const data = await this.http.get("/external-keys");
|
|
3429
|
-
const result =
|
|
4140
|
+
const result = unwrap25(data);
|
|
3430
4141
|
if (Array.isArray(result)) return result;
|
|
3431
4142
|
return [];
|
|
3432
4143
|
}
|
|
3433
4144
|
/** Create / register an external provider key. */
|
|
3434
4145
|
async create(params) {
|
|
3435
|
-
const body =
|
|
4146
|
+
const body = stripUndefined11(params);
|
|
3436
4147
|
const data = await this.http.post("/external-keys", body);
|
|
3437
|
-
return
|
|
4148
|
+
return unwrap25(data);
|
|
3438
4149
|
}
|
|
3439
4150
|
/** Resolve (preview) the stored key for a provider. */
|
|
3440
4151
|
async resolve(provider) {
|
|
3441
4152
|
const data = await this.http.get(
|
|
3442
4153
|
`/external-keys/${provider}/resolve`
|
|
3443
4154
|
);
|
|
3444
|
-
return
|
|
4155
|
+
return unwrap25(data);
|
|
3445
4156
|
}
|
|
3446
4157
|
/**
|
|
3447
4158
|
* Delete the stored key for a provider.
|
|
@@ -3451,7 +4162,7 @@ var ExternalKeys = class {
|
|
|
3451
4162
|
await this.http.delete(`/external-keys/${provider}`);
|
|
3452
4163
|
}
|
|
3453
4164
|
};
|
|
3454
|
-
function
|
|
4165
|
+
function unwrap26(payload) {
|
|
3455
4166
|
if (payload && typeof payload === "object" && "data" in payload) {
|
|
3456
4167
|
return payload.data;
|
|
3457
4168
|
}
|
|
@@ -3467,7 +4178,7 @@ function listItems5(payload, candidateKeys = ["data", "domains", "items"]) {
|
|
|
3467
4178
|
}
|
|
3468
4179
|
return [];
|
|
3469
4180
|
}
|
|
3470
|
-
function
|
|
4181
|
+
function stripUndefined12(input) {
|
|
3471
4182
|
return Object.fromEntries(
|
|
3472
4183
|
Object.entries(input).filter(([, v]) => v !== void 0)
|
|
3473
4184
|
);
|
|
@@ -3481,7 +4192,7 @@ var FlatCustomDomains = class {
|
|
|
3481
4192
|
}
|
|
3482
4193
|
http;
|
|
3483
4194
|
async list(params = {}) {
|
|
3484
|
-
const query =
|
|
4195
|
+
const query = stripUndefined12({ ...params });
|
|
3485
4196
|
const data = await this.http.get("/custom-domains", query);
|
|
3486
4197
|
return listItems5(data);
|
|
3487
4198
|
}
|
|
@@ -3493,7 +4204,7 @@ var FlatCustomDomains = class {
|
|
|
3493
4204
|
redirectPolicy,
|
|
3494
4205
|
...rest
|
|
3495
4206
|
} = params;
|
|
3496
|
-
const body =
|
|
4207
|
+
const body = stripUndefined12({
|
|
3497
4208
|
...rest,
|
|
3498
4209
|
resource_type: resourceType ?? rest.resource_type,
|
|
3499
4210
|
resource_id: resourceId ?? rest.resource_id,
|
|
@@ -3504,13 +4215,13 @@ var FlatCustomDomains = class {
|
|
|
3504
4215
|
body,
|
|
3505
4216
|
headers: { "Idempotency-Key": idempotencyKey5(ikey) }
|
|
3506
4217
|
});
|
|
3507
|
-
return
|
|
4218
|
+
return unwrap26(data);
|
|
3508
4219
|
}
|
|
3509
4220
|
async delete(domainId) {
|
|
3510
4221
|
await this.http.delete(`/custom-domains/${domainId}`);
|
|
3511
4222
|
}
|
|
3512
4223
|
};
|
|
3513
|
-
function
|
|
4224
|
+
function unwrap27(payload) {
|
|
3514
4225
|
if (payload && typeof payload === "object" && "data" in payload) {
|
|
3515
4226
|
return payload.data;
|
|
3516
4227
|
}
|
|
@@ -3526,7 +4237,7 @@ function listItems6(payload, candidateKeys = ["data", "functions", "items"]) {
|
|
|
3526
4237
|
}
|
|
3527
4238
|
return [];
|
|
3528
4239
|
}
|
|
3529
|
-
function
|
|
4240
|
+
function stripUndefined13(input) {
|
|
3530
4241
|
return Object.fromEntries(
|
|
3531
4242
|
Object.entries(input).filter(([, v]) => v !== void 0)
|
|
3532
4243
|
);
|
|
@@ -3540,17 +4251,17 @@ var Functions = class {
|
|
|
3540
4251
|
}
|
|
3541
4252
|
http;
|
|
3542
4253
|
async list(params = {}) {
|
|
3543
|
-
const query =
|
|
4254
|
+
const query = stripUndefined13({ ...params });
|
|
3544
4255
|
const data = await this.http.get("/functions", query);
|
|
3545
4256
|
return listItems6(data);
|
|
3546
4257
|
}
|
|
3547
4258
|
async get(functionId) {
|
|
3548
4259
|
const data = await this.http.get(`/functions/${functionId}`);
|
|
3549
|
-
return
|
|
4260
|
+
return unwrap27(data);
|
|
3550
4261
|
}
|
|
3551
4262
|
async create(params) {
|
|
3552
4263
|
const { idempotencyKey: ikey, memoryMb, timeoutSec, ...rest } = params;
|
|
3553
|
-
const body =
|
|
4264
|
+
const body = stripUndefined13({
|
|
3554
4265
|
...rest,
|
|
3555
4266
|
memory_mb: memoryMb ?? rest.memory_mb,
|
|
3556
4267
|
timeout_sec: timeoutSec ?? rest.timeout_sec
|
|
@@ -3560,11 +4271,11 @@ var Functions = class {
|
|
|
3560
4271
|
body,
|
|
3561
4272
|
headers: { "Idempotency-Key": idempotencyKey6(ikey) }
|
|
3562
4273
|
});
|
|
3563
|
-
return
|
|
4274
|
+
return unwrap27(data);
|
|
3564
4275
|
}
|
|
3565
4276
|
async update(functionId, params) {
|
|
3566
4277
|
const { memoryMb, timeoutSec, ...rest } = params;
|
|
3567
|
-
const body =
|
|
4278
|
+
const body = stripUndefined13({
|
|
3568
4279
|
...rest,
|
|
3569
4280
|
memory_mb: memoryMb ?? rest.memory_mb,
|
|
3570
4281
|
timeout_sec: timeoutSec ?? rest.timeout_sec
|
|
@@ -3573,7 +4284,7 @@ var Functions = class {
|
|
|
3573
4284
|
`/functions/${functionId}`,
|
|
3574
4285
|
body
|
|
3575
4286
|
);
|
|
3576
|
-
return
|
|
4287
|
+
return unwrap27(data);
|
|
3577
4288
|
}
|
|
3578
4289
|
async delete(functionId) {
|
|
3579
4290
|
await this.http.delete(`/functions/${functionId}`);
|
|
@@ -3594,7 +4305,7 @@ var Functions = class {
|
|
|
3594
4305
|
return data ?? {};
|
|
3595
4306
|
}
|
|
3596
4307
|
};
|
|
3597
|
-
function
|
|
4308
|
+
function unwrap28(payload) {
|
|
3598
4309
|
if (payload && typeof payload === "object" && "data" in payload) {
|
|
3599
4310
|
return payload.data;
|
|
3600
4311
|
}
|
|
@@ -3610,7 +4321,7 @@ function listItems7(payload, candidateKeys = ["data", "health_checks", "items"])
|
|
|
3610
4321
|
}
|
|
3611
4322
|
return [];
|
|
3612
4323
|
}
|
|
3613
|
-
function
|
|
4324
|
+
function stripUndefined14(input) {
|
|
3614
4325
|
return Object.fromEntries(
|
|
3615
4326
|
Object.entries(input).filter(([, v]) => v !== void 0)
|
|
3616
4327
|
);
|
|
@@ -3624,13 +4335,13 @@ var HealthChecks = class {
|
|
|
3624
4335
|
}
|
|
3625
4336
|
http;
|
|
3626
4337
|
async list(params = {}) {
|
|
3627
|
-
const query =
|
|
4338
|
+
const query = stripUndefined14({ ...params });
|
|
3628
4339
|
const data = await this.http.get("/health-checks", query);
|
|
3629
4340
|
return listItems7(data);
|
|
3630
4341
|
}
|
|
3631
4342
|
async get(checkId) {
|
|
3632
4343
|
const data = await this.http.get(`/health-checks/${checkId}`);
|
|
3633
|
-
return
|
|
4344
|
+
return unwrap28(data);
|
|
3634
4345
|
}
|
|
3635
4346
|
async create(params) {
|
|
3636
4347
|
const {
|
|
@@ -3640,7 +4351,7 @@ var HealthChecks = class {
|
|
|
3640
4351
|
expectedStatus,
|
|
3641
4352
|
...rest
|
|
3642
4353
|
} = params;
|
|
3643
|
-
const body =
|
|
4354
|
+
const body = stripUndefined14({
|
|
3644
4355
|
...rest,
|
|
3645
4356
|
interval_sec: intervalSec ?? rest.interval_sec,
|
|
3646
4357
|
timeout_sec: timeoutSec ?? rest.timeout_sec,
|
|
@@ -3651,11 +4362,11 @@ var HealthChecks = class {
|
|
|
3651
4362
|
body,
|
|
3652
4363
|
headers: { "Idempotency-Key": idempotencyKey7(ikey) }
|
|
3653
4364
|
});
|
|
3654
|
-
return
|
|
4365
|
+
return unwrap28(data);
|
|
3655
4366
|
}
|
|
3656
4367
|
async update(checkId, params) {
|
|
3657
4368
|
const { intervalSec, timeoutSec, expectedStatus, ...rest } = params;
|
|
3658
|
-
const body =
|
|
4369
|
+
const body = stripUndefined14({
|
|
3659
4370
|
...rest,
|
|
3660
4371
|
interval_sec: intervalSec ?? rest.interval_sec,
|
|
3661
4372
|
timeout_sec: timeoutSec ?? rest.timeout_sec,
|
|
@@ -3665,7 +4376,7 @@ var HealthChecks = class {
|
|
|
3665
4376
|
`/health-checks/${checkId}`,
|
|
3666
4377
|
body
|
|
3667
4378
|
);
|
|
3668
|
-
return
|
|
4379
|
+
return unwrap28(data);
|
|
3669
4380
|
}
|
|
3670
4381
|
async delete(checkId) {
|
|
3671
4382
|
await this.http.delete(`/health-checks/${checkId}`);
|
|
@@ -3673,7 +4384,7 @@ var HealthChecks = class {
|
|
|
3673
4384
|
};
|
|
3674
4385
|
|
|
3675
4386
|
// src/resources/integrations.ts
|
|
3676
|
-
function
|
|
4387
|
+
function unwrap29(payload) {
|
|
3677
4388
|
if (payload && typeof payload === "object") {
|
|
3678
4389
|
const p = payload;
|
|
3679
4390
|
for (const k of ["data", "integrations", "catalog", "items"]) {
|
|
@@ -3683,11 +4394,11 @@ function unwrap26(payload) {
|
|
|
3683
4394
|
return payload;
|
|
3684
4395
|
}
|
|
3685
4396
|
function listItems8(payload) {
|
|
3686
|
-
const result =
|
|
4397
|
+
const result = unwrap29(payload);
|
|
3687
4398
|
if (Array.isArray(result)) return result;
|
|
3688
4399
|
return [];
|
|
3689
4400
|
}
|
|
3690
|
-
function
|
|
4401
|
+
function stripUndefined15(input) {
|
|
3691
4402
|
return Object.fromEntries(
|
|
3692
4403
|
Object.entries(input).filter(([, v]) => v !== void 0)
|
|
3693
4404
|
);
|
|
@@ -3712,14 +4423,14 @@ var Integrations = class {
|
|
|
3712
4423
|
const data = await this.http.get(
|
|
3713
4424
|
`/integrations/${provider}/start`
|
|
3714
4425
|
);
|
|
3715
|
-
return
|
|
4426
|
+
return unwrap29(data);
|
|
3716
4427
|
}
|
|
3717
4428
|
/** Force-refresh the access token for a provider. */
|
|
3718
4429
|
async refresh(provider) {
|
|
3719
4430
|
const data = await this.http.post(
|
|
3720
4431
|
`/integrations/${provider}/refresh`
|
|
3721
4432
|
);
|
|
3722
|
-
return
|
|
4433
|
+
return unwrap29(data);
|
|
3723
4434
|
}
|
|
3724
4435
|
/** Disconnect (revoke) an integration. */
|
|
3725
4436
|
async disconnect(provider) {
|
|
@@ -3739,41 +4450,41 @@ var Integrations = class {
|
|
|
3739
4450
|
// ── Test hooks ─────────────────────────────────────────────────────────────
|
|
3740
4451
|
/** Send a test message to the connected Slack channel. */
|
|
3741
4452
|
async slackSendTest(params = {}) {
|
|
3742
|
-
const body =
|
|
4453
|
+
const body = stripUndefined15(params);
|
|
3743
4454
|
const data = await this.http.post(
|
|
3744
4455
|
"/integrations/slack/send-test",
|
|
3745
4456
|
body
|
|
3746
4457
|
);
|
|
3747
|
-
return
|
|
4458
|
+
return unwrap29(data);
|
|
3748
4459
|
}
|
|
3749
4460
|
/** Send a test message to the connected Discord channel. */
|
|
3750
4461
|
async discordSendTest(params = {}) {
|
|
3751
|
-
const body =
|
|
4462
|
+
const body = stripUndefined15(params);
|
|
3752
4463
|
const data = await this.http.post(
|
|
3753
4464
|
"/integrations/discord/send-test",
|
|
3754
4465
|
body
|
|
3755
4466
|
);
|
|
3756
|
-
return
|
|
4467
|
+
return unwrap29(data);
|
|
3757
4468
|
}
|
|
3758
4469
|
// ── Linear dedicated controller ────────────────────────────────────────────
|
|
3759
4470
|
/** Begin Linear OAuth — Linear has provider-specific error shapes. */
|
|
3760
4471
|
async linearStart() {
|
|
3761
4472
|
const data = await this.http.get("/integrations/linear/start");
|
|
3762
|
-
return
|
|
4473
|
+
return unwrap29(data);
|
|
3763
4474
|
}
|
|
3764
4475
|
/** Create a Linear issue via the connected workspace. */
|
|
3765
4476
|
async linearCreateIssue(params = {}) {
|
|
3766
|
-
const body =
|
|
4477
|
+
const body = stripUndefined15(params);
|
|
3767
4478
|
const data = await this.http.post(
|
|
3768
4479
|
"/integrations/linear/create-issue",
|
|
3769
4480
|
body
|
|
3770
4481
|
);
|
|
3771
|
-
return
|
|
4482
|
+
return unwrap29(data);
|
|
3772
4483
|
}
|
|
3773
4484
|
};
|
|
3774
4485
|
|
|
3775
4486
|
// src/resources/mcp.ts
|
|
3776
|
-
function
|
|
4487
|
+
function unwrap30(payload) {
|
|
3777
4488
|
if (payload && typeof payload === "object") {
|
|
3778
4489
|
const p = payload;
|
|
3779
4490
|
for (const k of ["data", "mcp", "result", "items"]) {
|
|
@@ -3782,7 +4493,7 @@ function unwrap27(payload) {
|
|
|
3782
4493
|
}
|
|
3783
4494
|
return payload;
|
|
3784
4495
|
}
|
|
3785
|
-
function
|
|
4496
|
+
function stripUndefined16(input) {
|
|
3786
4497
|
return Object.fromEntries(
|
|
3787
4498
|
Object.entries(input).filter(([, v]) => v !== void 0)
|
|
3788
4499
|
);
|
|
@@ -3794,12 +4505,12 @@ var Mcp = class {
|
|
|
3794
4505
|
http;
|
|
3795
4506
|
/** Send a JSON-RPC request to the MCP endpoint. */
|
|
3796
4507
|
async dispatch(params = {}) {
|
|
3797
|
-
const body =
|
|
4508
|
+
const body = stripUndefined16(params);
|
|
3798
4509
|
const data = await this.http.post(
|
|
3799
4510
|
"/mcp",
|
|
3800
4511
|
Object.keys(body).length > 0 ? body : void 0
|
|
3801
4512
|
);
|
|
3802
|
-
return
|
|
4513
|
+
return unwrap30(data);
|
|
3803
4514
|
}
|
|
3804
4515
|
/**
|
|
3805
4516
|
* Open the MCP listen channel (GET).
|
|
@@ -3809,7 +4520,7 @@ var Mcp = class {
|
|
|
3809
4520
|
*/
|
|
3810
4521
|
async listen() {
|
|
3811
4522
|
const data = await this.http.get("/mcp");
|
|
3812
|
-
return
|
|
4523
|
+
return unwrap30(data);
|
|
3813
4524
|
}
|
|
3814
4525
|
/** Close (terminate) the MCP session. */
|
|
3815
4526
|
async close() {
|
|
@@ -3818,7 +4529,7 @@ var Mcp = class {
|
|
|
3818
4529
|
};
|
|
3819
4530
|
|
|
3820
4531
|
// src/resources/models.ts
|
|
3821
|
-
function
|
|
4532
|
+
function unwrap31(data) {
|
|
3822
4533
|
if (Array.isArray(data)) return data;
|
|
3823
4534
|
if (data && typeof data === "object") {
|
|
3824
4535
|
const d = data;
|
|
@@ -3839,7 +4550,7 @@ var Models = class {
|
|
|
3839
4550
|
Object.entries(filters).filter(([, v]) => v !== void 0)
|
|
3840
4551
|
);
|
|
3841
4552
|
const data = await this.http.get("/intelligence/models", query);
|
|
3842
|
-
return
|
|
4553
|
+
return unwrap31(data);
|
|
3843
4554
|
}
|
|
3844
4555
|
/**
|
|
3845
4556
|
* Get a single model by id.
|
|
@@ -4469,7 +5180,7 @@ function resourcePayload(params) {
|
|
|
4469
5180
|
return { resource_type, resource_id };
|
|
4470
5181
|
}
|
|
4471
5182
|
function authConfig(params) {
|
|
4472
|
-
return
|
|
5183
|
+
return stripUndefined17({
|
|
4473
5184
|
...params.config ?? {},
|
|
4474
5185
|
signup_enabled: params.signup_enabled ?? params.signupEnabled,
|
|
4475
5186
|
email_confirm_required: params.email_confirm_required ?? params.emailConfirmRequired,
|
|
@@ -4477,12 +5188,12 @@ function authConfig(params) {
|
|
|
4477
5188
|
});
|
|
4478
5189
|
}
|
|
4479
5190
|
function requestBody(params) {
|
|
4480
|
-
return
|
|
5191
|
+
return stripUndefined17({
|
|
4481
5192
|
...resourcePayload(params),
|
|
4482
5193
|
config: authConfig(params)
|
|
4483
5194
|
});
|
|
4484
5195
|
}
|
|
4485
|
-
function
|
|
5196
|
+
function unwrap32(payload) {
|
|
4486
5197
|
if (payload && typeof payload === "object") {
|
|
4487
5198
|
const p = payload;
|
|
4488
5199
|
for (const k of ["data", "project_auth", "config", "items"]) {
|
|
@@ -4491,7 +5202,7 @@ function unwrap29(payload) {
|
|
|
4491
5202
|
}
|
|
4492
5203
|
return payload;
|
|
4493
5204
|
}
|
|
4494
|
-
function
|
|
5205
|
+
function stripUndefined17(input) {
|
|
4495
5206
|
return Object.fromEntries(
|
|
4496
5207
|
Object.entries(input).filter(([, v]) => v !== void 0)
|
|
4497
5208
|
);
|
|
@@ -4507,13 +5218,13 @@ var ProjectAuth = class {
|
|
|
4507
5218
|
"/project-auth/status",
|
|
4508
5219
|
resourcePayload(params)
|
|
4509
5220
|
);
|
|
4510
|
-
return
|
|
5221
|
+
return unwrap32(data);
|
|
4511
5222
|
}
|
|
4512
5223
|
/** Enable project auth. */
|
|
4513
5224
|
async enable(params) {
|
|
4514
5225
|
const body = requestBody(params);
|
|
4515
5226
|
const data = await this.http.post("/project-auth/enable", body);
|
|
4516
|
-
return
|
|
5227
|
+
return unwrap32(data);
|
|
4517
5228
|
}
|
|
4518
5229
|
/** Disable project auth. */
|
|
4519
5230
|
async disable(params) {
|
|
@@ -4521,18 +5232,18 @@ var ProjectAuth = class {
|
|
|
4521
5232
|
"/project-auth/disable",
|
|
4522
5233
|
resourcePayload(params)
|
|
4523
5234
|
);
|
|
4524
|
-
return
|
|
5235
|
+
return unwrap32(data);
|
|
4525
5236
|
}
|
|
4526
5237
|
/** Update project-auth configuration. */
|
|
4527
5238
|
async update(params) {
|
|
4528
5239
|
const body = requestBody(params);
|
|
4529
5240
|
const data = await this.http.patch("/project-auth/config", body);
|
|
4530
|
-
return
|
|
5241
|
+
return unwrap32(data);
|
|
4531
5242
|
}
|
|
4532
5243
|
};
|
|
4533
5244
|
|
|
4534
5245
|
// src/resources/project-integrations.ts
|
|
4535
|
-
function
|
|
5246
|
+
function unwrap33(payload) {
|
|
4536
5247
|
if (payload && typeof payload === "object") {
|
|
4537
5248
|
const p = payload;
|
|
4538
5249
|
for (const k of ["data", "project_integrations", "catalog", "items"]) {
|
|
@@ -4542,11 +5253,11 @@ function unwrap30(payload) {
|
|
|
4542
5253
|
return payload;
|
|
4543
5254
|
}
|
|
4544
5255
|
function listItems9(payload) {
|
|
4545
|
-
const result =
|
|
5256
|
+
const result = unwrap33(payload);
|
|
4546
5257
|
if (Array.isArray(result)) return result;
|
|
4547
5258
|
return [];
|
|
4548
5259
|
}
|
|
4549
|
-
function
|
|
5260
|
+
function stripUndefined18(input) {
|
|
4550
5261
|
return Object.fromEntries(
|
|
4551
5262
|
Object.entries(input).filter(([, v]) => v !== void 0)
|
|
4552
5263
|
);
|
|
@@ -4563,7 +5274,7 @@ var ProjectIntegrations = class {
|
|
|
4563
5274
|
http;
|
|
4564
5275
|
/** List project integrations. */
|
|
4565
5276
|
async list(params = {}) {
|
|
4566
|
-
const query =
|
|
5277
|
+
const query = stripUndefined18(params);
|
|
4567
5278
|
const data = await this.http.get("/project-integrations", query);
|
|
4568
5279
|
return listItems9(data);
|
|
4569
5280
|
}
|
|
@@ -4577,13 +5288,13 @@ var ProjectIntegrations = class {
|
|
|
4577
5288
|
const data = await this.http.get(
|
|
4578
5289
|
`/project-integrations/${integrationId}`
|
|
4579
5290
|
);
|
|
4580
|
-
return
|
|
5291
|
+
return unwrap33(data);
|
|
4581
5292
|
}
|
|
4582
5293
|
/** Create a project integration. */
|
|
4583
5294
|
async create(params) {
|
|
4584
5295
|
const body = stripUndefObj2(params);
|
|
4585
5296
|
const data = await this.http.post("/project-integrations", body);
|
|
4586
|
-
return
|
|
5297
|
+
return unwrap33(data);
|
|
4587
5298
|
}
|
|
4588
5299
|
/** Update a project integration. */
|
|
4589
5300
|
async update(integrationId, params) {
|
|
@@ -4592,7 +5303,7 @@ var ProjectIntegrations = class {
|
|
|
4592
5303
|
`/project-integrations/${integrationId}`,
|
|
4593
5304
|
body
|
|
4594
5305
|
);
|
|
4595
|
-
return
|
|
5306
|
+
return unwrap33(data);
|
|
4596
5307
|
}
|
|
4597
5308
|
/** Delete a project integration. */
|
|
4598
5309
|
async delete(integrationId) {
|
|
@@ -4601,7 +5312,7 @@ var ProjectIntegrations = class {
|
|
|
4601
5312
|
};
|
|
4602
5313
|
|
|
4603
5314
|
// src/resources/provider-defaults.ts
|
|
4604
|
-
function
|
|
5315
|
+
function unwrap34(data) {
|
|
4605
5316
|
if (data && typeof data === "object") {
|
|
4606
5317
|
const d = data;
|
|
4607
5318
|
for (const k of ["data", "defaults", "provider_defaults", "config"]) {
|
|
@@ -4617,7 +5328,7 @@ var ProviderDefaults = class {
|
|
|
4617
5328
|
http;
|
|
4618
5329
|
/** Get the current fleet-wide provider defaults. */
|
|
4619
5330
|
async list() {
|
|
4620
|
-
return
|
|
5331
|
+
return unwrap34(await this.http.get("/admin/provider-defaults"));
|
|
4621
5332
|
}
|
|
4622
5333
|
/** Return the defaults entry for a single provider, or {} if missing. */
|
|
4623
5334
|
async get(provider) {
|
|
@@ -4633,13 +5344,13 @@ var ProviderDefaults = class {
|
|
|
4633
5344
|
const body = Object.fromEntries(
|
|
4634
5345
|
Object.entries(opts).filter(([, v]) => v !== void 0)
|
|
4635
5346
|
);
|
|
4636
|
-
return
|
|
5347
|
+
return unwrap34(
|
|
4637
5348
|
await this.http.put("/admin/provider-defaults", body)
|
|
4638
5349
|
);
|
|
4639
5350
|
}
|
|
4640
5351
|
// ── Per-tenant overrides ────────────────────────────────────────────────
|
|
4641
5352
|
async getTenant(tenantId) {
|
|
4642
|
-
return
|
|
5353
|
+
return unwrap34(
|
|
4643
5354
|
await this.http.get(
|
|
4644
5355
|
`/admin/tenants/${tenantId}/provider-config`
|
|
4645
5356
|
)
|
|
@@ -4649,7 +5360,7 @@ var ProviderDefaults = class {
|
|
|
4649
5360
|
const body = Object.fromEntries(
|
|
4650
5361
|
Object.entries(opts).filter(([, v]) => v !== void 0)
|
|
4651
5362
|
);
|
|
4652
|
-
return
|
|
5363
|
+
return unwrap34(
|
|
4653
5364
|
await this.http.put(
|
|
4654
5365
|
`/admin/tenants/${tenantId}/provider-config`,
|
|
4655
5366
|
body
|
|
@@ -4662,7 +5373,7 @@ var ProviderDefaults = class {
|
|
|
4662
5373
|
};
|
|
4663
5374
|
|
|
4664
5375
|
// src/resources/regions.ts
|
|
4665
|
-
function
|
|
5376
|
+
function unwrap35(payload) {
|
|
4666
5377
|
if (payload && typeof payload === "object") {
|
|
4667
5378
|
const p = payload;
|
|
4668
5379
|
for (const k of [
|
|
@@ -4679,7 +5390,7 @@ function unwrap32(payload) {
|
|
|
4679
5390
|
return payload;
|
|
4680
5391
|
}
|
|
4681
5392
|
function listItems10(payload) {
|
|
4682
|
-
const result =
|
|
5393
|
+
const result = unwrap35(payload);
|
|
4683
5394
|
if (Array.isArray(result)) return result;
|
|
4684
5395
|
return [];
|
|
4685
5396
|
}
|
|
@@ -4701,7 +5412,7 @@ var Regions = class {
|
|
|
4701
5412
|
/** Get static compute pricing data. */
|
|
4702
5413
|
async pricing() {
|
|
4703
5414
|
const data = await this.http.get("/compute/pricing");
|
|
4704
|
-
return
|
|
5415
|
+
return unwrap35(data);
|
|
4705
5416
|
}
|
|
4706
5417
|
/** List community computer templates. */
|
|
4707
5418
|
async listTemplates() {
|
|
@@ -4713,13 +5424,21 @@ var Regions = class {
|
|
|
4713
5424
|
const data = await this.http.get(
|
|
4714
5425
|
`/compute/templates/${templateId}`
|
|
4715
5426
|
);
|
|
4716
|
-
return
|
|
5427
|
+
return unwrap35(data);
|
|
4717
5428
|
}
|
|
4718
5429
|
};
|
|
4719
5430
|
|
|
4720
5431
|
// src/resources/sandboxes.ts
|
|
5432
|
+
function encodeContent(content) {
|
|
5433
|
+
const bytes = typeof content === "string" ? new TextEncoder().encode(content) : content;
|
|
5434
|
+
const maybeBuffer = globalThis.Buffer;
|
|
5435
|
+
if (maybeBuffer) return maybeBuffer.from(bytes).toString("base64");
|
|
5436
|
+
let bin = "";
|
|
5437
|
+
for (let i = 0; i < bytes.length; i++) bin += String.fromCharCode(bytes[i]);
|
|
5438
|
+
return btoa(bin);
|
|
5439
|
+
}
|
|
4721
5440
|
var SANDBOX_TEMPLATE = "miosa-sandbox";
|
|
4722
|
-
function
|
|
5441
|
+
function unwrap36(payload) {
|
|
4723
5442
|
if (payload !== null && typeof payload === "object" && "data" in payload && payload.data !== void 0) {
|
|
4724
5443
|
return payload.data;
|
|
4725
5444
|
}
|
|
@@ -4735,7 +5454,7 @@ function listItems11(payload) {
|
|
|
4735
5454
|
}
|
|
4736
5455
|
function createBody(params = {}) {
|
|
4737
5456
|
const templateId = params.templateId ?? params.template_id ?? params.image ?? SANDBOX_TEMPLATE;
|
|
4738
|
-
return
|
|
5457
|
+
return stripUndefined19({
|
|
4739
5458
|
template_id: templateId,
|
|
4740
5459
|
cpu_count: params.cpuCount ?? params.cpu_count,
|
|
4741
5460
|
memory_mb: params.memoryMb ?? params.memory_mb,
|
|
@@ -4756,20 +5475,21 @@ function createBody(params = {}) {
|
|
|
4756
5475
|
region: params.region,
|
|
4757
5476
|
entrypoint: params.entrypoint,
|
|
4758
5477
|
tags: params.tags,
|
|
5478
|
+
slug: params.slug,
|
|
4759
5479
|
external_workspace_id: params.externalWorkspaceId ?? params.external_workspace_id,
|
|
4760
5480
|
external_user_id: params.externalUserId ?? params.external_user_id,
|
|
4761
5481
|
external_project_id: params.externalProjectId ?? params.external_project_id
|
|
4762
5482
|
});
|
|
4763
5483
|
}
|
|
4764
5484
|
function execBody(command, options = {}) {
|
|
4765
|
-
return
|
|
5485
|
+
return stripUndefined19({
|
|
4766
5486
|
command,
|
|
4767
5487
|
cwd: options.cwd ?? options.workingDir ?? options.working_dir,
|
|
4768
5488
|
env: options.env,
|
|
4769
5489
|
timeout: options.timeout ?? options.timeoutSec ?? options.timeout_sec
|
|
4770
5490
|
});
|
|
4771
5491
|
}
|
|
4772
|
-
function
|
|
5492
|
+
function stripUndefined19(input) {
|
|
4773
5493
|
return Object.fromEntries(
|
|
4774
5494
|
Object.entries(input).filter(([, value]) => value !== void 0)
|
|
4775
5495
|
);
|
|
@@ -4812,6 +5532,41 @@ var SandboxFiles = class {
|
|
|
4812
5532
|
download(path) {
|
|
4813
5533
|
return this.read(path);
|
|
4814
5534
|
}
|
|
5535
|
+
/** GET /api/v1/sandboxes/{id}/files/tree — recursive directory tree. */
|
|
5536
|
+
async tree(path = "/workspace", depth = 3) {
|
|
5537
|
+
const http = this.sandbox.http;
|
|
5538
|
+
const response = await http.get(
|
|
5539
|
+
`/sandboxes/${this.sandbox.id}/files/tree`,
|
|
5540
|
+
{ path, depth }
|
|
5541
|
+
);
|
|
5542
|
+
if (response && typeof response === "object" && "data" in response) {
|
|
5543
|
+
return response.data;
|
|
5544
|
+
}
|
|
5545
|
+
return response;
|
|
5546
|
+
}
|
|
5547
|
+
/** POST /api/v1/sandboxes/{id}/files/write-many — write multiple files atomically. */
|
|
5548
|
+
async writeMany(files) {
|
|
5549
|
+
const http = this.sandbox.http;
|
|
5550
|
+
const payload = files.map((f) => ({
|
|
5551
|
+
path: f.path,
|
|
5552
|
+
content_base64: encodeContent(f.content)
|
|
5553
|
+
}));
|
|
5554
|
+
const response = await http.post(
|
|
5555
|
+
`/sandboxes/${this.sandbox.id}/files/write-many`,
|
|
5556
|
+
{ files: payload }
|
|
5557
|
+
);
|
|
5558
|
+
if (response && typeof response === "object" && "data" in response) {
|
|
5559
|
+
return response.data;
|
|
5560
|
+
}
|
|
5561
|
+
return response;
|
|
5562
|
+
}
|
|
5563
|
+
/** GET /api/v1/sandboxes/{id}/files/watch (SSE) — live file change events. */
|
|
5564
|
+
watch() {
|
|
5565
|
+
const http = this.sandbox.http;
|
|
5566
|
+
return http.stream(
|
|
5567
|
+
`/sandboxes/${this.sandbox.id}/files/watch`
|
|
5568
|
+
);
|
|
5569
|
+
}
|
|
4815
5570
|
};
|
|
4816
5571
|
var SandboxPreview = class {
|
|
4817
5572
|
constructor(sandbox) {
|
|
@@ -4870,7 +5625,7 @@ var SandboxTerminal = class {
|
|
|
4870
5625
|
const body = Object.fromEntries(
|
|
4871
5626
|
Object.entries(params).filter(([, v]) => v !== void 0)
|
|
4872
5627
|
);
|
|
4873
|
-
const response =
|
|
5628
|
+
const response = unwrap36(
|
|
4874
5629
|
await this.sandbox.http.post(`/sandboxes/${this.sandbox.id}/terminal`, body)
|
|
4875
5630
|
);
|
|
4876
5631
|
return response;
|
|
@@ -4919,7 +5674,7 @@ var SandboxPreviews = class {
|
|
|
4919
5674
|
Object.entries(opts).filter(([, v]) => v !== void 0)
|
|
4920
5675
|
)
|
|
4921
5676
|
};
|
|
4922
|
-
return
|
|
5677
|
+
return unwrap36(
|
|
4923
5678
|
await this.http.post(
|
|
4924
5679
|
`/sandboxes/${this.sandbox.id}/previews`,
|
|
4925
5680
|
body
|
|
@@ -4927,7 +5682,7 @@ var SandboxPreviews = class {
|
|
|
4927
5682
|
);
|
|
4928
5683
|
}
|
|
4929
5684
|
async get(previewId) {
|
|
4930
|
-
return
|
|
5685
|
+
return unwrap36(
|
|
4931
5686
|
await this.http.get(
|
|
4932
5687
|
`/sandboxes/${this.sandbox.id}/previews/${previewId}`
|
|
4933
5688
|
)
|
|
@@ -4940,7 +5695,7 @@ var SandboxPreviews = class {
|
|
|
4940
5695
|
}
|
|
4941
5696
|
/** Mint a share token for previewId. */
|
|
4942
5697
|
async share(previewId, opts = {}) {
|
|
4943
|
-
return
|
|
5698
|
+
return unwrap36(
|
|
4944
5699
|
await this.http.post(
|
|
4945
5700
|
`/sandboxes/${this.sandbox.id}/previews/${previewId}/share`,
|
|
4946
5701
|
{ ttl_seconds: opts.ttl_seconds ?? opts.expires_in_sec ?? 3600 }
|
|
@@ -4959,13 +5714,46 @@ var SandboxEnv = class {
|
|
|
4959
5714
|
this.sandbox = sandbox;
|
|
4960
5715
|
}
|
|
4961
5716
|
sandbox;
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
|
|
5717
|
+
get http() {
|
|
5718
|
+
return this.sandbox.http;
|
|
5719
|
+
}
|
|
5720
|
+
/** GET /api/v1/sandboxes/{id}/env → list of env vars. */
|
|
5721
|
+
async get() {
|
|
5722
|
+
const response = await this.http.get(
|
|
5723
|
+
`/sandboxes/${this.sandbox.id}/env`
|
|
5724
|
+
);
|
|
5725
|
+
if (Array.isArray(response)) return response;
|
|
5726
|
+
if (response && typeof response === "object") {
|
|
5727
|
+
const r = response;
|
|
5728
|
+
for (const k of ["data", "vars", "env", "items"]) {
|
|
5729
|
+
if (Array.isArray(r[k])) return r[k];
|
|
5730
|
+
}
|
|
5731
|
+
}
|
|
5732
|
+
return [];
|
|
5733
|
+
}
|
|
5734
|
+
/** @deprecated Use get() */
|
|
4966
5735
|
async list() {
|
|
4967
|
-
return
|
|
4968
|
-
|
|
5736
|
+
return this.get();
|
|
5737
|
+
}
|
|
5738
|
+
/** PUT /api/v1/sandboxes/{id}/env — set (replace) env vars. */
|
|
5739
|
+
async set(vars) {
|
|
5740
|
+
const response = await this.http.put(
|
|
5741
|
+
`/sandboxes/${this.sandbox.id}/env`,
|
|
5742
|
+
{ vars }
|
|
5743
|
+
);
|
|
5744
|
+
if (Array.isArray(response)) return response;
|
|
5745
|
+
if (response && typeof response === "object") {
|
|
5746
|
+
const r = response;
|
|
5747
|
+
for (const k of ["data", "vars", "env", "items"]) {
|
|
5748
|
+
if (Array.isArray(r[k])) return r[k];
|
|
5749
|
+
}
|
|
5750
|
+
}
|
|
5751
|
+
return [];
|
|
5752
|
+
}
|
|
5753
|
+
/** DELETE /api/v1/sandboxes/{id}/env/{key} — remove a single env var. */
|
|
5754
|
+
async delete(key) {
|
|
5755
|
+
await this.http.delete(
|
|
5756
|
+
`/sandboxes/${this.sandbox.id}/env/${encodeURIComponent(key)}`
|
|
4969
5757
|
);
|
|
4970
5758
|
}
|
|
4971
5759
|
};
|
|
@@ -4976,7 +5764,7 @@ var SandboxTags = class {
|
|
|
4976
5764
|
sandbox;
|
|
4977
5765
|
/** Replace the full tag list with tags. */
|
|
4978
5766
|
async set(tags) {
|
|
4979
|
-
return
|
|
5767
|
+
return unwrap36(
|
|
4980
5768
|
await this.sandbox.http.patch(`/sandboxes/${this.sandbox.id}/tags`, { tags })
|
|
4981
5769
|
);
|
|
4982
5770
|
}
|
|
@@ -5001,6 +5789,10 @@ var Sandbox = class _Sandbox {
|
|
|
5001
5789
|
this.previews = new SandboxPreviews(this);
|
|
5002
5790
|
this.env = new SandboxEnv(this);
|
|
5003
5791
|
this.tags = new SandboxTags(this);
|
|
5792
|
+
const sandboxId = data.id;
|
|
5793
|
+
this.secrets = new SandboxSecrets(http, sandboxId);
|
|
5794
|
+
this.network = new SandboxNetwork(http, sandboxId);
|
|
5795
|
+
this.audit = new SandboxAudit(http, sandboxId);
|
|
5004
5796
|
}
|
|
5005
5797
|
http;
|
|
5006
5798
|
data;
|
|
@@ -5021,6 +5813,12 @@ var Sandbox = class _Sandbox {
|
|
|
5021
5813
|
env;
|
|
5022
5814
|
/** Tag replacement. */
|
|
5023
5815
|
tags;
|
|
5816
|
+
/** Encrypted secrets + OAuth credentials scoped to this sandbox. */
|
|
5817
|
+
secrets;
|
|
5818
|
+
/** Egress allowlist + policies scoped to this sandbox. */
|
|
5819
|
+
network;
|
|
5820
|
+
/** Egress audit log + live tail scoped to this sandbox. */
|
|
5821
|
+
audit;
|
|
5024
5822
|
get id() {
|
|
5025
5823
|
return this.data.id;
|
|
5026
5824
|
}
|
|
@@ -5034,14 +5832,14 @@ var Sandbox = class _Sandbox {
|
|
|
5034
5832
|
return this.data.template_id ?? this.data.image_id ?? "";
|
|
5035
5833
|
}
|
|
5036
5834
|
async refresh() {
|
|
5037
|
-
this.data =
|
|
5835
|
+
this.data = unwrap36(
|
|
5038
5836
|
await this.http.get(`/sandboxes/${this.id}`)
|
|
5039
5837
|
);
|
|
5040
5838
|
return this;
|
|
5041
5839
|
}
|
|
5042
5840
|
async runExec(command, options) {
|
|
5043
5841
|
this.assertRunning("exec");
|
|
5044
|
-
const response =
|
|
5842
|
+
const response = unwrap36(
|
|
5045
5843
|
await this.http.post(
|
|
5046
5844
|
`/sandboxes/${this.id}/exec`,
|
|
5047
5845
|
execBody(command, options)
|
|
@@ -5089,7 +5887,7 @@ var Sandbox = class _Sandbox {
|
|
|
5089
5887
|
}
|
|
5090
5888
|
async listFiles(path = "/workspace") {
|
|
5091
5889
|
this.assertRunning("files.list");
|
|
5092
|
-
const response =
|
|
5890
|
+
const response = unwrap36(
|
|
5093
5891
|
await this.http.get(
|
|
5094
5892
|
`/sandboxes/${this.id}/files`,
|
|
5095
5893
|
{ path }
|
|
@@ -5099,7 +5897,7 @@ var Sandbox = class _Sandbox {
|
|
|
5099
5897
|
}
|
|
5100
5898
|
async statFile(path) {
|
|
5101
5899
|
this.assertRunning("files.stat");
|
|
5102
|
-
return
|
|
5900
|
+
return unwrap36(
|
|
5103
5901
|
await this.http.post(
|
|
5104
5902
|
`/sandboxes/${this.id}/files/stat`,
|
|
5105
5903
|
{ path }
|
|
@@ -5108,7 +5906,7 @@ var Sandbox = class _Sandbox {
|
|
|
5108
5906
|
}
|
|
5109
5907
|
async expose(port) {
|
|
5110
5908
|
this.assertRunning("expose");
|
|
5111
|
-
const response =
|
|
5909
|
+
const response = unwrap36(
|
|
5112
5910
|
await this.http.post(
|
|
5113
5911
|
`/sandboxes/${this.id}/expose`,
|
|
5114
5912
|
port === void 0 ? {} : { port }
|
|
@@ -5118,7 +5916,7 @@ var Sandbox = class _Sandbox {
|
|
|
5118
5916
|
}
|
|
5119
5917
|
async startTemplate(options = {}) {
|
|
5120
5918
|
this.assertRunning("startTemplate");
|
|
5121
|
-
return
|
|
5919
|
+
return unwrap36(
|
|
5122
5920
|
await this.http.post(
|
|
5123
5921
|
`/sandboxes/${this.id}/template/start`,
|
|
5124
5922
|
options
|
|
@@ -5126,7 +5924,7 @@ var Sandbox = class _Sandbox {
|
|
|
5126
5924
|
);
|
|
5127
5925
|
}
|
|
5128
5926
|
async getArtifacts() {
|
|
5129
|
-
return
|
|
5927
|
+
return unwrap36(
|
|
5130
5928
|
await this.http.get(
|
|
5131
5929
|
`/sandboxes/${this.id}/artifacts`
|
|
5132
5930
|
)
|
|
@@ -5137,7 +5935,7 @@ var Sandbox = class _Sandbox {
|
|
|
5137
5935
|
`/sandboxes/${this.id}/logs`,
|
|
5138
5936
|
{ lines }
|
|
5139
5937
|
);
|
|
5140
|
-
return
|
|
5938
|
+
return unwrap36(response);
|
|
5141
5939
|
}
|
|
5142
5940
|
streamLogs() {
|
|
5143
5941
|
return this.http.stream(
|
|
@@ -5146,7 +5944,7 @@ var Sandbox = class _Sandbox {
|
|
|
5146
5944
|
}
|
|
5147
5945
|
async createSnapshot(comment) {
|
|
5148
5946
|
this.assertRunning("snapshots.create");
|
|
5149
|
-
return
|
|
5947
|
+
return unwrap36(
|
|
5150
5948
|
await this.http.post(
|
|
5151
5949
|
`/sandboxes/${this.id}/snapshots`,
|
|
5152
5950
|
comment ? { comment } : {}
|
|
@@ -5154,14 +5952,14 @@ var Sandbox = class _Sandbox {
|
|
|
5154
5952
|
);
|
|
5155
5953
|
}
|
|
5156
5954
|
async listSnapshots() {
|
|
5157
|
-
return
|
|
5955
|
+
return unwrap36(
|
|
5158
5956
|
await this.http.get(
|
|
5159
5957
|
`/sandboxes/${this.id}/snapshots`
|
|
5160
5958
|
)
|
|
5161
5959
|
);
|
|
5162
5960
|
}
|
|
5163
5961
|
async restoreSnapshot(snapshotId) {
|
|
5164
|
-
const data =
|
|
5962
|
+
const data = unwrap36(
|
|
5165
5963
|
await this.http.post(
|
|
5166
5964
|
`/sandboxes/${this.id}/restore/${snapshotId}`,
|
|
5167
5965
|
{}
|
|
@@ -5172,8 +5970,55 @@ var Sandbox = class _Sandbox {
|
|
|
5172
5970
|
async deleteSnapshot(snapshotId) {
|
|
5173
5971
|
await this.http.delete(`/sandboxes/${this.id}/snapshots/${snapshotId}`);
|
|
5174
5972
|
}
|
|
5973
|
+
/**
|
|
5974
|
+
* Fork (clone) this sandbox into a new sandbox via copy-on-write snapshot.
|
|
5975
|
+
* The original sandbox continues running unchanged.
|
|
5976
|
+
*/
|
|
5977
|
+
async fork(opts = {}) {
|
|
5978
|
+
this.assertRunning("fork");
|
|
5979
|
+
const body = {};
|
|
5980
|
+
if (opts.name !== void 0) body.name = opts.name;
|
|
5981
|
+
if (opts.metadata !== void 0) body.metadata = opts.metadata;
|
|
5982
|
+
const data = unwrap36(
|
|
5983
|
+
await this.http.post(
|
|
5984
|
+
`/sandboxes/${this.id}/fork`,
|
|
5985
|
+
body
|
|
5986
|
+
)
|
|
5987
|
+
);
|
|
5988
|
+
return new _Sandbox(this.http, data);
|
|
5989
|
+
}
|
|
5990
|
+
/**
|
|
5991
|
+
* PATCH /api/v1/sandboxes/{id} — update mutable sandbox fields.
|
|
5992
|
+
*/
|
|
5993
|
+
async update(params) {
|
|
5994
|
+
const body = {};
|
|
5995
|
+
for (const [k, v] of Object.entries(params)) {
|
|
5996
|
+
if (v !== void 0) body[k] = v;
|
|
5997
|
+
}
|
|
5998
|
+
const data = unwrap36(
|
|
5999
|
+
await this.http.patch(
|
|
6000
|
+
`/sandboxes/${this.id}`,
|
|
6001
|
+
body
|
|
6002
|
+
)
|
|
6003
|
+
);
|
|
6004
|
+
this.data = data;
|
|
6005
|
+
return this;
|
|
6006
|
+
}
|
|
6007
|
+
/**
|
|
6008
|
+
* POST /api/v1/sandboxes/{id}/preview-token → {token, url, expires_at, scope}
|
|
6009
|
+
*/
|
|
6010
|
+
async previewToken(expiresIn = 3600, scope = "read") {
|
|
6011
|
+
const raw = await this.http.post(
|
|
6012
|
+
`/sandboxes/${this.id}/preview-token`,
|
|
6013
|
+
{ expires_in: expiresIn, scope }
|
|
6014
|
+
);
|
|
6015
|
+
if (raw && typeof raw === "object" && "data" in raw) {
|
|
6016
|
+
return raw.data;
|
|
6017
|
+
}
|
|
6018
|
+
return raw;
|
|
6019
|
+
}
|
|
5175
6020
|
async pause() {
|
|
5176
|
-
const data =
|
|
6021
|
+
const data = unwrap36(
|
|
5177
6022
|
await this.http.post(
|
|
5178
6023
|
`/sandboxes/${this.id}/pause`,
|
|
5179
6024
|
{}
|
|
@@ -5183,7 +6028,7 @@ var Sandbox = class _Sandbox {
|
|
|
5183
6028
|
return this;
|
|
5184
6029
|
}
|
|
5185
6030
|
async resume() {
|
|
5186
|
-
const data =
|
|
6031
|
+
const data = unwrap36(
|
|
5187
6032
|
await this.http.post(
|
|
5188
6033
|
`/sandboxes/${this.id}/resume`,
|
|
5189
6034
|
{}
|
|
@@ -5196,7 +6041,7 @@ var Sandbox = class _Sandbox {
|
|
|
5196
6041
|
const idempotencyKey11 = params.idempotencyKey ?? params.idempotency_key;
|
|
5197
6042
|
const requestOptions = {
|
|
5198
6043
|
method: "POST",
|
|
5199
|
-
body:
|
|
6044
|
+
body: stripUndefined19({
|
|
5200
6045
|
name: params.name,
|
|
5201
6046
|
deployment_id: params.deploymentId ?? params.deployment_id,
|
|
5202
6047
|
output_path: params.outputPath ?? params.output_path ?? params.path ?? params.sourcePath ?? params.source_path,
|
|
@@ -5209,7 +6054,7 @@ var Sandbox = class _Sandbox {
|
|
|
5209
6054
|
if (idempotencyKey11) {
|
|
5210
6055
|
requestOptions.headers = { "Idempotency-Key": idempotencyKey11 };
|
|
5211
6056
|
}
|
|
5212
|
-
return
|
|
6057
|
+
return unwrap36(
|
|
5213
6058
|
await this.http.request(
|
|
5214
6059
|
`/sandboxes/${this.id}/deploy`,
|
|
5215
6060
|
requestOptions
|
|
@@ -5218,7 +6063,7 @@ var Sandbox = class _Sandbox {
|
|
|
5218
6063
|
}
|
|
5219
6064
|
/** Check readiness of the sandbox (GET /sandboxes/:id/readiness). */
|
|
5220
6065
|
async readiness() {
|
|
5221
|
-
return
|
|
6066
|
+
return unwrap36(
|
|
5222
6067
|
await this.http.get(
|
|
5223
6068
|
`/sandboxes/${this.id}/readiness`
|
|
5224
6069
|
)
|
|
@@ -5357,7 +6202,7 @@ var Sandboxes = class {
|
|
|
5357
6202
|
if (idempotencyKey11) {
|
|
5358
6203
|
requestOptions.headers = { "Idempotency-Key": idempotencyKey11 };
|
|
5359
6204
|
}
|
|
5360
|
-
const data =
|
|
6205
|
+
const data = unwrap36(
|
|
5361
6206
|
await this.http.request(
|
|
5362
6207
|
"/sandboxes",
|
|
5363
6208
|
requestOptions
|
|
@@ -5376,7 +6221,7 @@ var Sandboxes = class {
|
|
|
5376
6221
|
return listItems11(data).map((item) => new Sandbox(this.http, item));
|
|
5377
6222
|
}
|
|
5378
6223
|
async get(id) {
|
|
5379
|
-
const data =
|
|
6224
|
+
const data = unwrap36(
|
|
5380
6225
|
await this.http.get(`/sandboxes/${id}`)
|
|
5381
6226
|
);
|
|
5382
6227
|
return new Sandbox(this.http, data);
|
|
@@ -5411,7 +6256,7 @@ var Sandboxes = class {
|
|
|
5411
6256
|
async createTemplate(params) {
|
|
5412
6257
|
const response = await this.http.post(
|
|
5413
6258
|
"/sandbox-templates",
|
|
5414
|
-
|
|
6259
|
+
stripUndefined19({
|
|
5415
6260
|
name: params.name,
|
|
5416
6261
|
slug: params.slug,
|
|
5417
6262
|
description: params.description,
|
|
@@ -5419,29 +6264,29 @@ var Sandboxes = class {
|
|
|
5419
6264
|
metadata: params.metadata
|
|
5420
6265
|
})
|
|
5421
6266
|
);
|
|
5422
|
-
return
|
|
6267
|
+
return unwrap36(response);
|
|
5423
6268
|
}
|
|
5424
6269
|
async createTemplateBuild(templateId, params = {}) {
|
|
5425
6270
|
const response = await this.http.post(
|
|
5426
6271
|
`/sandbox-templates/${templateId}/builds`,
|
|
5427
|
-
|
|
6272
|
+
stripUndefined19({
|
|
5428
6273
|
build_spec: params.buildSpec ?? params.build_spec,
|
|
5429
6274
|
metadata: params.metadata
|
|
5430
6275
|
})
|
|
5431
6276
|
);
|
|
5432
|
-
return
|
|
6277
|
+
return unwrap36(response);
|
|
5433
6278
|
}
|
|
5434
6279
|
async listTemplateBuilds(templateId) {
|
|
5435
6280
|
const response = await this.http.get(
|
|
5436
6281
|
`/sandbox-templates/${templateId}/builds`
|
|
5437
6282
|
);
|
|
5438
|
-
return
|
|
6283
|
+
return unwrap36(response);
|
|
5439
6284
|
}
|
|
5440
6285
|
async getTemplateBuild(buildId) {
|
|
5441
6286
|
const response = await this.http.get(
|
|
5442
6287
|
`/sandbox-template-builds/${buildId}`
|
|
5443
6288
|
);
|
|
5444
|
-
return
|
|
6289
|
+
return unwrap36(response);
|
|
5445
6290
|
}
|
|
5446
6291
|
};
|
|
5447
6292
|
function toBase642(bytes) {
|
|
@@ -5453,7 +6298,7 @@ function toBase642(bytes) {
|
|
|
5453
6298
|
}
|
|
5454
6299
|
return btoa(binary);
|
|
5455
6300
|
}
|
|
5456
|
-
function
|
|
6301
|
+
function unwrap37(payload) {
|
|
5457
6302
|
if (payload && typeof payload === "object" && "data" in payload) {
|
|
5458
6303
|
return payload.data;
|
|
5459
6304
|
}
|
|
@@ -5469,7 +6314,7 @@ function listItems12(payload, candidateKeys = ["data", "templates", "builds", "i
|
|
|
5469
6314
|
}
|
|
5470
6315
|
return [];
|
|
5471
6316
|
}
|
|
5472
|
-
function
|
|
6317
|
+
function stripUndefined20(input) {
|
|
5473
6318
|
return Object.fromEntries(
|
|
5474
6319
|
Object.entries(input).filter(([, v]) => v !== void 0)
|
|
5475
6320
|
);
|
|
@@ -5496,7 +6341,7 @@ var SandboxTemplates = class {
|
|
|
5496
6341
|
const data = await this.http.get(
|
|
5497
6342
|
`/sandbox-templates/${templateId}`
|
|
5498
6343
|
);
|
|
5499
|
-
return
|
|
6344
|
+
return unwrap37(data);
|
|
5500
6345
|
}
|
|
5501
6346
|
async create(params) {
|
|
5502
6347
|
const {
|
|
@@ -5506,7 +6351,7 @@ var SandboxTemplates = class {
|
|
|
5506
6351
|
name,
|
|
5507
6352
|
...rest
|
|
5508
6353
|
} = params;
|
|
5509
|
-
const body =
|
|
6354
|
+
const body = stripUndefined20({
|
|
5510
6355
|
name,
|
|
5511
6356
|
build_spec: buildSpec ?? build_spec,
|
|
5512
6357
|
...rest
|
|
@@ -5516,7 +6361,7 @@ var SandboxTemplates = class {
|
|
|
5516
6361
|
body,
|
|
5517
6362
|
headers: { "Idempotency-Key": idempotencyKey8(ikey) }
|
|
5518
6363
|
});
|
|
5519
|
-
return
|
|
6364
|
+
return unwrap37(data);
|
|
5520
6365
|
}
|
|
5521
6366
|
async buildSpecSchema() {
|
|
5522
6367
|
const data = await this.http.get("/sandbox-templates/build-spec");
|
|
@@ -5540,7 +6385,7 @@ var SandboxTemplates = class {
|
|
|
5540
6385
|
}
|
|
5541
6386
|
async createBuild(templateId, params = {}) {
|
|
5542
6387
|
const { idempotencyKey: ikey, ...rest } = params;
|
|
5543
|
-
const body =
|
|
6388
|
+
const body = stripUndefined20(rest);
|
|
5544
6389
|
const data = await this.http.request(
|
|
5545
6390
|
`/sandbox-templates/${templateId}/builds`,
|
|
5546
6391
|
{
|
|
@@ -5549,12 +6394,12 @@ var SandboxTemplates = class {
|
|
|
5549
6394
|
headers: { "Idempotency-Key": idempotencyKey8(ikey) }
|
|
5550
6395
|
}
|
|
5551
6396
|
);
|
|
5552
|
-
return
|
|
6397
|
+
return unwrap37(data);
|
|
5553
6398
|
}
|
|
5554
6399
|
};
|
|
5555
6400
|
|
|
5556
6401
|
// src/resources/settings.ts
|
|
5557
|
-
function
|
|
6402
|
+
function unwrap38(payload) {
|
|
5558
6403
|
if (payload && typeof payload === "object") {
|
|
5559
6404
|
const p = payload;
|
|
5560
6405
|
for (const k of [
|
|
@@ -5570,11 +6415,11 @@ function unwrap35(payload) {
|
|
|
5570
6415
|
return payload;
|
|
5571
6416
|
}
|
|
5572
6417
|
function listItems13(payload) {
|
|
5573
|
-
const result =
|
|
6418
|
+
const result = unwrap38(payload);
|
|
5574
6419
|
if (Array.isArray(result)) return result;
|
|
5575
6420
|
return [];
|
|
5576
6421
|
}
|
|
5577
|
-
function
|
|
6422
|
+
function stripUndefined21(input) {
|
|
5578
6423
|
return Object.fromEntries(
|
|
5579
6424
|
Object.entries(input).filter(([, v]) => v !== void 0)
|
|
5580
6425
|
);
|
|
@@ -5587,46 +6432,46 @@ var Settings = class {
|
|
|
5587
6432
|
/** Get the current tenant settings. */
|
|
5588
6433
|
async get() {
|
|
5589
6434
|
const data = await this.http.get("/settings");
|
|
5590
|
-
return
|
|
6435
|
+
return unwrap38(data);
|
|
5591
6436
|
}
|
|
5592
6437
|
/** Update tenant settings. */
|
|
5593
6438
|
async update(params) {
|
|
5594
|
-
const body =
|
|
6439
|
+
const body = stripUndefined21(params);
|
|
5595
6440
|
const data = await this.http.put("/settings", body);
|
|
5596
|
-
return
|
|
6441
|
+
return unwrap38(data);
|
|
5597
6442
|
}
|
|
5598
6443
|
// ── Branding ──────────────────────────────────────────────────────────────
|
|
5599
6444
|
/** Get tenant branding (logo, colors, custom wordmark). */
|
|
5600
6445
|
async getBranding() {
|
|
5601
6446
|
const data = await this.http.get("/settings/branding");
|
|
5602
|
-
return
|
|
6447
|
+
return unwrap38(data);
|
|
5603
6448
|
}
|
|
5604
6449
|
/** Update tenant branding. */
|
|
5605
6450
|
async updateBranding(params) {
|
|
5606
|
-
const body =
|
|
6451
|
+
const body = stripUndefined21(params);
|
|
5607
6452
|
const data = await this.http.put("/settings/branding", body);
|
|
5608
|
-
return
|
|
6453
|
+
return unwrap38(data);
|
|
5609
6454
|
}
|
|
5610
6455
|
// ── Read-only reference data ───────────────────────────────────────────────
|
|
5611
6456
|
/** Get tenant-scoped compute pricing. */
|
|
5612
6457
|
async computePricing() {
|
|
5613
6458
|
const data = await this.http.get("/settings/compute-pricing");
|
|
5614
|
-
return
|
|
6459
|
+
return unwrap38(data);
|
|
5615
6460
|
}
|
|
5616
6461
|
/** Get tenant-scoped GPU pricing. */
|
|
5617
6462
|
async gpuPricing() {
|
|
5618
6463
|
const data = await this.http.get("/settings/gpu-pricing");
|
|
5619
|
-
return
|
|
6464
|
+
return unwrap38(data);
|
|
5620
6465
|
}
|
|
5621
6466
|
/** List models available to this tenant. */
|
|
5622
6467
|
async availableModels() {
|
|
5623
6468
|
const data = await this.http.get("/settings/available-models");
|
|
5624
|
-
return
|
|
6469
|
+
return unwrap38(data);
|
|
5625
6470
|
}
|
|
5626
6471
|
/** List regions enabled for this tenant. */
|
|
5627
6472
|
async regions() {
|
|
5628
6473
|
const data = await this.http.get("/settings/regions");
|
|
5629
|
-
return
|
|
6474
|
+
return unwrap38(data);
|
|
5630
6475
|
}
|
|
5631
6476
|
// ── BYOK provider keys ────────────────────────────────────────────────────
|
|
5632
6477
|
/** List tenant-level BYOK provider keys (Anthropic, OpenAI, etc.). */
|
|
@@ -5636,12 +6481,12 @@ var Settings = class {
|
|
|
5636
6481
|
}
|
|
5637
6482
|
/** Create or update a BYOK provider key. */
|
|
5638
6483
|
async upsertProviderKey(provider, params) {
|
|
5639
|
-
const body =
|
|
6484
|
+
const body = stripUndefined21(params);
|
|
5640
6485
|
const data = await this.http.put(
|
|
5641
6486
|
`/settings/provider-keys/${provider}`,
|
|
5642
6487
|
body
|
|
5643
6488
|
);
|
|
5644
|
-
return
|
|
6489
|
+
return unwrap38(data);
|
|
5645
6490
|
}
|
|
5646
6491
|
/** Delete a BYOK provider key. */
|
|
5647
6492
|
async deleteProviderKey(provider) {
|
|
@@ -5650,7 +6495,7 @@ var Settings = class {
|
|
|
5650
6495
|
};
|
|
5651
6496
|
|
|
5652
6497
|
// src/resources/snapshots-standalone.ts
|
|
5653
|
-
function
|
|
6498
|
+
function unwrap39(data) {
|
|
5654
6499
|
if (data && typeof data === "object") {
|
|
5655
6500
|
const d = data;
|
|
5656
6501
|
for (const k of ["data", "snapshots", "items"]) {
|
|
@@ -5659,7 +6504,7 @@ function unwrap36(data) {
|
|
|
5659
6504
|
}
|
|
5660
6505
|
return data;
|
|
5661
6506
|
}
|
|
5662
|
-
function
|
|
6507
|
+
function unwrapList12(data) {
|
|
5663
6508
|
if (Array.isArray(data)) return data;
|
|
5664
6509
|
if (data && typeof data === "object") {
|
|
5665
6510
|
const d = data;
|
|
@@ -5678,17 +6523,17 @@ var SnapshotsStandalone = class {
|
|
|
5678
6523
|
const query = Object.fromEntries(
|
|
5679
6524
|
Object.entries(filters).filter(([, v]) => v !== void 0)
|
|
5680
6525
|
);
|
|
5681
|
-
return
|
|
6526
|
+
return unwrapList12(await this.http.get("/admin/snapshots", query));
|
|
5682
6527
|
}
|
|
5683
6528
|
async get(snapshotId) {
|
|
5684
|
-
return
|
|
6529
|
+
return unwrap39(
|
|
5685
6530
|
await this.http.get(`/admin/snapshots/${snapshotId}`)
|
|
5686
6531
|
);
|
|
5687
6532
|
}
|
|
5688
6533
|
};
|
|
5689
6534
|
|
|
5690
6535
|
// src/resources/storage.ts
|
|
5691
|
-
function
|
|
6536
|
+
function unwrap40(payload) {
|
|
5692
6537
|
if (payload && typeof payload === "object" && "data" in payload) {
|
|
5693
6538
|
return payload.data;
|
|
5694
6539
|
}
|
|
@@ -5704,7 +6549,7 @@ function listItems14(payload, candidateKeys = ["data", "buckets", "objects", "it
|
|
|
5704
6549
|
}
|
|
5705
6550
|
return [];
|
|
5706
6551
|
}
|
|
5707
|
-
function
|
|
6552
|
+
function stripUndefined22(input) {
|
|
5708
6553
|
return Object.fromEntries(
|
|
5709
6554
|
Object.entries(input).filter(([, v]) => v !== void 0)
|
|
5710
6555
|
);
|
|
@@ -5721,24 +6566,24 @@ var Storage = class {
|
|
|
5721
6566
|
}
|
|
5722
6567
|
async createBucket(params) {
|
|
5723
6568
|
const { name, public: isPublic, visibility, ...rest } = params;
|
|
5724
|
-
const body =
|
|
6569
|
+
const body = stripUndefined22({
|
|
5725
6570
|
name,
|
|
5726
6571
|
visibility: visibility ?? (isPublic === void 0 ? void 0 : isPublic ? "public" : "private"),
|
|
5727
6572
|
...rest
|
|
5728
6573
|
});
|
|
5729
6574
|
const data = await this.http.post("/storage/buckets", body);
|
|
5730
|
-
return
|
|
6575
|
+
return unwrap40(data);
|
|
5731
6576
|
}
|
|
5732
6577
|
async getBucket(bucketId) {
|
|
5733
6578
|
const data = await this.http.get(`/storage/buckets/${bucketId}`);
|
|
5734
|
-
return
|
|
6579
|
+
return unwrap40(data);
|
|
5735
6580
|
}
|
|
5736
6581
|
async deleteBucket(bucketId) {
|
|
5737
6582
|
await this.http.delete(`/storage/buckets/${bucketId}`);
|
|
5738
6583
|
}
|
|
5739
6584
|
// ── Objects ────────────────────────────────────────────────────────────────
|
|
5740
6585
|
async listObjects(bucketId, params = {}) {
|
|
5741
|
-
const query =
|
|
6586
|
+
const query = stripUndefined22({
|
|
5742
6587
|
prefix: params.prefix,
|
|
5743
6588
|
max_keys: params.max_keys ?? params.maxKeys ?? params.limit,
|
|
5744
6589
|
marker: params.marker ?? params.cursor
|
|
@@ -5772,7 +6617,7 @@ var Storage = class {
|
|
|
5772
6617
|
// ── Presigned URLs ─────────────────────────────────────────────────────────
|
|
5773
6618
|
async presign(bucketId, params) {
|
|
5774
6619
|
const operationMethod = params.operation === "put" ? "PUT" : params.operation === "get" ? "GET" : void 0;
|
|
5775
|
-
const body =
|
|
6620
|
+
const body = stripUndefined22({
|
|
5776
6621
|
key: params.key,
|
|
5777
6622
|
method: params.method ?? operationMethod ?? "GET",
|
|
5778
6623
|
expires_in: params.expiresIn ?? params.expires_in ?? params.expiresInSec ?? params.expires_in_sec ?? 3600
|
|
@@ -5781,12 +6626,97 @@ var Storage = class {
|
|
|
5781
6626
|
`/storage/buckets/${bucketId}/presign`,
|
|
5782
6627
|
body
|
|
5783
6628
|
);
|
|
5784
|
-
return
|
|
6629
|
+
return unwrap40(data);
|
|
6630
|
+
}
|
|
6631
|
+
};
|
|
6632
|
+
|
|
6633
|
+
// src/resources/org-invites.ts
|
|
6634
|
+
var OrgInvites = class {
|
|
6635
|
+
constructor(http) {
|
|
6636
|
+
this.http = http;
|
|
6637
|
+
}
|
|
6638
|
+
http;
|
|
6639
|
+
/**
|
|
6640
|
+
* Create an org invite and dispatch the invite email.
|
|
6641
|
+
*
|
|
6642
|
+
* The invite URL in the response is host-aware: on white-label tenants it
|
|
6643
|
+
* uses the custom domain so the recipient lands on the branded experience.
|
|
6644
|
+
* Requires `admin` or `owner` role in the tenant.
|
|
6645
|
+
*
|
|
6646
|
+
* `POST /tenants/:id/invites`
|
|
6647
|
+
*/
|
|
6648
|
+
async create(tenantId, params) {
|
|
6649
|
+
const res = await this.http.post(
|
|
6650
|
+
`/tenants/${tenantId}/invites`,
|
|
6651
|
+
params
|
|
6652
|
+
);
|
|
6653
|
+
return res.data;
|
|
6654
|
+
}
|
|
6655
|
+
/**
|
|
6656
|
+
* List all pending (non-expired, non-accepted, non-revoked) org invites.
|
|
6657
|
+
*
|
|
6658
|
+
* Requires `admin` or `owner` role.
|
|
6659
|
+
*
|
|
6660
|
+
* `GET /tenants/:id/invites`
|
|
6661
|
+
*/
|
|
6662
|
+
async list(tenantId) {
|
|
6663
|
+
const res = await this.http.get(
|
|
6664
|
+
`/tenants/${tenantId}/invites`
|
|
6665
|
+
);
|
|
6666
|
+
return res.data ?? [];
|
|
6667
|
+
}
|
|
6668
|
+
/**
|
|
6669
|
+
* Revoke a pending org invite.
|
|
6670
|
+
*
|
|
6671
|
+
* Returns `409` when the invite was already legitimately accepted.
|
|
6672
|
+
* Requires `admin` or `owner` role.
|
|
6673
|
+
*
|
|
6674
|
+
* `DELETE /tenants/:id/invites/:invite_id`
|
|
6675
|
+
*/
|
|
6676
|
+
async revoke(tenantId, inviteId) {
|
|
6677
|
+
return this.http.delete(
|
|
6678
|
+
`/tenants/${tenantId}/invites/${inviteId}`
|
|
6679
|
+
);
|
|
6680
|
+
}
|
|
6681
|
+
/**
|
|
6682
|
+
* Preview an org invite by token (no auth required).
|
|
6683
|
+
*
|
|
6684
|
+
* Returns `null` when the token is unknown or has been revoked.
|
|
6685
|
+
*
|
|
6686
|
+
* `GET /invites/:token`
|
|
6687
|
+
*/
|
|
6688
|
+
async preview(token) {
|
|
6689
|
+
try {
|
|
6690
|
+
const res = await this.http.get(
|
|
6691
|
+
`/invites/${token}`
|
|
6692
|
+
);
|
|
6693
|
+
return res.data ?? null;
|
|
6694
|
+
} catch {
|
|
6695
|
+
return null;
|
|
6696
|
+
}
|
|
6697
|
+
}
|
|
6698
|
+
/**
|
|
6699
|
+
* Accept an org invite on behalf of the authenticated user.
|
|
6700
|
+
*
|
|
6701
|
+
* The caller's JWT email must match the invite email (case-insensitive).
|
|
6702
|
+
* On success inserts a `tenant_members` row.
|
|
6703
|
+
*
|
|
6704
|
+
* Error responses:
|
|
6705
|
+
* - `400` — invalid or expired token.
|
|
6706
|
+
* - `422 EMAIL_MISMATCH` — JWT email does not match the invite email.
|
|
6707
|
+
*
|
|
6708
|
+
* `POST /invites/:token/accept`
|
|
6709
|
+
*/
|
|
6710
|
+
async accept(token) {
|
|
6711
|
+
return this.http.post(
|
|
6712
|
+
`/invites/${token}/accept`,
|
|
6713
|
+
{}
|
|
6714
|
+
);
|
|
5785
6715
|
}
|
|
5786
6716
|
};
|
|
5787
6717
|
|
|
5788
6718
|
// src/resources/tenant.ts
|
|
5789
|
-
function
|
|
6719
|
+
function unwrap41(payload) {
|
|
5790
6720
|
if (payload && typeof payload === "object") {
|
|
5791
6721
|
const p = payload;
|
|
5792
6722
|
for (const k of ["data", "tenant", "items"]) {
|
|
@@ -5803,12 +6733,12 @@ var Tenant = class {
|
|
|
5803
6733
|
/** Get the current tenant's plan, limits, and live usage counters. */
|
|
5804
6734
|
async current() {
|
|
5805
6735
|
const data = await this.http.get("/tenant/plan");
|
|
5806
|
-
return
|
|
6736
|
+
return unwrap41(data);
|
|
5807
6737
|
}
|
|
5808
6738
|
};
|
|
5809
6739
|
|
|
5810
6740
|
// src/resources/usage.ts
|
|
5811
|
-
function
|
|
6741
|
+
function unwrap42(payload) {
|
|
5812
6742
|
if (payload && typeof payload === "object") {
|
|
5813
6743
|
const p = payload;
|
|
5814
6744
|
for (const k of ["data", "usage", "sessions", "summary", "items"]) {
|
|
@@ -5817,7 +6747,7 @@ function unwrap39(payload) {
|
|
|
5817
6747
|
}
|
|
5818
6748
|
return payload;
|
|
5819
6749
|
}
|
|
5820
|
-
function
|
|
6750
|
+
function stripUndefined23(input) {
|
|
5821
6751
|
return Object.fromEntries(
|
|
5822
6752
|
Object.entries(input).filter(([, v]) => v !== void 0)
|
|
5823
6753
|
);
|
|
@@ -5830,24 +6760,24 @@ var Usage = class {
|
|
|
5830
6760
|
/** Get the current period usage summary. */
|
|
5831
6761
|
async current() {
|
|
5832
6762
|
const data = await this.http.get("/usage/summary");
|
|
5833
|
-
return
|
|
6763
|
+
return unwrap42(data);
|
|
5834
6764
|
}
|
|
5835
6765
|
/** List per-session metering events. */
|
|
5836
6766
|
async sessions(params = {}) {
|
|
5837
|
-
const query =
|
|
6767
|
+
const query = stripUndefined23(params);
|
|
5838
6768
|
const data = await this.http.get("/usage/sessions", query);
|
|
5839
|
-
const result =
|
|
6769
|
+
const result = unwrap42(data);
|
|
5840
6770
|
if (Array.isArray(result)) return result;
|
|
5841
6771
|
return [];
|
|
5842
6772
|
}
|
|
5843
6773
|
/** Get a usage report for a period. */
|
|
5844
6774
|
async report(params = {}) {
|
|
5845
|
-
const query =
|
|
6775
|
+
const query = stripUndefined23(params);
|
|
5846
6776
|
const data = await this.http.get("/usage/summary", query);
|
|
5847
|
-
return
|
|
6777
|
+
return unwrap42(data);
|
|
5848
6778
|
}
|
|
5849
6779
|
};
|
|
5850
|
-
function
|
|
6780
|
+
function unwrap43(payload) {
|
|
5851
6781
|
if (payload && typeof payload === "object" && "data" in payload) {
|
|
5852
6782
|
return payload.data;
|
|
5853
6783
|
}
|
|
@@ -5863,7 +6793,7 @@ function listItems15(payload, candidateKeys = ["data", "volumes", "items"]) {
|
|
|
5863
6793
|
}
|
|
5864
6794
|
return [];
|
|
5865
6795
|
}
|
|
5866
|
-
function
|
|
6796
|
+
function stripUndefined24(input) {
|
|
5867
6797
|
return Object.fromEntries(
|
|
5868
6798
|
Object.entries(input).filter(([, v]) => v !== void 0)
|
|
5869
6799
|
);
|
|
@@ -5877,17 +6807,17 @@ var Volumes = class {
|
|
|
5877
6807
|
}
|
|
5878
6808
|
http;
|
|
5879
6809
|
async list(params = {}) {
|
|
5880
|
-
const query =
|
|
6810
|
+
const query = stripUndefined24({ ...params });
|
|
5881
6811
|
const data = await this.http.get("/volumes", query);
|
|
5882
6812
|
return listItems15(data);
|
|
5883
6813
|
}
|
|
5884
6814
|
async get(volumeId) {
|
|
5885
6815
|
const data = await this.http.get(`/volumes/${volumeId}`);
|
|
5886
|
-
return
|
|
6816
|
+
return unwrap43(data);
|
|
5887
6817
|
}
|
|
5888
6818
|
async create(params) {
|
|
5889
6819
|
const { idempotencyKey: ikey, sizeGb, ...rest } = params;
|
|
5890
|
-
const body =
|
|
6820
|
+
const body = stripUndefined24({
|
|
5891
6821
|
...rest,
|
|
5892
6822
|
size_gb: sizeGb ?? rest.size_gb
|
|
5893
6823
|
});
|
|
@@ -5896,13 +6826,13 @@ var Volumes = class {
|
|
|
5896
6826
|
body,
|
|
5897
6827
|
headers: { "Idempotency-Key": idempotencyKey9(ikey) }
|
|
5898
6828
|
});
|
|
5899
|
-
return
|
|
6829
|
+
return unwrap43(data);
|
|
5900
6830
|
}
|
|
5901
6831
|
async delete(volumeId) {
|
|
5902
6832
|
await this.http.delete(`/volumes/${volumeId}`);
|
|
5903
6833
|
}
|
|
5904
6834
|
};
|
|
5905
|
-
function
|
|
6835
|
+
function unwrap44(payload) {
|
|
5906
6836
|
if (payload && typeof payload === "object" && "data" in payload) {
|
|
5907
6837
|
return payload.data;
|
|
5908
6838
|
}
|
|
@@ -5918,7 +6848,7 @@ function listItems16(payload, candidateKeys = ["data", "webhooks", "deliveries",
|
|
|
5918
6848
|
}
|
|
5919
6849
|
return [];
|
|
5920
6850
|
}
|
|
5921
|
-
function
|
|
6851
|
+
function stripUndefined25(input) {
|
|
5922
6852
|
return Object.fromEntries(
|
|
5923
6853
|
Object.entries(input).filter(([, v]) => v !== void 0)
|
|
5924
6854
|
);
|
|
@@ -5932,28 +6862,28 @@ var Webhooks = class {
|
|
|
5932
6862
|
}
|
|
5933
6863
|
http;
|
|
5934
6864
|
async list(params = {}) {
|
|
5935
|
-
const query =
|
|
6865
|
+
const query = stripUndefined25({ ...params });
|
|
5936
6866
|
const data = await this.http.get("/webhooks", query);
|
|
5937
6867
|
return listItems16(data);
|
|
5938
6868
|
}
|
|
5939
6869
|
async get(webhookId) {
|
|
5940
6870
|
const data = await this.http.get(`/webhooks/${webhookId}`);
|
|
5941
|
-
return
|
|
6871
|
+
return unwrap44(data);
|
|
5942
6872
|
}
|
|
5943
6873
|
async create(params) {
|
|
5944
6874
|
const { idempotencyKey: ikey, ...rest } = params;
|
|
5945
|
-
const body =
|
|
6875
|
+
const body = stripUndefined25(rest);
|
|
5946
6876
|
const data = await this.http.request("/webhooks", {
|
|
5947
6877
|
method: "POST",
|
|
5948
6878
|
body,
|
|
5949
6879
|
headers: { "Idempotency-Key": idempotencyKey10(ikey) }
|
|
5950
6880
|
});
|
|
5951
|
-
return
|
|
6881
|
+
return unwrap44(data);
|
|
5952
6882
|
}
|
|
5953
6883
|
async update(webhookId, params) {
|
|
5954
|
-
const body =
|
|
6884
|
+
const body = stripUndefined25(params);
|
|
5955
6885
|
const data = await this.http.patch(`/webhooks/${webhookId}`, body);
|
|
5956
|
-
return
|
|
6886
|
+
return unwrap44(data);
|
|
5957
6887
|
}
|
|
5958
6888
|
async delete(webhookId) {
|
|
5959
6889
|
await this.http.delete(`/webhooks/${webhookId}`);
|
|
@@ -5966,7 +6896,7 @@ var Webhooks = class {
|
|
|
5966
6896
|
headers: { "Idempotency-Key": idempotencyKey10(opts.idempotencyKey) }
|
|
5967
6897
|
}
|
|
5968
6898
|
);
|
|
5969
|
-
return
|
|
6899
|
+
return unwrap44(data);
|
|
5970
6900
|
}
|
|
5971
6901
|
async deliveries(webhookId) {
|
|
5972
6902
|
const data = await this.http.get(
|
|
@@ -5980,11 +6910,173 @@ var Webhooks = class {
|
|
|
5980
6910
|
}
|
|
5981
6911
|
};
|
|
5982
6912
|
|
|
6913
|
+
// src/resources/workspace-invites.ts
|
|
6914
|
+
var WorkspaceInvites = class {
|
|
6915
|
+
constructor(http) {
|
|
6916
|
+
this.http = http;
|
|
6917
|
+
}
|
|
6918
|
+
http;
|
|
6919
|
+
/**
|
|
6920
|
+
* Create a workspace invite or add a member directly.
|
|
6921
|
+
*
|
|
6922
|
+
* If `email` already maps to a tenant member the user is added directly and
|
|
6923
|
+
* `type === "added"` is returned with a `WorkspaceMemberRecord`. Otherwise
|
|
6924
|
+
* an invite row is created and `type === "invited"` is returned.
|
|
6925
|
+
*
|
|
6926
|
+
* `POST /workspaces/:id/invites`
|
|
6927
|
+
*/
|
|
6928
|
+
async create(workspaceId, params) {
|
|
6929
|
+
return this.http.post(
|
|
6930
|
+
`/workspaces/${workspaceId}/invites`,
|
|
6931
|
+
params
|
|
6932
|
+
);
|
|
6933
|
+
}
|
|
6934
|
+
/**
|
|
6935
|
+
* List all pending (non-expired, non-accepted, non-revoked) workspace invites.
|
|
6936
|
+
*
|
|
6937
|
+
* `GET /workspaces/:id/invites`
|
|
6938
|
+
*/
|
|
6939
|
+
async list(workspaceId) {
|
|
6940
|
+
const res = await this.http.get(
|
|
6941
|
+
`/workspaces/${workspaceId}/invites`
|
|
6942
|
+
);
|
|
6943
|
+
return res.data ?? [];
|
|
6944
|
+
}
|
|
6945
|
+
/**
|
|
6946
|
+
* Revoke a pending workspace invite.
|
|
6947
|
+
*
|
|
6948
|
+
* Already-revoked invites are idempotent (returns `revoked: true`). An invite
|
|
6949
|
+
* that was legitimately accepted throws `409 ALREADY_ACCEPTED`.
|
|
6950
|
+
*
|
|
6951
|
+
* `DELETE /workspaces/:id/invites/:invite_id`
|
|
6952
|
+
*/
|
|
6953
|
+
async revoke(workspaceId, inviteId) {
|
|
6954
|
+
return this.http.delete(
|
|
6955
|
+
`/workspaces/${workspaceId}/invites/${inviteId}`
|
|
6956
|
+
);
|
|
6957
|
+
}
|
|
6958
|
+
/**
|
|
6959
|
+
* Preview a workspace invite by token (no auth required).
|
|
6960
|
+
*
|
|
6961
|
+
* Use this to render the invite landing page before prompting the user to
|
|
6962
|
+
* log in or sign up. Returns `null` when the token is unknown or revoked.
|
|
6963
|
+
*
|
|
6964
|
+
* `GET /workspace-invites/:token`
|
|
6965
|
+
*/
|
|
6966
|
+
async preview(token) {
|
|
6967
|
+
try {
|
|
6968
|
+
const res = await this.http.get(
|
|
6969
|
+
`/workspace-invites/${token}`
|
|
6970
|
+
);
|
|
6971
|
+
return res.data ?? null;
|
|
6972
|
+
} catch {
|
|
6973
|
+
return null;
|
|
6974
|
+
}
|
|
6975
|
+
}
|
|
6976
|
+
/**
|
|
6977
|
+
* Accept a workspace invite on behalf of the authenticated user.
|
|
6978
|
+
*
|
|
6979
|
+
* The caller's JWT email must match the invite email (case-insensitive).
|
|
6980
|
+
*
|
|
6981
|
+
* Error codes:
|
|
6982
|
+
* - `INVALID_TOKEN` (404) — token not found.
|
|
6983
|
+
* - `EXPIRED` (410) — invite TTL elapsed.
|
|
6984
|
+
* - `REVOKED` (409) — invite was revoked.
|
|
6985
|
+
* - `ALREADY_ACCEPTED` (409) — already used.
|
|
6986
|
+
* - `EMAIL_MISMATCH` (422) — JWT email differs from invite email.
|
|
6987
|
+
*
|
|
6988
|
+
* `POST /workspace-invites/:token/accept`
|
|
6989
|
+
*/
|
|
6990
|
+
async accept(token) {
|
|
6991
|
+
return this.http.post(
|
|
6992
|
+
`/workspace-invites/${token}/accept`,
|
|
6993
|
+
{}
|
|
6994
|
+
);
|
|
6995
|
+
}
|
|
6996
|
+
};
|
|
6997
|
+
|
|
6998
|
+
// src/resources/workspace-members.ts
|
|
6999
|
+
var WorkspaceMembers = class {
|
|
7000
|
+
constructor(http) {
|
|
7001
|
+
this.http = http;
|
|
7002
|
+
}
|
|
7003
|
+
http;
|
|
7004
|
+
/**
|
|
7005
|
+
* List all members of a workspace.
|
|
7006
|
+
*
|
|
7007
|
+
* `GET /workspaces/:id/members`
|
|
7008
|
+
*/
|
|
7009
|
+
async list(workspaceId) {
|
|
7010
|
+
const res = await this.http.get(
|
|
7011
|
+
`/workspaces/${workspaceId}/members`
|
|
7012
|
+
);
|
|
7013
|
+
return res.data ?? res;
|
|
7014
|
+
}
|
|
7015
|
+
/**
|
|
7016
|
+
* Add an existing tenant user to a workspace.
|
|
7017
|
+
*
|
|
7018
|
+
* The `user_id` must already hold a `tenant_members` row for the parent org.
|
|
7019
|
+
* Use {@link WorkspaceInvites.create} to invite someone who is not yet an org
|
|
7020
|
+
* member.
|
|
7021
|
+
*
|
|
7022
|
+
* `POST /workspaces/:id/members`
|
|
7023
|
+
*
|
|
7024
|
+
* @throws `MiosaError` with code `NOT_TENANT_MEMBER` if the user is not an
|
|
7025
|
+
* org member.
|
|
7026
|
+
*/
|
|
7027
|
+
async add(workspaceId, params) {
|
|
7028
|
+
const res = await this.http.post(
|
|
7029
|
+
`/workspaces/${workspaceId}/members`,
|
|
7030
|
+
params
|
|
7031
|
+
);
|
|
7032
|
+
return res.data ?? res;
|
|
7033
|
+
}
|
|
7034
|
+
/**
|
|
7035
|
+
* Change a workspace member's role.
|
|
7036
|
+
*
|
|
7037
|
+
* `PATCH /workspaces/:id/members/:user_id`
|
|
7038
|
+
*/
|
|
7039
|
+
async updateRole(workspaceId, userId, params) {
|
|
7040
|
+
const res = await this.http.patch(
|
|
7041
|
+
`/workspaces/${workspaceId}/members/${userId}`,
|
|
7042
|
+
params
|
|
7043
|
+
);
|
|
7044
|
+
return res.data ?? res;
|
|
7045
|
+
}
|
|
7046
|
+
/**
|
|
7047
|
+
* Remove a user from a workspace.
|
|
7048
|
+
*
|
|
7049
|
+
* The last `owner` of a workspace cannot be removed. Promote another member
|
|
7050
|
+
* to `owner` first using {@link updateRole}.
|
|
7051
|
+
*
|
|
7052
|
+
* `DELETE /workspaces/:id/members/:user_id`
|
|
7053
|
+
*
|
|
7054
|
+
* @throws `MiosaError` with code `LAST_OWNER` if the target is the sole owner.
|
|
7055
|
+
*/
|
|
7056
|
+
async remove(workspaceId, userId) {
|
|
7057
|
+
return this.http.delete(
|
|
7058
|
+
`/workspaces/${workspaceId}/members/${userId}`
|
|
7059
|
+
);
|
|
7060
|
+
}
|
|
7061
|
+
};
|
|
7062
|
+
|
|
5983
7063
|
// src/client.ts
|
|
5984
7064
|
var DEFAULT_BASE_URL = "https://api.miosa.ai/api/v1";
|
|
5985
7065
|
var DEFAULT_TIMEOUT2 = 3e4;
|
|
5986
7066
|
var DEFAULT_MAX_RETRIES2 = 3;
|
|
5987
7067
|
var Miosa = class {
|
|
7068
|
+
/** Per-workspace user roster — list, add, update role, remove. */
|
|
7069
|
+
workspaceMembers;
|
|
7070
|
+
/**
|
|
7071
|
+
* Workspace invite flow — create invite, list, revoke, preview, accept.
|
|
7072
|
+
* Sending to an email already in the org adds the user directly.
|
|
7073
|
+
*/
|
|
7074
|
+
workspaceInvites;
|
|
7075
|
+
/**
|
|
7076
|
+
* Org invite flow — create invite, list, revoke, preview, accept.
|
|
7077
|
+
* Requires admin/owner role for write operations.
|
|
7078
|
+
*/
|
|
7079
|
+
orgInvites;
|
|
5988
7080
|
/** Current tenant plan, limits, and live usage counters. */
|
|
5989
7081
|
tenant;
|
|
5990
7082
|
/** Datacenter regions, compute sizes, pricing, community templates. */
|
|
@@ -6070,6 +7162,13 @@ var Miosa = class {
|
|
|
6070
7162
|
builderSessions;
|
|
6071
7163
|
/** Admin: fleet-wide snapshot index. */
|
|
6072
7164
|
snapshotsStandalone;
|
|
7165
|
+
// ── Egress (security) namespaces ───────────────────────────────────────────
|
|
7166
|
+
/** Encrypted secret + OAuth credential vault (`/egress/secrets`). */
|
|
7167
|
+
secrets;
|
|
7168
|
+
/** Egress allowlist + policies — host-level firewall (`/egress/policies`). */
|
|
7169
|
+
network;
|
|
7170
|
+
/** Egress audit log — every outbound request, paginated query + tail. */
|
|
7171
|
+
audit;
|
|
6073
7172
|
http;
|
|
6074
7173
|
constructor(config) {
|
|
6075
7174
|
if (!config.apiKey) {
|
|
@@ -6088,6 +7187,9 @@ var Miosa = class {
|
|
|
6088
7187
|
timeout: config.timeout ?? DEFAULT_TIMEOUT2,
|
|
6089
7188
|
maxRetries: config.maxRetries ?? DEFAULT_MAX_RETRIES2
|
|
6090
7189
|
});
|
|
7190
|
+
this.workspaceMembers = new WorkspaceMembers(this.http);
|
|
7191
|
+
this.workspaceInvites = new WorkspaceInvites(this.http);
|
|
7192
|
+
this.orgInvites = new OrgInvites(this.http);
|
|
6091
7193
|
this.tenant = new Tenant(this.http);
|
|
6092
7194
|
this.regions = new Regions(this.http);
|
|
6093
7195
|
this.settings = new Settings(this.http);
|
|
@@ -6127,9 +7229,12 @@ var Miosa = class {
|
|
|
6127
7229
|
this.email = new Email(this.http);
|
|
6128
7230
|
this.builderSessions = new BuilderSessions(this.http);
|
|
6129
7231
|
this.snapshotsStandalone = new SnapshotsStandalone(this.http);
|
|
7232
|
+
this.secrets = new EgressSecrets(this.http);
|
|
7233
|
+
this.network = new EgressNetwork(this.http);
|
|
7234
|
+
this.audit = new EgressAudit(this.http);
|
|
6130
7235
|
}
|
|
6131
7236
|
};
|
|
6132
7237
|
|
|
6133
|
-
export { Admin, Analytics, ApiKeys, AuditLog, AuthError, Benchmarks, BuilderSessions, Channels, Checkpoints, CommandCenter, Community, Completions, Computer, ComputerAutoStop, ComputerEnv, ComputerInbox, ComputerLogs, ComputerOsa, ComputerPorts, ComputerTerminal, ComputerVolumes, Computers, Credits, CronJobs, Dashboard, Databases, DeploymentDomains, DeploymentReleases, DeploymentRuntimeInstances, DeploymentVersions, Deployments, Desktop, Email, EmailCampaigns, EmailInbox, EmailTemplates, Embeddings, Exec, ExternalKeys, Files, FlatCustomDomains, Functions, HealthChecks, InsufficientCreditsError, Integrations, Mcp, Miosa, MiosaError, Models, NetworkError, NetworkPolicy, NotFoundError, OpenComputers, ProjectAuth, ProjectIntegrations, ProviderDefaults, RateLimitError, Regions, SANDBOX_TEMPLATE, Sandbox, SandboxArtifacts, SandboxCommands, SandboxEnv, SandboxEvents, SandboxFiles, SandboxPreview, SandboxPreviews, SandboxTags, SandboxTemplates, SandboxTerminal, Sandboxes, ScopedFs, Settings, SnapshotsStandalone, Storage, Tenant, TimeoutError, Usage, ValidationError, Volumes, Webhooks };
|
|
7238
|
+
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 };
|
|
6134
7239
|
//# sourceMappingURL=index.js.map
|
|
6135
7240
|
//# sourceMappingURL=index.js.map
|