@stacksjs/ts-cloud 0.7.108 → 0.7.109
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/alerts/delivery.d.ts +10 -0
- package/dist/alerts/model.d.ts +1 -1
- package/dist/api/client.d.ts +53 -0
- package/dist/api/handler.d.ts +10 -0
- package/dist/api/service.d.ts +1 -0
- package/dist/aws/index.js +10 -10
- package/dist/aws/lambda.d.ts +19 -0
- package/dist/bin/cli.js +1677 -1369
- package/dist/bin/dashboard-server.js +927 -621
- package/dist/{chunk-fmt40tpw.js → chunk-53jatzaw.js} +2 -2
- package/dist/{chunk-ef2dwfrg.js → chunk-8kh577qh.js} +5 -5
- package/dist/{chunk-s9c2x5jv.js → chunk-9v2pwxv9.js} +2 -2
- package/dist/chunk-aa2dkn7b.js +205 -0
- package/dist/{chunk-eg8ck25v.js → chunk-cktwk9hy.js} +6935 -15274
- package/dist/{chunk-33sy72r8.js → chunk-d3vx2ekv.js} +71 -25
- package/dist/chunk-grx1rp09.js +12163 -0
- package/dist/{chunk-c6db5m63.js → chunk-t2s3gdq6.js} +253 -8
- package/dist/chunk-va2yd85b.js +200 -0
- package/dist/{chunk-3g4r09dd.js → chunk-wmbep3b5.js} +1 -1
- package/dist/{chunk-ybcz6sxc.js → chunk-x6yzgv7y.js} +33 -0
- package/dist/chunk-xrtwv3v2.js +420 -0
- package/dist/control-plane/types.d.ts +1 -1
- package/dist/deploy/dashboard-protection.test.d.ts +1 -0
- package/dist/deploy/dashboard-spend.test.d.ts +1 -0
- package/dist/deploy/index.js +11 -8
- package/dist/deploy/local-dashboard-server.d.ts +2 -0
- package/dist/drivers/index.js +4 -2
- package/dist/drivers/shared/protection.d.ts +43 -0
- package/dist/drivers/shared/protection.test.d.ts +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +364 -102
- package/dist/protection/controls.d.ts +113 -0
- package/dist/protection/controls.test.d.ts +1 -0
- package/dist/protection/ddos.d.ts +130 -0
- package/dist/protection/ddos.test.d.ts +1 -0
- package/dist/protection/index.d.ts +11 -0
- package/dist/protection/index.js +87 -0
- package/dist/protection/ratelimit.d.ts +154 -0
- package/dist/protection/ratelimit.test.d.ts +1 -0
- package/dist/protection/waf.d.ts +143 -0
- package/dist/protection/waf.test.d.ts +1 -0
- package/dist/spend/anomaly-config.d.ts +130 -0
- package/dist/spend/anomaly-config.test.d.ts +1 -0
- package/dist/spend/anomaly.d.ts +114 -0
- package/dist/spend/anomaly.test.d.ts +1 -0
- package/dist/spend/api.d.ts +42 -0
- package/dist/spend/api.test.d.ts +1 -0
- package/dist/spend/appliers.d.ts +126 -0
- package/dist/spend/docs.test.d.ts +1 -0
- package/dist/spend/enforcement.d.ts +111 -0
- package/dist/spend/enforcement.integration.test.d.ts +1 -0
- package/dist/spend/evaluator.d.ts +70 -0
- package/dist/spend/evaluator.test.d.ts +1 -0
- package/dist/spend/focus.d.ts +93 -0
- package/dist/spend/focus.test.d.ts +1 -0
- package/dist/spend/gate.d.ts +96 -0
- package/dist/spend/index.d.ts +20 -0
- package/dist/spend/index.js +173 -0
- package/dist/spend/lease.d.ts +54 -0
- package/dist/spend/lease.test.d.ts +1 -0
- package/dist/spend/meter.d.ts +70 -0
- package/dist/spend/meter.test.d.ts +1 -0
- package/dist/spend/model.d.ts +228 -0
- package/dist/spend/notifications.d.ts +58 -0
- package/dist/spend/pricing.d.ts +109 -0
- package/dist/spend/pricing.test.d.ts +1 -0
- package/dist/spend/projection.d.ts +36 -0
- package/dist/spend/runner.d.ts +130 -0
- package/dist/spend/service.d.ts +129 -0
- package/dist/spend/signals.d.ts +110 -0
- package/dist/spend/signals.test.d.ts +1 -0
- package/dist/spend/sms-sdk.test.d.ts +1 -0
- package/dist/spend/spend.integration.test.d.ts +1 -0
- package/dist/spend/store.d.ts +166 -0
- package/dist/spend/transports.d.ts +169 -0
- package/dist/spend/transports.test.d.ts +1 -0
- package/dist/spend/window.d.ts +52 -0
- package/dist/spend/window.test.d.ts +1 -0
- package/dist/ui/404.html +1 -0
- package/dist/ui/access-denied.html +2 -2
- package/dist/ui/account/automation.html +3 -3
- package/dist/ui/account/security.html +2 -2
- package/dist/ui/applications/compose.html +3 -3
- package/dist/ui/applications/new.html +2 -2
- package/dist/ui/data/backups.html +4 -4
- package/dist/ui/data/services.html +4 -4
- package/dist/ui/data/volumes.html +4 -4
- package/dist/ui/index.html +4 -4
- package/dist/ui/infrastructure/topology.html +4 -4
- package/dist/ui/integrations.html +1 -1
- package/dist/ui/operations/alerts.html +4 -4
- package/dist/ui/operations/configuration.html +4 -4
- package/dist/ui/operations/jobs.html +4 -4
- package/dist/ui/operations/maintenance.html +4 -4
- package/dist/ui/operations/observability.html +4 -4
- package/dist/ui/operations/previews.html +4 -4
- package/dist/ui/operations/queue.html +4 -4
- package/dist/ui/operations/regions.html +4 -4
- package/dist/ui/operations/releases.html +4 -4
- package/dist/ui/operations/spend.html +1634 -0
- package/dist/ui/operations/workloads.html +4 -4
- package/dist/ui/security.html +2 -2
- package/dist/ui/server/actions.html +4 -4
- package/dist/ui/server/activity.html +2 -2
- package/dist/ui/server/capacity.html +4 -4
- package/dist/ui/server/database.html +4 -4
- package/dist/ui/server/deployments.html +4 -4
- package/dist/ui/server/diagnostics.html +2 -2
- package/dist/ui/server/firewall.html +100 -161
- package/dist/ui/server/fleet.html +4 -4
- package/dist/ui/server/logs.html +4 -4
- package/dist/ui/server/metrics.html +4 -4
- package/dist/ui/server/security.html +2 -2
- package/dist/ui/server/services.html +2 -2
- package/dist/ui/server/sites.html +3 -3
- package/dist/ui/server/ssh-keys.html +4 -4
- package/dist/ui/server/team.html +4 -4
- package/dist/ui/server/terminal.html +2 -2
- package/dist/ui/serverless/alarms.html +4 -4
- package/dist/ui/serverless/assets.html +2 -2
- package/dist/ui/serverless/cost.html +2 -2
- package/dist/ui/serverless/data.html +4 -4
- package/dist/ui/serverless/deployments.html +1 -1
- package/dist/ui/serverless/firewall.html +2 -2
- package/dist/ui/serverless/functions.html +4 -4
- package/dist/ui/serverless/logs.html +4 -4
- package/dist/ui/serverless/metrics.html +2 -2
- package/dist/ui/serverless/queues.html +4 -4
- package/dist/ui/serverless/secrets.html +4 -4
- package/dist/ui/serverless/traces.html +4 -4
- package/dist/ui/serverless.html +4 -4
- package/dist/ui-src/pages/operations/spend.stx +225 -0
- package/dist/ui-src/pages/partials/nav.stx +2 -0
- package/dist/ui-src/pages/server/firewall.stx +89 -0
- package/package.json +11 -3
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
deploymentCoexistenceError,
|
|
3
|
-
hasManagementDashboardSite,
|
|
4
|
-
isManagementDashboardSiteName,
|
|
5
|
-
resolveAppDatabase,
|
|
6
|
-
resolveCloudProvider,
|
|
7
|
-
resolveManagementDashboardSites,
|
|
8
|
-
resolveProjectStackName,
|
|
9
|
-
resolveStatePath,
|
|
10
|
-
statePath
|
|
11
|
-
} from "./chunk-c6db5m63.js";
|
|
12
1
|
import {
|
|
13
2
|
EC2Client,
|
|
14
3
|
SSMClient
|
|
@@ -19,6 +8,23 @@ import {
|
|
|
19
8
|
import {
|
|
20
9
|
S3Client
|
|
21
10
|
} from "./chunk-wj3s95p9.js";
|
|
11
|
+
import {
|
|
12
|
+
renderWafInstallScript
|
|
13
|
+
} from "./chunk-va2yd85b.js";
|
|
14
|
+
import {
|
|
15
|
+
renderDdosInstallScript
|
|
16
|
+
} from "./chunk-aa2dkn7b.js";
|
|
17
|
+
import {
|
|
18
|
+
deploymentCoexistenceError,
|
|
19
|
+
hasManagementDashboardSite,
|
|
20
|
+
isManagementDashboardSiteName,
|
|
21
|
+
resolveAppDatabase,
|
|
22
|
+
resolveCloudProvider,
|
|
23
|
+
resolveManagementDashboardSites,
|
|
24
|
+
resolveProjectStackName,
|
|
25
|
+
resolveStatePath,
|
|
26
|
+
statePath
|
|
27
|
+
} from "./chunk-t2s3gdq6.js";
|
|
22
28
|
import {
|
|
23
29
|
__require
|
|
24
30
|
} from "./chunk-v0bahtg2.js";
|
|
@@ -1926,6 +1932,45 @@ function escapeSed(value) {
|
|
|
1926
1932
|
return value.replace(/[.*[\]\\/^$]/g, "\\$&");
|
|
1927
1933
|
}
|
|
1928
1934
|
|
|
1935
|
+
// src/drivers/shared/protection.ts
|
|
1936
|
+
function runAsScript(name, script) {
|
|
1937
|
+
const path = `/tmp/ts-cloud-${name}.sh`;
|
|
1938
|
+
const marker = `TS_CLOUD_${name.toUpperCase().replace(/[^A-Z0-9]/g, "_")}_EOF`;
|
|
1939
|
+
return [
|
|
1940
|
+
`cat > ${path} <<'${marker}'`,
|
|
1941
|
+
script.replace(/\n$/, ""),
|
|
1942
|
+
marker,
|
|
1943
|
+
`chmod +x ${path}`,
|
|
1944
|
+
`bash ${path} || echo "ts-cloud: ${name} setup did not complete; continuing" >&2`,
|
|
1945
|
+
`rm -f ${path}`
|
|
1946
|
+
];
|
|
1947
|
+
}
|
|
1948
|
+
function resolve(setting, fallback) {
|
|
1949
|
+
if (setting === false)
|
|
1950
|
+
return;
|
|
1951
|
+
if (setting === true || setting === undefined)
|
|
1952
|
+
return fallback;
|
|
1953
|
+
return setting;
|
|
1954
|
+
}
|
|
1955
|
+
var DEFAULT_COMPUTE_DDOS = { enabled: true, ports: [80, 443] };
|
|
1956
|
+
var DEFAULT_COMPUTE_WAF = { mode: "detection", paranoiaLevel: 1 };
|
|
1957
|
+
function buildDdosScript(setting = true, extraPorts = []) {
|
|
1958
|
+
const config = resolve(setting, DEFAULT_COMPUTE_DDOS);
|
|
1959
|
+
if (!config || config.enabled === false)
|
|
1960
|
+
return [];
|
|
1961
|
+
const ports = [...new Set([...config.ports ?? DEFAULT_COMPUTE_DDOS.ports ?? [], ...extraPorts])].sort((a, b) => a - b);
|
|
1962
|
+
return runAsScript("ddos", renderDdosInstallScript({ ...config, ports }));
|
|
1963
|
+
}
|
|
1964
|
+
function buildWafScript(setting = true) {
|
|
1965
|
+
const config = resolve(setting, DEFAULT_COMPUTE_WAF);
|
|
1966
|
+
if (!config || config.mode === "off")
|
|
1967
|
+
return [];
|
|
1968
|
+
return runAsScript("waf", renderWafInstallScript(config));
|
|
1969
|
+
}
|
|
1970
|
+
function buildProtectionScript(protection = {}, extraPorts = []) {
|
|
1971
|
+
return [...buildDdosScript(protection.ddos, extraPorts), ...buildWafScript(protection.waf)];
|
|
1972
|
+
}
|
|
1973
|
+
|
|
1929
1974
|
// src/drivers/shared/ufw.ts
|
|
1930
1975
|
var UFW_BASE_PORTS = [80, 443];
|
|
1931
1976
|
function buildUfwScript(firewall = {}) {
|
|
@@ -1974,6 +2019,7 @@ function buildComputeProvisionScripts(config) {
|
|
|
1974
2019
|
extras.push(...buildServicesProvisionScript(compute.managedServices), ...buildDatabaseSetupScript(appDatabase, compute.managedServices));
|
|
1975
2020
|
}
|
|
1976
2021
|
extras.push(...buildUfwScript(compute.firewall ?? (phpBox ? { enabled: true } : { enabled: false })));
|
|
2022
|
+
extras.push(...buildProtectionScript({ ddos: compute.ddos, waf: compute.waf }, compute.firewall?.allowedPorts ?? []));
|
|
1977
2023
|
extras.push(...buildAutoUpdatesScript(compute.autoUpdates ?? phpBox));
|
|
1978
2024
|
extras.push(...buildMonitoringScript(compute.monitoring ?? phpBox));
|
|
1979
2025
|
extras.push(...buildAuthorizedKeysScript(compute.sshKeys));
|
|
@@ -2507,7 +2553,7 @@ class AwsDriver {
|
|
|
2507
2553
|
const terminalStatuses = new Set(["Success", "Failed", "Cancelled", "TimedOut"]);
|
|
2508
2554
|
let lastInvocations = [];
|
|
2509
2555
|
while (Date.now() - startTime < maxWait) {
|
|
2510
|
-
await new Promise((
|
|
2556
|
+
await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
|
|
2511
2557
|
try {
|
|
2512
2558
|
const invocations = await ssm.listCommandInvocations({ CommandId: commandId, Details: true });
|
|
2513
2559
|
lastInvocations = invocations;
|
|
@@ -2886,7 +2932,7 @@ class HetznerClient {
|
|
|
2886
2932
|
while (Date.now() - start < grace) {
|
|
2887
2933
|
if ((await this.getServer(serverId)).status === "off")
|
|
2888
2934
|
return;
|
|
2889
|
-
await new Promise((
|
|
2935
|
+
await new Promise((resolve2) => setTimeout(resolve2, poll));
|
|
2890
2936
|
}
|
|
2891
2937
|
const action = await this.powerOffServer(serverId);
|
|
2892
2938
|
await this.waitForAction(action.id);
|
|
@@ -2941,7 +2987,7 @@ class HetznerClient {
|
|
|
2941
2987
|
if (action.status === "error") {
|
|
2942
2988
|
throw new HetznerActionError(action.error?.message || "Hetzner action failed", action);
|
|
2943
2989
|
}
|
|
2944
|
-
await new Promise((
|
|
2990
|
+
await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
|
|
2945
2991
|
}
|
|
2946
2992
|
throw new Error(`Timed out waiting for Hetzner action ${actionId}`);
|
|
2947
2993
|
}
|
|
@@ -2953,7 +2999,7 @@ class HetznerClient {
|
|
|
2953
2999
|
const server = await this.getServer(serverId);
|
|
2954
3000
|
if (server.status === "running")
|
|
2955
3001
|
return server;
|
|
2956
|
-
await new Promise((
|
|
3002
|
+
await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
|
|
2957
3003
|
}
|
|
2958
3004
|
throw new Error(`Timed out waiting for server ${serverId} to reach running state`);
|
|
2959
3005
|
}
|
|
@@ -2965,7 +3011,7 @@ class HetznerClient {
|
|
|
2965
3011
|
const server = await this.getServer(serverId);
|
|
2966
3012
|
if (server.status === status)
|
|
2967
3013
|
return server;
|
|
2968
|
-
await new Promise((
|
|
3014
|
+
await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
|
|
2969
3015
|
}
|
|
2970
3016
|
throw new Error(`Timed out waiting for server ${serverId} to reach ${status} state`);
|
|
2971
3017
|
}
|
|
@@ -3913,7 +3959,7 @@ class HetznerDriver {
|
|
|
3913
3959
|
return [...ports].filter((port) => ![80, 443].includes(port));
|
|
3914
3960
|
}
|
|
3915
3961
|
async sleep(ms) {
|
|
3916
|
-
await new Promise((
|
|
3962
|
+
await new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
3917
3963
|
}
|
|
3918
3964
|
async waitForSshReady(host) {
|
|
3919
3965
|
const { sshIntervalMs, sshTimeoutMs } = this.bootWait;
|
|
@@ -4324,7 +4370,7 @@ async function waitForSsh(host, options = {}) {
|
|
|
4324
4370
|
const r = await sshExec(host, "echo ready", options);
|
|
4325
4371
|
if (r.code === 0 && r.stdout.includes("ready"))
|
|
4326
4372
|
return;
|
|
4327
|
-
await new Promise((
|
|
4373
|
+
await new Promise((resolve2) => setTimeout(resolve2, pollIntervalMs));
|
|
4328
4374
|
}
|
|
4329
4375
|
throw new Error(`SSH not ready on ${host} after ${timeoutMs}ms`);
|
|
4330
4376
|
}
|
|
@@ -4338,7 +4384,7 @@ async function waitForCloudInit(host, options = {}) {
|
|
|
4338
4384
|
return;
|
|
4339
4385
|
if (r.stdout.includes("status: error"))
|
|
4340
4386
|
throw new Error(`cloud-init reported an error on ${host}; check /var/log/cloud-init-output.log`);
|
|
4341
|
-
await new Promise((
|
|
4387
|
+
await new Promise((resolve2) => setTimeout(resolve2, pollIntervalMs));
|
|
4342
4388
|
}
|
|
4343
4389
|
throw new Error(`cloud-init did not finish on ${host} after ${timeoutMs}ms`);
|
|
4344
4390
|
}
|
|
@@ -4934,7 +4980,7 @@ class HetznerBoxProvisioner {
|
|
|
4934
4980
|
} catch {
|
|
4935
4981
|
if (i === 9)
|
|
4936
4982
|
break;
|
|
4937
|
-
await new Promise((
|
|
4983
|
+
await new Promise((resolve2) => setTimeout(resolve2, 3000));
|
|
4938
4984
|
}
|
|
4939
4985
|
}
|
|
4940
4986
|
}
|
|
@@ -4974,7 +5020,7 @@ class AwsBoxProvisioner {
|
|
|
4974
5020
|
const instance = await this.ec2.getInstance(instanceId);
|
|
4975
5021
|
if (instance?.State?.Name === "running" && instance.PublicIpAddress)
|
|
4976
5022
|
return instance;
|
|
4977
|
-
await new Promise((
|
|
5023
|
+
await new Promise((resolve2) => setTimeout(resolve2, 5000));
|
|
4978
5024
|
}
|
|
4979
5025
|
throw new Error(`EC2 instance ${instanceId} did not reach running with a public IP within ${timeoutMs}ms`);
|
|
4980
5026
|
}
|
|
@@ -5050,7 +5096,7 @@ class AwsBoxProvisioner {
|
|
|
5050
5096
|
const current = await this.ec2.getInstance(instance.InstanceId);
|
|
5051
5097
|
if (!current || current.State?.Name === "terminated")
|
|
5052
5098
|
break;
|
|
5053
|
-
await new Promise((
|
|
5099
|
+
await new Promise((resolve2) => setTimeout(resolve2, 5000));
|
|
5054
5100
|
}
|
|
5055
5101
|
}
|
|
5056
5102
|
const groups = await this.ec2.describeSecurityGroups({
|
|
@@ -5066,7 +5112,7 @@ class AwsBoxProvisioner {
|
|
|
5066
5112
|
} catch {
|
|
5067
5113
|
if (i === 9)
|
|
5068
5114
|
break;
|
|
5069
|
-
await new Promise((
|
|
5115
|
+
await new Promise((resolve2) => setTimeout(resolve2, 3000));
|
|
5070
5116
|
}
|
|
5071
5117
|
}
|
|
5072
5118
|
}
|
|
@@ -5501,7 +5547,7 @@ import { execSync as execSync2 } from "node:child_process";
|
|
|
5501
5547
|
import { randomBytes } from "node:crypto";
|
|
5502
5548
|
import { chmodSync, copyFileSync, existsSync as existsSync2, mkdirSync, readFileSync as readFileSync3, statSync, writeFileSync } from "node:fs";
|
|
5503
5549
|
import { tmpdir } from "node:os";
|
|
5504
|
-
import { basename, dirname, isAbsolute, join as join5, resolve } from "node:path";
|
|
5550
|
+
import { basename, dirname, isAbsolute, join as join5, resolve as resolve2 } from "node:path";
|
|
5505
5551
|
import { fileURLToPath } from "node:url";
|
|
5506
5552
|
|
|
5507
5553
|
// src/deploy/dashboard-config-module.ts
|
|
@@ -5621,7 +5667,7 @@ function stageLiveDashboardRoot(config, cwd, logger) {
|
|
|
5621
5667
|
let dependency = resolveDashboardVersion();
|
|
5622
5668
|
if (dependency.startsWith("file:")) {
|
|
5623
5669
|
const requested = dependency.slice("file:".length);
|
|
5624
|
-
const source = isAbsolute(requested) ? requested :
|
|
5670
|
+
const source = isAbsolute(requested) ? requested : resolve2(cwd, requested);
|
|
5625
5671
|
if (!existsSync2(source) || !statSync(source).isFile()) {
|
|
5626
5672
|
dependency = resolvePackagedDashboardVersion();
|
|
5627
5673
|
logger.warn(`Management dashboard: TS_CLOUD_UI_VERSION points to a missing package file (${source}); using the deploying ts-cloud version ${dependency} instead.`);
|