@ts-cloud/core 0.4.2 → 0.5.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/dist/index.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ export * from './presets/traditional-web-app';
|
|
|
29
29
|
export * from './presets/laravel';
|
|
30
30
|
export * from './presets/serverless-laravel';
|
|
31
31
|
export * from './presets/dashboard';
|
|
32
|
+
export * from './presets/management-dashboard';
|
|
32
33
|
export * from './presets/extend';
|
|
33
34
|
export * from './aws/signature';
|
|
34
35
|
export * from './aws/credentials';
|
package/dist/index.js
CHANGED
|
@@ -22307,6 +22307,57 @@ function createDashboardSite(options) {
|
|
|
22307
22307
|
}
|
|
22308
22308
|
};
|
|
22309
22309
|
}
|
|
22310
|
+
// src/presets/management-dashboard.ts
|
|
22311
|
+
function apexOf(domain) {
|
|
22312
|
+
const parts = domain.split(".").filter(Boolean);
|
|
22313
|
+
return parts.length <= 2 ? domain : parts.slice(-2).join(".");
|
|
22314
|
+
}
|
|
22315
|
+
function resolveDashboardDomain(config, environment, explicit) {
|
|
22316
|
+
if (explicit)
|
|
22317
|
+
return explicit;
|
|
22318
|
+
const candidates = [];
|
|
22319
|
+
for (const site of Object.values(config.sites ?? {})) {
|
|
22320
|
+
const d = site?.domain;
|
|
22321
|
+
if (typeof d === "string")
|
|
22322
|
+
candidates.push(d);
|
|
22323
|
+
else if (Array.isArray(d))
|
|
22324
|
+
candidates.push(...d.filter((x) => typeof x === "string"));
|
|
22325
|
+
}
|
|
22326
|
+
if (environment && config.environments?.[environment]?.domain)
|
|
22327
|
+
candidates.push(config.environments[environment].domain);
|
|
22328
|
+
const dnsDomain = config.infrastructure?.dns?.domain;
|
|
22329
|
+
if (dnsDomain)
|
|
22330
|
+
candidates.push(dnsDomain);
|
|
22331
|
+
const base = candidates.find((d) => d && !d.startsWith("dashboard."));
|
|
22332
|
+
if (!base)
|
|
22333
|
+
return null;
|
|
22334
|
+
return `dashboard.${apexOf(base)}`;
|
|
22335
|
+
}
|
|
22336
|
+
function hasManagementDashboardSite(config) {
|
|
22337
|
+
return Object.entries(config.sites ?? {}).some(([name, site]) => {
|
|
22338
|
+
if (!site)
|
|
22339
|
+
return false;
|
|
22340
|
+
const root = site.root ?? "";
|
|
22341
|
+
return name === "dashboard" || root === "ui/dist" || root.endsWith("/ui/dist") || root.endsWith("/dist/ui");
|
|
22342
|
+
});
|
|
22343
|
+
}
|
|
22344
|
+
function resolveManagementDashboardSite(config, environment, opts) {
|
|
22345
|
+
if (hasManagementDashboardSite(config))
|
|
22346
|
+
return null;
|
|
22347
|
+
const domain = resolveDashboardDomain(config, environment, opts.domain);
|
|
22348
|
+
if (!domain)
|
|
22349
|
+
return null;
|
|
22350
|
+
const site = {
|
|
22351
|
+
root: opts.uiRoot,
|
|
22352
|
+
deploy: "server",
|
|
22353
|
+
type: "static",
|
|
22354
|
+
domain,
|
|
22355
|
+
ssl: { provider: "letsencrypt" },
|
|
22356
|
+
...opts.build === false || opts.build === undefined ? {} : { build: opts.build },
|
|
22357
|
+
...opts.password ? { auth: { username: opts.username || "admin", password: opts.password, realm: opts.realm } } : {}
|
|
22358
|
+
};
|
|
22359
|
+
return { name: "dashboard", site };
|
|
22360
|
+
}
|
|
22310
22361
|
// src/presets/extend.ts
|
|
22311
22362
|
function deepMerge(target, source) {
|
|
22312
22363
|
const result = { ...target };
|
|
@@ -46910,7 +46961,9 @@ export {
|
|
|
46910
46961
|
resolveRegion,
|
|
46911
46962
|
resolveQueueNames,
|
|
46912
46963
|
resolveProjectStackName,
|
|
46964
|
+
resolveManagementDashboardSite,
|
|
46913
46965
|
resolveDeployBucketName,
|
|
46966
|
+
resolveDashboardDomain,
|
|
46914
46967
|
resolveCredentials,
|
|
46915
46968
|
resolveCloudProvider,
|
|
46916
46969
|
resolveApp,
|
|
@@ -46964,6 +47017,7 @@ export {
|
|
|
46964
47017
|
hashFile,
|
|
46965
47018
|
hashDirectory,
|
|
46966
47019
|
hashBuffer,
|
|
47020
|
+
hasManagementDashboardSite,
|
|
46967
47021
|
guardDutyManager,
|
|
46968
47022
|
globalResourceManager,
|
|
46969
47023
|
getTimestamp,
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { CloudConfig, EnvironmentType, SiteConfig } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Auto-deployed management dashboard (the `@ts-cloud/ui` stx app — the Server +
|
|
4
|
+
* Serverless views). When a server is provisioned, ts-cloud injects this as a
|
|
5
|
+
* server-static site so the dashboard ships automatically with every box.
|
|
6
|
+
*
|
|
7
|
+
* It is served behind HTTP Basic auth (htpasswd) whose password comes from an
|
|
8
|
+
* environment value (`TS_CLOUD_UI_PASSWORD`). If that value is NOT set, the
|
|
9
|
+
* dashboard is served WITHOUT auth — no password is invented.
|
|
10
|
+
*/
|
|
11
|
+
export interface ManagementDashboardOptions {
|
|
12
|
+
/** Directory shipped as the static site root (built UI, or source dir + build). */
|
|
13
|
+
uiRoot: string;
|
|
14
|
+
/** Build command producing {@link uiRoot}, or false when it is already built. */
|
|
15
|
+
build?: string | false;
|
|
16
|
+
/** Explicit domain (e.g. from `TS_CLOUD_UI_DOMAIN`); else derived. */
|
|
17
|
+
domain?: string;
|
|
18
|
+
/** Basic-auth username. @default 'admin' */
|
|
19
|
+
username?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Basic-auth password. When empty/undefined the dashboard is served WITHOUT
|
|
22
|
+
* htpasswd (no default password is invented).
|
|
23
|
+
*/
|
|
24
|
+
password?: string;
|
|
25
|
+
/** Browser auth realm. */
|
|
26
|
+
realm?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Derive a dashboard hostname (`dashboard.<apex>`) from the project's configured
|
|
30
|
+
* domains. Prefers `explicit`, then any site domain, then the environment domain,
|
|
31
|
+
* then `infrastructure.dns.domain`. Returns null when nothing is available.
|
|
32
|
+
*/
|
|
33
|
+
export declare function resolveDashboardDomain(config: Pick<CloudConfig, 'sites' | 'environments' | 'infrastructure'>, environment?: EnvironmentType, explicit?: string): string | null;
|
|
34
|
+
/** Does the config already define the management dashboard as a site? */
|
|
35
|
+
export declare function hasManagementDashboardSite(config: Pick<CloudConfig, 'sites'>): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Build the management-dashboard site to auto-inject on server deploys, or null
|
|
38
|
+
* when no domain can be resolved (the static-site model is domain-routed) or it
|
|
39
|
+
* is already configured.
|
|
40
|
+
*/
|
|
41
|
+
export declare function resolveManagementDashboardSite(config: Pick<CloudConfig, 'sites' | 'environments' | 'infrastructure'>, environment: EnvironmentType, opts: ManagementDashboardOptions): {
|
|
42
|
+
name: string;
|
|
43
|
+
site: SiteConfig;
|
|
44
|
+
} | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ts-cloud/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
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.
|
|
34
|
+
"@ts-cloud/aws-types": "0.5.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"typescript": "^5.9.3"
|