@ts-cloud/core 0.7.28 → 0.7.29

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.js CHANGED
@@ -22339,6 +22339,19 @@ function apexOf(domain) {
22339
22339
  const parts = domain.split(".").filter(Boolean);
22340
22340
  return parts.length <= 2 ? domain : parts.slice(-2).join(".");
22341
22341
  }
22342
+ function fnv1a(str) {
22343
+ let h = 2166136261;
22344
+ for (let i = 0;i < str.length; i++) {
22345
+ h ^= str.charCodeAt(i);
22346
+ h = Math.imul(h, 16777619);
22347
+ }
22348
+ return h >>> 0;
22349
+ }
22350
+ var DASHBOARD_PORT_BASE = 20000;
22351
+ var DASHBOARD_PORT_SPAN = 12000;
22352
+ function deriveManagementDashboardPort(dashboardHost) {
22353
+ return DASHBOARD_PORT_BASE + fnv1a(dashboardHost) % DASHBOARD_PORT_SPAN;
22354
+ }
22342
22355
  function dashboardHostFor(domain, ownedDomains) {
22343
22356
  const apex = apexOf(domain);
22344
22357
  if (apex === domain)
@@ -22413,7 +22426,7 @@ function resolveManagementDashboardSites(config, environment, opts) {
22413
22426
  const domain = resolveDashboardDomain(config, environment, opts.domain);
22414
22427
  if (!domain)
22415
22428
  return [];
22416
- const port = opts.port ?? 7676;
22429
+ const port = opts.port ?? deriveManagementDashboardPort(domain);
22417
22430
  const site = {
22418
22431
  root: opts.uiRoot,
22419
22432
  deploy: "server",
@@ -47400,6 +47413,7 @@ export {
47400
47413
  detectServiceRegion,
47401
47414
  detectMisconfigurations,
47402
47415
  detectDeploymentTargets,
47416
+ deriveManagementDashboardPort,
47403
47417
  deploymentCoexistenceError,
47404
47418
  defaultLocalConfig,
47405
47419
  databaseUserManager,
@@ -47568,6 +47582,8 @@ export {
47568
47582
  DLQMonitoringManager,
47569
47583
  DEFAULT_SERVICE_LIMITS,
47570
47584
  DASHBOARD_STATE_DIR,
47585
+ DASHBOARD_PORT_SPAN,
47586
+ DASHBOARD_PORT_BASE,
47571
47587
  DASHBOARD_ENTRY,
47572
47588
  CrossRegionReferenceManager,
47573
47589
  CredentialError,
@@ -45,7 +45,11 @@ export interface ManagementDashboardOptions {
45
45
  * @default true
46
46
  */
47
47
  live?: boolean;
48
- /** Loopback port for the live (box-mode) dashboard service. @default 7676 */
48
+ /**
49
+ * Loopback port for the live (box-mode) dashboard service. Defaults to a value
50
+ * derived per dashboard host via {@link deriveManagementDashboardPort} so two
51
+ * apps on one box never collide; set this (or `TS_CLOUD_UI_PORT`) to pin it.
52
+ */
49
53
  port?: number;
50
54
  /**
51
55
  * ts-cloud version the box installs to run the dashboard. Defaults to the
@@ -65,6 +69,29 @@ export declare const DASHBOARD_STATE_DIR = ".ts-cloud";
65
69
  * be resolved by bun as a FILE to execute, and the service would never start.
66
70
  */
67
71
  export declare const DASHBOARD_ENTRY = "./node_modules/@stacksjs/ts-cloud/dist/bin/cli.js";
72
+ /**
73
+ * Loopback port band for box-mode dashboards. Chosen to sit ABOVE the app port
74
+ * range projects use (3000s) and BELOW the Linux ephemeral range (32768+), so a
75
+ * derived dashboard port can neither clash with a project's own service nor with
76
+ * an outbound socket the box opens.
77
+ */
78
+ export declare const DASHBOARD_PORT_BASE = 20000;
79
+ export declare const DASHBOARD_PORT_SPAN = 12000;
80
+ /**
81
+ * The loopback port for a tenant's box-mode dashboard, derived deterministically
82
+ * from its dashboard host.
83
+ *
84
+ * Every dashboard used to default to a single hard-coded port (7676), so two
85
+ * Stacks apps sharing a box both tried to bind it: the first won, the second
86
+ * crash-looped on EADDRINUSE, and — because its rpx route still pointed at that
87
+ * port — the second tenant's `dashboard.<domain>` silently served the FIRST
88
+ * tenant's dashboard. Deriving from the (globally unique) dashboard host gives
89
+ * each tenant its own port with no cross-tenant coordination, stays stable
90
+ * across deploys (same host → same port), and stays inside {@link
91
+ * DASHBOARD_PORT_BASE}..+{@link DASHBOARD_PORT_SPAN}. An explicit port (config
92
+ * `port` / `TS_CLOUD_UI_PORT`) still wins for anyone who wants to pin it.
93
+ */
94
+ export declare function deriveManagementDashboardPort(dashboardHost: string): number;
68
95
  /**
69
96
  * Derive the PRIMARY dashboard hostname (`dashboard.<apex>`) for the project.
70
97
  * Prefers `explicit`, else the project's canonical domain (`infrastructure.dns.domain`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ts-cloud/core",
3
- "version": "0.7.28",
3
+ "version": "0.7.29",
4
4
  "type": "module",
5
5
  "description": "Core CloudFormation generation library for ts-cloud",
6
6
  "author": "Chris Breuer <chris@stacksjs.com>",
@@ -31,7 +31,7 @@
31
31
  "typecheck": "tsc --noEmit"
32
32
  },
33
33
  "dependencies": {
34
- "@ts-cloud/aws-types": "0.7.28"
34
+ "@ts-cloud/aws-types": "0.7.29"
35
35
  },
36
36
  "devDependencies": {
37
37
  "typescript": "^7.0.2"