@empire-builder-kit/nx 1.0.0-rc.46 → 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 +99 -6
- 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 +43 -2
- 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/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 +47 -4
- package/src/generators/preset/workspace-files-thin-docs.js +33 -5
- package/src/generators/preset/workspace-files.js +207 -13
- 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 +116 -11
- 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 +21 -4
- 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-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 -4
- package/src/generators/slice/built-in-plan-web-files.js +65 -0
- 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 +259 -593
- package/src/generators/workload/workload.js +60 -4
- package/src/git-policy/github-bootstrap.d.ts +6 -5
- package/src/git-policy/github-bootstrap.js +6 -4
- package/src/local-dev/fleet-process.d.ts +9 -2
- package/src/local-dev/fleet-process.js +27 -7
- 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 +21 -3
- package/src/supply-chain/generated-blueprint-trust-command.js +15 -0
- 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,284 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.renderSiteWebFiles = renderSiteWebFiles;
|
|
4
|
+
const root_site_js_1 = require("../../foundation/root-site.js");
|
|
5
|
+
const built_in_plan_shared_js_1 = require("../slice/built-in-plan-shared.js");
|
|
6
|
+
const built_in_site_shared_js_1 = require("./built-in-site-shared.js");
|
|
7
|
+
/** @internal */
|
|
8
|
+
function renderSiteWebFiles() {
|
|
9
|
+
return {
|
|
10
|
+
'web/tsconfig.json': (0, built_in_plan_shared_js_1.json)({
|
|
11
|
+
extends: '../tsconfig.json',
|
|
12
|
+
compilerOptions: {
|
|
13
|
+
// The web app is a leaf checked by Next's project-local tsc.
|
|
14
|
+
composite: false,
|
|
15
|
+
incremental: true,
|
|
16
|
+
plugins: [{ name: 'next' }],
|
|
17
|
+
},
|
|
18
|
+
// Next rewrites tsconfig.json when these entries are missing, so the
|
|
19
|
+
// generated include matches its output.
|
|
20
|
+
include: [
|
|
21
|
+
'next-env.d.ts',
|
|
22
|
+
'.next/types/**/*.ts',
|
|
23
|
+
'**/*.ts',
|
|
24
|
+
'**/*.tsx',
|
|
25
|
+
'.next/dev/types/**/*.ts',
|
|
26
|
+
],
|
|
27
|
+
exclude: ['node_modules'],
|
|
28
|
+
}),
|
|
29
|
+
'web/next.config.ts': `import type { NextConfig } from 'next';
|
|
30
|
+
|
|
31
|
+
const sourceCommit = process.env.EBK_SOURCE_COMMIT?.trim();
|
|
32
|
+
const sourceCommitPattern = ${built_in_site_shared_js_1.SOURCE_COMMIT_PATTERN};
|
|
33
|
+
|
|
34
|
+
function exactBuildId(): string {
|
|
35
|
+
if (sourceCommitPattern.test(sourceCommit ?? '')) return sourceCommit!;
|
|
36
|
+
if (process.env.SST === '1') {
|
|
37
|
+
throw new Error(
|
|
38
|
+
'A deployed Next build requires one exact EBK source commit.',
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
return 'local-development';
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// The root site is served at the Router's '/', so it has no base path.
|
|
45
|
+
const config: NextConfig = {
|
|
46
|
+
generateBuildId: async () => exactBuildId(),
|
|
47
|
+
reactStrictMode: true,
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default config;
|
|
51
|
+
`,
|
|
52
|
+
'web/open-next.config.ts': `// OpenNext's defaults apply: a 404 or 500 is never cached by the Router and
|
|
53
|
+
// the managed proxy's response headers win. Keep the dangerous options unset.
|
|
54
|
+
const config = {
|
|
55
|
+
// OpenNext runs from this web directory. Point it at the site package so it
|
|
56
|
+
// builds only this application instead of recursively invoking the Nx root.
|
|
57
|
+
buildCommand: 'pnpm exec next build --webpack web',
|
|
58
|
+
default: {},
|
|
59
|
+
// OpenNext installs the image-optimization Function's sharp with npm during
|
|
60
|
+
// the build, outside the lockfile. The Function runs on arm64 Linux (glibc).
|
|
61
|
+
imageOptimization: {
|
|
62
|
+
install: {
|
|
63
|
+
additionalArgs: '--cpu=arm64',
|
|
64
|
+
libc: 'glibc',
|
|
65
|
+
os: 'linux',
|
|
66
|
+
packages: ['sharp@${built_in_plan_shared_js_1.OPEN_NEXT_IMAGE_OPTIMIZATION_SHARP_VERSION}'],
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
packageJsonPath: '../package.json',
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export default config;
|
|
73
|
+
`,
|
|
74
|
+
'web/src/proxy.ts': `import { randomBytes } from 'node:crypto';
|
|
75
|
+
import {
|
|
76
|
+
composeFrontendSecurityHeaders,
|
|
77
|
+
resolveFrontendSecurityHeaderProfile,
|
|
78
|
+
} from '@empire-builder-kit/nx/frontend-security';
|
|
79
|
+
import { NextResponse, type NextRequest } from 'next/server';
|
|
80
|
+
import foundationPolicy from '../../../foundation/contracts/frontend-security-headers.json';
|
|
81
|
+
import sitePolicy from '../../frontend/security-headers.json';
|
|
82
|
+
|
|
83
|
+
// Every response this proxy handles is marked, not-found responses included,
|
|
84
|
+
// so a Product Slice route that has not reached a Router edge yet and falls
|
|
85
|
+
// through to the root site reads as edge routing, never as a Slice failure.
|
|
86
|
+
const ROUTE_HEADER = '${root_site_js_1.ROOT_SITE_ROUTE_HEADER}';
|
|
87
|
+
const ROUTE_HEADER_VALUE = '${root_site_js_1.ROOT_SITE_ROUTE_HEADER_VALUE}';
|
|
88
|
+
|
|
89
|
+
function requestNonce(): string {
|
|
90
|
+
return randomBytes(18).toString('base64');
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// On a bound stage the site answers only on its root domain. The Router sets
|
|
94
|
+
// x-forwarded-host to the viewer's Host before every server origin. The
|
|
95
|
+
// location is concatenated onto the fixed origin, never resolved against it,
|
|
96
|
+
// so a path such as //example.org/x cannot change its host.
|
|
97
|
+
function canonicalLocation(request: NextRequest): string | undefined {
|
|
98
|
+
const canonical =
|
|
99
|
+
process.env.EBK_SITE_CANONICAL_HOST?.trim().toLowerCase() ?? '';
|
|
100
|
+
if (!canonical) return undefined;
|
|
101
|
+
const host = request.headers.get('x-forwarded-host')?.trim().toLowerCase();
|
|
102
|
+
if (host === canonical) return undefined;
|
|
103
|
+
const { pathname, search } = new URL(request.url);
|
|
104
|
+
return (
|
|
105
|
+
'https://' +
|
|
106
|
+
canonical +
|
|
107
|
+
(pathname.startsWith('/') ? pathname : '/' + pathname) +
|
|
108
|
+
search
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function proxy(request: NextRequest): NextResponse {
|
|
113
|
+
const profile = resolveFrontendSecurityHeaderProfile({
|
|
114
|
+
...process.env,
|
|
115
|
+
EBK_STAGE:
|
|
116
|
+
process.env.EBK_STAGE ??
|
|
117
|
+
(process.env.NODE_ENV === 'production' ? 'production' : 'development'),
|
|
118
|
+
});
|
|
119
|
+
const nonce = profile === 'deployed-https' ? requestNonce() : undefined;
|
|
120
|
+
const securityHeaders = composeFrontendSecurityHeaders({
|
|
121
|
+
foundation: foundationPolicy,
|
|
122
|
+
nonce,
|
|
123
|
+
profile,
|
|
124
|
+
slice: sitePolicy,
|
|
125
|
+
sliceName: '${root_site_js_1.ROOT_SITE_NAME}',
|
|
126
|
+
});
|
|
127
|
+
const location = canonicalLocation(request);
|
|
128
|
+
if (location) {
|
|
129
|
+
const redirect = new NextResponse(null, {
|
|
130
|
+
headers: { 'cache-control': 'no-store', location },
|
|
131
|
+
status: 308,
|
|
132
|
+
});
|
|
133
|
+
for (const { name, value } of securityHeaders) {
|
|
134
|
+
redirect.headers.set(name, value);
|
|
135
|
+
}
|
|
136
|
+
redirect.headers.set(ROUTE_HEADER, ROUTE_HEADER_VALUE);
|
|
137
|
+
return redirect;
|
|
138
|
+
}
|
|
139
|
+
const requestHeaders = new Headers(request.headers);
|
|
140
|
+
const csp = securityHeaders.find(
|
|
141
|
+
({ name }) => name.toLowerCase() === 'content-security-policy',
|
|
142
|
+
);
|
|
143
|
+
if (!csp) {
|
|
144
|
+
throw new Error('The root site proxy requires an enforced CSP.');
|
|
145
|
+
}
|
|
146
|
+
requestHeaders.set('Content-Security-Policy', csp.value);
|
|
147
|
+
if (nonce) requestHeaders.set('x-nonce', nonce);
|
|
148
|
+
else requestHeaders.delete('x-nonce');
|
|
149
|
+
|
|
150
|
+
const response = NextResponse.next({ request: { headers: requestHeaders } });
|
|
151
|
+
for (const { name, value } of securityHeaders) {
|
|
152
|
+
response.headers.set(name, value);
|
|
153
|
+
}
|
|
154
|
+
response.headers.set(ROUTE_HEADER, ROUTE_HEADER_VALUE);
|
|
155
|
+
return response;
|
|
156
|
+
}
|
|
157
|
+
`,
|
|
158
|
+
'web/src/proxy.spec.ts': `import { NextRequest } from 'next/server';
|
|
159
|
+
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
160
|
+
import { proxy } from './proxy';
|
|
161
|
+
|
|
162
|
+
function request(path: string, host?: string): NextRequest {
|
|
163
|
+
return new NextRequest('https://router.example.test' + path, {
|
|
164
|
+
headers: host ? { 'x-forwarded-host': host } : {},
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
afterEach(() => {
|
|
169
|
+
vi.unstubAllEnvs();
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
describe('root site proxy', () => {
|
|
173
|
+
it('marks every response and composes the managed local headers', () => {
|
|
174
|
+
const response = proxy(request('/', 'site.example.test'));
|
|
175
|
+
expect(response.status).toBe(200);
|
|
176
|
+
expect(response.headers.get('${root_site_js_1.ROOT_SITE_ROUTE_HEADER}')).toBe('${root_site_js_1.ROOT_SITE_ROUTE_HEADER_VALUE}');
|
|
177
|
+
expect(response.headers.get('content-security-policy')).toContain(
|
|
178
|
+
"worker-src 'none'",
|
|
179
|
+
);
|
|
180
|
+
expect(response.headers.get('strict-transport-security')).toBeNull();
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
it('sends a fresh nonce, HSTS and worker-src none when deployed', () => {
|
|
184
|
+
vi.stubEnv('EBK_STAGE', 'production');
|
|
185
|
+
const first = proxy(request('/'));
|
|
186
|
+
const second = proxy(request('/'));
|
|
187
|
+
const csp = first.headers.get('content-security-policy') ?? '';
|
|
188
|
+
expect(csp).toMatch(/'nonce-[A-Za-z0-9+/]+={0,2}'/);
|
|
189
|
+
expect(csp).toContain("worker-src 'none'");
|
|
190
|
+
expect(csp).not.toBe(second.headers.get('content-security-policy'));
|
|
191
|
+
expect(first.headers.get('strict-transport-security')).toBe(
|
|
192
|
+
'max-age=31536000; includeSubDomains',
|
|
193
|
+
);
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
it('never redirects when the stage has no custom domain', () => {
|
|
197
|
+
vi.stubEnv('EBK_SITE_CANONICAL_HOST', '');
|
|
198
|
+
for (const host of [undefined, 'router.example.test', 'a.example.test']) {
|
|
199
|
+
expect(proxy(request('/about', host)).status).toBe(200);
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
it('redirects every other host to the root domain on a bound stage', () => {
|
|
204
|
+
vi.stubEnv('EBK_SITE_CANONICAL_HOST', 'example.test');
|
|
205
|
+
expect(proxy(request('/about?x=1', 'example.test')).status).toBe(200);
|
|
206
|
+
for (const host of ['www.example.test', 'a.example.test', undefined]) {
|
|
207
|
+
const response = proxy(request('/about?x=1', host));
|
|
208
|
+
expect(response.status).toBe(308);
|
|
209
|
+
expect(response.headers.get('location')).toBe(
|
|
210
|
+
'https://example.test/about?x=1',
|
|
211
|
+
);
|
|
212
|
+
expect(response.headers.get('cache-control')).toBe('no-store');
|
|
213
|
+
expect(response.headers.get('${root_site_js_1.ROOT_SITE_ROUTE_HEADER}')).toBe('${root_site_js_1.ROOT_SITE_ROUTE_HEADER_VALUE}');
|
|
214
|
+
expect(response.headers.get('content-security-policy')).toBeTruthy();
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
it('keeps the root domain for a path that starts with two slashes', () => {
|
|
219
|
+
vi.stubEnv('EBK_SITE_CANONICAL_HOST', 'example.test');
|
|
220
|
+
const response = proxy(request('//example.org/x', 'a.example.test'));
|
|
221
|
+
expect(response.status).toBe(308);
|
|
222
|
+
const location = response.headers.get('location') ?? '';
|
|
223
|
+
expect(location.startsWith('https://example.test/')).toBe(true);
|
|
224
|
+
expect(new URL(location).host).toBe('example.test');
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
`,
|
|
228
|
+
[`web/${root_site_js_1.ROOT_SITE_HEALTH_ROUTE_SOURCE}`]: `// The framework-owned ${root_site_js_1.ROOT_SITE_HEALTH_PATH} route. Deployed readiness
|
|
229
|
+
// requires this exact JSON for the release source commit.
|
|
230
|
+
export const dynamic = 'force-dynamic';
|
|
231
|
+
|
|
232
|
+
export function GET(): Response {
|
|
233
|
+
return Response.json(
|
|
234
|
+
{
|
|
235
|
+
service: '${root_site_js_1.ROOT_SITE_NAME}',
|
|
236
|
+
stage: process.env.EBK_STAGE ?? 'development',
|
|
237
|
+
sourceCommit: process.env.EBK_SOURCE_COMMIT || 'local-development',
|
|
238
|
+
status: 'ok',
|
|
239
|
+
},
|
|
240
|
+
{ headers: { 'cache-control': 'no-store' } },
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
`,
|
|
244
|
+
'web/src/app/globals.css': `:root { color-scheme: light dark; font-family: system-ui, sans-serif; }
|
|
245
|
+
body { margin: 0; background: #07111f; color: #edf6ff; }
|
|
246
|
+
main { max-width: 64rem; margin: 0 auto; padding: 5rem 1.5rem; }
|
|
247
|
+
a { color: #78d5ff; }
|
|
248
|
+
`,
|
|
249
|
+
'web/src/app/icon.svg': `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
|
|
250
|
+
<rect width="64" height="64" rx="12" fill="#102238"/>
|
|
251
|
+
<path d="M17 17h30v8H25v7h18v8H25v7h22v8H17z" fill="#78d5ff"/>
|
|
252
|
+
</svg>
|
|
253
|
+
`,
|
|
254
|
+
'web/src/app/layout.tsx': `import type { Metadata } from 'next';
|
|
255
|
+
import { connection } from 'next/server';
|
|
256
|
+
import type { ReactNode } from 'react';
|
|
257
|
+
import './globals.css';
|
|
258
|
+
|
|
259
|
+
export const metadata: Metadata = { title: 'Home' };
|
|
260
|
+
|
|
261
|
+
// Rendering per request lets Next.js apply the proxy's request nonce to its
|
|
262
|
+
// scripts, which the managed content-security policy requires.
|
|
263
|
+
export default async function Layout({ children }: Readonly<{ children: ReactNode }>) {
|
|
264
|
+
await connection();
|
|
265
|
+
return <html lang="en"><body>{children}</body></html>;
|
|
266
|
+
}
|
|
267
|
+
`,
|
|
268
|
+
'web/src/app/page.tsx': `export default function Home() {
|
|
269
|
+
return <main>
|
|
270
|
+
<h1>Home</h1>
|
|
271
|
+
<p>This is the workspace root site. Edit web/src/app/page.tsx to change it.</p>
|
|
272
|
+
</main>;
|
|
273
|
+
}
|
|
274
|
+
`,
|
|
275
|
+
'web/src/app/not-found.tsx': `export default function NotFound() {
|
|
276
|
+
return <main>
|
|
277
|
+
<h1>Page not found</h1>
|
|
278
|
+
<p><a href="/">Go to the home page</a></p>
|
|
279
|
+
</main>;
|
|
280
|
+
}
|
|
281
|
+
`,
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
//# sourceMappingURL=built-in-site-web-files.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"$id": "EmpireBuilderKitSite",
|
|
4
|
+
"title": "Create the Empire Builder Kit workspace root site",
|
|
5
|
+
"description": "Generate the fixed packages/site Next.js app that the Foundation Router serves at /, beside the Product Slices.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"properties": {
|
|
9
|
+
"skipFormat": {
|
|
10
|
+
"type": "boolean",
|
|
11
|
+
"description": "Skip formatting generated files.",
|
|
12
|
+
"default": false
|
|
13
|
+
},
|
|
14
|
+
"skipInstall": {
|
|
15
|
+
"type": "boolean",
|
|
16
|
+
"description": "Skip installing the generated root site dependencies.",
|
|
17
|
+
"default": false
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type GeneratorCallback, type Tree } from '@nx/devkit';
|
|
2
|
+
import type { SiteGeneratorSchema } from './schema.js';
|
|
3
|
+
export { createBuiltInSitePlan, type BuiltInSitePlan, } from './built-in-site-plan.js';
|
|
4
|
+
/** The workspace's Product Slices: every package project tagged type:slice. */
|
|
5
|
+
export declare function workspaceSliceNames(tree: Tree): string[];
|
|
6
|
+
/**
|
|
7
|
+
* Every file below the root site's route roots, relative to packages/site/web.
|
|
8
|
+
* The walk stops at the route check's entry bound, so a symbolic-link cycle,
|
|
9
|
+
* which the Tree follows, cannot hold it.
|
|
10
|
+
*/
|
|
11
|
+
export declare function rootSiteWebFiles(tree: Tree, entryLimit?: number): string[];
|
|
12
|
+
export declare function siteGenerator(tree: Tree, options?: SiteGeneratorSchema): Promise<GeneratorCallback | void>;
|
|
13
|
+
export default siteGenerator;
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createBuiltInSitePlan = void 0;
|
|
4
|
+
exports.workspaceSliceNames = workspaceSliceNames;
|
|
5
|
+
exports.rootSiteWebFiles = rootSiteWebFiles;
|
|
6
|
+
exports.siteGenerator = siteGenerator;
|
|
7
|
+
const devkit_1 = require("@nx/devkit");
|
|
8
|
+
const node_path_1 = require("node:path");
|
|
9
|
+
const preview_changes_js_1 = require("../../developer-agent/preview-changes.js");
|
|
10
|
+
const root_site_readiness_js_1 = require("../../foundation/root-site-readiness.js");
|
|
11
|
+
const root_site_js_1 = require("../../foundation/root-site.js");
|
|
12
|
+
const index_js_1 = require("../../ownership/index.js");
|
|
13
|
+
const index_js_2 = require("../../repository-policy/index.js");
|
|
14
|
+
const formatting_js_1 = require("../formatting.js");
|
|
15
|
+
const framework_prerequisites_js_1 = require("../framework-prerequisites.js");
|
|
16
|
+
const post_generation_install_js_1 = require("../post-generation-install.js");
|
|
17
|
+
const generator_js_1 = require("../preset/generator.js");
|
|
18
|
+
const workspace_files_js_1 = require("../preset/workspace-files.js");
|
|
19
|
+
const tree_policy_js_1 = require("../repository-policy/tree-policy.js");
|
|
20
|
+
const built_in_site_plan_js_1 = require("./built-in-site-plan.js");
|
|
21
|
+
var built_in_site_plan_js_2 = require("./built-in-site-plan.js");
|
|
22
|
+
Object.defineProperty(exports, "createBuiltInSitePlan", { enumerable: true, get: function () { return built_in_site_plan_js_2.createBuiltInSitePlan; } });
|
|
23
|
+
const FOUNDATION_DESCRIPTOR_PATH = 'packages/foundation/contracts/foundation.json';
|
|
24
|
+
function readWorkspacePackage(tree) {
|
|
25
|
+
const contents = tree.read('package.json', 'utf8');
|
|
26
|
+
if (contents === null) {
|
|
27
|
+
throw new Error('Workspace package.json does not exist.');
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
return JSON.parse(contents);
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
throw new Error(`Workspace package.json is not valid JSON: ${error instanceof Error ? error.message : String(error)}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function workspaceScope(packageJson) {
|
|
37
|
+
const name = packageJson.name?.trim();
|
|
38
|
+
if (!name || !/^[a-z0-9][a-z0-9-]*$/.test(name)) {
|
|
39
|
+
throw new Error('Workspace package.json must have an unscoped lowercase name before generating the root site.');
|
|
40
|
+
}
|
|
41
|
+
return `@${name}`;
|
|
42
|
+
}
|
|
43
|
+
/** The workspace's Product Slices: every package project tagged type:slice. */
|
|
44
|
+
function workspaceSliceNames(tree) {
|
|
45
|
+
return workspaceSliceProjects(tree).map(({ name }) => name);
|
|
46
|
+
}
|
|
47
|
+
function workspaceSliceProjects(tree) {
|
|
48
|
+
if (!tree.exists('packages'))
|
|
49
|
+
return [];
|
|
50
|
+
return tree
|
|
51
|
+
.children('packages')
|
|
52
|
+
.flatMap((directory) => {
|
|
53
|
+
const contents = tree.read(node_path_1.posix.join('packages', directory, 'project.json'), 'utf8');
|
|
54
|
+
if (contents === null)
|
|
55
|
+
return [];
|
|
56
|
+
let project;
|
|
57
|
+
try {
|
|
58
|
+
project = JSON.parse(contents);
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return [];
|
|
62
|
+
}
|
|
63
|
+
return Array.isArray(project.tags) && project.tags.includes('type:slice')
|
|
64
|
+
? [
|
|
65
|
+
{
|
|
66
|
+
name: typeof project.name === 'string' ? project.name : directory,
|
|
67
|
+
root: node_path_1.posix.join('packages', directory),
|
|
68
|
+
},
|
|
69
|
+
]
|
|
70
|
+
: [];
|
|
71
|
+
})
|
|
72
|
+
.sort((left, right) => left.name < right.name ? -1 : left.name > right.name ? 1 : 0);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Every file below the root site's route roots, relative to packages/site/web.
|
|
76
|
+
* The walk stops at the route check's entry bound, so a symbolic-link cycle,
|
|
77
|
+
* which the Tree follows, cannot hold it.
|
|
78
|
+
*/
|
|
79
|
+
function rootSiteWebFiles(tree, entryLimit = root_site_js_1.ROOT_SITE_ROUTE_ENTRY_LIMIT) {
|
|
80
|
+
const root = node_path_1.posix.join(root_site_js_1.ROOT_SITE_ROOT, 'web');
|
|
81
|
+
const files = [];
|
|
82
|
+
let observedEntries = 0;
|
|
83
|
+
const visitChildren = (path) => {
|
|
84
|
+
for (const child of tree.children(path)) {
|
|
85
|
+
observedEntries += 1;
|
|
86
|
+
if (observedEntries > entryLimit) {
|
|
87
|
+
throw new Error('The root site source tree exceeds its entry bound.');
|
|
88
|
+
}
|
|
89
|
+
const childPath = node_path_1.posix.join(path, child);
|
|
90
|
+
if (tree.isFile(childPath))
|
|
91
|
+
files.push(node_path_1.posix.relative(root, childPath));
|
|
92
|
+
else
|
|
93
|
+
visitChildren(childPath);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
for (const routeRoot of root_site_js_1.ROOT_SITE_ROUTE_ROOTS) {
|
|
97
|
+
const path = node_path_1.posix.join(root, routeRoot);
|
|
98
|
+
if (tree.exists(path) && !tree.isFile(path))
|
|
99
|
+
visitChildren(path);
|
|
100
|
+
}
|
|
101
|
+
return files.sort();
|
|
102
|
+
}
|
|
103
|
+
function reportSitePolicyPosture(tree) {
|
|
104
|
+
if (tree.read(index_js_2.REPOSITORY_POLICY_FILE, 'utf8') === null) {
|
|
105
|
+
devkit_1.logger.warn(`[ebk-repository-policy] ${index_js_2.REPOSITORY_POLICY_FILE} is missing. The root site is blocked from production until the workspace policy upgrade is applied and site.productionStatus is committed.`);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
try {
|
|
109
|
+
const status = (0, index_js_2.rootSiteProductionStatus)((0, tree_policy_js_1.readRepositoryOperatingPolicyFromTree)(tree));
|
|
110
|
+
if (status === 'ready') {
|
|
111
|
+
devkit_1.logger.info('[ebk-repository-policy] The root site retains explicit production status ready.');
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
devkit_1.logger.warn('[ebk-repository-policy] The root site is blocked from production. Report the adopter-owned source change with pnpm nx g @empire-builder-kit/nx:repository-policy --site=ready, then rerun with --apply after review.');
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
devkit_1.logger.warn(`[ebk-repository-policy] The root site is blocked from production because the repository policy is invalid. ${error instanceof Error ? error.message : String(error)}`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
async function siteGenerator(tree, options = {}) {
|
|
121
|
+
const installOperation = {
|
|
122
|
+
generator: 'site',
|
|
123
|
+
id: 'generator:site',
|
|
124
|
+
key: 'site',
|
|
125
|
+
request: { skipFormat: options.skipFormat ?? false },
|
|
126
|
+
resumeArguments: [
|
|
127
|
+
'pnpm',
|
|
128
|
+
'--config.verify-deps-before-run=warn',
|
|
129
|
+
'nx',
|
|
130
|
+
'generate',
|
|
131
|
+
'@empire-builder-kit/nx:site',
|
|
132
|
+
`--skipFormat=${String(options.skipFormat ?? false)}`,
|
|
133
|
+
'--skipInstall=false',
|
|
134
|
+
'--interactive=false',
|
|
135
|
+
],
|
|
136
|
+
sourceRoot: root_site_js_1.ROOT_SITE_ROOT,
|
|
137
|
+
};
|
|
138
|
+
const pendingInstall = (0, post_generation_install_js_1.resumePendingPostGenerationInstall)(tree, installOperation, options.skipInstall);
|
|
139
|
+
if (pendingInstall)
|
|
140
|
+
return pendingInstall;
|
|
141
|
+
// One / per workspace. Any content here, including a Product Slice named
|
|
142
|
+
// site from before the name was reserved, refuses generation.
|
|
143
|
+
if (tree.exists(root_site_js_1.ROOT_SITE_ROOT)) {
|
|
144
|
+
throw new Error(`${root_site_js_1.ROOT_SITE_ROOT} already exists. The workspace has one root site, and ${root_site_js_1.ROOT_SITE_NAME} is reserved for it; rename or remove what is there first.`);
|
|
145
|
+
}
|
|
146
|
+
// The generated project is named site; another project with that name, or
|
|
147
|
+
// one that aliases it, would break the Nx project graph.
|
|
148
|
+
for (const [name, project] of (0, devkit_1.getProjects)(tree)) {
|
|
149
|
+
if (name.normalize('NFC').toLocaleLowerCase('en-US') === root_site_js_1.ROOT_SITE_NAME) {
|
|
150
|
+
throw new Error(`Nx project ${name} already exists at ${project.root}; ${root_site_js_1.ROOT_SITE_NAME} is reserved for the workspace root site at ${root_site_js_1.ROOT_SITE_ROOT}.`);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
if (!tree.exists(FOUNDATION_DESCRIPTOR_PATH)) {
|
|
154
|
+
throw new Error(`The root site attaches to the Standard Foundation Router; ${FOUNDATION_DESCRIPTOR_PATH} does not exist.`);
|
|
155
|
+
}
|
|
156
|
+
// The site renders from the installed framework, so the workspace tooling
|
|
157
|
+
// and the Foundation must already be recorded at that version, as the root
|
|
158
|
+
// site upgrade requires. This also reads the observability policy.
|
|
159
|
+
(0, framework_prerequisites_js_1.requireUpgradePrerequisites)(tree, 'site', 'generating');
|
|
160
|
+
const packageJson = readWorkspacePackage(tree);
|
|
161
|
+
const scope = workspaceScope(packageJson);
|
|
162
|
+
const runtimeVersion = packageJson.dependencies?.['@empire-builder-kit/runtime'];
|
|
163
|
+
if (!runtimeVersion) {
|
|
164
|
+
throw new Error('Workspace package.json must depend on @empire-builder-kit/runtime before generating the root site.');
|
|
165
|
+
}
|
|
166
|
+
const plan = (0, built_in_site_plan_js_1.createBuiltInSitePlan)({
|
|
167
|
+
frameworkVersion: (0, generator_js_1.frameworkPackageVersion)(),
|
|
168
|
+
runtimeVersion,
|
|
169
|
+
scope,
|
|
170
|
+
});
|
|
171
|
+
const ownership = (0, index_js_1.validateSiteOwnershipRecord)(plan.ownership);
|
|
172
|
+
if (!ownership.valid) {
|
|
173
|
+
throw new Error(`Generated root site ownership metadata is invalid:\n${ownership.issues
|
|
174
|
+
.map((issue) => `- ${issue.path}: ${issue.message}`)
|
|
175
|
+
.join('\n')}`);
|
|
176
|
+
}
|
|
177
|
+
const inventory = (0, root_site_js_1.inspectRootSiteRoutes)({
|
|
178
|
+
files: Object.keys(plan.files)
|
|
179
|
+
.filter((path) => path.startsWith('web/'))
|
|
180
|
+
.map((path) => path.slice('web/'.length)),
|
|
181
|
+
sliceNames: workspaceSliceNames(tree),
|
|
182
|
+
});
|
|
183
|
+
if (inventory.findings.length > 0) {
|
|
184
|
+
throw new Error(`The root site's routes collide with this workspace:\n${(0, root_site_js_1.formatRootSiteRouteInventory)(inventory)}`);
|
|
185
|
+
}
|
|
186
|
+
// A Slice whose readiness predates the site would fail its next deploy
|
|
187
|
+
// whenever its route falls through to the site (mixed versions).
|
|
188
|
+
const staleReadiness = (0, root_site_readiness_js_1.slicesNeedingRootSiteReadinessUpgrade)((path) => tree.read(path, 'utf8') ?? undefined, workspaceSliceProjects(tree));
|
|
189
|
+
if (staleReadiness.length > 0) {
|
|
190
|
+
throw new Error((0, root_site_readiness_js_1.formatRootSiteReadinessUpgrade)(staleReadiness));
|
|
191
|
+
}
|
|
192
|
+
const installScope = {
|
|
193
|
+
requiredPaths: [index_js_1.SITE_OWNERSHIP_PATH],
|
|
194
|
+
roots: [root_site_js_1.ROOT_SITE_ROOT],
|
|
195
|
+
};
|
|
196
|
+
const installState = options.skipInstall
|
|
197
|
+
? undefined
|
|
198
|
+
: (0, post_generation_install_js_1.capturePostGenerationInstallState)(tree, installScope, installOperation);
|
|
199
|
+
const deferred = new preview_changes_js_1.DeferredDeveloperAgentTree(tree);
|
|
200
|
+
for (const [path, contents] of Object.entries(plan.files)) {
|
|
201
|
+
deferred.write(node_path_1.posix.join(root_site_js_1.ROOT_SITE_ROOT, path), contents);
|
|
202
|
+
}
|
|
203
|
+
if (!options.skipFormat) {
|
|
204
|
+
const prefix = `${root_site_js_1.ROOT_SITE_ROOT}/`;
|
|
205
|
+
await (0, formatting_js_1.formatChangedTreeToFixedPoint)(deferred, (0, formatting_js_1.createTreeFileRestorer)(deferred, (path) => !path.startsWith(prefix) || (0, workspace_files_js_1.isRawWorkspaceAuthorityPath)(path)));
|
|
206
|
+
}
|
|
207
|
+
(0, index_js_1.restampSiteOwnership)(deferred);
|
|
208
|
+
if (!options.skipFormat) {
|
|
209
|
+
await (0, formatting_js_1.formatTreeFileToFixedPoint)(deferred, index_js_1.SITE_OWNERSHIP_PATH);
|
|
210
|
+
}
|
|
211
|
+
deferred.apply();
|
|
212
|
+
reportSitePolicyPosture(tree);
|
|
213
|
+
if (options.skipInstall)
|
|
214
|
+
return undefined;
|
|
215
|
+
if (!installState) {
|
|
216
|
+
throw new Error('Post-generation install state was not prepared.');
|
|
217
|
+
}
|
|
218
|
+
return (0, post_generation_install_js_1.createPostGenerationInstallCallback)(tree, installState, installScope, installOperation);
|
|
219
|
+
}
|
|
220
|
+
exports.default = siteGenerator;
|
|
221
|
+
//# sourceMappingURL=site.js.map
|
|
@@ -164,6 +164,15 @@ export declare function sliceAlarmIdentity(name: string, id: SliceAlarmId): Slic
|
|
|
164
164
|
* route, schema version and Slice from sliceAlarmOwnership.
|
|
165
165
|
*/
|
|
166
166
|
export declare function renderSliceAlarmDescriptionInput(name: string, id: SliceAlarmId, indent: string): string;
|
|
167
|
+
/**
|
|
168
|
+
* A description helper's argument for any alarm identity, as TypeScript
|
|
169
|
+
* source: the root site renders its own alarms' arguments with it.
|
|
170
|
+
*/
|
|
171
|
+
export declare function renderAlarmDescriptionInput(identity: {
|
|
172
|
+
businessSymptom: string;
|
|
173
|
+
id: string;
|
|
174
|
+
runbook: string;
|
|
175
|
+
}, indent: string): string;
|
|
167
176
|
/**
|
|
168
177
|
* The complete alarm description object for one alarm, as TypeScript source
|
|
169
178
|
* for an emitter without a description helper. Keys are in the helpers'
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.sliceAlarmOwnership = sliceAlarmOwnership;
|
|
4
4
|
exports.sliceAlarmIdentity = sliceAlarmIdentity;
|
|
5
5
|
exports.renderSliceAlarmDescriptionInput = renderSliceAlarmDescriptionInput;
|
|
6
|
+
exports.renderAlarmDescriptionInput = renderAlarmDescriptionInput;
|
|
6
7
|
exports.renderSliceAlarmDescriptionObject = renderSliceAlarmDescriptionObject;
|
|
7
8
|
/**
|
|
8
9
|
* The one identity table for every alarm a Standard Slice registers.
|
|
@@ -177,7 +178,13 @@ function typescriptString(value) {
|
|
|
177
178
|
* route, schema version and Slice from sliceAlarmOwnership.
|
|
178
179
|
*/
|
|
179
180
|
function renderSliceAlarmDescriptionInput(name, id, indent) {
|
|
180
|
-
|
|
181
|
+
return renderAlarmDescriptionInput(sliceAlarmIdentity(name, id), indent);
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* A description helper's argument for any alarm identity, as TypeScript
|
|
185
|
+
* source: the root site renders its own alarms' arguments with it.
|
|
186
|
+
*/
|
|
187
|
+
function renderAlarmDescriptionInput(identity, indent) {
|
|
181
188
|
const symptom = `${indent} businessSymptom: ${typescriptString(identity.businessSymptom)},`;
|
|
182
189
|
return [
|
|
183
190
|
'{',
|
|
@@ -2050,6 +2050,7 @@ const {
|
|
|
2050
2050
|
} = require('@empire-builder-kit/nx/api-contract');
|
|
2051
2051
|
const {
|
|
2052
2052
|
validateGeneratedOwnershipRecord,
|
|
2053
|
+
validateSiteOwnershipRecord,
|
|
2053
2054
|
} = require('@empire-builder-kit/nx/ownership');
|
|
2054
2055
|
|
|
2055
2056
|
const projectRoot = process.cwd();
|
|
@@ -2394,6 +2395,23 @@ for (const entry of readdirSync(packagesRoot, { withFileTypes: true })) {
|
|
|
2394
2395
|
},
|
|
2395
2396
|
}
|
|
2396
2397
|
: readJson(candidateOwnershipPath);
|
|
2398
|
+
// The root site publishes no contracts. packages/site holds only its
|
|
2399
|
+
// record, and its record belongs only there.
|
|
2400
|
+
if (entry.name === 'site' || candidateOwnership?.kind === 'site') {
|
|
2401
|
+
if (
|
|
2402
|
+
entry.name === 'site' &&
|
|
2403
|
+
validateSiteOwnershipRecord(candidateOwnership).valid
|
|
2404
|
+
) {
|
|
2405
|
+
continue;
|
|
2406
|
+
}
|
|
2407
|
+
throw new Error(
|
|
2408
|
+
entry.name === 'site'
|
|
2409
|
+
? 'packages/site is reserved for the workspace root site and must hold valid root site ownership.'
|
|
2410
|
+
: 'Root site ownership belongs only in packages/site, not packages/' +
|
|
2411
|
+
entry.name +
|
|
2412
|
+
'.',
|
|
2413
|
+
);
|
|
2414
|
+
}
|
|
2397
2415
|
const validation = validateGeneratedOwnershipRecord(candidateOwnership);
|
|
2398
2416
|
if (!validation.valid) {
|
|
2399
2417
|
throw new Error(
|
|
@@ -6094,6 +6094,24 @@ SQL Slices only (see docs/runbooks/sql-events.md):
|
|
|
6094
6094
|
Diagnose with the content-free \`ebk-key-value-reconciliation\` log summary and
|
|
6095
6095
|
the EventBridge target before any recovery. Do not delete or edit retained
|
|
6096
6096
|
intents to clear an alarm.
|
|
6097
|
+
|
|
6098
|
+
## Inbox cleanup alarms
|
|
6099
|
+
|
|
6100
|
+
- \`inbox-cleanup-errors\` reports Lambda errors for the exact
|
|
6101
|
+
\`async/inbox-cleanup\` Function.
|
|
6102
|
+
- \`inbox-cleanup-backlog\` reports the Minimum of
|
|
6103
|
+
\`InboxCleanupContinuationRequired\`, which each cleanup run sets to 1 when it
|
|
6104
|
+
could not complete a full provider-inbox inventory within 10,000 receipts and
|
|
6105
|
+
four minutes, over three consecutive hours (3600 s x 3). It alarms when
|
|
6106
|
+
cleanup keeps succeeding but never converges. One interrupted run can need
|
|
6107
|
+
several runs to converge, because a resumed scan rescans from the start. A
|
|
6108
|
+
retained inbox near or above 10,000 receipts reports continuation on every
|
|
6109
|
+
run, which is a capacity signal rather than a failed cleanup. A paused
|
|
6110
|
+
cleanup reports nothing, and a cadence slower than hourly can leave the
|
|
6111
|
+
alarm unable to fire.
|
|
6112
|
+
|
|
6113
|
+
Expired receipts are already rejected by logical expiry, so slow cleanup delays
|
|
6114
|
+
physical removal only. Do not delete receipts by hand to clear the alarm.
|
|
6097
6115
|
`,
|
|
6098
6116
|
};
|
|
6099
6117
|
}
|