@stacksjs/ts-cloud 0.7.105 → 0.7.108

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.
Files changed (75) hide show
  1. package/dist/bin/cli.js +784 -785
  2. package/dist/bin/dashboard-server.js +292 -292
  3. package/dist/{chunk-dmzez5f8.js → chunk-33sy72r8.js} +52 -3
  4. package/dist/{chunk-vkd2y0fs.js → chunk-eg8ck25v.js} +858 -150
  5. package/dist/deploy/dashboard-bundle-encoding.test.d.ts +1 -0
  6. package/dist/deploy/dashboard-payload.d.ts +20 -0
  7. package/dist/deploy/dashboard-payload.test.d.ts +1 -0
  8. package/dist/deploy/dashboard-topology.d.ts +85 -0
  9. package/dist/deploy/dashboard-topology.test.d.ts +1 -0
  10. package/dist/deploy/egress-collection.d.ts +60 -0
  11. package/dist/deploy/index.d.ts +2 -0
  12. package/dist/deploy/index.js +14 -2
  13. package/dist/drivers/index.js +1 -1
  14. package/dist/index.js +2 -2
  15. package/dist/ui/404.html +1 -0
  16. package/dist/ui/access-denied.html +1 -1
  17. package/dist/ui/account/automation.html +4 -4
  18. package/dist/ui/account/security.html +2 -2
  19. package/dist/ui/applications/compose.html +4 -4
  20. package/dist/ui/applications/new.html +2 -2
  21. package/dist/ui/data/backups.html +22 -9
  22. package/dist/ui/data/services.html +22 -9
  23. package/dist/ui/data/volumes.html +22 -9
  24. package/dist/ui/index.html +22 -9
  25. package/dist/ui/infrastructure/topology.html +2223 -0
  26. package/dist/ui/integrations.html +2 -2
  27. package/dist/ui/operations/alerts.html +22 -9
  28. package/dist/ui/operations/configuration.html +4 -4
  29. package/dist/ui/operations/jobs.html +22 -9
  30. package/dist/ui/operations/maintenance.html +4 -4
  31. package/dist/ui/operations/observability.html +22 -9
  32. package/dist/ui/operations/previews.html +4 -4
  33. package/dist/ui/operations/queue.html +4 -4
  34. package/dist/ui/operations/regions.html +4 -4
  35. package/dist/ui/operations/releases.html +4 -4
  36. package/dist/ui/operations/workloads.html +22 -9
  37. package/dist/ui/security.html +2 -2
  38. package/dist/ui/server/actions.html +3 -3
  39. package/dist/ui/server/activity.html +1 -1
  40. package/dist/ui/server/capacity.html +4 -4
  41. package/dist/ui/server/database.html +4 -4
  42. package/dist/ui/server/deployments.html +4 -4
  43. package/dist/ui/server/diagnostics.html +2 -2
  44. package/dist/ui/server/firewall.html +4 -4
  45. package/dist/ui/server/fleet.html +22 -9
  46. package/dist/ui/server/logs.html +22 -9
  47. package/dist/ui/server/metrics.html +130 -14
  48. package/dist/ui/server/security.html +2 -2
  49. package/dist/ui/server/services.html +2 -2
  50. package/dist/ui/server/sites.html +22 -9
  51. package/dist/ui/server/ssh-keys.html +4 -4
  52. package/dist/ui/server/team.html +4 -4
  53. package/dist/ui/server/terminal.html +2 -2
  54. package/dist/ui/serverless/alarms.html +3 -3
  55. package/dist/ui/serverless/assets.html +2 -2
  56. package/dist/ui/serverless/cost.html +2 -2
  57. package/dist/ui/serverless/data.html +4 -4
  58. package/dist/ui/serverless/deployments.html +2 -2
  59. package/dist/ui/serverless/firewall.html +2 -2
  60. package/dist/ui/serverless/functions.html +4 -4
  61. package/dist/ui/serverless/logs.html +21 -8
  62. package/dist/ui/serverless/metrics.html +2 -2
  63. package/dist/ui/serverless/queues.html +4 -4
  64. package/dist/ui/serverless/secrets.html +4 -4
  65. package/dist/ui/serverless/traces.html +4 -4
  66. package/dist/ui/serverless.html +4 -4
  67. package/dist/ui-src/functions/requestJson.ts +41 -0
  68. package/dist/ui-src/functions/useOpConfirm.ts +132 -0
  69. package/dist/ui-src/functions/usePolling.ts +98 -0
  70. package/dist/ui-src/functions/useTerminal.ts +79 -0
  71. package/dist/ui-src/pages/infrastructure/topology.stx +517 -0
  72. package/dist/ui-src/pages/partials/nav.stx +2 -0
  73. package/dist/ui-src/pages/server/metrics.stx +140 -6
  74. package/dist/ui-src/src/topology.ts +485 -0
  75. package/package.json +3 -3
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Serialize the dashboard payload for the trip through an environment variable.
3
+ *
4
+ * The UI is rebuilt by spawning stx with the resolved data in
5
+ * `TSCLOUD_DASHBOARD_DATA`. Environment variables are bytes, and the child
6
+ * decodes them using its locale — so on a box whose locale is `POSIX`/`C`
7
+ * (the default on most minimal server images) every non-ASCII character in the
8
+ * payload comes back mis-decoded and is then re-encoded as UTF-8, arriving in
9
+ * the built page as mojibake: `—` renders as `â€"`, `·` as `·`.
10
+ *
11
+ * That is not hypothetical or cosmetic. It corrupts any project name, domain,
12
+ * or status text carrying an accent or a dash, on exactly the hosts operators
13
+ * are most likely to provision.
14
+ *
15
+ * Escaping every non-ASCII code point makes the transport pure ASCII, which no
16
+ * locale can misread. `JSON.parse` on the other side turns the escapes back
17
+ * into the original characters, so the payload is unchanged — only its wire
18
+ * form is narrowed.
19
+ */
20
+ export declare function encodeDashboardPayload(data: unknown): string;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Derive the infrastructure topology the dashboard draws as a diagram.
3
+ *
4
+ * Deliberately built from the *resolved dashboard data* rather than straight
5
+ * from the cloud config: the diagram then shows what the rest of the cockpit
6
+ * shows — the same sites, services, functions and queues, with the same
7
+ * statuses — instead of a second, subtly different reading of the world.
8
+ *
9
+ * Nothing here invents a resource. A slice that could not be read simply
10
+ * contributes no node, and the reason lands in `notes` so the page can say so
11
+ * out loud. See `packages/ui/pages/infrastructure/topology.stx`.
12
+ */
13
+ export type TopologyStatus = 'ok' | 'warn' | 'bad' | 'idle' | 'unknown';
14
+ export type TopologyKind = 'internet' | 'dns' | 'waf' | 'firewall' | 'cdn' | 'gateway' | 'proxy' | 'site' | 'function' | 'worker' | 'scheduler' | 'queue' | 'cache' | 'database' | 'storage' | 'filesystem' | 'backup';
15
+ /** How traffic or state moves along an edge — drives the edge styling. */
16
+ export type TopologyFlow = 'request' | 'async' | 'data' | 'backup';
17
+ export interface TopologyFact {
18
+ label: string;
19
+ value: string;
20
+ }
21
+ export interface TopologyNode {
22
+ id: string;
23
+ label: string;
24
+ kind: TopologyKind;
25
+ /** Row in the diagram: 0 is the internet, higher is deeper in the stack. */
26
+ layer: number;
27
+ status: TopologyStatus;
28
+ /** One-line subtitle: runtime, engine, instance class… */
29
+ sub?: string;
30
+ facts: TopologyFact[];
31
+ /** Dashboard page this resource is managed from. */
32
+ href?: string;
33
+ /** Boundary this node sits inside (a box, a VPC, a managed account). */
34
+ group?: string;
35
+ /** Outside the deployment — drawn as an open shape. */
36
+ external?: boolean;
37
+ }
38
+ export interface TopologyLink {
39
+ source: string;
40
+ target: string;
41
+ flow: TopologyFlow;
42
+ label?: string;
43
+ status?: TopologyStatus;
44
+ }
45
+ export interface TopologyGroup {
46
+ id: string;
47
+ label: string;
48
+ sub?: string;
49
+ }
50
+ export interface TopologyLayer {
51
+ index: number;
52
+ id: string;
53
+ label: string;
54
+ }
55
+ /** Identity the data bag doesn't carry on its own. */
56
+ export interface TopologyContext {
57
+ project?: string;
58
+ environment?: string;
59
+ }
60
+ export interface TopologyModel {
61
+ mode: 'server' | 'serverless';
62
+ project: string;
63
+ environment: string;
64
+ provider: string;
65
+ region: string;
66
+ generatedAt: string;
67
+ layers: TopologyLayer[];
68
+ groups: TopologyGroup[];
69
+ nodes: TopologyNode[];
70
+ links: TopologyLink[];
71
+ /** What the diagram could not show, and why. Never left implicit. */
72
+ notes: string[];
73
+ }
74
+ /**
75
+ * Server-mode topology: clients → DNS → host firewall → reverse proxy → sites,
76
+ * with the box's workers, scheduler, data services and backups hanging off it.
77
+ */
78
+ export declare function buildServerTopology(data: Record<string, any>, context?: TopologyContext): TopologyModel;
79
+ /**
80
+ * Serverless-mode topology: clients → DNS → WAF/CDN → the HTTP entry point →
81
+ * functions, with queues, database, cache and object storage behind them.
82
+ */
83
+ export declare function buildServerlessTopology(data: Record<string, any>, context?: TopologyContext): TopologyModel;
84
+ /** Build the topology matching the dashboard mode the data was resolved for. */
85
+ export declare function buildTopology(mode: 'server' | 'serverless', data: Record<string, any>, context?: TopologyContext): TopologyModel;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Object-storage egress collection.
3
+ *
4
+ * Host network counters answer a different question than the one an
5
+ * object-storage invoice asks. When an application redirects downloads to a
6
+ * bucket (or to a CDN in front of one), those bytes never traverse the host's
7
+ * NIC — the box can sit idle while the bucket serves terabytes. The only
8
+ * component that knows a transfer happened, and how large it was, is the
9
+ * application that authorized it, so this polls it instead of guessing.
10
+ *
11
+ * The reports carry a per-day history rather than a single counter, and that is
12
+ * deliberately exploited here: each day becomes one metric point stamped with
13
+ * that day's own timestamp. Because record ids are a deterministic hash of
14
+ * (source, name, timestamp) and the store inserts with OR IGNORE, replaying a
15
+ * history is idempotent. A collector that was down for six hours — or six days
16
+ * — backfills what it missed on its next run instead of leaving a hole, and
17
+ * re-reading the same day never double-counts it.
18
+ */
19
+ import type { EgressEndpointConfig, EgressReport } from '@ts-cloud/core';
20
+ export interface EgressMetric {
21
+ name: string;
22
+ value: number;
23
+ unit: string;
24
+ /** ISO timestamp this point belongs to. */
25
+ timestamp: string;
26
+ attributes: Record<string, string>;
27
+ }
28
+ export interface EgressCollectionResult {
29
+ metrics: EgressMetric[];
30
+ errors: Array<{
31
+ source: string;
32
+ message: string;
33
+ }>;
34
+ }
35
+ /**
36
+ * Turn one report into metric points.
37
+ *
38
+ * Pure: no clock, no network. `now` is the timestamp for the point-in-time
39
+ * series (month-to-date, projection, allowance), which describe the moment of
40
+ * collection rather than a calendar day.
41
+ */
42
+ export declare function egressReportMetrics(report: EgressReport | null | undefined, options: {
43
+ name: string;
44
+ now: string;
45
+ maxReplayDays?: number;
46
+ }): EgressMetric[];
47
+ /**
48
+ * Fetch one endpoint's report.
49
+ *
50
+ * Returns null on any failure. An egress endpoint is supplementary — it must
51
+ * never be able to fail a telemetry collection that is also carrying host
52
+ * metrics, so problems surface as an error entry rather than a throw.
53
+ */
54
+ export declare function fetchEgressReport(endpoint: EgressEndpointConfig, env?: NodeJS.ProcessEnv, fetchImpl?: typeof fetch): Promise<EgressReport | null>;
55
+ /** Poll every configured endpoint and flatten the results. */
56
+ export declare function collectEgressMetrics(endpoints: EgressEndpointConfig[] | undefined, options: {
57
+ now: string;
58
+ env?: NodeJS.ProcessEnv;
59
+ fetchImpl?: typeof fetch;
60
+ }): Promise<EgressCollectionResult>;
@@ -15,5 +15,7 @@ export * from './container-image';
15
15
  export { buildFunctionEnv, type CodeSource, deployServerlessApp, type DeployServerlessOptions, infraEnvFromOutputs, redeployServerlessApp, type ResolvedContext, rollbackServerlessApp, runRemoteCommand, setMaintenance, } from './serverless-app';
