@empire-builder-kit/nx 1.0.0-rc.45 → 1.0.0-rc.47
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/generators.json +11 -1
- package/package.json +3 -3
- package/src/aws-authority/stage-authority.d.ts +30 -2
- package/src/aws-authority/stage-authority.js +220 -25
- package/src/developer-agent/generator-planning.js +109 -9
- package/src/developer-agent/model.d.ts +7 -3
- package/src/developer-agent/model.js +1 -0
- package/src/developer-agent/operation-registry.d.ts +1 -0
- package/src/developer-agent/operation-registry.js +44 -3
- package/src/developer-agent/planning.js +5 -2
- package/src/developer-agent/preview-changes.js +10 -0
- package/src/developer-agent/validation.js +7 -3
- package/src/developer-agent/workspace-inspection.js +51 -4
- package/src/executors/deployment-plan/deployment-plan.js +3 -0
- package/src/executors/dev-doctor/dev-doctor.d.ts +25 -3
- package/src/executors/dev-doctor/dev-doctor.js +136 -49
- package/src/executors/dev-setup/dev-setup.d.ts +18 -1
- package/src/executors/dev-setup/dev-setup.js +320 -196
- package/src/executors/foundation-preflight/foundation-preflight.js +9 -1
- package/src/executors/foundation-remove-preflight/foundation-remove-preflight.js +2 -2
- package/src/executors/github-bootstrap/github-bootstrap.d.ts +3 -0
- package/src/executors/github-bootstrap/github-bootstrap.js +28 -0
- package/src/executors/github-bootstrap/schema.json +14 -0
- package/src/executors/infrastructure-plan/infrastructure-plan.js +10 -3
- package/src/executors/local-deploy/local-deploy.d.ts +15 -0
- package/src/executors/local-deploy/local-deploy.js +96 -14
- package/src/executors/sst-lifecycle/logging-preflight.js +12 -1
- package/src/executors/sst-lifecycle/run-sst-command.js +51 -5
- package/src/foundation/cost-estimate.js +1 -1
- package/src/foundation/identity-domain-parent-ready.d.ts +91 -0
- package/src/foundation/identity-domain-parent-ready.js +333 -0
- package/src/foundation/identity-domain.d.ts +94 -0
- package/src/foundation/identity-domain.js +115 -0
- package/src/foundation/index.d.ts +2 -0
- package/src/foundation/index.js +7 -0
- package/src/foundation/preflight.js +17 -1
- package/src/foundation/root-site-readiness.d.ts +27 -0
- package/src/foundation/root-site-readiness.js +78 -0
- package/src/foundation/root-site.d.ts +81 -0
- package/src/foundation/root-site.js +268 -0
- package/src/generators/framework-prerequisites.d.ts +2 -0
- package/src/generators/framework-prerequisites.js +34 -0
- package/src/generators/function/function-registration.d.ts +24 -0
- package/src/generators/function/function-registration.js +66 -0
- package/src/generators/function/function.d.ts +16 -1
- package/src/generators/function/function.js +101 -18
- package/src/generators/function/schema.d.ts +1 -0
- package/src/generators/function/schema.json +6 -0
- package/src/generators/function-access/function-access.d.ts +14 -0
- package/src/generators/function-access/function-access.js +141 -0
- package/src/generators/function-access/schema.d.ts +6 -0
- package/src/generators/function-access/schema.json +25 -0
- package/src/generators/post-generation-install.d.ts +1 -1
- package/src/generators/post-generation-install.js +1 -1
- package/src/generators/preset/dependency-overrides.d.ts +1 -1
- package/src/generators/preset/dependency-overrides.js +1 -1
- package/src/generators/preset/workspace-files-adopter-skills.js +14 -0
- package/src/generators/preset/workspace-files-developer-agent.js +17 -11
- package/src/generators/preset/workspace-files-stage-authority.js +58 -1
- package/src/generators/preset/workspace-files-thin-deploy.d.ts +11 -0
- package/src/generators/preset/workspace-files-thin-deploy.js +52 -5
- package/src/generators/preset/workspace-files-thin-docs.js +33 -5
- package/src/generators/preset/workspace-files.js +238 -41
- package/src/generators/repository-policy/repository-policy.js +2 -1
- package/src/generators/repository-policy/schema.d.ts +2 -0
- package/src/generators/repository-policy/schema.json +7 -2
- package/src/generators/site/built-in-site-documentation-files.d.ts +2 -0
- package/src/generators/site/built-in-site-documentation-files.js +92 -0
- package/src/generators/site/built-in-site-files.d.ts +8 -0
- package/src/generators/site/built-in-site-files.js +40 -0
- package/src/generators/site/built-in-site-infrastructure-files.d.ts +2 -0
- package/src/generators/site/built-in-site-infrastructure-files.js +275 -0
- package/src/generators/site/built-in-site-plan.d.ts +19 -0
- package/src/generators/site/built-in-site-plan.js +65 -0
- package/src/generators/site/built-in-site-project-files.d.ts +3 -0
- package/src/generators/site/built-in-site-project-files.js +258 -0
- package/src/generators/site/built-in-site-script-files.d.ts +2 -0
- package/src/generators/site/built-in-site-script-files.js +306 -0
- package/src/generators/site/built-in-site-shared.d.ts +9 -0
- package/src/generators/site/built-in-site-shared.js +21 -0
- package/src/generators/site/built-in-site-smoke-files.d.ts +2 -0
- package/src/generators/site/built-in-site-smoke-files.js +37 -0
- package/src/generators/site/built-in-site-sst-config-files.d.ts +2 -0
- package/src/generators/site/built-in-site-sst-config-files.js +39 -0
- package/src/generators/site/built-in-site-web-files.d.ts +2 -0
- package/src/generators/site/built-in-site-web-files.js +284 -0
- package/src/generators/site/schema.d.ts +4 -0
- package/src/generators/site/schema.json +20 -0
- package/src/generators/site/site.d.ts +13 -0
- package/src/generators/site/site.js +221 -0
- package/src/generators/slice/built-in-plan-alarm-identity.d.ts +9 -0
- package/src/generators/slice/built-in-plan-alarm-identity.js +8 -1
- package/src/generators/slice/built-in-plan-api-contract-files.js +18 -0
- package/src/generators/slice/built-in-plan-async-work-files.js +18 -0
- package/src/generators/slice/built-in-plan-data-files.js +126 -14
- package/src/generators/slice/built-in-plan-foundation-files.d.ts +12 -0
- package/src/generators/slice/built-in-plan-foundation-files.js +114 -5
- package/src/generators/slice/built-in-plan-frontend-files.js +2 -271
- package/src/generators/slice/built-in-plan-frontend-header-proof.d.ts +6 -0
- package/src/generators/slice/built-in-plan-frontend-header-proof.js +282 -0
- package/src/generators/slice/built-in-plan-infrastructure-files.js +151 -237
- package/src/generators/slice/built-in-plan-key-value-cleanup.js +4 -3
- package/src/generators/slice/built-in-plan-log-group-helpers.d.ts +29 -0
- package/src/generators/slice/built-in-plan-log-group-helpers.js +130 -0
- package/src/generators/slice/built-in-plan-metadata-files.js +25 -5
- package/src/generators/slice/built-in-plan-next-build-authority.d.ts +5 -0
- package/src/generators/slice/built-in-plan-next-build-authority.js +124 -0
- package/src/generators/slice/built-in-plan-operations-files.d.ts +6 -0
- package/src/generators/slice/built-in-plan-operations-files.js +107 -219
- package/src/generators/slice/built-in-plan-performance-files.js +6 -1
- package/src/generators/slice/built-in-plan-release-files.js +0 -1
- package/src/generators/slice/built-in-plan-reliability-files.js +12 -8
- package/src/generators/slice/built-in-plan-shared.d.ts +1 -1
- package/src/generators/slice/built-in-plan-shared.js +1 -1
- package/src/generators/slice/built-in-plan-sst-config.d.ts +49 -0
- package/src/generators/slice/built-in-plan-sst-config.js +160 -0
- package/src/generators/slice/built-in-plan-testing-files.js +92 -49
- package/src/generators/slice/built-in-plan-verification-files.js +15 -5
- package/src/generators/slice/built-in-plan-web-files.js +69 -5
- package/src/generators/slice/built-in-plan.js +1 -2
- package/src/generators/slice/deployed-smoke-diagnostics.d.ts +35 -0
- package/src/generators/slice/deployed-smoke-diagnostics.js +189 -0
- package/src/generators/slice/deployed-smoke-readiness.d.ts +7 -0
- package/src/generators/slice/deployed-smoke-readiness.js +118 -23
- package/src/generators/slice/persistence-contract.js +2 -2
- package/src/generators/slice/pnpm-launch-script.d.ts +13 -0
- package/src/generators/slice/pnpm-launch-script.js +28 -0
- package/src/generators/slice/slice.js +27 -0
- package/src/generators/upgrade/custom-domain-notice.d.ts +19 -0
- package/src/generators/upgrade/custom-domain-notice.js +38 -0
- package/src/generators/upgrade/external-blueprint-compositions.d.ts +84 -0
- package/src/generators/upgrade/external-blueprint-compositions.js +478 -0
- package/src/generators/upgrade/framework-package-upgrade.d.ts +58 -0
- package/src/generators/upgrade/framework-package-upgrade.js +78 -0
- package/src/generators/upgrade/function-authentication-notice.d.ts +29 -0
- package/src/generators/upgrade/function-authentication-notice.js +74 -0
- package/src/generators/upgrade/schema.json +2 -2
- package/src/generators/upgrade/upgrade-plan.d.ts +52 -0
- package/src/generators/upgrade/upgrade-plan.js +406 -0
- package/src/generators/upgrade/upgrade.d.ts +1 -35
- package/src/generators/upgrade/upgrade.js +347 -595
- package/src/generators/workload/reliability-registration.d.ts +1 -1
- package/src/generators/workload/reliability-registration.js +9 -9
- package/src/generators/workload/workload.d.ts +1 -1
- package/src/generators/workload/workload.js +87 -13
- package/src/git-policy/github-bootstrap.d.ts +24 -5
- package/src/git-policy/github-bootstrap.js +105 -10
- package/src/local-dev/fleet-process.d.ts +9 -2
- package/src/local-dev/fleet-process.js +27 -7
- package/src/local-dev/fleet-session.js +41 -4
- package/src/local-dev/fleet-supervisor-daemon.js +1 -5
- package/src/local-dev/fleet-supervisor.d.ts +1 -0
- package/src/local-dev/fleet-supervisor.js +34 -11
- package/src/local-dev/gateway-daemon.d.ts +1 -1
- package/src/local-dev/gateway-daemon.js +6 -4
- package/src/local-dev/portless.d.ts +5 -0
- package/src/local-dev/portless.js +5 -0
- package/src/local-dev/process-group.d.ts +10 -0
- package/src/local-dev/process-group.js +33 -0
- package/src/local-dev/tls.js +31 -2
- package/src/local-dev/trust-store.d.ts +42 -0
- package/src/local-dev/trust-store.js +87 -0
- package/src/ownership/composition.d.ts +7 -0
- package/src/ownership/composition.js +64 -56
- package/src/ownership/index.d.ts +1 -0
- package/src/ownership/index.js +1 -0
- package/src/ownership/record.d.ts +19 -0
- package/src/ownership/record.js +26 -2
- package/src/ownership/site-record.d.ts +18 -0
- package/src/ownership/site-record.js +105 -0
- package/src/repository-policy/deployment-plan.d.ts +3 -0
- package/src/repository-policy/deployment-plan.js +33 -4
- package/src/repository-policy/index.d.ts +1 -0
- package/src/repository-policy/index.js +1 -0
- package/src/repository-policy/policy.d.ts +13 -1
- package/src/repository-policy/policy.js +55 -1
- package/src/repository-policy/public-dns.d.ts +65 -0
- package/src/repository-policy/public-dns.js +168 -0
- package/src/schemas/generated-ownership-v2.json +6 -0
- package/src/schemas/repository-policy-v1.json +67 -1
- package/src/supply-chain/blueprint-trust-git.js +24 -0
- package/src/supply-chain/blueprint-verification-authority.js +42 -3
- package/src/supply-chain/generated-blueprint-trust-command.js +15 -0
- package/src/supply-chain/sbom.js +74 -12
- package/src/work-markers/work-markers.js +4 -1
- package/src/workspace-deployment/ownership.d.ts +15 -0
- package/src/workspace-deployment/ownership.js +19 -3
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.renderSiteDocumentationFiles = renderSiteDocumentationFiles;
|
|
4
|
+
const root_site_js_1 = require("../../foundation/root-site.js");
|
|
5
|
+
const built_in_site_shared_js_1 = require("./built-in-site-shared.js");
|
|
6
|
+
/** @internal */
|
|
7
|
+
function renderSiteDocumentationFiles() {
|
|
8
|
+
const logComponents = root_site_js_1.ROOT_SITE_LOG_COMPONENTS.map((component) => `\`${component}\``);
|
|
9
|
+
const logComponentList = `${logComponents.slice(0, -1).join(', ')} and ${logComponents[logComponents.length - 1]}`;
|
|
10
|
+
return {
|
|
11
|
+
'README.md': `# Root site
|
|
12
|
+
|
|
13
|
+
The workspace root site: a Next.js app that the Foundation Router serves at
|
|
14
|
+
\`/\` of each stage, beside the Product Slices at \`/<slice>\`. On a stage bound
|
|
15
|
+
to a custom domain it is the website at \`https://example.com/\`.
|
|
16
|
+
|
|
17
|
+
- Pages, components and content live under \`web/src/app/\` and
|
|
18
|
+
\`web/public/\`. They are yours to change.
|
|
19
|
+
- Managed files (see \`.ebk/ownership.json\`) are re-rendered by the root site
|
|
20
|
+
upgrade. Seeded files, such as this README, the starting pages and
|
|
21
|
+
\`frontend/security-headers.json\`, are yours after generation.
|
|
22
|
+
|
|
23
|
+
## Routing
|
|
24
|
+
|
|
25
|
+
Every Product Slice path takes precedence over the root site on every host:
|
|
26
|
+
\`/billing\` and \`/billing/...\` go to a \`billing\` Slice, and \`/\`,
|
|
27
|
+
\`/billing-faq\` and any other path go to the site. \`pnpm nx run
|
|
28
|
+
site:route-check\` refuses a site route that a Slice would take:
|
|
29
|
+
|
|
30
|
+
- a top-level page, folder or public file named like a Product Slice;
|
|
31
|
+
- a top-level \`web/public/\` directory whose name starts another path, because
|
|
32
|
+
the Router serves such a directory for every path with that prefix;
|
|
33
|
+
- an HTML file under \`web/public/\`, which the Router would serve without the
|
|
34
|
+
managed security headers;
|
|
35
|
+
- a top-level catch-all route, the \`/__ebk\` and \`/_next\` paths, and the Pages
|
|
36
|
+
Router.
|
|
37
|
+
|
|
38
|
+
A one-segment dynamic route such as \`[slug]\` cannot be checked. Slices take
|
|
39
|
+
its names, and its responses must stay dynamic or \`no-store\`.
|
|
40
|
+
|
|
41
|
+
The site answers \`${root_site_js_1.ROOT_SITE_HEALTH_PATH}\` for deployed readiness. Its managed proxy
|
|
42
|
+
marks every response it handles with \`${root_site_js_1.ROOT_SITE_ROUTE_HEADER}: ${root_site_js_1.ROOT_SITE_ROUTE_HEADER_VALUE}\`; Next.js's own
|
|
43
|
+
path-normalization redirects and the files the Router serves from storage
|
|
44
|
+
carry no marker. On a bound stage it answers only on the root domain and
|
|
45
|
+
redirects every other subdomain there with a 308.
|
|
46
|
+
|
|
47
|
+
## Security
|
|
48
|
+
|
|
49
|
+
The site shares its origin with every Product Slice, and every Slice session
|
|
50
|
+
cookie reaches it. It has no sign-in, API or mutating routes in this release;
|
|
51
|
+
link to a Slice's \`/<slice>/sign-in\` page instead. A script on the site can
|
|
52
|
+
call every Slice's same-origin routes, so keep \`frontend/security-headers.json\`
|
|
53
|
+
strict. Its \`worker-src 'none'\` keeps a service worker from taking scope \`/\`,
|
|
54
|
+
where it would intercept every Slice page; relaxing it is your decision.
|
|
55
|
+
|
|
56
|
+
## Commands
|
|
57
|
+
|
|
58
|
+
- \`pnpm nx run site:dev\`: local development at
|
|
59
|
+
\`http://127.0.0.1:${built_in_site_shared_js_1.ROOT_SITE_DEV_PORT}\`. The local Fleet does not route \`/\`, and the
|
|
60
|
+
site has no \`sst dev\` mode.
|
|
61
|
+
- \`pnpm nx run site:verify\`: typecheck, lint, route check, tests, the
|
|
62
|
+
deployed smoke listing and build.
|
|
63
|
+
- \`pnpm nx run site:smoke-deployed\`: deployed readiness on
|
|
64
|
+
\`${root_site_js_1.ROOT_SITE_HEALTH_PATH}\`, then \`e2e/site.spec.ts\` and the header proof on
|
|
65
|
+
the deployed URL. \`ebk deploy\` runs it after each site deploy.
|
|
66
|
+
- \`ebk deploy development\`: deploys the Foundation, then the site, then the
|
|
67
|
+
Slices. Remove the site after the Slices and before the Foundation.
|
|
68
|
+
|
|
69
|
+
Production deploys the site only when \`site.productionStatus\` is \`ready\` in
|
|
70
|
+
\`ebk.repository-policy.json\`.
|
|
71
|
+
|
|
72
|
+
## Site recovery
|
|
73
|
+
|
|
74
|
+
The \`site-server-errors\` alarm reports server errors from the site's
|
|
75
|
+
Next.js server. Read \`/ebk/<stage>/${root_site_js_1.ROOT_SITE_NAME}/next-server\` in CloudWatch Logs,
|
|
76
|
+
fix the cause, and redeploy.
|
|
77
|
+
|
|
78
|
+
A \`site-data-protection-findings\` alarm reports a protected-data finding in
|
|
79
|
+
one of the site's managed log groups, \`/ebk/<stage>/${root_site_js_1.ROOT_SITE_NAME}/<component>\` for
|
|
80
|
+
${logComponentList}.
|
|
81
|
+
Each group's data protection policy masks the matched value and audits the
|
|
82
|
+
finding, and the alarm's \`LogGroupName\` dimension names the group. Query
|
|
83
|
+
that group in CloudWatch Logs Insights over a bounded time range with
|
|
84
|
+
\`filter ispresent(@dataProtection)\`: the results show the events with a
|
|
85
|
+
finding, with the value masked. Unmasking it is a separate break-glass
|
|
86
|
+
authority, not implied by query access. Find the page, route or dependency
|
|
87
|
+
that logged the value, stop it logging the value, and redeploy. An empty
|
|
88
|
+
query result does not by itself resolve the incident.
|
|
89
|
+
`,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=built-in-site-documentation-files.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { ROOT_SITE_PACKAGE_MANAGED_JSON_POINTERS } from './built-in-site-project-files.js';
|
|
2
|
+
export { ROOT_SITE_DEV_PORT, ROOT_SITE_NEXT_BUILD_ENVIRONMENT_KEYS, } from './built-in-site-shared.js';
|
|
3
|
+
/** Every file of a generated root site, keyed by its path in packages/site. */
|
|
4
|
+
export declare function renderBuiltInSiteFiles(input: {
|
|
5
|
+
/** The workspace runtime version, stamped as the framework version tag. */
|
|
6
|
+
runtimeVersion: string;
|
|
7
|
+
scope: string;
|
|
8
|
+
}): Record<string, string>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ROOT_SITE_NEXT_BUILD_ENVIRONMENT_KEYS = exports.ROOT_SITE_DEV_PORT = exports.ROOT_SITE_PACKAGE_MANAGED_JSON_POINTERS = void 0;
|
|
4
|
+
exports.renderBuiltInSiteFiles = renderBuiltInSiteFiles;
|
|
5
|
+
const built_in_site_documentation_files_js_1 = require("./built-in-site-documentation-files.js");
|
|
6
|
+
const built_in_site_infrastructure_files_js_1 = require("./built-in-site-infrastructure-files.js");
|
|
7
|
+
const built_in_site_project_files_js_1 = require("./built-in-site-project-files.js");
|
|
8
|
+
const built_in_site_script_files_js_1 = require("./built-in-site-script-files.js");
|
|
9
|
+
const built_in_site_smoke_files_js_1 = require("./built-in-site-smoke-files.js");
|
|
10
|
+
const built_in_site_sst_config_files_js_1 = require("./built-in-site-sst-config-files.js");
|
|
11
|
+
const built_in_site_web_files_js_1 = require("./built-in-site-web-files.js");
|
|
12
|
+
var built_in_site_project_files_js_2 = require("./built-in-site-project-files.js");
|
|
13
|
+
Object.defineProperty(exports, "ROOT_SITE_PACKAGE_MANAGED_JSON_POINTERS", { enumerable: true, get: function () { return built_in_site_project_files_js_2.ROOT_SITE_PACKAGE_MANAGED_JSON_POINTERS; } });
|
|
14
|
+
var built_in_site_shared_js_1 = require("./built-in-site-shared.js");
|
|
15
|
+
Object.defineProperty(exports, "ROOT_SITE_DEV_PORT", { enumerable: true, get: function () { return built_in_site_shared_js_1.ROOT_SITE_DEV_PORT; } });
|
|
16
|
+
Object.defineProperty(exports, "ROOT_SITE_NEXT_BUILD_ENVIRONMENT_KEYS", { enumerable: true, get: function () { return built_in_site_shared_js_1.ROOT_SITE_NEXT_BUILD_ENVIRONMENT_KEYS; } });
|
|
17
|
+
/** Every file of a generated root site, keyed by its path in packages/site. */
|
|
18
|
+
function renderBuiltInSiteFiles(input) {
|
|
19
|
+
const workspace = input.scope.slice(1);
|
|
20
|
+
const groups = [
|
|
21
|
+
(0, built_in_site_project_files_js_1.renderSiteProjectFiles)(input.scope),
|
|
22
|
+
(0, built_in_site_sst_config_files_js_1.renderSiteSstConfigFiles)(workspace, input.runtimeVersion),
|
|
23
|
+
(0, built_in_site_infrastructure_files_js_1.renderSiteInfrastructureFiles)(workspace),
|
|
24
|
+
(0, built_in_site_web_files_js_1.renderSiteWebFiles)(),
|
|
25
|
+
(0, built_in_site_script_files_js_1.renderSiteScriptFiles)(),
|
|
26
|
+
(0, built_in_site_documentation_files_js_1.renderSiteDocumentationFiles)(),
|
|
27
|
+
(0, built_in_site_smoke_files_js_1.renderSiteSmokeFiles)(),
|
|
28
|
+
];
|
|
29
|
+
const files = {};
|
|
30
|
+
for (const group of groups) {
|
|
31
|
+
for (const [path, contents] of Object.entries(group)) {
|
|
32
|
+
if (Object.prototype.hasOwnProperty.call(files, path)) {
|
|
33
|
+
throw new Error(`Root site renderer duplicates ${path}.`);
|
|
34
|
+
}
|
|
35
|
+
files[path] = contents;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return files;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=built-in-site-files.js.map
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.renderSiteInfrastructureFiles = renderSiteInfrastructureFiles;
|
|
4
|
+
const root_site_js_1 = require("../../foundation/root-site.js");
|
|
5
|
+
const built_in_plan_alarm_identity_js_1 = require("../slice/built-in-plan-alarm-identity.js");
|
|
6
|
+
const built_in_plan_foundation_files_js_1 = require("../slice/built-in-plan-foundation-files.js");
|
|
7
|
+
const built_in_plan_log_group_helpers_js_1 = require("../slice/built-in-plan-log-group-helpers.js");
|
|
8
|
+
const built_in_plan_next_build_authority_js_1 = require("../slice/built-in-plan-next-build-authority.js");
|
|
9
|
+
const built_in_site_shared_js_1 = require("./built-in-site-shared.js");
|
|
10
|
+
/** The root site's alarms; both name the README's Site recovery section. */
|
|
11
|
+
const SITE_SERVER_ERRORS_ALARM = {
|
|
12
|
+
businessSymptom: 'The root site is failing requests.',
|
|
13
|
+
id: 'site-server-errors',
|
|
14
|
+
runbook: 'site-recovery',
|
|
15
|
+
};
|
|
16
|
+
const SITE_DATA_PROTECTION_ALARM = {
|
|
17
|
+
// The symptom every Slice log group's findings alarm reports.
|
|
18
|
+
businessSymptom: (0, built_in_plan_alarm_identity_js_1.sliceAlarmIdentity)(root_site_js_1.ROOT_SITE_NAME, 'data-protection-findings').businessSymptom,
|
|
19
|
+
id: 'site-data-protection-findings',
|
|
20
|
+
runbook: 'site-recovery',
|
|
21
|
+
};
|
|
22
|
+
/** @internal */
|
|
23
|
+
function renderSiteInfrastructureFiles(workspace) {
|
|
24
|
+
// The Slice's managed log-group helpers: each group gets the Slice's
|
|
25
|
+
// contract, data protection policy and findings alarm.
|
|
26
|
+
const logHelpers = (0, built_in_plan_log_group_helpers_js_1.renderManagedLogHelpers)({
|
|
27
|
+
dataProtectionAlarm: SITE_DATA_PROTECTION_ALARM,
|
|
28
|
+
name: root_site_js_1.ROOT_SITE_NAME,
|
|
29
|
+
workspace,
|
|
30
|
+
});
|
|
31
|
+
return {
|
|
32
|
+
'infra/foundation.ts': `import {
|
|
33
|
+
foundationSsmPath,
|
|
34
|
+
productSliceRegistrationPath,
|
|
35
|
+
resolveFoundationStages,
|
|
36
|
+
} from '@empire-builder-kit/nx/foundation';
|
|
37
|
+
|
|
38
|
+
const stages = resolveFoundationStages({
|
|
39
|
+
consumerStage: $app.stage,
|
|
40
|
+
foundationStage: process.env.EBK_FOUNDATION_STAGE,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
function foundationParameter(name: Parameters<typeof foundationSsmPath>[1]) {
|
|
44
|
+
return aws.ssm.getParameterOutput({
|
|
45
|
+
name: foundationSsmPath(stages.foundationStage, name),
|
|
46
|
+
}).value;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// The root site reads only the Router discovery it attaches to.
|
|
50
|
+
export function getFoundation() {
|
|
51
|
+
return {
|
|
52
|
+
alertTopicArn: foundationParameter('alertTopicArn'),
|
|
53
|
+
hasPublicDomain: foundationParameter('hasPublicDomain').apply(
|
|
54
|
+
(value: string) => value === 'true',
|
|
55
|
+
),
|
|
56
|
+
rootDomain: foundationParameter('rootDomain').apply((value: string) =>
|
|
57
|
+
value === 'none' ? undefined : value,
|
|
58
|
+
),
|
|
59
|
+
routerDistributionId: foundationParameter('routerDistributionId'),
|
|
60
|
+
routerUrl: foundationParameter('routerUrl'),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
${(0, built_in_plan_foundation_files_js_1.renderFoundationRouterWebUrl)({
|
|
65
|
+
comment: `// SST derives a referenced Router's url from the distribution's first alias,
|
|
66
|
+
// which can be the wildcard alias when the Foundation serves a custom domain.
|
|
67
|
+
// The root site's deployed URL comes only from the Foundation's published
|
|
68
|
+
// routerUrl, never from the referenced Router or the Next.js component. The
|
|
69
|
+
// host check refuses a '*' and any character outside letters, digits, '.' and
|
|
70
|
+
// '-'; it is not a hostname validator.
|
|
71
|
+
`,
|
|
72
|
+
functionName: 'foundationSiteWebUrl',
|
|
73
|
+
path: '/',
|
|
74
|
+
subject: 'the root site',
|
|
75
|
+
})}
|
|
76
|
+
export function getFoundationInfrastructure() {
|
|
77
|
+
const discovery = getFoundation();
|
|
78
|
+
const router = sst.aws.Router.get(
|
|
79
|
+
'FoundationRouter',
|
|
80
|
+
discovery.routerDistributionId,
|
|
81
|
+
);
|
|
82
|
+
return { discovery, router };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// The Foundation's remove fails closed while this registration exists, so
|
|
86
|
+
// the Foundation cannot be removed from under a deployed root site.
|
|
87
|
+
export function registerRootSite() {
|
|
88
|
+
return new aws.ssm.Parameter('SiteRegistration', {
|
|
89
|
+
name: productSliceRegistrationPath(
|
|
90
|
+
stages.foundationStage,
|
|
91
|
+
stages.consumerStage,
|
|
92
|
+
'${root_site_js_1.ROOT_SITE_NAME}',
|
|
93
|
+
),
|
|
94
|
+
type: 'String',
|
|
95
|
+
value: JSON.stringify({
|
|
96
|
+
consumerStage: stages.consumerStage,
|
|
97
|
+
foundationContract: '^2.0.0',
|
|
98
|
+
foundationStage: stages.foundationStage,
|
|
99
|
+
kind: 'root-site',
|
|
100
|
+
name: '${root_site_js_1.ROOT_SITE_NAME}',
|
|
101
|
+
registrationVersion: 1,
|
|
102
|
+
}),
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
`,
|
|
106
|
+
'infra/index.ts': `import { registerRootSite } from './foundation.js';
|
|
107
|
+
import { site } from './site.js';
|
|
108
|
+
|
|
109
|
+
export function app(accountId: string) {
|
|
110
|
+
const registration = registerRootSite();
|
|
111
|
+
const resources = site(accountId);
|
|
112
|
+
return {
|
|
113
|
+
kind: 'site',
|
|
114
|
+
name: '${root_site_js_1.ROOT_SITE_NAME}',
|
|
115
|
+
registration: registration.name,
|
|
116
|
+
stage: $app.stage,
|
|
117
|
+
webUrl: resources.webUrl,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
`,
|
|
121
|
+
// The Slice web's managed Finder-metadata seal.
|
|
122
|
+
'infra/next-build-authority.ts': (0, built_in_plan_next_build_authority_js_1.renderNextBuildAuthority)(),
|
|
123
|
+
'infra/site.ts': `import {
|
|
124
|
+
createManagedLogGroupContract,
|
|
125
|
+
resolveObservabilityPolicy,
|
|
126
|
+
} from '@empire-builder-kit/nx/foundation';
|
|
127
|
+
import observabilityPolicy from '../../../ebk.observability.json';
|
|
128
|
+
import {
|
|
129
|
+
foundationSiteWebUrl,
|
|
130
|
+
getFoundationInfrastructure,
|
|
131
|
+
} from './foundation.js';
|
|
132
|
+
import { removeFinderMetadataFromBuiltFunction } from './next-build-authority.js';
|
|
133
|
+
|
|
134
|
+
const observability = resolveObservabilityPolicy({
|
|
135
|
+
policy: observabilityPolicy,
|
|
136
|
+
stage: $app.stage,
|
|
137
|
+
productionProfile: process.env.EBK_PRODUCTION_FOUNDATION_PROFILE,
|
|
138
|
+
local: false,
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
${logHelpers.managedLogGroup}
|
|
142
|
+
${logHelpers.managedLogContract}
|
|
143
|
+
${logHelpers.operationalAlarmDescription}
|
|
144
|
+
${logHelpers.managedLogDataProtection}
|
|
145
|
+
${logHelpers.lambdaLogging}
|
|
146
|
+
const builtFunctionHook = {
|
|
147
|
+
async postbuild(directory: string) {
|
|
148
|
+
removeFinderMetadataFromBuiltFunction(directory);
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
export function site(accountId: string) {
|
|
153
|
+
// Readiness compares the health route's sourceCommit with the release
|
|
154
|
+
// source: a promoted deploy runs one commit and serves the release it
|
|
155
|
+
// promotes, as a Product Slice's web does.
|
|
156
|
+
const sourceCommit = process.env.EBK_SOURCE_COMMIT ?? '';
|
|
157
|
+
const releaseSourceCommit =
|
|
158
|
+
process.env.EBK_RELEASE_SOURCE_COMMIT ?? sourceCommit;
|
|
159
|
+
if (
|
|
160
|
+
!${built_in_site_shared_js_1.SOURCE_COMMIT_PATTERN}.test(sourceCommit) ||
|
|
161
|
+
!${built_in_site_shared_js_1.SOURCE_COMMIT_PATTERN}.test(releaseSourceCommit)
|
|
162
|
+
) {
|
|
163
|
+
throw new Error(
|
|
164
|
+
'The root site requires exact deployment and release source Git object IDs.',
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
const resourceNames = {
|
|
168
|
+
webAssetsBucket: [
|
|
169
|
+
'ebk',
|
|
170
|
+
accountId,
|
|
171
|
+
$app.stage,
|
|
172
|
+
'${root_site_js_1.ROOT_SITE_NAME}',
|
|
173
|
+
'web-assets',
|
|
174
|
+
].join('-'),
|
|
175
|
+
webRevalidationQueue:
|
|
176
|
+
['ebk', $app.stage, '${root_site_js_1.ROOT_SITE_NAME}', 'web-revalidation'].join('-') +
|
|
177
|
+
'.fifo',
|
|
178
|
+
webRevalidationTable: [
|
|
179
|
+
'ebk',
|
|
180
|
+
$app.stage,
|
|
181
|
+
'${root_site_js_1.ROOT_SITE_NAME}',
|
|
182
|
+
'web-revalidation',
|
|
183
|
+
].join('-'),
|
|
184
|
+
};
|
|
185
|
+
$transform(aws.dynamodb.Table, (args: any, _opts: any, logicalName: string) => {
|
|
186
|
+
if (logicalName === 'SiteWebRevalidationTable') {
|
|
187
|
+
args.name = resourceNames.webRevalidationTable;
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
$transform(aws.sqs.Queue, (args: any, _opts: any, logicalName: string) => {
|
|
191
|
+
if (logicalName === 'SiteWebRevalidationEventsQueue') {
|
|
192
|
+
args.name = resourceNames.webRevalidationQueue;
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
const foundation = getFoundationInfrastructure();
|
|
196
|
+
// Under a custom domain SST's own URL for the Next.js component names the
|
|
197
|
+
// wildcard alias host; the published URL is the Foundation's routerUrl with
|
|
198
|
+
// path '/'.
|
|
199
|
+
const webUrl = foundationSiteWebUrl(foundation.discovery);
|
|
200
|
+
// On a bound stage the site answers only on the root domain; every other
|
|
201
|
+
// alias host is redirected there. Unbound, it answers on the Router host.
|
|
202
|
+
const canonicalHost = $resolve({
|
|
203
|
+
hasPublicDomain: foundation.discovery.hasPublicDomain,
|
|
204
|
+
webUrl,
|
|
205
|
+
}).apply(({ hasPublicDomain, webUrl }) =>
|
|
206
|
+
hasPublicDomain ? new URL(webUrl).hostname : '',
|
|
207
|
+
);
|
|
208
|
+
${root_site_js_1.ROOT_SITE_LOG_COMPONENTS.map((component) => ` const ${component.replace(/-([a-z])/g, (_match, letter) => letter.toUpperCase())}Logs = managedLogGroup(
|
|
209
|
+
'Site${component
|
|
210
|
+
.split('-')
|
|
211
|
+
.map((part) => part[0]?.toUpperCase() + part.slice(1))
|
|
212
|
+
.join('')}Logs',
|
|
213
|
+
'${component}',
|
|
214
|
+
foundation.discovery.alertTopicArn,
|
|
215
|
+
);
|
|
216
|
+
`).join('')}\
|
|
217
|
+
const webServerLogging = lambdaLogging(nextServerLogs.logGroup.name);
|
|
218
|
+
const web = new sst.aws.Nextjs('SiteWeb', {
|
|
219
|
+
buildCommand: 'node ../tools/ebk-next-build-environment.mjs',
|
|
220
|
+
environment: {
|
|
221
|
+
EBK_SITE_CANONICAL_HOST: canonicalHost,
|
|
222
|
+
EBK_SOURCE_COMMIT: releaseSourceCommit,
|
|
223
|
+
EBK_STAGE: $app.stage,
|
|
224
|
+
},
|
|
225
|
+
invalidation: { wait: true },
|
|
226
|
+
path: 'web',
|
|
227
|
+
// A host-less root route: every Slice path is longer, so the Router
|
|
228
|
+
// gives each Slice precedence on every host.
|
|
229
|
+
router: { instance: foundation.router, path: '/' },
|
|
230
|
+
transform: {
|
|
231
|
+
assets: {
|
|
232
|
+
transform: {
|
|
233
|
+
bucket: { bucket: resourceNames.webAssetsBucket },
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
imageOptimizer: {
|
|
237
|
+
hook: builtFunctionHook,
|
|
238
|
+
...lambdaLogging(nextImageOptimizerLogs.logGroup.name),
|
|
239
|
+
},
|
|
240
|
+
revalidationEventsSubscriber: lambdaLogging(
|
|
241
|
+
nextRevalidationSubscriberLogs.logGroup.name,
|
|
242
|
+
),
|
|
243
|
+
revalidationSeeder: lambdaLogging(
|
|
244
|
+
nextRevalidationSeederLogs.logGroup.name,
|
|
245
|
+
),
|
|
246
|
+
server(args: Record<string, unknown>) {
|
|
247
|
+
args.hook = builtFunctionHook;
|
|
248
|
+
Object.assign(args, webServerLogging);
|
|
249
|
+
args.transform = { ...webServerLogging.transform };
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
});
|
|
253
|
+
const serverErrors = new aws.cloudwatch.MetricAlarm('SiteWebServerErrors', {
|
|
254
|
+
alarmActions: [foundation.discovery.alertTopicArn],
|
|
255
|
+
alarmDescription: operationalAlarmDescription(${(0, built_in_plan_alarm_identity_js_1.renderAlarmDescriptionInput)(SITE_SERVER_ERRORS_ALARM, ' ')}),
|
|
256
|
+
comparisonOperator: 'GreaterThanOrEqualToThreshold',
|
|
257
|
+
dimensions: {
|
|
258
|
+
FunctionName: web.nodes.server.apply(
|
|
259
|
+
(server: any) => server.nodes.function.name,
|
|
260
|
+
),
|
|
261
|
+
},
|
|
262
|
+
evaluationPeriods: 1,
|
|
263
|
+
metricName: 'Errors',
|
|
264
|
+
namespace: 'AWS/Lambda',
|
|
265
|
+
period: 300,
|
|
266
|
+
statistic: 'Sum',
|
|
267
|
+
threshold: 1,
|
|
268
|
+
treatMissingData: 'notBreaching',
|
|
269
|
+
});
|
|
270
|
+
return { serverErrors, web, webUrl };
|
|
271
|
+
}
|
|
272
|
+
`,
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
//# sourceMappingURL=built-in-site-infrastructure-files.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type SiteOwnershipRecord } from '../../ownership/index.js';
|
|
2
|
+
/** Starting files that belong to the adopter after generation. */
|
|
3
|
+
export declare const ROOT_SITE_SEEDED_PATHS: readonly ["README.md", "e2e/site.spec.ts", "frontend/security-headers.json", "web/src/app/globals.css", "web/src/app/icon.svg", "web/src/app/layout.tsx", "web/src/app/not-found.tsx", "web/src/app/page.tsx"];
|
|
4
|
+
export interface BuiltInSitePlan {
|
|
5
|
+
files: Readonly<Record<string, string>>;
|
|
6
|
+
ownership: SiteOwnershipRecord;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The deterministic file plan and ownership record of the workspace root site
|
|
10
|
+
* at packages/site.
|
|
11
|
+
*/
|
|
12
|
+
export declare function createBuiltInSitePlan(input: {
|
|
13
|
+
/** The installed @empire-builder-kit/nx version, recorded in ownership. */
|
|
14
|
+
frameworkVersion: string;
|
|
15
|
+
/** The workspace runtime version, stamped into resource tags. */
|
|
16
|
+
runtimeVersion: string;
|
|
17
|
+
/** The workspace package scope, such as `@sample-product`. */
|
|
18
|
+
scope: string;
|
|
19
|
+
}): BuiltInSitePlan;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ROOT_SITE_SEEDED_PATHS = void 0;
|
|
4
|
+
exports.createBuiltInSitePlan = createBuiltInSitePlan;
|
|
5
|
+
const deterministic_order_js_1 = require("../../deterministic-order.js");
|
|
6
|
+
const index_js_1 = require("../../ownership/index.js");
|
|
7
|
+
const built_in_site_files_js_1 = require("./built-in-site-files.js");
|
|
8
|
+
/** Starting files that belong to the adopter after generation. */
|
|
9
|
+
exports.ROOT_SITE_SEEDED_PATHS = [
|
|
10
|
+
'README.md',
|
|
11
|
+
'e2e/site.spec.ts',
|
|
12
|
+
'frontend/security-headers.json',
|
|
13
|
+
'web/src/app/globals.css',
|
|
14
|
+
'web/src/app/icon.svg',
|
|
15
|
+
'web/src/app/layout.tsx',
|
|
16
|
+
'web/src/app/not-found.tsx',
|
|
17
|
+
'web/src/app/page.tsx',
|
|
18
|
+
];
|
|
19
|
+
/** Files SST owns and rewrites; generated once, never hash-checked. */
|
|
20
|
+
const TOOL_OWNED_PATHS = new Set(['sst-env.d.ts']);
|
|
21
|
+
function classifyPaths(files) {
|
|
22
|
+
const seeded = new Set(exports.ROOT_SITE_SEEDED_PATHS);
|
|
23
|
+
return Object.entries(files)
|
|
24
|
+
.filter(([path]) => !TOOL_OWNED_PATHS.has(path))
|
|
25
|
+
.map(([path, contents]) => {
|
|
26
|
+
const managedJsonPointers = path === 'package.json'
|
|
27
|
+
? [...built_in_site_files_js_1.ROOT_SITE_PACKAGE_MANAGED_JSON_POINTERS]
|
|
28
|
+
: undefined;
|
|
29
|
+
if (managedJsonPointers) {
|
|
30
|
+
(0, index_js_1.assertManagedJsonPointersExist)(contents, managedJsonPointers, `Root site ${path}`);
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
...(managedJsonPointers ? { managedJsonPointers } : {}),
|
|
34
|
+
mode: seeded.has(path) ? 'seeded' : 'managed',
|
|
35
|
+
origin: 'framework',
|
|
36
|
+
path,
|
|
37
|
+
sha256: (0, index_js_1.hashOwnedContent)(contents, { managedJsonPointers }),
|
|
38
|
+
};
|
|
39
|
+
})
|
|
40
|
+
.sort((left, right) => (0, deterministic_order_js_1.compareUtf16)(left.path, right.path));
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The deterministic file plan and ownership record of the workspace root site
|
|
44
|
+
* at packages/site.
|
|
45
|
+
*/
|
|
46
|
+
function createBuiltInSitePlan(input) {
|
|
47
|
+
const files = (0, built_in_site_files_js_1.renderBuiltInSiteFiles)({
|
|
48
|
+
runtimeVersion: input.runtimeVersion,
|
|
49
|
+
scope: input.scope,
|
|
50
|
+
});
|
|
51
|
+
const ownership = {
|
|
52
|
+
frameworkVersion: input.frameworkVersion,
|
|
53
|
+
kind: 'site',
|
|
54
|
+
paths: classifyPaths(files),
|
|
55
|
+
schemaVersion: index_js_1.SITE_OWNERSHIP_SCHEMA_VERSION,
|
|
56
|
+
};
|
|
57
|
+
return {
|
|
58
|
+
files: {
|
|
59
|
+
...files,
|
|
60
|
+
'.ebk/ownership.json': `${JSON.stringify(ownership, null, 2)}\n`,
|
|
61
|
+
},
|
|
62
|
+
ownership,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=built-in-site-plan.js.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const ROOT_SITE_PACKAGE_MANAGED_JSON_POINTERS: readonly ["/name", "/version", "/private", "/type", "/dependencies/next", "/dependencies/react", "/dependencies/react-dom", "/devDependencies/@opennextjs~1aws", "/devDependencies/@playwright~1test", "/devDependencies/@types~1node", "/devDependencies/@types~1react", "/devDependencies/@types~1react-dom", "/devDependencies/vitest"];
|
|
2
|
+
/** @internal */
|
|
3
|
+
export declare function renderSiteProjectFiles(scope: string): Record<string, string>;
|