@fractal_cloud/sdk 1.1.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/README.md +33 -0
- package/dist/index.cjs +258 -77
- package/dist/index.d.cts +99 -59
- package/dist/index.d.mts +99 -59
- package/dist/index.mjs +258 -77
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1143,28 +1143,61 @@ let BlueprintComponent;
|
|
|
1143
1143
|
const CLIENT_ID_HEADER$1 = "X-ClientID";
|
|
1144
1144
|
const CLIENT_SECRET_HEADER$1 = "X-ClientSecret";
|
|
1145
1145
|
const FRACTAL_API_URL$1 = "https://api.fractal.cloud";
|
|
1146
|
+
/**
|
|
1147
|
+
* Converts a raw superagent error into a descriptive Error with context.
|
|
1148
|
+
* Includes the operation name, target ID, HTTP status (if any), and response
|
|
1149
|
+
* body (if any) so the caller always knows what went wrong and where.
|
|
1150
|
+
*/
|
|
1151
|
+
const toApiError$1 = (operation, target, err) => {
|
|
1152
|
+
const e = err;
|
|
1153
|
+
const status = e.status ? `HTTP ${e.status}` : "network error";
|
|
1154
|
+
const body = e.response?.text?.trim();
|
|
1155
|
+
const detail = body ? ` — ${body}` : "";
|
|
1156
|
+
return /* @__PURE__ */ new Error(`${operation} failed (${status}) for ${target}${detail}`);
|
|
1157
|
+
};
|
|
1158
|
+
const authHeaders$1 = (credentials) => ({
|
|
1159
|
+
[CLIENT_ID_HEADER$1]: credentials.id.serviceAccountIdValue,
|
|
1160
|
+
[CLIENT_SECRET_HEADER$1]: credentials.secret
|
|
1161
|
+
});
|
|
1146
1162
|
const deployFractal = async (credentials, fractal) => {
|
|
1147
|
-
const
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1163
|
+
const target = fractal.id.toString();
|
|
1164
|
+
const fractalUrl = `${FRACTAL_API_URL$1}/blueprints/${target.replace(":", "/")}`;
|
|
1165
|
+
let getFractalResponse;
|
|
1166
|
+
try {
|
|
1167
|
+
getFractalResponse = await superagent.get(fractalUrl).ok((res) => res.status === 200 || res.status === 404).set(authHeaders$1(credentials)).send();
|
|
1168
|
+
} catch (err) {
|
|
1169
|
+
throw toApiError$1("check fractal existence", target, err);
|
|
1170
|
+
}
|
|
1171
|
+
const request = getFractalResponse.status === 200 ? superagent.put(fractalUrl) : superagent.post(fractalUrl);
|
|
1172
|
+
try {
|
|
1173
|
+
await request.set(authHeaders$1(credentials)).send({
|
|
1174
|
+
description: fractal.description,
|
|
1175
|
+
isPrivate: fractal.isPrivate,
|
|
1176
|
+
components: fractal.components.map((c) => ({
|
|
1177
|
+
...c,
|
|
1178
|
+
type: c.type.toString(),
|
|
1179
|
+
id: c.id.value.toString(),
|
|
1180
|
+
version: c.version.toString(),
|
|
1181
|
+
parameters: c.parameters.toMap(),
|
|
1182
|
+
dependencies: c.dependencies.map((d) => d.id.value.toString()),
|
|
1183
|
+
links: c.links.map((l) => ({
|
|
1184
|
+
componentId: l.id.value.toString(),
|
|
1185
|
+
settings: l.parameters.toMap()
|
|
1186
|
+
})),
|
|
1187
|
+
outputFields: Object.keys(c.outputFields.value)
|
|
1188
|
+
}))
|
|
1189
|
+
});
|
|
1190
|
+
} catch (err) {
|
|
1191
|
+
throw toApiError$1(getFractalResponse.status === 200 ? "update fractal" : "create fractal", target, err);
|
|
1192
|
+
}
|
|
1165
1193
|
};
|
|
1166
1194
|
const destroyFractal = async (credentials, id) => {
|
|
1167
|
-
|
|
1195
|
+
const target = id.toString();
|
|
1196
|
+
try {
|
|
1197
|
+
await superagent.delete(`${FRACTAL_API_URL$1}/blueprints/${target.replace(":", "/")}`).set(authHeaders$1(credentials));
|
|
1198
|
+
} catch (err) {
|
|
1199
|
+
throw toApiError$1("destroy fractal", target, err);
|
|
1200
|
+
}
|
|
1168
1201
|
};
|
|
1169
1202
|
let FractalService;
|
|
1170
1203
|
(function(_FractalService) {
|
|
@@ -1806,43 +1839,178 @@ const getLiveSystemComponentBuilder = () => {
|
|
|
1806
1839
|
const CLIENT_ID_HEADER = "X-ClientID";
|
|
1807
1840
|
const CLIENT_SECRET_HEADER = "X-ClientSecret";
|
|
1808
1841
|
const FRACTAL_API_URL = "https://api.fractal.cloud";
|
|
1809
|
-
const
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1842
|
+
const DEFAULT_POLL_INTERVAL_MS = 5e3;
|
|
1843
|
+
const DEFAULT_TIMEOUT_MS = 6e5;
|
|
1844
|
+
const TERMINAL_FAILURE_STATUSES = ["FailedMutation", "Error"];
|
|
1845
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
1846
|
+
const log = (quiet, level, message, fields) => {
|
|
1847
|
+
if (quiet) return;
|
|
1848
|
+
const ts = (/* @__PURE__ */ new Date()).toISOString();
|
|
1849
|
+
const fieldStr = fields ? " " + Object.entries(fields).map(([k, v]) => `${k}=${v}`).join(" ") : "";
|
|
1850
|
+
console.log(`[${ts}] ${level.padEnd(5)} ${message}${fieldStr}`);
|
|
1851
|
+
};
|
|
1852
|
+
const elapsedSec = (startMs) => `${Math.round((Date.now() - startMs) / 1e3)}s`;
|
|
1853
|
+
/**
|
|
1854
|
+
* Converts a raw superagent error into a descriptive Error with context.
|
|
1855
|
+
* Includes the operation name, target ID, HTTP status (if any), and response
|
|
1856
|
+
* body (if any) so the caller always knows what went wrong and where.
|
|
1857
|
+
*/
|
|
1858
|
+
const toApiError = (operation, target, err) => {
|
|
1859
|
+
const e = err;
|
|
1860
|
+
const status = e.status ? `HTTP ${e.status}` : "network error";
|
|
1861
|
+
const body = e.response?.text?.trim();
|
|
1862
|
+
const detail = body ? ` — ${body}` : "";
|
|
1863
|
+
return /* @__PURE__ */ new Error(`${operation} failed (${status}) for ${target}${detail}`);
|
|
1864
|
+
};
|
|
1865
|
+
/**
|
|
1866
|
+
* Returns true for 4xx client errors that will not self-heal on retry
|
|
1867
|
+
* (e.g. 401 Unauthorized, 403 Forbidden, 404 Not Found, 422 Unprocessable).
|
|
1868
|
+
*/
|
|
1869
|
+
const isClientError = (err) => {
|
|
1870
|
+
const status = err.status;
|
|
1871
|
+
return status !== void 0 && status >= 400 && status < 500;
|
|
1872
|
+
};
|
|
1873
|
+
const authHeaders = (credentials) => ({
|
|
1874
|
+
[CLIENT_ID_HEADER]: credentials.id.serviceAccountIdValue,
|
|
1875
|
+
[CLIENT_SECRET_HEADER]: credentials.secret
|
|
1876
|
+
});
|
|
1877
|
+
const buildBody = (liveSystem) => ({
|
|
1878
|
+
liveSystemId: liveSystem.id.toString(),
|
|
1879
|
+
fractalId: liveSystem.fractalId.toString(),
|
|
1880
|
+
description: liveSystem.description,
|
|
1881
|
+
provider: liveSystem.genericProvider,
|
|
1882
|
+
blueprintMap: liveSystem.components.reduce((acc, c) => {
|
|
1883
|
+
acc[c.id.value.toString()] = {
|
|
1884
|
+
...c,
|
|
1885
|
+
type: c.type.toString(),
|
|
1886
|
+
id: c.id.value.toString(),
|
|
1887
|
+
version: c.version.toString(),
|
|
1888
|
+
parameters: c.parameters.toMap(),
|
|
1889
|
+
dependencies: c.dependencies.map((d) => d.id.value.toString()),
|
|
1890
|
+
links: c.links.map((l) => ({
|
|
1891
|
+
componentId: l.id.value.toString(),
|
|
1892
|
+
settings: l.parameters.toMap()
|
|
1893
|
+
})),
|
|
1894
|
+
outputFields: c.outputFields.value
|
|
1895
|
+
};
|
|
1896
|
+
return acc;
|
|
1897
|
+
}, {}),
|
|
1898
|
+
parameters: liveSystem.parameters.toMap(),
|
|
1899
|
+
environment: {
|
|
1900
|
+
id: {
|
|
1901
|
+
type: liveSystem.environment.id.ownerType,
|
|
1902
|
+
ownerId: liveSystem.environment.id.ownerId.toString(),
|
|
1903
|
+
shortName: liveSystem.environment.id.name.toString()
|
|
1904
|
+
},
|
|
1905
|
+
parameters: liveSystem.environment.parameters.toMap()
|
|
1906
|
+
}
|
|
1907
|
+
});
|
|
1908
|
+
const submitDeploy = async (credentials, liveSystem) => {
|
|
1909
|
+
const target = liveSystem.id.toString();
|
|
1910
|
+
const liveSystemUrl = `${FRACTAL_API_URL}/livesystems/${target}`;
|
|
1911
|
+
let getResponse;
|
|
1912
|
+
try {
|
|
1913
|
+
getResponse = await superagent.get(liveSystemUrl).ok((res) => res.status === 200 || res.status === 404).set(authHeaders(credentials)).send();
|
|
1914
|
+
} catch (err) {
|
|
1915
|
+
throw toApiError("check live system existence", target, err);
|
|
1916
|
+
}
|
|
1917
|
+
const request = getResponse.status === 200 ? superagent.put(liveSystemUrl) : superagent.post(`${FRACTAL_API_URL}/livesystems`);
|
|
1918
|
+
try {
|
|
1919
|
+
await request.set(authHeaders(credentials)).send(buildBody(liveSystem));
|
|
1920
|
+
} catch (err) {
|
|
1921
|
+
throw toApiError(getResponse.status === 200 ? "update live system" : "create live system", target, err);
|
|
1922
|
+
}
|
|
1923
|
+
};
|
|
1924
|
+
const getLiveSystemStatus = async (credentials, id) => {
|
|
1925
|
+
try {
|
|
1926
|
+
return (await superagent.get(`${FRACTAL_API_URL}/livesystems/${id.toString()}`).set(authHeaders(credentials)).send()).body.status;
|
|
1927
|
+
} catch (err) {
|
|
1928
|
+
throw toApiError("get live system status", id.toString(), err);
|
|
1929
|
+
}
|
|
1930
|
+
};
|
|
1931
|
+
const pollUntilActive = async (credentials, id, options, startMs) => {
|
|
1932
|
+
const quiet = options.quiet ?? false;
|
|
1933
|
+
const interval = options.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;
|
|
1934
|
+
const timeout = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
1935
|
+
const deadline = Date.now() + timeout;
|
|
1936
|
+
let round = 0;
|
|
1937
|
+
while (Date.now() < deadline) {
|
|
1938
|
+
await sleep(interval);
|
|
1939
|
+
round++;
|
|
1940
|
+
let status;
|
|
1941
|
+
try {
|
|
1942
|
+
status = await getLiveSystemStatus(credentials, id);
|
|
1943
|
+
} catch (err) {
|
|
1944
|
+
if (isClientError(err)) {
|
|
1945
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
1946
|
+
log(quiet, "ERROR", "Fatal error polling Live System status", {
|
|
1947
|
+
system: id.toString(),
|
|
1948
|
+
round,
|
|
1949
|
+
elapsed: elapsedSec(startMs),
|
|
1950
|
+
error: message
|
|
1951
|
+
});
|
|
1952
|
+
throw err;
|
|
1953
|
+
}
|
|
1954
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
1955
|
+
log(quiet, "WARN", "Transient error polling status, will retry", {
|
|
1956
|
+
system: id.toString(),
|
|
1957
|
+
round,
|
|
1958
|
+
elapsed: elapsedSec(startMs),
|
|
1959
|
+
error: message
|
|
1960
|
+
});
|
|
1961
|
+
continue;
|
|
1839
1962
|
}
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1963
|
+
if (status === "Active") return;
|
|
1964
|
+
if (TERMINAL_FAILURE_STATUSES.includes(status)) {
|
|
1965
|
+
log(quiet, "ERROR", "Live System deployment failed", {
|
|
1966
|
+
system: id.toString(),
|
|
1967
|
+
status,
|
|
1968
|
+
elapsed: elapsedSec(startMs)
|
|
1969
|
+
});
|
|
1970
|
+
throw new Error(`Live system deployment failed with status: ${status} — check the Fractal Cloud console for component-level errors`);
|
|
1971
|
+
}
|
|
1972
|
+
log(quiet, "CHECK", "Polling Live System status", {
|
|
1973
|
+
system: id.toString(),
|
|
1974
|
+
round,
|
|
1975
|
+
status,
|
|
1976
|
+
elapsed: elapsedSec(startMs)
|
|
1977
|
+
});
|
|
1978
|
+
}
|
|
1979
|
+
log(quiet, "ERROR", "Live System deployment timed out", {
|
|
1980
|
+
system: id.toString(),
|
|
1981
|
+
elapsed: elapsedSec(startMs),
|
|
1982
|
+
timeoutMs: timeout
|
|
1983
|
+
});
|
|
1984
|
+
throw new Error(`Live system deployment timed out after ${timeout}ms. Increase timeoutMs in DeployOptions if provisioning takes longer.`);
|
|
1985
|
+
};
|
|
1986
|
+
const deployLiveSystem = async (credentials, liveSystem, options = { mode: "fire-and-forget" }) => {
|
|
1987
|
+
if (options.mode === "fire-and-forget") {
|
|
1988
|
+
submitDeploy(credentials, liveSystem).catch((err) => {
|
|
1989
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
1990
|
+
console.error(`[Fractal] live system deploy error: ${message}`);
|
|
1991
|
+
});
|
|
1992
|
+
return;
|
|
1993
|
+
}
|
|
1994
|
+
const quiet = options.quiet ?? false;
|
|
1995
|
+
const startMs = Date.now();
|
|
1996
|
+
log(quiet, "INFO", "Deploying Live System", {
|
|
1997
|
+
system: liveSystem.id.toString(),
|
|
1998
|
+
fractal: liveSystem.fractalId.toString(),
|
|
1999
|
+
provider: liveSystem.genericProvider
|
|
2000
|
+
});
|
|
2001
|
+
await submitDeploy(credentials, liveSystem);
|
|
2002
|
+
await pollUntilActive(credentials, liveSystem.id, options, startMs);
|
|
2003
|
+
log(quiet, "INFO", "Live System Active", {
|
|
2004
|
+
system: liveSystem.id.toString(),
|
|
2005
|
+
elapsed: elapsedSec(startMs)
|
|
2006
|
+
});
|
|
1843
2007
|
};
|
|
1844
2008
|
const destroyLiveSystem = async (credentials, id) => {
|
|
1845
|
-
|
|
2009
|
+
try {
|
|
2010
|
+
await superagent.delete(`${FRACTAL_API_URL}/livesystems/${id.toString()}`).set(authHeaders(credentials));
|
|
2011
|
+
} catch (err) {
|
|
2012
|
+
throw toApiError("destroy live system", id.toString(), err);
|
|
2013
|
+
}
|
|
1846
2014
|
};
|
|
1847
2015
|
let LiveSystemService;
|
|
1848
2016
|
(function(_LiveSystemService) {
|
|
@@ -1987,7 +2155,7 @@ const getLiveSystemBuilder = () => {
|
|
|
1987
2155
|
if (validationErrors.length > 0) throw new SyntaxError(validationErrors.join("\n"));
|
|
1988
2156
|
return {
|
|
1989
2157
|
...internalState,
|
|
1990
|
-
deploy: (credentials) => LiveSystemService.deploy(credentials, internalState),
|
|
2158
|
+
deploy: (credentials, options) => LiveSystemService.deploy(credentials, internalState, options),
|
|
1991
2159
|
destroy: (credentials) => LiveSystemService.destroy(credentials, internalState.id)
|
|
1992
2160
|
};
|
|
1993
2161
|
}
|
|
@@ -2026,7 +2194,7 @@ function buildVirtualNetworkType() {
|
|
|
2026
2194
|
function pushParam$25(params, key, value) {
|
|
2027
2195
|
params.push(key, value);
|
|
2028
2196
|
}
|
|
2029
|
-
function
|
|
2197
|
+
function makeVirtualNetworkComponent(vpc, subnetNodes, sgs) {
|
|
2030
2198
|
const vpcDep = { id: vpc.id };
|
|
2031
2199
|
const wiredSubnets = subnetNodes.map((n) => ({
|
|
2032
2200
|
...n.subnet,
|
|
@@ -2051,8 +2219,8 @@ function makeVirtualNetworkNode(vpc, subnetNodes, sgs) {
|
|
|
2051
2219
|
...allVMs,
|
|
2052
2220
|
...allEcsSvcs
|
|
2053
2221
|
],
|
|
2054
|
-
withSubnets: (newSubnets) =>
|
|
2055
|
-
withSecurityGroups: (newSgs) =>
|
|
2222
|
+
withSubnets: (newSubnets) => makeVirtualNetworkComponent(vpc, newSubnets, sgs),
|
|
2223
|
+
withSecurityGroups: (newSgs) => makeVirtualNetworkComponent(vpc, subnetNodes, newSgs)
|
|
2056
2224
|
};
|
|
2057
2225
|
}
|
|
2058
2226
|
let VirtualNetwork;
|
|
@@ -2128,7 +2296,7 @@ let VirtualNetwork;
|
|
|
2128
2296
|
const b = getBuilder().withId(config.id).withVersion(config.version.major, config.version.minor, config.version.patch).withDisplayName(config.displayName);
|
|
2129
2297
|
if (config.cidrBlock) b.withCidrBlock(config.cidrBlock);
|
|
2130
2298
|
if (config.description) b.withDescription(config.description);
|
|
2131
|
-
return
|
|
2299
|
+
return makeVirtualNetworkComponent(b.build().vpc, [], []);
|
|
2132
2300
|
};
|
|
2133
2301
|
})(VirtualNetwork || (VirtualNetwork = {}));
|
|
2134
2302
|
|
|
@@ -2148,7 +2316,7 @@ function buildSubnetType() {
|
|
|
2148
2316
|
function pushParam$24(params, key, value) {
|
|
2149
2317
|
params.push(key, value);
|
|
2150
2318
|
}
|
|
2151
|
-
function
|
|
2319
|
+
function makeSubnetComponent(subnet, vms, workloadNodes) {
|
|
2152
2320
|
const subnetDep = { id: subnet.id };
|
|
2153
2321
|
const wiredVMs = vms.map((n) => ({
|
|
2154
2322
|
...n.component,
|
|
@@ -2167,8 +2335,8 @@ function makeSubnetNode(subnet, vms, workloadNodes) {
|
|
|
2167
2335
|
...wiredVMs,
|
|
2168
2336
|
...wiredWorkloads
|
|
2169
2337
|
],
|
|
2170
|
-
withVirtualMachines: (newVMs) =>
|
|
2171
|
-
withWorkloads: (newWorkloads) =>
|
|
2338
|
+
withVirtualMachines: (newVMs) => makeSubnetComponent(subnet, newVMs, workloadNodes),
|
|
2339
|
+
withWorkloads: (newWorkloads) => makeSubnetComponent(subnet, vms, newWorkloads)
|
|
2172
2340
|
};
|
|
2173
2341
|
}
|
|
2174
2342
|
let Subnet;
|
|
@@ -2226,7 +2394,7 @@ let Subnet;
|
|
|
2226
2394
|
const b = getBuilder().withId(config.id).withVersion(config.version.major, config.version.minor, config.version.patch).withDisplayName(config.displayName);
|
|
2227
2395
|
if (config.cidrBlock) b.withCidrBlock(config.cidrBlock);
|
|
2228
2396
|
if (config.description) b.withDescription(config.description);
|
|
2229
|
-
return
|
|
2397
|
+
return makeSubnetComponent(b.build().subnet, [], []);
|
|
2230
2398
|
};
|
|
2231
2399
|
})(Subnet || (Subnet = {}));
|
|
2232
2400
|
|
|
@@ -2308,16 +2476,23 @@ function buildLinkParams$1(link) {
|
|
|
2308
2476
|
if (link.protocol) params.push("protocol", link.protocol);
|
|
2309
2477
|
return params;
|
|
2310
2478
|
}
|
|
2311
|
-
function
|
|
2479
|
+
function makeVirtualMachineComponent(component) {
|
|
2312
2480
|
return {
|
|
2313
2481
|
component,
|
|
2314
2482
|
components: [component],
|
|
2315
|
-
|
|
2483
|
+
linkToVirtualMachine: (links) => {
|
|
2316
2484
|
const componentLinks = links.map((l) => getLinkBuilder().withId(l.target.component.id).withType(buildVirtualMachineType()).withParameters(buildLinkParams$1(l)).build());
|
|
2317
|
-
return
|
|
2485
|
+
return makeVirtualMachineComponent({
|
|
2318
2486
|
...component,
|
|
2319
2487
|
links: [...component.links, ...componentLinks]
|
|
2320
2488
|
});
|
|
2489
|
+
},
|
|
2490
|
+
linkToSecurityGroup: (sgs) => {
|
|
2491
|
+
const sgLinks = sgs.map((sg) => getLinkBuilder().withId(sg.id).withType(sg.type).withParameters(getParametersInstance()).build());
|
|
2492
|
+
return makeVirtualMachineComponent({
|
|
2493
|
+
...component,
|
|
2494
|
+
links: [...component.links, ...sgLinks]
|
|
2495
|
+
});
|
|
2321
2496
|
}
|
|
2322
2497
|
};
|
|
2323
2498
|
}
|
|
@@ -2353,7 +2528,7 @@ let VirtualMachine;
|
|
|
2353
2528
|
_VirtualMachine.create = (config) => {
|
|
2354
2529
|
const b = getBuilder().withId(config.id).withVersion(config.version.major, config.version.minor, config.version.patch).withDisplayName(config.displayName);
|
|
2355
2530
|
if (config.description) b.withDescription(config.description);
|
|
2356
|
-
return
|
|
2531
|
+
return makeVirtualMachineComponent(b.build());
|
|
2357
2532
|
};
|
|
2358
2533
|
})(VirtualMachine || (VirtualMachine = {}));
|
|
2359
2534
|
|
|
@@ -2524,7 +2699,7 @@ let AwsSubnet;
|
|
|
2524
2699
|
|
|
2525
2700
|
//#endregion
|
|
2526
2701
|
//#region src/live_system/component/network_and_compute/iaas/security_group.ts
|
|
2527
|
-
const AWS_SG_TYPE_NAME = "
|
|
2702
|
+
const AWS_SG_TYPE_NAME = "SecurityGroup";
|
|
2528
2703
|
function buildId$22(id) {
|
|
2529
2704
|
return getComponentIdBuilder().withValue(KebabCaseString$1.getBuilder().withValue(id).build()).build();
|
|
2530
2705
|
}
|
|
@@ -4106,7 +4281,7 @@ function buildVersion$4(major, minor, patch) {
|
|
|
4106
4281
|
function buildContainerPlatformType() {
|
|
4107
4282
|
return getBlueprintComponentTypeBuilder().withInfrastructureDomain(InfrastructureDomain$1.NetworkAndCompute).withServiceDeliveryModel(ServiceDeliveryModel$1.PaaS).withName(PascalCaseString$1.getBuilder().withValue(CONTAINER_PLATFORM_TYPE_NAME).build()).build();
|
|
4108
4283
|
}
|
|
4109
|
-
function
|
|
4284
|
+
function makeContainerPlatformComponent(platform, workloadNodes) {
|
|
4110
4285
|
const platformDep = { id: platform.id };
|
|
4111
4286
|
return {
|
|
4112
4287
|
platform,
|
|
@@ -4117,7 +4292,7 @@ function makeContainerPlatformNode(platform, workloadNodes) {
|
|
|
4117
4292
|
dependencies: [...w.component.dependencies, platformDep]
|
|
4118
4293
|
}
|
|
4119
4294
|
})),
|
|
4120
|
-
withWorkloads: (newWorkloads) =>
|
|
4295
|
+
withWorkloads: (newWorkloads) => makeContainerPlatformComponent(platform, newWorkloads)
|
|
4121
4296
|
};
|
|
4122
4297
|
}
|
|
4123
4298
|
let ContainerPlatform;
|
|
@@ -4149,7 +4324,7 @@ let ContainerPlatform;
|
|
|
4149
4324
|
_ContainerPlatform.create = (config) => {
|
|
4150
4325
|
const b = getBuilder().withId(config.id).withVersion(config.version.major, config.version.minor, config.version.patch).withDisplayName(config.displayName);
|
|
4151
4326
|
if (config.description) b.withDescription(config.description);
|
|
4152
|
-
return
|
|
4327
|
+
return makeContainerPlatformComponent(b.build(), []);
|
|
4153
4328
|
};
|
|
4154
4329
|
})(ContainerPlatform || (ContainerPlatform = {}));
|
|
4155
4330
|
|
|
@@ -4181,20 +4356,20 @@ function buildLinkParams(fromPort, toPort, protocol) {
|
|
|
4181
4356
|
if (protocol) p.push("protocol", protocol);
|
|
4182
4357
|
return p;
|
|
4183
4358
|
}
|
|
4184
|
-
function
|
|
4359
|
+
function makeWorkloadComponent(component) {
|
|
4185
4360
|
return {
|
|
4186
4361
|
component,
|
|
4187
4362
|
components: [component],
|
|
4188
|
-
|
|
4363
|
+
linkToWorkload: (links) => {
|
|
4189
4364
|
const portLinks = links.map((l) => getLinkBuilder().withId(l.target.component.id).withType(buildWorkloadType()).withParameters(buildLinkParams(l.fromPort, l.toPort, l.protocol)).build());
|
|
4190
|
-
return
|
|
4365
|
+
return makeWorkloadComponent({
|
|
4191
4366
|
...component,
|
|
4192
4367
|
links: [...component.links, ...portLinks]
|
|
4193
4368
|
});
|
|
4194
4369
|
},
|
|
4195
|
-
|
|
4370
|
+
linkToSecurityGroup: (sgs) => {
|
|
4196
4371
|
const sgLinks = sgs.map((sg) => getLinkBuilder().withId(sg.id).withType(sg.type).withParameters(getParametersInstance()).build());
|
|
4197
|
-
return
|
|
4372
|
+
return makeWorkloadComponent({
|
|
4198
4373
|
...component,
|
|
4199
4374
|
links: [...component.links, ...sgLinks]
|
|
4200
4375
|
});
|
|
@@ -4259,7 +4434,7 @@ let Workload;
|
|
|
4259
4434
|
if (config.cpu) b.withCpu(config.cpu);
|
|
4260
4435
|
if (config.memory) b.withMemory(config.memory);
|
|
4261
4436
|
if (config.desiredCount !== void 0) b.withDesiredCount(config.desiredCount);
|
|
4262
|
-
return
|
|
4437
|
+
return makeWorkloadComponent(b.build());
|
|
4263
4438
|
};
|
|
4264
4439
|
})(Workload || (Workload = {}));
|
|
4265
4440
|
|
|
@@ -4492,7 +4667,8 @@ let AwsEcsService;
|
|
|
4492
4667
|
};
|
|
4493
4668
|
_AwsEcsService.satisfy = (workload) => {
|
|
4494
4669
|
const params = getParametersInstance();
|
|
4495
|
-
const
|
|
4670
|
+
const deps = [...workload.dependencies];
|
|
4671
|
+
const inner = getLiveSystemComponentBuilder().withType(buildAwsEcsServiceType()).withParameters(params).withProvider("AWS").withId(buildId(workload.id.toString())).withVersion(buildVersion(workload.version.major, workload.version.minor, workload.version.patch)).withDisplayName(workload.displayName).withDependencies(deps).withLinks(workload.links);
|
|
4496
4672
|
if (workload.description) inner.withDescription(workload.description);
|
|
4497
4673
|
const desiredCount = workload.parameters.getOptionalFieldByName(DESIRED_COUNT_PARAM);
|
|
4498
4674
|
if (desiredCount !== null) pushParam(params, DESIRED_COUNT_PARAM, desiredCount);
|
|
@@ -4505,6 +4681,11 @@ let AwsEcsService;
|
|
|
4505
4681
|
pushParam(params, ASSIGN_PUBLIC_IP_PARAM, assign);
|
|
4506
4682
|
return satisfiedBuilder;
|
|
4507
4683
|
},
|
|
4684
|
+
withTaskDefinition: (taskDef) => {
|
|
4685
|
+
deps.push({ id: taskDef.id });
|
|
4686
|
+
inner.withDependencies(deps);
|
|
4687
|
+
return satisfiedBuilder;
|
|
4688
|
+
},
|
|
4508
4689
|
build: () => inner.build()
|
|
4509
4690
|
};
|
|
4510
4691
|
return satisfiedBuilder;
|