16
16
  export { buildAndPushServerlessImage, type BuildImageOptions, type BuiltImage } from './serverless-image';
17
17
  export { type DashboardData, resolveDashboardData } from './dashboard-data';
18
+ export { buildServerlessTopology, buildServerTopology, buildTopology, type TopologyContext, type TopologyFact, type TopologyFlow, type TopologyGroup, type TopologyKind, type TopologyLayer, type TopologyLink, type TopologyModel, type TopologyNode, type TopologyStatus, } from './dashboard-topology';
19
+ export { collectEgressMetrics, type EgressCollectionResult, egressReportMetrics, type EgressMetric, fetchEgressReport, } from './egress-collection';
18
20
  export { dashboardActions, resolveDashboardAction, sanitizeCloudConfig, startLocalDashboardServer, type DashboardAction, type LocalDashboardServer, type LocalDashboardServerOptions, } from './local-dashboard-server';
19
21
  export { buildManagementDashboardArtifact, dashboardCredentialsFile, ensureManagementDashboard, type EnsureDashboardLogger, MANAGEMENT_DASHBOARD_SITE, resolveDashboardAuth, type ResolvedDashboardAuth, resolveUiSource, } from './management-dashboard';
@@ -1,6 +1,10 @@
1
1
  import {
2
2
  buildAndPushContainerImage,
3
3
  buildFunctionEnv,
4
+ buildServerTopology,
5
+ buildServerlessTopology,
6
+ buildTopology,
7
+ collectEgressMetrics,
4
8
  createContainerImageDependencies,
5
9
  createExistingStaticFullStackDependencies,
6
10
  createStaticApiOriginDependencies,
@@ -10,9 +14,11 @@ import {
10
14
  deployServerlessApp,
11
15
  deploySite,
12
16
  deployStaticApiOrigin,
17
+ egressReportMetrics,
13
18
  ensureDashboardActor,
14
19
  estimateExistingStaticFullStackMonthlyCost,
15
20
  estimateStaticApiOriginMonthlyCost,
21
+ fetchEgressReport,
16
22
  generateExistingStaticFullStackTemplate,
17
23
  hashContainerContext,
18
24
  infraEnvFromOutputs,
@@ -30,7 +36,7 @@ import {
30
36
  synchronizeDashboardUsers,
31
37
  trackDashboardOperation,
32
38
  verifyStaticApiOrigin
33
- } from "../chunk-vkd2y0fs.js";
39
+ } from "../chunk-eg8ck25v.js";
34
40
  import {
35
41
  deleteStaticSite,
36
42
  deployStaticSite,
@@ -70,7 +76,7 @@ import {
70
76
  siteInstallBase,
71
77
  validateDeploymentConfig,
72
78
  verifyAddressRecord
73
- } from "../chunk-dmzez5f8.js";
79
+ } from "../chunk-33sy72r8.js";
74
80
  import"../chunk-c6db5m63.js";
75
81
  import"../chunk-7m60qnc8.js";
76
82
  import"../chunk-4cjrg98a.js";
@@ -114,10 +120,12 @@ export {
114
120
  generateStaticSiteTemplate,
115
121
  generateExternalDnsStaticSiteTemplate,
116
122
  generateExistingStaticFullStackTemplate,
123
+ fetchEgressReport,
117
124
  estimateStaticApiOriginMonthlyCost,
118
125
  estimateExistingStaticFullStackMonthlyCost,
119
126
  ensureManagementDashboard,
120
127
  ensureDashboardActor,
128
+ egressReportMetrics,
121
129
  deployStaticSiteWithExternalDnsFull,
122
130
  deployStaticSiteWithExternalDns,
123
131
  deployStaticSiteFull,
@@ -134,6 +142,10 @@ export {
134
142
  createExistingStaticFullStackDependencies,
135
143
  createContainerImageDependencies,
136
144
  collectServerDnsDomains,
145
+ collectEgressMetrics,
146
+ buildTopology,
147
+ buildServerlessTopology,
148
+ buildServerTopology,
137
149
  buildManagementDashboardArtifact,
138
150
  buildFunctionEnv,
139
151
  buildAndPushServerlessImage,
@@ -68,7 +68,7 @@ import {
68
68
  waitForSsh,
69
69
  wrapCloudInitUserData,
70
70
  writeResizeCheckpoint
71
- } from "../chunk-dmzez5f8.js";
71
+ } from "../chunk-33sy72r8.js";
72
72
  import"../chunk-c6db5m63.js";
73
73
  import"../chunk-7m60qnc8.js";
74
74
  import"../chunk-4cjrg98a.js";
package/dist/index.js CHANGED
@@ -283,7 +283,7 @@ import {
283
283
  volumeCapabilities,
284
284
  webhookEndpoint,
285
285
  zeroCapacity
286
- } from "./chunk-vkd2y0fs.js";
286
+ } from "./chunk-eg8ck25v.js";
287
287
  import {
288
288
  deleteStaticSite,
289
289
  deployStaticSite,
@@ -405,7 +405,7 @@ import {
405
405
  waitForCloudInit,
406
406
  waitForSsh,
407
407
  wrapCloudInitUserData
408
- } from "./chunk-dmzez5f8.js";
408
+ } from "./chunk-33sy72r8.js";
409
409
  import {
410
410
  ABTestManager,
411
411
  AI,
package/dist/ui/404.html CHANGED
@@ -793,6 +793,7 @@ video {
793
793
 
794
794
  <section class="nav-group">
795
795
  <h2>Infrastructure</h2>
796
+ <a class="" href="/infrastructure/topology?env=production">Infrastructure map</a>
796
797
  <a class="" href="/data/services?env=production">Data services</a>
797
798
  <a class="" href="/data/volumes?env=production">Persistent volumes</a>
798
799
  <a href="/server/firewall?env=production">Network & firewall</a><a href="/server/ssh-keys?env=production">SSH keys</a>