@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/README.md
CHANGED
|
@@ -178,6 +178,39 @@ await getLiveSystem().deploy(credentials);
|
|
|
178
178
|
|
|
179
179
|
The blueprint is registered with Fractal Cloud. The Automation Engine reconciles cloud resources to match the Live System definition.
|
|
180
180
|
|
|
181
|
+
## Deployment modes
|
|
182
|
+
|
|
183
|
+
`liveSystem.deploy()` supports two modes via an optional `DeployOptions` argument.
|
|
184
|
+
|
|
185
|
+
### Fire and forget (default)
|
|
186
|
+
|
|
187
|
+
Submits the live system to Fractal Cloud and returns immediately. Provisioning happens asynchronously. Errors are logged but not thrown. This is the default when no options are passed.
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
// Equivalent — both are fire-and-forget
|
|
191
|
+
await liveSystem.deploy(credentials);
|
|
192
|
+
await liveSystem.deploy(credentials, {mode: 'fire-and-forget'});
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Best for: **applications, CLIs, scripts** where infrastructure deployment is a background concern.
|
|
196
|
+
|
|
197
|
+
### Wait for Active
|
|
198
|
+
|
|
199
|
+
Submits the live system, then polls until all components reach `Active` status. Throws if deployment fails (`FailedMutation`, `Error`) or if the timeout is exceeded.
|
|
200
|
+
|
|
201
|
+
```typescript
|
|
202
|
+
await liveSystem.deploy(credentials, {
|
|
203
|
+
mode: 'wait',
|
|
204
|
+
pollIntervalMs: 10_000, // check every 10 s (default: 5 s)
|
|
205
|
+
timeoutMs: 900_000, // give up after 15 min (default: 10 min)
|
|
206
|
+
});
|
|
207
|
+
// reaches here only when the live system is fully Active
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
Best for: **CI/CD pipelines** where the pipeline must not advance until infrastructure is fully provisioned.
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
181
214
|
## Multi-provider support
|
|
182
215
|
|
|
183
216
|
The same blueprint can be deployed on any supported provider. Live system files are short and only contain vendor-specific parameters — all structural decisions (dependencies, traffic rules, security rules) stay in the blueprint.
|
package/dist/index.cjs
CHANGED
|
@@ -1172,28 +1172,61 @@ let BlueprintComponent;
|
|
|
1172
1172
|
const CLIENT_ID_HEADER$1 = "X-ClientID";
|
|
1173
1173
|
const CLIENT_SECRET_HEADER$1 = "X-ClientSecret";
|
|
1174
1174
|
const FRACTAL_API_URL$1 = "https://api.fractal.cloud";
|
|
1175
|
+
/**
|
|
1176
|
+
* Converts a raw superagent error into a descriptive Error with context.
|
|
1177
|
+
* Includes the operation name, target ID, HTTP status (if any), and response
|
|
1178
|
+
* body (if any) so the caller always knows what went wrong and where.
|
|
1179
|
+
*/
|
|
1180
|
+
const toApiError$1 = (operation, target, err) => {
|
|
1181
|
+
const e = err;
|
|
1182
|
+
const status = e.status ? `HTTP ${e.status}` : "network error";
|
|
1183
|
+
const body = e.response?.text?.trim();
|
|
1184
|
+
const detail = body ? ` — ${body}` : "";
|
|
1185
|
+
return /* @__PURE__ */ new Error(`${operation} failed (${status}) for ${target}${detail}`);
|
|
1186
|
+
};
|
|
1187
|
+
const authHeaders$1 = (credentials) => ({
|
|
1188
|
+
[CLIENT_ID_HEADER$1]: credentials.id.serviceAccountIdValue,
|
|
1189
|
+
[CLIENT_SECRET_HEADER$1]: credentials.secret
|
|
1190
|
+
});
|
|
1175
1191
|
const deployFractal = async (credentials, fractal) => {
|
|
1176
|
-
const
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1192
|
+
const target = fractal.id.toString();
|
|
1193
|
+
const fractalUrl = `${FRACTAL_API_URL$1}/blueprints/${target.replace(":", "/")}`;
|
|
1194
|
+
let getFractalResponse;
|
|
1195
|
+
try {
|
|
1196
|
+
getFractalResponse = await superagent.default.get(fractalUrl).ok((res) => res.status === 200 || res.status === 404).set(authHeaders$1(credentials)).send();
|
|
1197
|
+
} catch (err) {
|
|
1198
|
+
throw toApiError$1("check fractal existence", target, err);
|
|
1199
|
+
}
|
|
1200
|
+
const request = getFractalResponse.status === 200 ? superagent.default.put(fractalUrl) : superagent.default.post(fractalUrl);
|
|
1201
|
+
try {
|
|
1202
|
+
await request.set(authHeaders$1(credentials)).send({
|
|
1203
|
+
description: fractal.description,
|
|
1204
|
+
isPrivate: fractal.isPrivate,
|
|
1205
|
+
components: fractal.components.map((c) => ({
|
|
1206
|
+
...c,
|
|
1207
|
+
type: c.type.toString(),
|
|
1208
|
+
id: c.id.value.toString(),
|
|
1209
|
+
version: c.version.toString(),
|
|
1210
|
+
parameters: c.parameters.toMap(),
|
|
1211
|
+
dependencies: c.dependencies.map((d) => d.id.value.toString()),
|
|
1212
|
+
links: c.links.map((l) => ({
|
|
1213
|
+
componentId: l.id.value.toString(),
|
|
1214
|
+
settings: l.parameters.toMap()
|
|
1215
|
+
})),
|
|
1216
|
+
outputFields: Object.keys(c.outputFields.value)
|
|
1217
|
+
}))
|
|
1218
|
+
});
|
|
1219
|
+
} catch (err) {
|
|
1220
|
+
throw toApiError$1(getFractalResponse.status === 200 ? "update fractal" : "create fractal", target, err);
|
|
1221
|
+
}
|
|
1194
1222
|
};
|
|
1195
1223
|
const destroyFractal = async (credentials, id) => {
|
|
1196
|
-
|
|
1224
|
+
const target = id.toString();
|
|
1225
|
+
try {
|
|
1226
|
+
await superagent.default.delete(`${FRACTAL_API_URL$1}/blueprints/${target.replace(":", "/")}`).set(authHeaders$1(credentials));
|
|
1227
|
+
} catch (err) {
|
|
1228
|
+
throw toApiError$1("destroy fractal", target, err);
|
|
1229
|
+
}
|
|
1197
1230
|
};
|
|
1198
1231
|
let FractalService;
|
|
1199
1232
|
(function(_FractalService) {
|
|
@@ -1835,43 +1868,178 @@ const getLiveSystemComponentBuilder = () => {
|
|
|
1835
1868
|
const CLIENT_ID_HEADER = "X-ClientID";
|
|
1836
1869
|
const CLIENT_SECRET_HEADER = "X-ClientSecret";
|
|
1837
1870
|
const FRACTAL_API_URL = "https://api.fractal.cloud";
|
|
1838
|
-
const
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1871
|
+
const DEFAULT_POLL_INTERVAL_MS = 5e3;
|
|
1872
|
+
const DEFAULT_TIMEOUT_MS = 6e5;
|
|
1873
|
+
const TERMINAL_FAILURE_STATUSES = ["FailedMutation", "Error"];
|
|
1874
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
1875
|
+
const log = (quiet, level, message, fields) => {
|
|
1876
|
+
if (quiet) return;
|
|
1877
|
+
const ts = (/* @__PURE__ */ new Date()).toISOString();
|
|
1878
|
+
const fieldStr = fields ? " " + Object.entries(fields).map(([k, v]) => `${k}=${v}`).join(" ") : "";
|
|
1879
|
+
console.log(`[${ts}] ${level.padEnd(5)} ${message}${fieldStr}`);
|
|
1880
|
+
};
|
|
1881
|
+
const elapsedSec = (startMs) => `${Math.round((Date.now() - startMs) / 1e3)}s`;
|
|
1882
|
+
/**
|
|
1883
|
+
* Converts a raw superagent error into a descriptive Error with context.
|
|
1884
|
+
* Includes the operation name, target ID, HTTP status (if any), and response
|
|
1885
|
+
* body (if any) so the caller always knows what went wrong and where.
|
|
1886
|
+
*/
|
|
1887
|
+
const toApiError = (operation, target, err) => {
|
|
1888
|
+
const e = err;
|
|
1889
|
+
const status = e.status ? `HTTP ${e.status}` : "network error";
|
|
1890
|
+
const body = e.response?.text?.trim();
|
|
1891
|
+
const detail = body ? ` — ${body}` : "";
|
|
1892
|
+
return /* @__PURE__ */ new Error(`${operation} failed (${status}) for ${target}${detail}`);
|
|
1893
|
+
};
|
|
1894
|
+
/**
|
|
1895
|
+
* Returns true for 4xx client errors that will not self-heal on retry
|
|
1896
|
+
* (e.g. 401 Unauthorized, 403 Forbidden, 404 Not Found, 422 Unprocessable).
|
|
1897
|
+
*/
|
|
1898
|
+
const isClientError = (err) => {
|
|
1899
|
+
const status = err.status;
|
|
1900
|
+
return status !== void 0 && status >= 400 && status < 500;
|
|
1901
|
+
};
|
|
1902
|
+
const authHeaders = (credentials) => ({
|
|
1903
|
+
[CLIENT_ID_HEADER]: credentials.id.serviceAccountIdValue,
|
|
1904
|
+
[CLIENT_SECRET_HEADER]: credentials.secret
|
|
1905
|
+
});
|
|
1906
|
+
const buildBody = (liveSystem) => ({
|
|
1907
|
+
liveSystemId: liveSystem.id.toString(),
|
|
1908
|
+
fractalId: liveSystem.fractalId.toString(),
|
|
1909
|
+
description: liveSystem.description,
|
|
1910
|
+
provider: liveSystem.genericProvider,
|
|
1911
|
+
blueprintMap: liveSystem.components.reduce((acc, c) => {
|
|
1912
|
+
acc[c.id.value.toString()] = {
|
|
1913
|
+
...c,
|
|
1914
|
+
type: c.type.toString(),
|
|
1915
|
+
id: c.id.value.toString(),
|
|
1916
|
+
version: c.version.toString(),
|
|
1917
|
+
parameters: c.parameters.toMap(),
|
|
1918
|
+
dependencies: c.dependencies.map((d) => d.id.value.toString()),
|
|
1919
|
+
links: c.links.map((l) => ({
|
|
1920
|
+
componentId: l.id.value.toString(),
|
|
1921
|
+
settings: l.parameters.toMap()
|
|
1922
|
+
})),
|
|
1923
|
+
outputFields: c.outputFields.value
|
|
1924
|
+
};
|
|
1925
|
+
return acc;
|
|
1926
|
+
}, {}),
|
|
1927
|
+
parameters: liveSystem.parameters.toMap(),
|
|
1928
|
+
environment: {
|
|
1929
|
+
id: {
|
|
1930
|
+
type: liveSystem.environment.id.ownerType,
|
|
1931
|
+
ownerId: liveSystem.environment.id.ownerId.toString(),
|
|
1932
|
+
shortName: liveSystem.environment.id.name.toString()
|
|
1933
|
+
},
|
|
1934
|
+
parameters: liveSystem.environment.parameters.toMap()
|
|
1935
|
+
}
|
|
1936
|
+
});
|
|
1937
|
+
const submitDeploy = async (credentials, liveSystem) => {
|
|
1938
|
+
const target = liveSystem.id.toString();
|
|
1939
|
+
const liveSystemUrl = `${FRACTAL_API_URL}/livesystems/${target}`;
|
|
1940
|
+
let getResponse;
|
|
1941
|
+
try {
|
|
1942
|
+
getResponse = await superagent.default.get(liveSystemUrl).ok((res) => res.status === 200 || res.status === 404).set(authHeaders(credentials)).send();
|
|
1943
|
+
} catch (err) {
|
|
1944
|
+
throw toApiError("check live system existence", target, err);
|
|
1945
|
+
}
|
|
1946
|
+
const request = getResponse.status === 200 ? superagent.default.put(liveSystemUrl) : superagent.default.post(`${FRACTAL_API_URL}/livesystems`);
|
|
1947
|
+
try {
|
|
1948
|
+
await request.set(authHeaders(credentials)).send(buildBody(liveSystem));
|
|
1949
|
+
} catch (err) {
|
|
1950
|
+
throw toApiError(getResponse.status === 200 ? "update live system" : "create live system", target, err);
|
|
1951
|
+
}
|
|
1952
|
+
};
|
|
1953
|
+
const getLiveSystemStatus = async (credentials, id) => {
|
|
1954
|
+
try {
|
|
1955
|
+
return (await superagent.default.get(`${FRACTAL_API_URL}/livesystems/${id.toString()}`).set(authHeaders(credentials)).send()).body.status;
|
|
1956
|
+
} catch (err) {
|
|
1957
|
+
throw toApiError("get live system status", id.toString(), err);
|
|
1958
|
+
}
|
|
1959
|
+
};
|
|
1960
|
+
const pollUntilActive = async (credentials, id, options, startMs) => {
|
|
1961
|
+
const quiet = options.quiet ?? false;
|
|
1962
|
+
const interval = options.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;
|
|
1963
|
+
const timeout = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
1964
|
+
const deadline = Date.now() + timeout;
|
|
1965
|
+
let round = 0;
|
|
1966
|
+
while (Date.now() < deadline) {
|
|
1967
|
+
await sleep(interval);
|
|
1968
|
+
round++;
|
|
1969
|
+
let status;
|
|
1970
|
+
try {
|
|
1971
|
+
status = await getLiveSystemStatus(credentials, id);
|
|
1972
|
+
} catch (err) {
|
|
1973
|
+
if (isClientError(err)) {
|
|
1974
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
1975
|
+
log(quiet, "ERROR", "Fatal error polling Live System status", {
|
|
1976
|
+
system: id.toString(),
|
|
1977
|
+
round,
|
|
1978
|
+
elapsed: elapsedSec(startMs),
|
|
1979
|
+
error: message
|
|
1980
|
+
});
|
|
1981
|
+
throw err;
|
|
1982
|
+
}
|
|
1983
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
1984
|
+
log(quiet, "WARN", "Transient error polling status, will retry", {
|
|
1985
|
+
system: id.toString(),
|
|
1986
|
+
round,
|
|
1987
|
+
elapsed: elapsedSec(startMs),
|
|
1988
|
+
error: message
|
|
1989
|
+
});
|
|
1990
|
+
continue;
|
|
1868
1991
|
}
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1992
|
+
if (status === "Active") return;
|
|
1993
|
+
if (TERMINAL_FAILURE_STATUSES.includes(status)) {
|
|
1994
|
+
log(quiet, "ERROR", "Live System deployment failed", {
|
|
1995
|
+
system: id.toString(),
|
|
1996
|
+
status,
|
|
1997
|
+
elapsed: elapsedSec(startMs)
|
|
1998
|
+
});
|
|
1999
|
+
throw new Error(`Live system deployment failed with status: ${status} — check the Fractal Cloud console for component-level errors`);
|
|
2000
|
+
}
|
|
2001
|
+
log(quiet, "CHECK", "Polling Live System status", {
|
|
2002
|
+
system: id.toString(),
|
|
2003
|
+
round,
|
|
2004
|
+
status,
|
|
2005
|
+
elapsed: elapsedSec(startMs)
|
|
2006
|
+
});
|
|
2007
|
+
}
|
|
2008
|
+
log(quiet, "ERROR", "Live System deployment timed out", {
|
|
2009
|
+
system: id.toString(),
|
|
2010
|
+
elapsed: elapsedSec(startMs),
|
|
2011
|
+
timeoutMs: timeout
|
|
2012
|
+
});
|
|
2013
|
+
throw new Error(`Live system deployment timed out after ${timeout}ms. Increase timeoutMs in DeployOptions if provisioning takes longer.`);
|
|
2014
|
+
};
|
|
2015
|
+
const deployLiveSystem = async (credentials, liveSystem, options = { mode: "fire-and-forget" }) => {
|
|
2016
|
+
if (options.mode === "fire-and-forget") {
|
|
2017
|
+
submitDeploy(credentials, liveSystem).catch((err) => {
|
|
2018
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
2019
|
+
console.error(`[Fractal] live system deploy error: ${message}`);
|
|
2020
|
+
});
|
|
2021
|
+
return;
|
|
2022
|
+
}
|
|
2023
|
+
const quiet = options.quiet ?? false;
|
|
2024
|
+
const startMs = Date.now();
|
|
2025
|
+
log(quiet, "INFO", "Deploying Live System", {
|
|
2026
|
+
system: liveSystem.id.toString(),
|
|
2027
|
+
fractal: liveSystem.fractalId.toString(),
|
|
2028
|
+
provider: liveSystem.genericProvider
|
|
2029
|
+
});
|
|
2030
|
+
await submitDeploy(credentials, liveSystem);
|
|
2031
|
+
await pollUntilActive(credentials, liveSystem.id, options, startMs);
|
|
2032
|
+
log(quiet, "INFO", "Live System Active", {
|
|
2033
|
+
system: liveSystem.id.toString(),
|
|
2034
|
+
elapsed: elapsedSec(startMs)
|
|
2035
|
+
});
|
|
1872
2036
|
};
|
|
1873
2037
|
const destroyLiveSystem = async (credentials, id) => {
|
|
1874
|
-
|
|
2038
|
+
try {
|
|
2039
|
+
await superagent.default.delete(`${FRACTAL_API_URL}/livesystems/${id.toString()}`).set(authHeaders(credentials));
|
|
2040
|
+
} catch (err) {
|
|
2041
|
+
throw toApiError("destroy live system", id.toString(), err);
|
|
2042
|
+
}
|
|
1875
2043
|
};
|
|
1876
2044
|
let LiveSystemService;
|
|
1877
2045
|
(function(_LiveSystemService) {
|
|
@@ -2016,7 +2184,7 @@ const getLiveSystemBuilder = () => {
|
|
|
2016
2184
|
if (validationErrors.length > 0) throw new SyntaxError(validationErrors.join("\n"));
|
|
2017
2185
|
return {
|
|
2018
2186
|
...internalState,
|
|
2019
|
-
deploy: (credentials) => LiveSystemService.deploy(credentials, internalState),
|
|
2187
|
+
deploy: (credentials, options) => LiveSystemService.deploy(credentials, internalState, options),
|
|
2020
2188
|
destroy: (credentials) => LiveSystemService.destroy(credentials, internalState.id)
|
|
2021
2189
|
};
|
|
2022
2190
|
}
|
|
@@ -2055,7 +2223,7 @@ function buildVirtualNetworkType() {
|
|
|
2055
2223
|
function pushParam$25(params, key, value) {
|
|
2056
2224
|
params.push(key, value);
|
|
2057
2225
|
}
|
|
2058
|
-
function
|
|
2226
|
+
function makeVirtualNetworkComponent(vpc, subnetNodes, sgs) {
|
|
2059
2227
|
const vpcDep = { id: vpc.id };
|
|
2060
2228
|
const wiredSubnets = subnetNodes.map((n) => ({
|
|
2061
2229
|
...n.subnet,
|
|
@@ -2080,8 +2248,8 @@ function makeVirtualNetworkNode(vpc, subnetNodes, sgs) {
|
|
|
2080
2248
|
...allVMs,
|
|
2081
2249
|
...allEcsSvcs
|
|
2082
2250
|
],
|
|
2083
|
-
withSubnets: (newSubnets) =>
|
|
2084
|
-
withSecurityGroups: (newSgs) =>
|
|
2251
|
+
withSubnets: (newSubnets) => makeVirtualNetworkComponent(vpc, newSubnets, sgs),
|
|
2252
|
+
withSecurityGroups: (newSgs) => makeVirtualNetworkComponent(vpc, subnetNodes, newSgs)
|
|
2085
2253
|
};
|
|
2086
2254
|
}
|
|
2087
2255
|
let VirtualNetwork;
|
|
@@ -2157,7 +2325,7 @@ let VirtualNetwork;
|
|
|
2157
2325
|
const b = getBuilder().withId(config.id).withVersion(config.version.major, config.version.minor, config.version.patch).withDisplayName(config.displayName);
|
|
2158
2326
|
if (config.cidrBlock) b.withCidrBlock(config.cidrBlock);
|
|
2159
2327
|
if (config.description) b.withDescription(config.description);
|
|
2160
|
-
return
|
|
2328
|
+
return makeVirtualNetworkComponent(b.build().vpc, [], []);
|
|
2161
2329
|
};
|
|
2162
2330
|
})(VirtualNetwork || (VirtualNetwork = {}));
|
|
2163
2331
|
|
|
@@ -2177,7 +2345,7 @@ function buildSubnetType() {
|
|
|
2177
2345
|
function pushParam$24(params, key, value) {
|
|
2178
2346
|
params.push(key, value);
|
|
2179
2347
|
}
|
|
2180
|
-
function
|
|
2348
|
+
function makeSubnetComponent(subnet, vms, workloadNodes) {
|
|
2181
2349
|
const subnetDep = { id: subnet.id };
|
|
2182
2350
|
const wiredVMs = vms.map((n) => ({
|
|
2183
2351
|
...n.component,
|
|
@@ -2196,8 +2364,8 @@ function makeSubnetNode(subnet, vms, workloadNodes) {
|
|
|
2196
2364
|
...wiredVMs,
|
|
2197
2365
|
...wiredWorkloads
|
|
2198
2366
|
],
|
|
2199
|
-
withVirtualMachines: (newVMs) =>
|
|
2200
|
-
withWorkloads: (newWorkloads) =>
|
|
2367
|
+
withVirtualMachines: (newVMs) => makeSubnetComponent(subnet, newVMs, workloadNodes),
|
|
2368
|
+
withWorkloads: (newWorkloads) => makeSubnetComponent(subnet, vms, newWorkloads)
|
|
2201
2369
|
};
|
|
2202
2370
|
}
|
|
2203
2371
|
let Subnet;
|
|
@@ -2255,7 +2423,7 @@ let Subnet;
|
|
|
2255
2423
|
const b = getBuilder().withId(config.id).withVersion(config.version.major, config.version.minor, config.version.patch).withDisplayName(config.displayName);
|
|
2256
2424
|
if (config.cidrBlock) b.withCidrBlock(config.cidrBlock);
|
|
2257
2425
|
if (config.description) b.withDescription(config.description);
|
|
2258
|
-
return
|
|
2426
|
+
return makeSubnetComponent(b.build().subnet, [], []);
|
|
2259
2427
|
};
|
|
2260
2428
|
})(Subnet || (Subnet = {}));
|
|
2261
2429
|
|
|
@@ -2337,16 +2505,23 @@ function buildLinkParams$1(link) {
|
|
|
2337
2505
|
if (link.protocol) params.push("protocol", link.protocol);
|
|
2338
2506
|
return params;
|
|
2339
2507
|
}
|
|
2340
|
-
function
|
|
2508
|
+
function makeVirtualMachineComponent(component) {
|
|
2341
2509
|
return {
|
|
2342
2510
|
component,
|
|
2343
2511
|
components: [component],
|
|
2344
|
-
|
|
2512
|
+
linkToVirtualMachine: (links) => {
|
|
2345
2513
|
const componentLinks = links.map((l) => getLinkBuilder().withId(l.target.component.id).withType(buildVirtualMachineType()).withParameters(buildLinkParams$1(l)).build());
|
|
2346
|
-
return
|
|
2514
|
+
return makeVirtualMachineComponent({
|
|
2347
2515
|
...component,
|
|
2348
2516
|
links: [...component.links, ...componentLinks]
|
|
2349
2517
|
});
|
|
2518
|
+
},
|
|
2519
|
+
linkToSecurityGroup: (sgs) => {
|
|
2520
|
+
const sgLinks = sgs.map((sg) => getLinkBuilder().withId(sg.id).withType(sg.type).withParameters(getParametersInstance()).build());
|
|
2521
|
+
return makeVirtualMachineComponent({
|
|
2522
|
+
...component,
|
|
2523
|
+
links: [...component.links, ...sgLinks]
|
|
2524
|
+
});
|
|
2350
2525
|
}
|
|
2351
2526
|
};
|
|
2352
2527
|
}
|
|
@@ -2382,7 +2557,7 @@ let VirtualMachine;
|
|
|
2382
2557
|
_VirtualMachine.create = (config) => {
|
|
2383
2558
|
const b = getBuilder().withId(config.id).withVersion(config.version.major, config.version.minor, config.version.patch).withDisplayName(config.displayName);
|
|
2384
2559
|
if (config.description) b.withDescription(config.description);
|
|
2385
|
-
return
|
|
2560
|
+
return makeVirtualMachineComponent(b.build());
|
|
2386
2561
|
};
|
|
2387
2562
|
})(VirtualMachine || (VirtualMachine = {}));
|
|
2388
2563
|
|
|
@@ -2553,7 +2728,7 @@ let AwsSubnet;
|
|
|
2553
2728
|
|
|
2554
2729
|
//#endregion
|
|
2555
2730
|
//#region src/live_system/component/network_and_compute/iaas/security_group.ts
|
|
2556
|
-
const AWS_SG_TYPE_NAME = "
|
|
2731
|
+
const AWS_SG_TYPE_NAME = "SecurityGroup";
|
|
2557
2732
|
function buildId$22(id) {
|
|
2558
2733
|
return getComponentIdBuilder().withValue(KebabCaseString$1.getBuilder().withValue(id).build()).build();
|
|
2559
2734
|
}
|
|
@@ -4135,7 +4310,7 @@ function buildVersion$4(major, minor, patch) {
|
|
|
4135
4310
|
function buildContainerPlatformType() {
|
|
4136
4311
|
return getBlueprintComponentTypeBuilder().withInfrastructureDomain(InfrastructureDomain$1.NetworkAndCompute).withServiceDeliveryModel(ServiceDeliveryModel$1.PaaS).withName(PascalCaseString$1.getBuilder().withValue(CONTAINER_PLATFORM_TYPE_NAME).build()).build();
|
|
4137
4312
|
}
|
|
4138
|
-
function
|
|
4313
|
+
function makeContainerPlatformComponent(platform, workloadNodes) {
|
|
4139
4314
|
const platformDep = { id: platform.id };
|
|
4140
4315
|
return {
|
|
4141
4316
|
platform,
|
|
@@ -4146,7 +4321,7 @@ function makeContainerPlatformNode(platform, workloadNodes) {
|
|
|
4146
4321
|
dependencies: [...w.component.dependencies, platformDep]
|
|
4147
4322
|
}
|
|
4148
4323
|
})),
|
|
4149
|
-
withWorkloads: (newWorkloads) =>
|
|
4324
|
+
withWorkloads: (newWorkloads) => makeContainerPlatformComponent(platform, newWorkloads)
|
|
4150
4325
|
};
|
|
4151
4326
|
}
|
|
4152
4327
|
let ContainerPlatform;
|
|
@@ -4178,7 +4353,7 @@ let ContainerPlatform;
|
|
|
4178
4353
|
_ContainerPlatform.create = (config) => {
|
|
4179
4354
|
const b = getBuilder().withId(config.id).withVersion(config.version.major, config.version.minor, config.version.patch).withDisplayName(config.displayName);
|
|
4180
4355
|
if (config.description) b.withDescription(config.description);
|
|
4181
|
-
return
|
|
4356
|
+
return makeContainerPlatformComponent(b.build(), []);
|
|
4182
4357
|
};
|
|
4183
4358
|
})(ContainerPlatform || (ContainerPlatform = {}));
|
|
4184
4359
|
|
|
@@ -4210,20 +4385,20 @@ function buildLinkParams(fromPort, toPort, protocol) {
|
|
|
4210
4385
|
if (protocol) p.push("protocol", protocol);
|
|
4211
4386
|
return p;
|
|
4212
4387
|
}
|
|
4213
|
-
function
|
|
4388
|
+
function makeWorkloadComponent(component) {
|
|
4214
4389
|
return {
|
|
4215
4390
|
component,
|
|
4216
4391
|
components: [component],
|
|
4217
|
-
|
|
4392
|
+
linkToWorkload: (links) => {
|
|
4218
4393
|
const portLinks = links.map((l) => getLinkBuilder().withId(l.target.component.id).withType(buildWorkloadType()).withParameters(buildLinkParams(l.fromPort, l.toPort, l.protocol)).build());
|
|
4219
|
-
return
|
|
4394
|
+
return makeWorkloadComponent({
|
|
4220
4395
|
...component,
|
|
4221
4396
|
links: [...component.links, ...portLinks]
|
|
4222
4397
|
});
|
|
4223
4398
|
},
|
|
4224
|
-
|
|
4399
|
+
linkToSecurityGroup: (sgs) => {
|
|
4225
4400
|
const sgLinks = sgs.map((sg) => getLinkBuilder().withId(sg.id).withType(sg.type).withParameters(getParametersInstance()).build());
|
|
4226
|
-
return
|
|
4401
|
+
return makeWorkloadComponent({
|
|
4227
4402
|
...component,
|
|
4228
4403
|
links: [...component.links, ...sgLinks]
|
|
4229
4404
|
});
|
|
@@ -4288,7 +4463,7 @@ let Workload;
|
|
|
4288
4463
|
if (config.cpu) b.withCpu(config.cpu);
|
|
4289
4464
|
if (config.memory) b.withMemory(config.memory);
|
|
4290
4465
|
if (config.desiredCount !== void 0) b.withDesiredCount(config.desiredCount);
|
|
4291
|
-
return
|
|
4466
|
+
return makeWorkloadComponent(b.build());
|
|
4292
4467
|
};
|
|
4293
4468
|
})(Workload || (Workload = {}));
|
|
4294
4469
|
|
|
@@ -4521,7 +4696,8 @@ let AwsEcsService;
|
|
|
4521
4696
|
};
|
|
4522
4697
|
_AwsEcsService.satisfy = (workload) => {
|
|
4523
4698
|
const params = getParametersInstance();
|
|
4524
|
-
const
|
|
4699
|
+
const deps = [...workload.dependencies];
|
|
4700
|
+
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);
|
|
4525
4701
|
if (workload.description) inner.withDescription(workload.description);
|
|
4526
4702
|
const desiredCount = workload.parameters.getOptionalFieldByName(DESIRED_COUNT_PARAM);
|
|
4527
4703
|
if (desiredCount !== null) pushParam(params, DESIRED_COUNT_PARAM, desiredCount);
|
|
@@ -4534,6 +4710,11 @@ let AwsEcsService;
|
|
|
4534
4710
|
pushParam(params, ASSIGN_PUBLIC_IP_PARAM, assign);
|
|
4535
4711
|
return satisfiedBuilder;
|
|
4536
4712
|
},
|
|
4713
|
+
withTaskDefinition: (taskDef) => {
|
|
4714
|
+
deps.push({ id: taskDef.id });
|
|
4715
|
+
inner.withDependencies(deps);
|
|
4716
|
+
return satisfiedBuilder;
|
|
4717
|
+
},
|
|
4537
4718
|
build: () => inner.build()
|
|
4538
4719
|
};
|
|
4539
4720
|
return satisfiedBuilder;
|