@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.
Files changed (187) hide show
  1. package/generators.json +11 -1
  2. package/package.json +3 -3
  3. package/src/aws-authority/stage-authority.d.ts +30 -2
  4. package/src/aws-authority/stage-authority.js +220 -25
  5. package/src/developer-agent/generator-planning.js +109 -9
  6. package/src/developer-agent/model.d.ts +7 -3
  7. package/src/developer-agent/model.js +1 -0
  8. package/src/developer-agent/operation-registry.d.ts +1 -0
  9. package/src/developer-agent/operation-registry.js +44 -3
  10. package/src/developer-agent/planning.js +5 -2
  11. package/src/developer-agent/preview-changes.js +10 -0
  12. package/src/developer-agent/validation.js +7 -3
  13. package/src/developer-agent/workspace-inspection.js +51 -4
  14. package/src/executors/deployment-plan/deployment-plan.js +3 -0
  15. package/src/executors/dev-doctor/dev-doctor.d.ts +25 -3
  16. package/src/executors/dev-doctor/dev-doctor.js +136 -49
  17. package/src/executors/dev-setup/dev-setup.d.ts +18 -1
  18. package/src/executors/dev-setup/dev-setup.js +320 -196
  19. package/src/executors/foundation-preflight/foundation-preflight.js +9 -1
  20. package/src/executors/foundation-remove-preflight/foundation-remove-preflight.js +2 -2
  21. package/src/executors/github-bootstrap/github-bootstrap.d.ts +3 -0
  22. package/src/executors/github-bootstrap/github-bootstrap.js +28 -0
  23. package/src/executors/github-bootstrap/schema.json +14 -0
  24. package/src/executors/infrastructure-plan/infrastructure-plan.js +10 -3
  25. package/src/executors/local-deploy/local-deploy.d.ts +15 -0
  26. package/src/executors/local-deploy/local-deploy.js +96 -14
  27. package/src/executors/sst-lifecycle/logging-preflight.js +12 -1
  28. package/src/executors/sst-lifecycle/run-sst-command.js +51 -5
  29. package/src/foundation/cost-estimate.js +1 -1
  30. package/src/foundation/identity-domain-parent-ready.d.ts +91 -0
  31. package/src/foundation/identity-domain-parent-ready.js +333 -0
  32. package/src/foundation/identity-domain.d.ts +94 -0
  33. package/src/foundation/identity-domain.js +115 -0
  34. package/src/foundation/index.d.ts +2 -0
  35. package/src/foundation/index.js +7 -0
  36. package/src/foundation/preflight.js +17 -1
  37. package/src/foundation/root-site-readiness.d.ts +27 -0
  38. package/src/foundation/root-site-readiness.js +78 -0
  39. package/src/foundation/root-site.d.ts +81 -0
  40. package/src/foundation/root-site.js +268 -0
  41. package/src/generators/framework-prerequisites.d.ts +2 -0
  42. package/src/generators/framework-prerequisites.js +34 -0
  43. package/src/generators/function/function-registration.d.ts +24 -0
  44. package/src/generators/function/function-registration.js +66 -0
  45. package/src/generators/function/function.d.ts +16 -1
  46. package/src/generators/function/function.js +101 -18
  47. package/src/generators/function/schema.d.ts +1 -0
  48. package/src/generators/function/schema.json +6 -0
  49. package/src/generators/function-access/function-access.d.ts +14 -0
  50. package/src/generators/function-access/function-access.js +141 -0
  51. package/src/generators/function-access/schema.d.ts +6 -0
  52. package/src/generators/function-access/schema.json +25 -0
  53. package/src/generators/post-generation-install.d.ts +1 -1
  54. package/src/generators/post-generation-install.js +1 -1
  55. package/src/generators/preset/dependency-overrides.d.ts +1 -1
  56. package/src/generators/preset/dependency-overrides.js +1 -1
  57. package/src/generators/preset/workspace-files-adopter-skills.js +14 -0
  58. package/src/generators/preset/workspace-files-developer-agent.js +17 -11
  59. package/src/generators/preset/workspace-files-stage-authority.js +58 -1
  60. package/src/generators/preset/workspace-files-thin-deploy.d.ts +11 -0
  61. package/src/generators/preset/workspace-files-thin-deploy.js +52 -5
  62. package/src/generators/preset/workspace-files-thin-docs.js +33 -5
  63. package/src/generators/preset/workspace-files.js +238 -41
  64. package/src/generators/repository-policy/repository-policy.js +2 -1
  65. package/src/generators/repository-policy/schema.d.ts +2 -0
  66. package/src/generators/repository-policy/schema.json +7 -2
  67. package/src/generators/site/built-in-site-documentation-files.d.ts +2 -0
  68. package/src/generators/site/built-in-site-documentation-files.js +92 -0
  69. package/src/generators/site/built-in-site-files.d.ts +8 -0
  70. package/src/generators/site/built-in-site-files.js +40 -0
  71. package/src/generators/site/built-in-site-infrastructure-files.d.ts +2 -0
  72. package/src/generators/site/built-in-site-infrastructure-files.js +275 -0
  73. package/src/generators/site/built-in-site-plan.d.ts +19 -0
  74. package/src/generators/site/built-in-site-plan.js +65 -0
  75. package/src/generators/site/built-in-site-project-files.d.ts +3 -0
  76. package/src/generators/site/built-in-site-project-files.js +258 -0
  77. package/src/generators/site/built-in-site-script-files.d.ts +2 -0
  78. package/src/generators/site/built-in-site-script-files.js +306 -0
  79. package/src/generators/site/built-in-site-shared.d.ts +9 -0
  80. package/src/generators/site/built-in-site-shared.js +21 -0
  81. package/src/generators/site/built-in-site-smoke-files.d.ts +2 -0
  82. package/src/generators/site/built-in-site-smoke-files.js +37 -0
  83. package/src/generators/site/built-in-site-sst-config-files.d.ts +2 -0
  84. package/src/generators/site/built-in-site-sst-config-files.js +39 -0
  85. package/src/generators/site/built-in-site-web-files.d.ts +2 -0
  86. package/src/generators/site/built-in-site-web-files.js +284 -0
  87. package/src/generators/site/schema.d.ts +4 -0
  88. package/src/generators/site/schema.json +20 -0
  89. package/src/generators/site/site.d.ts +13 -0
  90. package/src/generators/site/site.js +221 -0
  91. package/src/generators/slice/built-in-plan-alarm-identity.d.ts +9 -0
  92. package/src/generators/slice/built-in-plan-alarm-identity.js +8 -1
  93. package/src/generators/slice/built-in-plan-api-contract-files.js +18 -0
  94. package/src/generators/slice/built-in-plan-async-work-files.js +18 -0
  95. package/src/generators/slice/built-in-plan-data-files.js +126 -14
  96. package/src/generators/slice/built-in-plan-foundation-files.d.ts +12 -0
  97. package/src/generators/slice/built-in-plan-foundation-files.js +114 -5
  98. package/src/generators/slice/built-in-plan-frontend-files.js +2 -271
  99. package/src/generators/slice/built-in-plan-frontend-header-proof.d.ts +6 -0
  100. package/src/generators/slice/built-in-plan-frontend-header-proof.js +282 -0
  101. package/src/generators/slice/built-in-plan-infrastructure-files.js +151 -237
  102. package/src/generators/slice/built-in-plan-key-value-cleanup.js +4 -3
  103. package/src/generators/slice/built-in-plan-log-group-helpers.d.ts +29 -0
  104. package/src/generators/slice/built-in-plan-log-group-helpers.js +130 -0
  105. package/src/generators/slice/built-in-plan-metadata-files.js +25 -5
  106. package/src/generators/slice/built-in-plan-next-build-authority.d.ts +5 -0
  107. package/src/generators/slice/built-in-plan-next-build-authority.js +124 -0
  108. package/src/generators/slice/built-in-plan-operations-files.d.ts +6 -0
  109. package/src/generators/slice/built-in-plan-operations-files.js +107 -219
  110. package/src/generators/slice/built-in-plan-performance-files.js +6 -1
  111. package/src/generators/slice/built-in-plan-release-files.js +0 -1
  112. package/src/generators/slice/built-in-plan-reliability-files.js +12 -8
  113. package/src/generators/slice/built-in-plan-shared.d.ts +1 -1
  114. package/src/generators/slice/built-in-plan-shared.js +1 -1
  115. package/src/generators/slice/built-in-plan-sst-config.d.ts +49 -0
  116. package/src/generators/slice/built-in-plan-sst-config.js +160 -0
  117. package/src/generators/slice/built-in-plan-testing-files.js +92 -49
  118. package/src/generators/slice/built-in-plan-verification-files.js +15 -5
  119. package/src/generators/slice/built-in-plan-web-files.js +69 -5
  120. package/src/generators/slice/built-in-plan.js +1 -2
  121. package/src/generators/slice/deployed-smoke-diagnostics.d.ts +35 -0
  122. package/src/generators/slice/deployed-smoke-diagnostics.js +189 -0
  123. package/src/generators/slice/deployed-smoke-readiness.d.ts +7 -0
  124. package/src/generators/slice/deployed-smoke-readiness.js +118 -23
  125. package/src/generators/slice/persistence-contract.js +2 -2
  126. package/src/generators/slice/pnpm-launch-script.d.ts +13 -0
  127. package/src/generators/slice/pnpm-launch-script.js +28 -0
  128. package/src/generators/slice/slice.js +27 -0
  129. package/src/generators/upgrade/custom-domain-notice.d.ts +19 -0
  130. package/src/generators/upgrade/custom-domain-notice.js +38 -0
  131. package/src/generators/upgrade/external-blueprint-compositions.d.ts +84 -0
  132. package/src/generators/upgrade/external-blueprint-compositions.js +478 -0
  133. package/src/generators/upgrade/framework-package-upgrade.d.ts +58 -0
  134. package/src/generators/upgrade/framework-package-upgrade.js +78 -0
  135. package/src/generators/upgrade/function-authentication-notice.d.ts +29 -0
  136. package/src/generators/upgrade/function-authentication-notice.js +74 -0
  137. package/src/generators/upgrade/schema.json +2 -2
  138. package/src/generators/upgrade/upgrade-plan.d.ts +52 -0
  139. package/src/generators/upgrade/upgrade-plan.js +406 -0
  140. package/src/generators/upgrade/upgrade.d.ts +1 -35
  141. package/src/generators/upgrade/upgrade.js +347 -595
  142. package/src/generators/workload/reliability-registration.d.ts +1 -1
  143. package/src/generators/workload/reliability-registration.js +9 -9
  144. package/src/generators/workload/workload.d.ts +1 -1
  145. package/src/generators/workload/workload.js +87 -13
  146. package/src/git-policy/github-bootstrap.d.ts +24 -5
  147. package/src/git-policy/github-bootstrap.js +105 -10
  148. package/src/local-dev/fleet-process.d.ts +9 -2
  149. package/src/local-dev/fleet-process.js +27 -7
  150. package/src/local-dev/fleet-session.js +41 -4
  151. package/src/local-dev/fleet-supervisor-daemon.js +1 -5
  152. package/src/local-dev/fleet-supervisor.d.ts +1 -0
  153. package/src/local-dev/fleet-supervisor.js +34 -11
  154. package/src/local-dev/gateway-daemon.d.ts +1 -1
  155. package/src/local-dev/gateway-daemon.js +6 -4
  156. package/src/local-dev/portless.d.ts +5 -0
  157. package/src/local-dev/portless.js +5 -0
  158. package/src/local-dev/process-group.d.ts +10 -0
  159. package/src/local-dev/process-group.js +33 -0
  160. package/src/local-dev/tls.js +31 -2
  161. package/src/local-dev/trust-store.d.ts +42 -0
  162. package/src/local-dev/trust-store.js +87 -0
  163. package/src/ownership/composition.d.ts +7 -0
  164. package/src/ownership/composition.js +64 -56
  165. package/src/ownership/index.d.ts +1 -0
  166. package/src/ownership/index.js +1 -0
  167. package/src/ownership/record.d.ts +19 -0
  168. package/src/ownership/record.js +26 -2
  169. package/src/ownership/site-record.d.ts +18 -0
  170. package/src/ownership/site-record.js +105 -0
  171. package/src/repository-policy/deployment-plan.d.ts +3 -0
  172. package/src/repository-policy/deployment-plan.js +33 -4
  173. package/src/repository-policy/index.d.ts +1 -0
  174. package/src/repository-policy/index.js +1 -0
  175. package/src/repository-policy/policy.d.ts +13 -1
  176. package/src/repository-policy/policy.js +55 -1
  177. package/src/repository-policy/public-dns.d.ts +65 -0
  178. package/src/repository-policy/public-dns.js +168 -0
  179. package/src/schemas/generated-ownership-v2.json +6 -0
  180. package/src/schemas/repository-policy-v1.json +67 -1
  181. package/src/supply-chain/blueprint-trust-git.js +24 -0
  182. package/src/supply-chain/blueprint-verification-authority.js +42 -3
  183. package/src/supply-chain/generated-blueprint-trust-command.js +15 -0
  184. package/src/supply-chain/sbom.js +74 -12
  185. package/src/work-markers/work-markers.js +4 -1
  186. package/src/workspace-deployment/ownership.d.ts +15 -0
  187. package/src/workspace-deployment/ownership.js +19 -3
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.renderManagedLogHelpers = renderManagedLogHelpers;
4
+ const built_in_plan_alarm_identity_js_1 = require("./built-in-plan-alarm-identity.js");
5
+ /**
6
+ * Each helper's generated TypeScript source, ending with a newline. The caller
7
+ * places them: `managedLogGroup` calls `managedLogContract` and
8
+ * `managedLogDataProtection`, whose alarm description calls
9
+ * `operationalAlarmDescription`; `lambdaLogging` stands alone.
10
+ */
11
+ function renderManagedLogHelpers(input) {
12
+ const { owner, route } = (0, built_in_plan_alarm_identity_js_1.sliceAlarmOwnership)(input.name);
13
+ return {
14
+ managedLogGroup: `function managedLogGroup(
15
+ logicalName: string,
16
+ component: string,
17
+ alertTopicArn: any,
18
+ resource?: string,
19
+ ) {
20
+ const contract = managedLogContract(component, resource);
21
+ const logGroup = new aws.cloudwatch.LogGroup(logicalName, {
22
+ logGroupClass: contract.logGroupClass,
23
+ name: contract.name,
24
+ retentionInDays: contract.retentionInDays,
25
+ tags: contract.tags,
26
+ });
27
+ const dataProtection = managedLogDataProtection(
28
+ logicalName,
29
+ contract,
30
+ logGroup.name,
31
+ [logGroup],
32
+ alertTopicArn,
33
+ );
34
+ return { contract, dataProtection, logGroup };
35
+ }
36
+ `,
37
+ managedLogContract: `function managedLogContract(component: string, resource?: string) {
38
+ return createManagedLogGroupContract({
39
+ component,
40
+ retentionInDays: observability.protectedRetentionDays,
41
+ ...(resource ? { resource } : {}),
42
+ slice: '${input.name}',
43
+ stage: $app.stage,
44
+ workspace: '${input.workspace}',
45
+ });
46
+ }
47
+ `,
48
+ operationalAlarmDescription: `function operationalAlarmDescription(input: {
49
+ businessSymptom: string;
50
+ id: string;
51
+ runbook: string;
52
+ }) {
53
+ return JSON.stringify({
54
+ businessSymptom: input.businessSymptom,
55
+ id: input.id,
56
+ owner: '${owner}',
57
+ route: '${route}',
58
+ runbook: input.runbook,
59
+ schemaVersion: 1,
60
+ slice: '${input.name}',
61
+ });
62
+ }
63
+ `,
64
+ managedLogDataProtection: `function managedLogDataProtection(
65
+ logicalName: string,
66
+ contract: ReturnType<typeof createManagedLogGroupContract>,
67
+ logGroupName: any,
68
+ dependsOn: any[],
69
+ alertTopicArn: any,
70
+ ) {
71
+ const policy = new aws.cloudwatch.LogDataProtectionPolicy(
72
+ logicalName + 'DataProtection',
73
+ {
74
+ logGroupName,
75
+ policyDocument: JSON.stringify(contract.dataProtectionPolicy),
76
+ },
77
+ { dependsOn },
78
+ );
79
+ const alarm = new aws.cloudwatch.MetricAlarm(
80
+ logicalName + 'DataProtectionFindings',
81
+ {
82
+ alarmActions: [alertTopicArn],
83
+ alarmDescription: operationalAlarmDescription(${(0, built_in_plan_alarm_identity_js_1.renderAlarmDescriptionInput)(input.dataProtectionAlarm, ' ')}),
84
+ comparisonOperator: 'GreaterThanOrEqualToThreshold',
85
+ dimensions: { LogGroupName: logGroupName },
86
+ evaluationPeriods: 1,
87
+ metricName: 'LogEventsWithFindings',
88
+ namespace: 'AWS/Logs',
89
+ period: 300,
90
+ statistic: 'Sum',
91
+ threshold: 1,
92
+ treatMissingData: 'notBreaching',
93
+ },
94
+ { dependsOn: [policy] },
95
+ );
96
+ return { alarm, policy };
97
+ }
98
+ `,
99
+ lambdaLogging: `function lambdaLogging(logGroupName: any, functionName?: any) {
100
+ return {
101
+ logging: { format: 'json' as const, logGroup: logGroupName },
102
+ transform: {
103
+ function(args: Record<string, any>): undefined {
104
+ if (functionName) args.name = functionName;
105
+ args.environment = $output(args.environment ?? {}).apply(
106
+ (environment: Record<string, any>) => ({
107
+ ...environment,
108
+ variables: $output(environment.variables ?? {}).apply(
109
+ (variables: Record<string, any>) => ({
110
+ ...variables,
111
+ EBK_OBSERVABILITY_SUCCESS_SAMPLE_RATE:
112
+ String(observability.routineSuccessSampleRate),
113
+ }),
114
+ ),
115
+ }),
116
+ );
117
+ args.loggingConfig = {
118
+ applicationLogLevel: 'TRACE',
119
+ logFormat: 'JSON',
120
+ logGroup: logGroupName,
121
+ systemLogLevel: observability.systemLogLevel,
122
+ };
123
+ },
124
+ },
125
+ };
126
+ }
127
+ `,
128
+ };
129
+ }
130
+ //# sourceMappingURL=built-in-plan-log-group-helpers.js.map
@@ -97,6 +97,10 @@ Functions added with \`nx g @empire-builder-kit/nx:function\` use
97
97
  development, generated Next routing forwards only that namespace to this task's
98
98
  SST API; handlers keep native SST live execution. This is not deployed-stage
99
99
  fallback. Keep user-owned Next API routes local and do not add a manual proxy.
100
+ A Function requires a signed-in caller unless it was generated with
101
+ \`--authentication=anonymous\`, so call it from a server route that sends the
102
+ access token as a bearer token; a browser request with only the session cookie
103
+ is refused.
100
104
 
101
105
  Use \`pnpm nx run ${name}:verify-local-browser\` against that owned fleet origin.
102
106
  Before its first run, install the pinned browser from this Slice's directory
@@ -162,8 +166,11 @@ Missed SQL notifications recover on the next hourly reconciliation by default;
162
166
  explicit cadence and maintenance pauses remain independent settings. No
163
167
  transaction spans SQL and DynamoDB.
164
168
 
165
- Ordinary Slice removal retains declared relational databases and their
166
- credential containers. The generated SQL retirement rehearsal is the protected
169
+ Ordinary Slice removal retains declared relational databases and their roles.
170
+ It deletes their generated credential containers in every stage except
171
+ \`production\`, which retains them. In those other stages a later deploy
172
+ recreates the containers, and its bootstrap publishes a fresh credential to the
173
+ retained roles. The generated SQL retirement rehearsal is the protected
167
174
  \`db-retirement-rehearsal\` target for the exact operations-declared
168
175
  \`development\` database named \`retirement_rehearsal\`. It accepts no stage,
169
176
  Slice, database, task, role, image, network, or workflow selection.
@@ -252,8 +259,18 @@ During replacement, first add the candidate to \`primary.provisioned\`, deploy
252
259
  infrastructure, then run \`db-migrate --database=<candidate>\` and complete
253
260
  candidate verification before changing \`primary.active\`.
254
261
 
255
- Ordinary removal retains every logical database and generated credential
256
- container. Outcome-2 evidence uses the separate protected
262
+ A \`db-migrate\` run deploys the Slice infrastructure first. With an unchanged
263
+ \`EBK_DATABASE_CREDENTIAL_GENERATION\` it re-applies the current generated
264
+ credential; with a different one, including omitting the variable after a
265
+ rotation, it rotates that credential. Rotate it only as
266
+ [the database credential rotation runbook](runbooks/database-credential-rotation.md)
267
+ describes.
268
+
269
+ Ordinary removal retains every logical database and its roles. It deletes the
270
+ generated credential containers in every stage except \`production\`, which
271
+ retains them. In those other stages a later deploy recreates the containers,
272
+ and its bootstrap publishes a fresh credential to the retained roles. Outcome-2
273
+ evidence uses the separate protected
257
274
  \`db-retirement-rehearsal\` target for exactly one reviewed, disposable
258
275
  \`development\` database named \`retirement_rehearsal\`. Its fixed
259
276
  AWS-internal callback task deletes that database, its three generated roles,
@@ -337,7 +354,10 @@ keep the source checkout, continue an interrupted report with its run
337
354
  reference, and retry the same approved run. Never delete its checkpoint,
338
355
  pending deletion work or retained evidence to silence the alarm.
339
356
  `,
