@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,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.upgradeFrameworkPackage = upgradeFrameworkPackage;
|
|
4
|
+
const node_path_1 = require("node:path");
|
|
5
|
+
const upgrade_plan_js_1 = require("./upgrade-plan.js");
|
|
6
|
+
async function upgradeFrameworkPackage(tree, options, output, upgrade) {
|
|
7
|
+
const root = upgrade.root;
|
|
8
|
+
const workspacePath = (path) => root === '' ? path : node_path_1.posix.join(root, path);
|
|
9
|
+
if (options.blueprint !== undefined || options.inputs !== undefined) {
|
|
10
|
+
throw new Error(`${upgrade.label} upgrades do not accept Blueprint or input options.`);
|
|
11
|
+
}
|
|
12
|
+
upgrade.requirePrerequisites?.();
|
|
13
|
+
const ownershipResult = upgrade.validateOwnership((0, upgrade_plan_js_1.readJson)(tree, workspacePath('.ebk/ownership.json'), `${upgrade.label} ownership metadata`));
|
|
14
|
+
if (!ownershipResult.valid) {
|
|
15
|
+
throw new Error((0, upgrade_plan_js_1.ownershipValidationMessage)(`${upgrade.label} ownership metadata`, ownershipResult.issues));
|
|
16
|
+
}
|
|
17
|
+
const currentOwnership = ownershipResult.value;
|
|
18
|
+
const renderedTarget = upgrade.render();
|
|
19
|
+
const target = {
|
|
20
|
+
...renderedTarget,
|
|
21
|
+
files: await (0, upgrade_plan_js_1.formatRenderedFiles)(tree, renderedTarget.files, root),
|
|
22
|
+
};
|
|
23
|
+
upgrade.validateTarget?.(target.ownership);
|
|
24
|
+
const allPaths = new Set([
|
|
25
|
+
...currentOwnership.paths.map(({ path }) => path),
|
|
26
|
+
...target.ownership.paths.map(({ path }) => path),
|
|
27
|
+
]);
|
|
28
|
+
const currentFiles = new Map([...allPaths].map((path) => [path, tree.read(workspacePath(path), 'utf8')]));
|
|
29
|
+
let mergedTarget = (0, upgrade_plan_js_1.mergeStructuredTargetFiles)(currentFiles, currentOwnership, new Map(Object.entries(target.files)), target.ownership);
|
|
30
|
+
mergedTarget = await (0, upgrade_plan_js_1.formatMergedManagedJsonFiles)(tree, root, mergedTarget, target.ownership);
|
|
31
|
+
const seededAppend = upgrade.planSeededAppend?.(currentFiles, target.files) ?? null;
|
|
32
|
+
if (seededAppend !== null) {
|
|
33
|
+
mergedTarget.files.set(seededAppend.path, seededAppend.contents);
|
|
34
|
+
}
|
|
35
|
+
const report = (0, upgrade_plan_js_1.createUpgradeReport)(currentFiles, currentOwnership, mergedTarget.files, target.ownership, mergedTarget);
|
|
36
|
+
if (seededAppend !== null) {
|
|
37
|
+
report.preservedSeeded = report.preservedSeeded.filter((path) => path !== seededAppend.path);
|
|
38
|
+
report.appendedSeeded.push(seededAppend.path);
|
|
39
|
+
}
|
|
40
|
+
output.info(`[ebk-upgrade] ${upgrade.reportName} ${currentOwnership.frameworkVersion} -> ${target.ownership.frameworkVersion}\n${JSON.stringify(upgrade.describeReport ? upgrade.describeReport(report) : report, null, 2)}`);
|
|
41
|
+
upgrade.afterReport?.(currentFiles);
|
|
42
|
+
if (!options.apply)
|
|
43
|
+
return;
|
|
44
|
+
if (upgrade.refusesSeededMigrationRewrites &&
|
|
45
|
+
report.incompatibleSeededMigrations.length > 0) {
|
|
46
|
+
throw new Error((0, upgrade_plan_js_1.seededMigrationUpgradeMessage)(upgrade.label, report));
|
|
47
|
+
}
|
|
48
|
+
if (report.conflicting.length > 0) {
|
|
49
|
+
throw new Error((0, upgrade_plan_js_1.upgradeConflictMessage)(upgrade.label, report));
|
|
50
|
+
}
|
|
51
|
+
for (const path of report.obsolete)
|
|
52
|
+
tree.delete(workspacePath(path));
|
|
53
|
+
const writePaths = new Set([
|
|
54
|
+
...report.changed,
|
|
55
|
+
...report.missing,
|
|
56
|
+
...report.addedSeeded,
|
|
57
|
+
...report.appendedSeeded,
|
|
58
|
+
'.ebk/ownership.json',
|
|
59
|
+
]);
|
|
60
|
+
for (const path of writePaths) {
|
|
61
|
+
if (path === seededAppend?.path)
|
|
62
|
+
continue;
|
|
63
|
+
const contents = mergedTarget.files.get(path);
|
|
64
|
+
if (contents === undefined) {
|
|
65
|
+
throw new Error(`Target ${upgrade.targetLabel} did not render ${path}.`);
|
|
66
|
+
}
|
|
67
|
+
tree.write(workspacePath(path), contents);
|
|
68
|
+
}
|
|
69
|
+
if (seededAppend !== null) {
|
|
70
|
+
tree.write(workspacePath(seededAppend.path), seededAppend.contents);
|
|
71
|
+
}
|
|
72
|
+
upgrade.restamp(tree);
|
|
73
|
+
// Ownership bytes are part of the upgrade result, including agent previews
|
|
74
|
+
// that skip workspace formatting. Canonicalize before binding those bytes.
|
|
75
|
+
await (0, upgrade_plan_js_1.formatOwnershipRecord)(tree, workspacePath('.ebk/ownership.json'), upgrade.label);
|
|
76
|
+
return upgrade.installCallback?.();
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=framework-package-upgrade.js.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { GeneratedCompositionOwnership } from '../../ownership/index.js';
|
|
2
|
+
import { type FunctionAuthentication } from '../function/function.js';
|
|
3
|
+
/**
|
|
4
|
+
* Who may call a retained Function today, read from its current managed
|
|
5
|
+
* `infra/functions/<name>.ts`. `unauthenticated` is a Function generated
|
|
6
|
+
* before Functions had an access setting: its route is public.
|
|
7
|
+
*/
|
|
8
|
+
export type CurrentFunctionAccess = FunctionAuthentication | 'unauthenticated';
|
|
9
|
+
export interface FunctionAccessTransition {
|
|
10
|
+
current: CurrentFunctionAccess;
|
|
11
|
+
name: string;
|
|
12
|
+
target: FunctionAuthentication;
|
|
13
|
+
}
|
|
14
|
+
export declare function currentFunctionAccess(name: string, source: string | null): CurrentFunctionAccess;
|
|
15
|
+
/**
|
|
16
|
+
* The upgrade's access rule. The ownership record says who may call each
|
|
17
|
+
* Function, and the current managed file says who may call it now. An upgrade
|
|
18
|
+
* moves a Function generated before access settings existed to signed-in and
|
|
19
|
+
* otherwise keeps its access: it never makes a Function public, and never
|
|
20
|
+
* changes a recorded access that its managed file does not already have.
|
|
21
|
+
*/
|
|
22
|
+
export declare function planFunctionAccessTransitions(compositions: readonly GeneratedCompositionOwnership[], readCurrentInfrastructure: (name: string) => string | null): FunctionAccessTransition[];
|
|
23
|
+
/**
|
|
24
|
+
* The Slice upgrade report's notice for Functions that become signed-in on
|
|
25
|
+
* their next deploy. Returns `null` when none does.
|
|
26
|
+
*/
|
|
27
|
+
export declare function functionAuthenticationNotice(slice: string, transitions: readonly FunctionAccessTransition[]): string | null;
|
|
28
|
+
/** Names every public Function on every upgrade, so none is invisible. */
|
|
29
|
+
export declare function anonymousFunctionNotice(slice: string, transitions: readonly FunctionAccessTransition[]): string | null;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.currentFunctionAccess = currentFunctionAccess;
|
|
4
|
+
exports.planFunctionAccessTransitions = planFunctionAccessTransitions;
|
|
5
|
+
exports.functionAuthenticationNotice = functionAuthenticationNotice;
|
|
6
|
+
exports.anonymousFunctionNotice = anonymousFunctionNotice;
|
|
7
|
+
const deterministic_order_js_1 = require("../../deterministic-order.js");
|
|
8
|
+
const function_js_1 = require("../function/function.js");
|
|
9
|
+
const ACCESS_SETTING = 'EBK_FUNCTION_AUTHENTICATION';
|
|
10
|
+
const ACCESS_LITERAL = /\bEBK_FUNCTION_AUTHENTICATION\s*:\s*(['"])(anonymous|signed-in)\1/gu;
|
|
11
|
+
function currentFunctionAccess(name, source) {
|
|
12
|
+
if (source === null)
|
|
13
|
+
return 'unauthenticated';
|
|
14
|
+
const mentions = source.split(ACCESS_SETTING).length - 1;
|
|
15
|
+
if (mentions === 0)
|
|
16
|
+
return 'unauthenticated';
|
|
17
|
+
const literals = [...source.matchAll(ACCESS_LITERAL)];
|
|
18
|
+
const [literal] = literals;
|
|
19
|
+
if (mentions !== 1 || literals.length !== 1 || !literal) {
|
|
20
|
+
throw new Error(`Retained Function ${name} does not expose one exact access setting in infra/functions/${name}.ts.`);
|
|
21
|
+
}
|
|
22
|
+
return literal[2];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The upgrade's access rule. The ownership record says who may call each
|
|
26
|
+
* Function, and the current managed file says who may call it now. An upgrade
|
|
27
|
+
* moves a Function generated before access settings existed to signed-in and
|
|
28
|
+
* otherwise keeps its access: it never makes a Function public, and never
|
|
29
|
+
* changes a recorded access that its managed file does not already have.
|
|
30
|
+
*/
|
|
31
|
+
function planFunctionAccessTransitions(compositions, readCurrentInfrastructure) {
|
|
32
|
+
const transitions = [];
|
|
33
|
+
for (const composition of compositions) {
|
|
34
|
+
if (composition.kind !== 'function')
|
|
35
|
+
continue;
|
|
36
|
+
const target = (0, function_js_1.functionAuthenticationOf)(composition);
|
|
37
|
+
const current = currentFunctionAccess(composition.name, readCurrentInfrastructure(composition.name));
|
|
38
|
+
// Neither this upgrade nor function-access can settle this state: the
|
|
39
|
+
// upgrade never makes a Function public, and function-access needs an
|
|
40
|
+
// access setting in the managed file. Say how to get out of it.
|
|
41
|
+
if (current === 'unauthenticated' && target === 'anonymous') {
|
|
42
|
+
throw new Error(`Function ${composition.name}'s ownership entry records anonymous, but its managed infra/functions/${composition.name}.ts has no access setting yet, so neither this upgrade nor function-access can change it. Restore both to what EBK generated, for example from version control. A Function generated before access settings becomes signed-in on this upgrade; to keep it public, run function-access with --authentication=anonymous after the upgrade and before deploying.`);
|
|
43
|
+
}
|
|
44
|
+
if (current !== target &&
|
|
45
|
+
!(current === 'unauthenticated' && target === 'signed-in')) {
|
|
46
|
+
throw new Error(`Function ${composition.name}'s recorded access (${target}) differs from its managed infra/functions/${composition.name}.ts (${current === 'unauthenticated' ? 'no access setting' : current}). An upgrade never changes who may call a Function; run function-access to change it.`);
|
|
47
|
+
}
|
|
48
|
+
transitions.push({ current, name: composition.name, target });
|
|
49
|
+
}
|
|
50
|
+
return transitions.sort((left, right) => (0, deterministic_order_js_1.compareUtf16)(left.name, right.name));
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The Slice upgrade report's notice for Functions that become signed-in on
|
|
54
|
+
* their next deploy. Returns `null` when none does.
|
|
55
|
+
*/
|
|
56
|
+
function functionAuthenticationNotice(slice, transitions) {
|
|
57
|
+
const moving = transitions.filter(({ current }) => current === 'unauthenticated');
|
|
58
|
+
if (moving.length === 0)
|
|
59
|
+
return null;
|
|
60
|
+
return [
|
|
61
|
+
`[ebk-upgrade] function-authentication: after this upgrade these Functions require a signed-in caller from their next deploy: ${moving.map(({ name }) => `${slice}/${name}`).join(', ')}.`,
|
|
62
|
+
`API Gateway then refuses, with 401, any request without a valid Cognito access token from the Slice's web client or machine clients, on /${slice}/api/functions/<name> and on the Slice API path. A browser request that carries only the session cookie is refused; call the Function from a server route that sends the access token as a bearer token. The handler receives the verified caller as context.actor.`,
|
|
63
|
+
`To keep a public route such as a webhook, run pnpm nx g @empire-builder-kit/nx:function-access <name> --slice=${slice} --authentication=anonymous after --apply and before deploying.`,
|
|
64
|
+
'See "Unreleased: Functions require a signed-in caller" in docs/upgrades.md.',
|
|
65
|
+
].join('\n');
|
|
66
|
+
}
|
|
67
|
+
/** Names every public Function on every upgrade, so none is invisible. */
|
|
68
|
+
function anonymousFunctionNotice(slice, transitions) {
|
|
69
|
+
const open = transitions.filter(({ target }) => target === 'anonymous');
|
|
70
|
+
if (open.length === 0)
|
|
71
|
+
return null;
|
|
72
|
+
return `[ebk-upgrade] function-authentication: these Functions stay public, with no authentication on the Router path or the Slice API path: ${open.map(({ name }) => `${slice}/${name}`).join(', ')}.`;
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=function-authentication-notice.js.map
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json-schema.org/schema",
|
|
3
3
|
"$id": "EmpireBuilderKitUpgrade",
|
|
4
|
-
"title": "Report or apply a v1 workspace, Standard Foundation, or Product Slice upgrade",
|
|
4
|
+
"title": "Report or apply a v1 workspace, Standard Foundation, root site, or Product Slice upgrade",
|
|
5
5
|
"type": "object",
|
|
6
6
|
"additionalProperties": false,
|
|
7
7
|
"properties": {
|
|
8
8
|
"name": {
|
|
9
9
|
"type": "string",
|
|
10
10
|
"$default": { "$source": "argv", "index": 0 },
|
|
11
|
-
"description": "Workspace root (`workspace`), Standard Foundation (`foundation`), or Product Slice name.",
|
|
11
|
+
"description": "Workspace root (`workspace`), Standard Foundation (`foundation`), root site (`site`), or Product Slice name.",
|
|
12
12
|
"x-prompt": "Which workspace layer or Product Slice should be upgraded?"
|
|
13
13
|
},
|
|
14
14
|
"blueprint": {
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Tree } from '@nx/devkit';
|
|
2
|
+
import { type GeneratedOwnershipRecord } from '../../ownership/index.js';
|
|
3
|
+
export interface UpgradeReport {
|
|
4
|
+
addedSeeded: string[];
|
|
5
|
+
appendedSeeded: string[];
|
|
6
|
+
changed: string[];
|
|
7
|
+
claimedJsonMembers: string[];
|
|
8
|
+
conflicting: string[];
|
|
9
|
+
conflictingJsonMembers: string[];
|
|
10
|
+
expandedJsonOwnership: string[];
|
|
11
|
+
incompatibleSeededMigrations: string[];
|
|
12
|
+
missing: string[];
|
|
13
|
+
obsolete: string[];
|
|
14
|
+
preservedSeeded: string[];
|
|
15
|
+
releasedJsonMembers: string[];
|
|
16
|
+
seededReconciliation: SeededReconciliationWork[];
|
|
17
|
+
unchanged: string[];
|
|
18
|
+
}
|
|
19
|
+
export interface SeededReconciliationWork {
|
|
20
|
+
adopterContentSha256: string | null;
|
|
21
|
+
category: 'api-base-path' | 'async-adapter' | 'async-settings' | 'configuration-contract' | 'configuration-values' | 'feature-controls' | 'frontend-contract' | 'frontend-security' | 'performance-aggregate-provider' | 'performance-policy' | 'reliability-metrics' | 'reliability-operations' | 'reliability-slo' | 'release-controls' | 'secret-contract';
|
|
22
|
+
currentFrameworkSha256: string | null;
|
|
23
|
+
guidance?: string;
|
|
24
|
+
implications: string[];
|
|
25
|
+
markerReference: 'PLAN:5.6/seeded-upgrade-reconciliation';
|
|
26
|
+
path: string;
|
|
27
|
+
requiredAction: 'declare-existing-custom-metric-series-before-promotion' | 'review-and-reconcile-preserving-adopter-content';
|
|
28
|
+
targetFrameworkSha256: string;
|
|
29
|
+
}
|
|
30
|
+
export interface JsonOwnershipChanges {
|
|
31
|
+
claimedJsonMembers: string[];
|
|
32
|
+
conflictingJsonMembers: string[];
|
|
33
|
+
expandedJsonOwnership: string[];
|
|
34
|
+
releasedJsonMembers: string[];
|
|
35
|
+
}
|
|
36
|
+
export interface StructuredTargetMerge extends JsonOwnershipChanges {
|
|
37
|
+
files: Map<string, string>;
|
|
38
|
+
}
|
|
39
|
+
export type OwnershipPaths = Pick<GeneratedOwnershipRecord, 'paths'>;
|
|
40
|
+
export declare const SEEDED_RECONCILIATION_MARKER_REFERENCE: "PLAN:5.6/seeded-upgrade-reconciliation";
|
|
41
|
+
export declare function upgradeConflictMessage(label: string, report: UpgradeReport): string;
|
|
42
|
+
export declare function seededMigrationUpgradeMessage(label: string, report: UpgradeReport): string;
|
|
43
|
+
export declare function formatRenderedFiles(tree: Tree, files: Readonly<Record<string, string>>, prefix?: string): Promise<Readonly<Record<string, string>>>;
|
|
44
|
+
export declare function formatOwnershipRecord(tree: Tree, path: string, label: string): Promise<void>;
|
|
45
|
+
export declare function readJson(tree: Tree, path: string, label: string): unknown;
|
|
46
|
+
export declare function ownershipValidationMessage(label: string, issues: ReadonlyArray<{
|
|
47
|
+
message: string;
|
|
48
|
+
path: string;
|
|
49
|
+
}>): string;
|
|
50
|
+
export declare function createUpgradeReport(currentFiles: ReadonlyMap<string, string | null>, currentOwnership: OwnershipPaths, targetFiles: ReadonlyMap<string, string>, targetOwnership: OwnershipPaths, jsonOwnershipChanges?: JsonOwnershipChanges): UpgradeReport;
|
|
51
|
+
export declare function mergeStructuredTargetFiles(currentFiles: ReadonlyMap<string, string | null>, currentOwnership: OwnershipPaths, targetFiles: ReadonlyMap<string, string>, targetOwnership: OwnershipPaths): StructuredTargetMerge;
|
|
52
|
+
export declare function formatMergedManagedJsonFiles(tree: Tree, root: string, merge: StructuredTargetMerge, ownership: OwnershipPaths): Promise<StructuredTargetMerge>;
|
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SEEDED_RECONCILIATION_MARKER_REFERENCE = void 0;
|
|
4
|
+
exports.upgradeConflictMessage = upgradeConflictMessage;
|
|
5
|
+
exports.seededMigrationUpgradeMessage = seededMigrationUpgradeMessage;
|
|
6
|
+
exports.formatRenderedFiles = formatRenderedFiles;
|
|
7
|
+
exports.formatOwnershipRecord = formatOwnershipRecord;
|
|
8
|
+
exports.readJson = readJson;
|
|
9
|
+
exports.ownershipValidationMessage = ownershipValidationMessage;
|
|
10
|
+
exports.createUpgradeReport = createUpgradeReport;
|
|
11
|
+
exports.mergeStructuredTargetFiles = mergeStructuredTargetFiles;
|
|
12
|
+
exports.formatMergedManagedJsonFiles = formatMergedManagedJsonFiles;
|
|
13
|
+
const deterministic_order_js_1 = require("../../deterministic-order.js");
|
|
14
|
+
const node_path_1 = require("node:path");
|
|
15
|
+
const index_js_1 = require("../../ownership/index.js");
|
|
16
|
+
const workspace_files_js_1 = require("../preset/workspace-files.js");
|
|
17
|
+
const built_in_plan_js_1 = require("../slice/built-in-plan.js");
|
|
18
|
+
const formatting_js_1 = require("../formatting.js");
|
|
19
|
+
const SEEDED_RECONCILIATION = {
|
|
20
|
+
'async/recovery-adapters.ts': {
|
|
21
|
+
category: 'async-adapter',
|
|
22
|
+
implications: [
|
|
23
|
+
'failure-semantics',
|
|
24
|
+
'provider-behavior',
|
|
25
|
+
'provider-permissions',
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
'async/runtime.ts': {
|
|
29
|
+
category: 'async-settings',
|
|
30
|
+
implications: [
|
|
31
|
+
'retry-and-dlq-settings',
|
|
32
|
+
'schedule-contracts',
|
|
33
|
+
'workflow-contracts',
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
'async/webhook.ts': {
|
|
37
|
+
category: 'async-adapter',
|
|
38
|
+
implications: [
|
|
39
|
+
'provider-authentication',
|
|
40
|
+
'provider-behavior',
|
|
41
|
+
'webhook-replay-protection',
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
'async/work-contract.json': {
|
|
45
|
+
category: 'async-settings',
|
|
46
|
+
implications: [
|
|
47
|
+
'recovery-authority',
|
|
48
|
+
'retry-and-dlq-settings',
|
|
49
|
+
'workflow-versioning',
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
'configuration/declarations.json': {
|
|
53
|
+
category: 'configuration-contract',
|
|
54
|
+
implications: [
|
|
55
|
+
'configuration-types',
|
|
56
|
+
'outage-policy',
|
|
57
|
+
'provider-permissions',
|
|
58
|
+
],
|
|
59
|
+
},
|
|
60
|
+
'configuration/declarations.ts': {
|
|
61
|
+
category: 'configuration-contract',
|
|
62
|
+
implications: [
|
|
63
|
+
'configuration-types',
|
|
64
|
+
'outage-policy',
|
|
65
|
+
'provider-permissions',
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
'configuration/local-values.json': {
|
|
69
|
+
category: 'configuration-values',
|
|
70
|
+
implications: ['local-defaults', 'safe-fallbacks'],
|
|
71
|
+
},
|
|
72
|
+
'docs/reliability/slo.json': {
|
|
73
|
+
category: 'reliability-slo',
|
|
74
|
+
implications: [
|
|
75
|
+
'error-budget-policy',
|
|
76
|
+
'journey-ownership',
|
|
77
|
+
'service-level-objectives',
|
|
78
|
+
],
|
|
79
|
+
},
|
|
80
|
+
'frontend/contract.json': {
|
|
81
|
+
category: 'frontend-contract',
|
|
82
|
+
implications: [
|
|
83
|
+
'accessibility-proof',
|
|
84
|
+
'browser-security-boundary',
|
|
85
|
+
'public-configuration',
|
|
86
|
+
],
|
|
87
|
+
},
|
|
88
|
+
'frontend/security-headers.json': {
|
|
89
|
+
category: 'frontend-security',
|
|
90
|
+
implications: [
|
|
91
|
+
'content-security-policy',
|
|
92
|
+
'response-header-ownership',
|
|
93
|
+
'transport-profile',
|
|
94
|
+
],
|
|
95
|
+
},
|
|
96
|
+
'operations/features.json': {
|
|
97
|
+
category: 'feature-controls',
|
|
98
|
+
implications: ['flag-lifecycle', 'owners', 'stop-conditions'],
|
|
99
|
+
},
|
|
100
|
+
'operations/reliability.json': {
|
|
101
|
+
category: 'reliability-operations',
|
|
102
|
+
implications: [
|
|
103
|
+
'alarm-registration',
|
|
104
|
+
'cleanup-backlog-alarms-read-continuation-required-minimum-three-hours',
|
|
105
|
+
'database-capacity-dynamodb-table-and-pending-events-throttle-metrics',
|
|
106
|
+
'diagnostic-authority',
|
|
107
|
+
'event-delivery-alarms-and-hourly-outbox-backlog-period',
|
|
108
|
+
'incident-remediation',
|
|
109
|
+
'performance-load-cleanup-backlog-two-evaluation-periods',
|
|
110
|
+
],
|
|
111
|
+
},
|
|
112
|
+
'operations/release.json': {
|
|
113
|
+
category: 'release-controls',
|
|
114
|
+
implications: [
|
|
115
|
+
'artifact-inventory',
|
|
116
|
+
'compatibility-sequence',
|
|
117
|
+
'rollout-controls',
|
|
118
|
+
],
|
|
119
|
+
},
|
|
120
|
+
'performance/aggregate-count-provider.ts': {
|
|
121
|
+
category: 'performance-aggregate-provider',
|
|
122
|
+
implications: [
|
|
123
|
+
'aggregate-source-authority',
|
|
124
|
+
'business-capability-counts',
|
|
125
|
+
'provider-data-access',
|
|
126
|
+
],
|
|
127
|
+
},
|
|
128
|
+
'performance/policy.json': {
|
|
129
|
+
category: 'performance-policy',
|
|
130
|
+
implications: [
|
|
131
|
+
'capacity-and-load-settings',
|
|
132
|
+
'cost-budgets',
|
|
133
|
+
'journey-authority',
|
|
134
|
+
],
|
|
135
|
+
},
|
|
136
|
+
'reliability/metric-declarations.ts': {
|
|
137
|
+
category: 'reliability-metrics',
|
|
138
|
+
guidance: 'Review existing custom recordReliabilityOperation calls and declare each finite deployment-owned component/feature/operation tuple in reliability/metric-declarations.ts. Undeclared custom series are dropped by the managed recorder. Never derive declarations from request, user, resource, or correlation IDs. Preserve existing declarations, verify custom metric emission, retain evidence, and resolve the seeded reconciliation marker before protected promotion.',
|
|
139
|
+
implications: [
|
|
140
|
+
'custom-metric-series-allowlist',
|
|
141
|
+
'finite-deployment-owned-dimensions',
|
|
142
|
+
'undeclared-custom-series-are-dropped',
|
|
143
|
+
],
|
|
144
|
+
},
|
|
145
|
+
'secrets/declarations.ts': {
|
|
146
|
+
category: 'secret-contract',
|
|
147
|
+
implications: [
|
|
148
|
+
'generation-authority',
|
|
149
|
+
'secret-value-ownership',
|
|
150
|
+
'stage-requirements',
|
|
151
|
+
],
|
|
152
|
+
},
|
|
153
|
+
'secrets/metadata.json': {
|
|
154
|
+
category: 'secret-contract',
|
|
155
|
+
implications: ['logical-identity', 'management-class', 'registry-schema'],
|
|
156
|
+
},
|
|
157
|
+
'secrets/workload-access.json': {
|
|
158
|
+
category: 'secret-contract',
|
|
159
|
+
implications: [
|
|
160
|
+
'logical-identity',
|
|
161
|
+
'runtime-secret-linkage',
|
|
162
|
+
'workload-iam',
|
|
163
|
+
],
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
exports.SEEDED_RECONCILIATION_MARKER_REFERENCE = 'PLAN:5.6/seeded-upgrade-reconciliation';
|
|
167
|
+
function seededReconciliationDefinition(path) {
|
|
168
|
+
return Object.prototype.hasOwnProperty.call(SEEDED_RECONCILIATION, path)
|
|
169
|
+
? SEEDED_RECONCILIATION[path]
|
|
170
|
+
: null;
|
|
171
|
+
}
|
|
172
|
+
function upgradeConflictMessage(label, report) {
|
|
173
|
+
const ownershipDetails = [
|
|
174
|
+
...report.conflictingJsonMembers.map((member) => `- conflicting JSON ownership claim: ${member}`),
|
|
175
|
+
...report.expandedJsonOwnership.map((path) => `- unsafe expansion to whole-file JSON ownership: ${path}`),
|
|
176
|
+
];
|
|
177
|
+
return `${label} upgrade has user-modified managed files or unsafe JSON ownership changes:\n${report.conflicting.map((path) => `- ${path}`).join('\n')}${ownershipDetails.length > 0 ? `\n${ownershipDetails.join('\n')}` : ''}\nResolve or restore them before applying the upgrade.`;
|
|
178
|
+
}
|
|
179
|
+
function seededMigrationUpgradeMessage(label, report) {
|
|
180
|
+
return `${label} upgrade cannot rewrite an existing seeded database migration:\n${report.incompatibleSeededMigrations.map((path) => `- ${path}`).join('\n')}\nAn upgrade never rewrites migration history; a stable release changes a generated schema only by adding a new migration. A workspace generated by a prerelease earlier than 1.0.0-rc.39 carries an older seeded migration and rebuilds instead, as docs/upgrades.md describes under "Declared prerelease breaks".`;
|
|
181
|
+
}
|
|
182
|
+
async function formatRenderedFiles(tree, files, prefix = '') {
|
|
183
|
+
const changedOptions = (0, formatting_js_1.changedTreePrettierOptions)(tree);
|
|
184
|
+
return Object.fromEntries(await Promise.all(Object.entries(files).map(async ([path, contents]) => {
|
|
185
|
+
const workspacePath = node_path_1.posix.join(prefix, path);
|
|
186
|
+
if ((0, built_in_plan_js_1.isBuiltInSliceFormatSensitivePath)(path) ||
|
|
187
|
+
(0, workspace_files_js_1.isRawWorkspaceAuthorityPath)(workspacePath)) {
|
|
188
|
+
return [path, contents];
|
|
189
|
+
}
|
|
190
|
+
try {
|
|
191
|
+
const options = await (0, formatting_js_1.effectiveTreePrettierOptions)(tree, workspacePath, changedOptions);
|
|
192
|
+
return [
|
|
193
|
+
path,
|
|
194
|
+
await (0, formatting_js_1.formatTreeContentsToFixedPoint)(contents, options, workspacePath),
|
|
195
|
+
];
|
|
196
|
+
}
|
|
197
|
+
catch {
|
|
198
|
+
return [path, contents];
|
|
199
|
+
}
|
|
200
|
+
})));
|
|
201
|
+
}
|
|
202
|
+
async function formatOwnershipRecord(tree, path, label) {
|
|
203
|
+
if (!tree.exists(path)) {
|
|
204
|
+
throw new Error(`${label} ownership metadata is missing at ${path}.`);
|
|
205
|
+
}
|
|
206
|
+
await (0, formatting_js_1.formatTreeFileToFixedPoint)(tree, path);
|
|
207
|
+
}
|
|
208
|
+
function readJson(tree, path, label) {
|
|
209
|
+
const contents = tree.read(path, 'utf8');
|
|
210
|
+
if (contents === null)
|
|
211
|
+
throw new Error(`${label} does not exist at ${path}.`);
|
|
212
|
+
try {
|
|
213
|
+
return JSON.parse(contents);
|
|
214
|
+
}
|
|
215
|
+
catch (error) {
|
|
216
|
+
throw new Error(`${label} is not valid JSON: ${error instanceof Error ? error.message : String(error)}`);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
function ownershipValidationMessage(label, issues) {
|
|
220
|
+
const details = issues
|
|
221
|
+
.map((issue) => `- ${issue.path}: ${issue.message}`)
|
|
222
|
+
.join('\n');
|
|
223
|
+
const regenerateHint = issues.some(({ path }) => path === 'ownership.schemaVersion')
|
|
224
|
+
? '\nOwnership schema v2 has no pre-release migration shim. Regenerate this unpublished alpha workspace as documented in docs/upgrades.md.'
|
|
225
|
+
: '';
|
|
226
|
+
return `${label} is invalid:\n${details}${regenerateHint}`;
|
|
227
|
+
}
|
|
228
|
+
function createUpgradeReport(currentFiles, currentOwnership, targetFiles, targetOwnership, jsonOwnershipChanges = {
|
|
229
|
+
claimedJsonMembers: [],
|
|
230
|
+
conflictingJsonMembers: [],
|
|
231
|
+
expandedJsonOwnership: [],
|
|
232
|
+
releasedJsonMembers: [],
|
|
233
|
+
}) {
|
|
234
|
+
const report = {
|
|
235
|
+
addedSeeded: [],
|
|
236
|
+
appendedSeeded: [],
|
|
237
|
+
changed: [],
|
|
238
|
+
claimedJsonMembers: [...jsonOwnershipChanges.claimedJsonMembers],
|
|
239
|
+
conflicting: [],
|
|
240
|
+
conflictingJsonMembers: [...jsonOwnershipChanges.conflictingJsonMembers],
|
|
241
|
+
expandedJsonOwnership: [...jsonOwnershipChanges.expandedJsonOwnership],
|
|
242
|
+
incompatibleSeededMigrations: [],
|
|
243
|
+
missing: [],
|
|
244
|
+
obsolete: [],
|
|
245
|
+
preservedSeeded: [],
|
|
246
|
+
releasedJsonMembers: [...jsonOwnershipChanges.releasedJsonMembers],
|
|
247
|
+
seededReconciliation: [],
|
|
248
|
+
unchanged: [],
|
|
249
|
+
};
|
|
250
|
+
const targetPaths = new Set(targetOwnership.paths.map(({ path }) => path));
|
|
251
|
+
const currentPathOwnership = new Map(currentOwnership.paths.map((entry) => [entry.path, entry]));
|
|
252
|
+
for (const targetEntry of targetOwnership.paths) {
|
|
253
|
+
const { mode, path, sha256: targetSha256 } = targetEntry;
|
|
254
|
+
const current = currentFiles.get(path) ?? null;
|
|
255
|
+
const target = targetFiles.get(path);
|
|
256
|
+
const currentEntry = currentPathOwnership.get(path);
|
|
257
|
+
if (target === undefined) {
|
|
258
|
+
throw new Error(`Target Blueprint did not render owned path ${path}.`);
|
|
259
|
+
}
|
|
260
|
+
if (mode === 'seeded') {
|
|
261
|
+
(current === null ? report.addedSeeded : report.preservedSeeded).push(path);
|
|
262
|
+
if (current !== null &&
|
|
263
|
+
currentEntry !== undefined &&
|
|
264
|
+
currentEntry.sha256 !== targetSha256 &&
|
|
265
|
+
path.startsWith('database/migrations/')) {
|
|
266
|
+
report.incompatibleSeededMigrations.push(path);
|
|
267
|
+
}
|
|
268
|
+
else if (((current !== null && currentEntry?.sha256 !== targetSha256) ||
|
|
269
|
+
(current === null &&
|
|
270
|
+
path === 'reliability/metric-declarations.ts')) &&
|
|
271
|
+
seededReconciliationDefinition(path) !== null) {
|
|
272
|
+
const reconciliation = seededReconciliationDefinition(path);
|
|
273
|
+
if (reconciliation === null) {
|
|
274
|
+
throw new Error(`Missing seeded reconciliation definition for ${path}.`);
|
|
275
|
+
}
|
|
276
|
+
report.seededReconciliation.push({
|
|
277
|
+
adopterContentSha256: current === null
|
|
278
|
+
? null
|
|
279
|
+
: (0, index_js_1.hashOwnedContent)(current, currentEntry ?? targetEntry),
|
|
280
|
+
category: reconciliation.category,
|
|
281
|
+
currentFrameworkSha256: currentEntry?.sha256 ?? null,
|
|
282
|
+
...('guidance' in reconciliation
|
|
283
|
+
? { guidance: reconciliation.guidance }
|
|
284
|
+
: {}),
|
|
285
|
+
implications: [...reconciliation.implications],
|
|
286
|
+
markerReference: exports.SEEDED_RECONCILIATION_MARKER_REFERENCE,
|
|
287
|
+
path,
|
|
288
|
+
requiredAction: current === null
|
|
289
|
+
? 'declare-existing-custom-metric-series-before-promotion'
|
|
290
|
+
: 'review-and-reconcile-preserving-adopter-content',
|
|
291
|
+
targetFrameworkSha256: targetSha256,
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
else if (current === null) {
|
|
296
|
+
report.missing.push(path);
|
|
297
|
+
}
|
|
298
|
+
else if (currentEntry !== undefined &&
|
|
299
|
+
(0, index_js_1.hashOwnedContent)(current, currentEntry) !== currentEntry.sha256) {
|
|
300
|
+
report.conflicting.push(path);
|
|
301
|
+
}
|
|
302
|
+
else if (current === target) {
|
|
303
|
+
report.unchanged.push(path);
|
|
304
|
+
}
|
|
305
|
+
else if (currentEntry === undefined) {
|
|
306
|
+
report.conflicting.push(path);
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
report.changed.push(path);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
for (const entry of currentOwnership.paths) {
|
|
313
|
+
const { mode, origin, path, sha256 } = entry;
|
|
314
|
+
if (mode !== 'managed' ||
|
|
315
|
+
origin === 'composition' ||
|
|
316
|
+
targetPaths.has(path)) {
|
|
317
|
+
continue;
|
|
318
|
+
}
|
|
319
|
+
const current = currentFiles.get(path) ?? null;
|
|
320
|
+
if (current === null)
|
|
321
|
+
continue;
|
|
322
|
+
if ((0, index_js_1.hashOwnedContent)(current, entry) === sha256) {
|
|
323
|
+
report.obsolete.push(path);
|
|
324
|
+
}
|
|
325
|
+
else if (!report.conflicting.includes(path)) {
|
|
326
|
+
report.conflicting.push(path);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
const ownershipConflictPaths = new Set([
|
|
330
|
+
...report.expandedJsonOwnership,
|
|
331
|
+
...report.conflictingJsonMembers.map((member) => member.slice(0, member.indexOf('#/'))),
|
|
332
|
+
]);
|
|
333
|
+
for (const path of ownershipConflictPaths) {
|
|
334
|
+
report.changed = report.changed.filter((entry) => entry !== path);
|
|
335
|
+
report.unchanged = report.unchanged.filter((entry) => entry !== path);
|
|
336
|
+
if (!report.conflicting.includes(path))
|
|
337
|
+
report.conflicting.push(path);
|
|
338
|
+
}
|
|
339
|
+
for (const paths of Object.values(report)) {
|
|
340
|
+
paths.sort((left, right) => typeof left === 'string' && typeof right === 'string'
|
|
341
|
+
? (0, deterministic_order_js_1.compareUtf16)(left, right)
|
|
342
|
+
: (0, deterministic_order_js_1.compareUtf16)(left.path, right.path));
|
|
343
|
+
}
|
|
344
|
+
return report;
|
|
345
|
+
}
|
|
346
|
+
function mergeStructuredTargetFiles(currentFiles, currentOwnership, targetFiles, targetOwnership) {
|
|
347
|
+
const files = new Map(targetFiles);
|
|
348
|
+
const changes = {
|
|
349
|
+
claimedJsonMembers: [],
|
|
350
|
+
conflictingJsonMembers: [],
|
|
351
|
+
expandedJsonOwnership: [],
|
|
352
|
+
releasedJsonMembers: [],
|
|
353
|
+
};
|
|
354
|
+
const currentEntries = new Map(currentOwnership.paths.map((entry) => [entry.path, entry]));
|
|
355
|
+
for (const targetEntry of targetOwnership.paths) {
|
|
356
|
+
const currentEntry = currentEntries.get(targetEntry.path);
|
|
357
|
+
const current = currentFiles.get(targetEntry.path) ?? null;
|
|
358
|
+
const target = files.get(targetEntry.path);
|
|
359
|
+
if (current === null || target === undefined)
|
|
360
|
+
continue;
|
|
361
|
+
if (targetEntry.mode === 'seeded') {
|
|
362
|
+
files.set(targetEntry.path, current);
|
|
363
|
+
continue;
|
|
364
|
+
}
|
|
365
|
+
if (currentEntry?.managedJsonPointers && !targetEntry.managedJsonPointers) {
|
|
366
|
+
if (targetEntry.mode === 'managed') {
|
|
367
|
+
changes.expandedJsonOwnership.push(targetEntry.path);
|
|
368
|
+
}
|
|
369
|
+
else {
|
|
370
|
+
changes.releasedJsonMembers.push(...currentEntry.managedJsonPointers.map((pointer) => `${targetEntry.path}#${pointer}`));
|
|
371
|
+
}
|
|
372
|
+
continue;
|
|
373
|
+
}
|
|
374
|
+
if (!targetEntry.managedJsonPointers)
|
|
375
|
+
continue;
|
|
376
|
+
if (currentEntry?.managedJsonPointers) {
|
|
377
|
+
const transition = (0, index_js_1.analyzeManagedJsonPointerTransition)(current, target, currentEntry.managedJsonPointers, targetEntry.managedJsonPointers);
|
|
378
|
+
changes.claimedJsonMembers.push(...transition.claimed.map((pointer) => `${targetEntry.path}#${pointer}`));
|
|
379
|
+
changes.conflictingJsonMembers.push(...transition.conflictingClaims.map((pointer) => `${targetEntry.path}#${pointer}`));
|
|
380
|
+
changes.releasedJsonMembers.push(...transition.released.map((pointer) => `${targetEntry.path}#${pointer}`));
|
|
381
|
+
if (transition.conflictingClaims.length > 0) {
|
|
382
|
+
files.set(targetEntry.path, current);
|
|
383
|
+
continue;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
files.set(targetEntry.path, (0, index_js_1.mergeManagedJsonContents)(current, target, targetEntry.managedJsonPointers));
|
|
387
|
+
}
|
|
388
|
+
return { files, ...changes };
|
|
389
|
+
}
|
|
390
|
+
async function formatMergedManagedJsonFiles(tree, root, merge, ownership) {
|
|
391
|
+
const files = new Map(merge.files);
|
|
392
|
+
const changedOptions = (0, formatting_js_1.changedTreePrettierOptions)(tree);
|
|
393
|
+
await Promise.all(ownership.paths.map(async (entry) => {
|
|
394
|
+
if (entry.mode !== 'managed' || !entry.managedJsonPointers)
|
|
395
|
+
return;
|
|
396
|
+
const contents = files.get(entry.path);
|
|
397
|
+
if (contents === undefined) {
|
|
398
|
+
throw new Error(`Target did not render managed JSON ${entry.path}.`);
|
|
399
|
+
}
|
|
400
|
+
const workspacePath = node_path_1.posix.join(root, entry.path);
|
|
401
|
+
const options = await (0, formatting_js_1.effectiveTreePrettierOptions)(tree, workspacePath, changedOptions);
|
|
402
|
+
files.set(entry.path, await (0, formatting_js_1.formatTreeContentsToFixedPoint)(contents, options, workspacePath));
|
|
403
|
+
}));
|
|
404
|
+
return { ...merge, files };
|
|
405
|
+
}
|
|
406
|
+
//# sourceMappingURL=upgrade-plan.js.map
|