340
- 'ebk-globals.d.ts': `import 'sst/resource';
357
+ 'ebk-globals.d.ts': `// Next.js ambient types, independent of the gitignored web/next-env.d.ts.
358
+ /// <reference types="next" />
359
+ /// <reference types="next/image-types/global" />
360
+ import 'sst/resource';
341
361
 
342
362
  declare global {
343
363
  type EbkSstOutput<T> = {
@@ -0,0 +1,5 @@
1
+ /**
2
+ * The managed Finder-metadata seal for a Next.js web's built Lambda bundles.
3
+ * Product Slices and the root site carry the same infra/next-build-authority.ts.
4
+ */
5
+ export declare function renderNextBuildAuthority(): string;
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.renderNextBuildAuthority = renderNextBuildAuthority;
4
+ /**
5
+ * The managed Finder-metadata seal for a Next.js web's built Lambda bundles.
6
+ * Product Slices and the root site carry the same infra/next-build-authority.ts.
7
+ */
8
+ function renderNextBuildAuthority() {
9
+ return `import {
10
+ chmodSync,
11
+ existsSync,
12
+ lstatSync,
13
+ readdirSync,
14
+ realpathSync,
15
+ unlinkSync,
16
+ } from 'node:fs';
17
+ import { join, relative, resolve } from 'node:path';
18
+
19
+ const maximumEntries = 65_536;
20
+ const maximumDepth = 64;
21
+ const maximumFinderMetadataFiles = 256;
22
+ const maximumFinderMetadataBytes = 1_048_576n;
23
+
24
+ // SST 4.17.1 awaits FunctionArgs.hook.postbuild after Runtime.Build has
25
+ // materialized the exact directory that its Lambda zipper consumes. Finder
26
+ // metadata removed only from OpenNext's earlier output can be recreated or
27
+ // copied through package-local node_modules before that boundary. Sanitize the
28
+ // final derived bundle here so the bytes reviewed by the infrastructure plan
29
+ // are the bytes SST packages.
30
+ export function removeFinderMetadataFromBuiltFunction(rootPath: string): number {
31
+ const root = resolve(rootPath);
32
+ const rootIdentity = lstatSync(root, { bigint: true });
33
+ if (
34
+ !rootIdentity.isDirectory() ||
35
+ rootIdentity.isSymbolicLink() ||
36
+ realpathSync(root) !== root
37
+ ) {
38
+ throw new Error('The built Function root has an invalid identity.');
39
+ }
40
+
41
+ const pendingDirectories = [{ depth: 0, path: root }];
42
+ let observedEntries = 0;
43
+ let removedFinderMetadata = 0;
44
+ while (pendingDirectories.length > 0) {
45
+ const current = pendingDirectories.pop();
46
+ if (!current) break;
47
+ if (current.depth > maximumDepth) {
48
+ throw new Error('The built Function tree exceeds its depth bound.');
49
+ }
50
+ for (const entry of readdirSync(current.path, { withFileTypes: true }).sort(
51
+ (left, right) =>
52
+ left.name < right.name ? -1 : left.name > right.name ? 1 : 0,
53
+ )) {
54
+ observedEntries += 1;
55
+ if (observedEntries > maximumEntries) {
56
+ throw new Error('The built Function tree exceeds its entry bound.');
57
+ }
58
+ const entryPath = join(current.path, entry.name);
59
+ const identity = lstatSync(entryPath, { bigint: true });
60
+ if (entry.name === '.DS_Store') {
61
+ removedFinderMetadata += 1;
62
+ if (
63
+ removedFinderMetadata > maximumFinderMetadataFiles ||
64
+ !identity.isFile() ||
65
+ identity.isSymbolicLink() ||
66
+ identity.nlink !== 1n ||
67
+ identity.size > maximumFinderMetadataBytes
68
+ ) {
69
+ throw new Error(
70
+ 'The built Function Finder metadata has an invalid identity.',
71
+ );
72
+ }
73
+ unlinkSync(entryPath);
74
+ if (existsSync(entryPath)) {
75
+ throw new Error(
76
+ 'The built Function Finder metadata was not removed.',
77
+ );
78
+ }
79
+ continue;
80
+ }
81
+ if (identity.isDirectory() && !identity.isSymbolicLink()) {
82
+ const confined = relative(root, entryPath);
83
+ if (
84
+ confined === '..' ||
85
+ confined.startsWith('../') ||
86
+ resolve(root, confined) !== entryPath
87
+ ) {
88
+ throw new Error('The built Function entry escapes its root.');
89
+ }
90
+ pendingDirectories.push({ depth: current.depth + 1, path: entryPath });
91
+ }
92
+ }
93
+ // Finder can recreate its metadata in the interval between this hook and
94
+ // SST's asynchronous glob/archive pass. On macOS, close that exact race by
95
+ // removing only the owner's write bit from each completed derived
96
+ // directory. The generated build wrapper restores it before the next
97
+ // OpenNext build. Group/other permission bits remain unchanged.
98
+ if (process.platform === 'darwin') {
99
+ const currentIdentity = lstatSync(current.path, { bigint: true });
100
+ if (
101
+ !currentIdentity.isDirectory() ||
102
+ currentIdentity.isSymbolicLink()
103
+ ) {
104
+ throw new Error('The built Function directory changed identity.');
105
+ }
106
+ chmodSync(
107
+ current.path,
108
+ Number((currentIdentity.mode & 0o7_777n) & ~0o200n),
109
+ );
110
+ if ((lstatSync(current.path, { bigint: true }).mode & 0o200n) !== 0n) {
111
+ throw new Error('The built Function directory was not sealed.');
112
+ }
113
+ if (existsSync(join(current.path, '.DS_Store'))) {
114
+ throw new Error(
115
+ 'The built Function Finder metadata raced its final seal.',
116
+ );
117
+ }
118
+ }
119
+ }
120
+ return removedFinderMetadata;
121
+ }
122
+ `;
123
+ }
124
+ //# sourceMappingURL=built-in-plan-next-build-authority.js.map
@@ -1,2 +1,8 @@
1
1
  /** @internal */
2
2
  export declare function renderSliceOperationsFiles(name: string, workspace?: string, frameworkVersion?: string, sql?: boolean): Readonly<Record<string, string>>;
3
+ /**
4
+ * The managed OpenNext build wrapper that SST's Next.js build command runs.
5
+ * It forwards only `applicationKeys` and operating-system keys to the exact
6
+ * managed OpenNext builder. Product Slices and the root site share it.
7
+ */
8
+ export declare function renderNextBuildEnvironmentWrapper(applicationKeys: readonly string[], owner?: string): string;