@anthusai/papyrus 5.112.0-next.2 → 5.112.0-next.3

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.
@@ -8,7 +8,7 @@ import { GITHUB_OIDC_PROVIDER_HOST } from "./github-oidc-provider.js";
8
8
  import { cmsProductionBuildSpec, cmsStagingBuildSpec, readerBuildSpec } from "./build-specs.js";
9
9
  import { applySiteCostTags } from "./cost-attribution.js";
10
10
  import { addSharedStackDeny } from "./shared-stack-deny.js";
11
- import { PROSPECTUS_PAPYRUS_SITE_ROUTES, hasCmsApp, hasReceiptGate, resolveGithubStatusTokenParameterName, isStagingEnabled, resolveRedirectSubDomainPrefix, resolveCmsHostName, resolveSiteOrigin, githubOidcSubjects, resolveGithubRepository, resolveProspectusAccountsEndpoint, resolveProspectusSessionSealingParameterName, resolveReaderPollSecretParameterName, resolveRevalidateSecretParameterName, resolveStackName, resolveStagingDomainName, resolveChatStackName, chatExportName, CHAT_EXPORTED_RESOURCES, CHAT_ENVIRONMENT_NAMES, CHAT_PRIVATE_ASSISTANT_ID, CHAT_PRIVATE_ASSISTANT_NAME, resolveStoragePreviewPrefix } from "./site-config.js";
11
+ import { PROSPECTUS_PAPYRUS_SITE_ROUTES, hasCmsApp, hasReceiptGate, resolveGithubStatusTokenParameterName, isStagingEnabled, resolveRedirectSubDomainPrefix, resolveCmsHostName, resolveSiteOrigin, githubOidcSubjects, resolveGithubRepository, resolveProspectusAccountsEndpoint, resolveProspectusSessionSealingParameterName, resolveReaderPollSecretParameterName, resolveRevalidateSecretParameterName, resolveStackName, resolveStagingDomainName, resolveChatStackName, chatExportName, CHAT_EXPORTED_RESOURCES, CHAT_ENVIRONMENT_NAMES, CHAT_PRIVATE_ASSISTANT_ID, CHAT_PRIVATE_ASSISTANT_NAME, resolveStoragePreviewPrefix, resolveBuildTimeoutMinutes } from "./site-config.js";
12
12
  function environmentVariables(variables) {
13
13
  return Object.entries(variables).map(([name, value]) => ({ name, value }));
14
14
  }
@@ -202,6 +202,9 @@ export class AmplifyAppShellStack extends Stack {
202
202
  computeRoleArn: computeRole.roleArn,
203
203
  buildSpec: cmsProductionBuildSpec(config),
204
204
  jobConfig: config.cms.buildComputeType ? { buildComputeType: config.cms.buildComputeType } : undefined,
205
+ // Amplify's only build timeout control; on the app, so every branch gets it. The branch sets no _BUILD_TIMEOUT of its own,
206
+ // because a branch's variable would override this one (docs/site-hosting.md, "Build timeout").
207
+ environmentVariables: [{ name: "_BUILD_TIMEOUT", value: String(resolveBuildTimeoutMinutes(config.cms)) }],
205
208
  customRules: [
206
209
  ...(config.cms.redirects ?? []).map((redirect) => ({
207
210
  source: `https://${redirect.source}`,
@@ -9,7 +9,7 @@ import { GITHUB_OIDC_PROVIDER_HOST } from "./github-oidc-provider";
9
9
  import { cmsProductionBuildSpec, cmsStagingBuildSpec, readerBuildSpec } from "./build-specs";
10
10
  import { applySiteCostTags } from "./cost-attribution";
11
11
  import { addSharedStackDeny } from "./shared-stack-deny";
12
- import { AmplifyAppShellSiteConfig, PROSPECTUS_PAPYRUS_SITE_ROUTES, ReaderCustomHeaderRule, hasCmsApp, hasReceiptGate, resolveGithubStatusTokenParameterName, isStagingEnabled, resolveRedirectSubDomainPrefix, resolveCmsHostName, resolveSiteOrigin, githubOidcSubjects, resolveGithubRepository, resolveProspectusAccountsEndpoint, resolveProspectusSessionSealingParameterName, resolveReaderPollSecretParameterName, resolveRevalidateSecretParameterName, resolveStackName, resolveStagingDomainName, resolveChatStackName, chatExportName, CHAT_EXPORTED_RESOURCES, CHAT_ENVIRONMENT_NAMES, CHAT_PRIVATE_ASSISTANT_ID, CHAT_PRIVATE_ASSISTANT_NAME, resolveStoragePreviewPrefix } from "./site-config";
12
+ import { AmplifyAppShellSiteConfig, PROSPECTUS_PAPYRUS_SITE_ROUTES, ReaderCustomHeaderRule, hasCmsApp, hasReceiptGate, resolveGithubStatusTokenParameterName, isStagingEnabled, resolveRedirectSubDomainPrefix, resolveCmsHostName, resolveSiteOrigin, githubOidcSubjects, resolveGithubRepository, resolveProspectusAccountsEndpoint, resolveProspectusSessionSealingParameterName, resolveReaderPollSecretParameterName, resolveRevalidateSecretParameterName, resolveStackName, resolveStagingDomainName, resolveChatStackName, chatExportName, CHAT_EXPORTED_RESOURCES, CHAT_ENVIRONMENT_NAMES, CHAT_PRIVATE_ASSISTANT_ID, CHAT_PRIVATE_ASSISTANT_NAME, resolveStoragePreviewPrefix, resolveBuildTimeoutMinutes } from "./site-config";
13
13
 
14
14
  function environmentVariables(variables: Record<string, string>): amplify.CfnBranch.EnvironmentVariableProperty[] {
15
15
  return Object.entries(variables).map(([name, value]) => ({ name, value }));
@@ -223,6 +223,9 @@ export class AmplifyAppShellStack extends Stack {
223
223
  computeRoleArn: computeRole.roleArn,
224
224
  buildSpec: cmsProductionBuildSpec(config),
225
225
  jobConfig: config.cms.buildComputeType ? { buildComputeType: config.cms.buildComputeType } : undefined,
226
+ // Amplify's only build timeout control; on the app, so every branch gets it. The branch sets no _BUILD_TIMEOUT of its own,
227
+ // because a branch's variable would override this one (docs/site-hosting.md, "Build timeout").
228
+ environmentVariables: [{ name: "_BUILD_TIMEOUT", value: String(resolveBuildTimeoutMinutes(config.cms)) }],
226
229
  customRules: [
227
230
  ...(config.cms.redirects ?? []).map((redirect) => ({
228
231
  source: `https://${redirect.source}`,
@@ -0,0 +1,64 @@
1
+ // Executes infra/amplify-app-shell/features/build-timeout.feature: the app shell sets Amplify's _BUILD_TIMEOUT from cms.buildTimeoutMinutes.
2
+ // Run by scripts/test-build-timeout.ts, which starts it inside the infrastructure package (one copy of aws-cdk-lib).
3
+ import assert from "node:assert/strict";
4
+ import fs from "node:fs";
5
+ import path from "node:path";
6
+ import { test } from "node:test";
7
+ import { App } from "aws-cdk-lib";
8
+ import { Template } from "aws-cdk-lib/assertions";
9
+ import { parse } from "yaml";
10
+ import { AmplifyAppShellStack } from "./amplify-app-shell.js";
11
+ import { MAX_BUILD_TIMEOUT_MINUTES, parseSiteConfig } from "./site-config.js";
12
+ const repo = path.resolve(__dirname, "../../..");
13
+ const env = { account: "111122223333", region: "us-east-1" };
14
+ const example = (change = () => { }) => {
15
+ const config = JSON.parse(fs.readFileSync(path.join(repo, "infra/amplify-app-shell/examples/shipped.site.json"), "utf8"));
16
+ change(config);
17
+ return config;
18
+ };
19
+ const synth = (config) => Template.fromStack(new AmplifyAppShellStack(new App(), "Shell", parseSiteConfig(config), { env })).toJSON();
20
+ const appVariables = (template) => {
21
+ // The CMS app is the WEB_COMPUTE one; a split site also has a reader app, which runs no backend build.
22
+ const apps = Object.values(template.Resources).filter((resource) => resource.Type === "AWS::Amplify::App" && resource.Properties.Platform === "WEB_COMPUTE");
23
+ assert.equal(apps.length, 1);
24
+ return Object.fromEntries((apps[0].Properties.EnvironmentVariables ?? []).map((variable) => [variable.Name, variable.Value]));
25
+ };
26
+ test("the app shell sets the build timeout from the site config, on the app and on no branch", () => {
27
+ const template = synth(example((c) => (c.cms.buildTimeoutMinutes = 90)));
28
+ assert.equal(appVariables(template)._BUILD_TIMEOUT, "90");
29
+ const branches = Object.values(template.Resources).filter((resource) => resource.Type === "AWS::Amplify::Branch");
30
+ assert.ok(branches.length > 0);
31
+ for (const branch of branches) {
32
+ assert.ok(!(branch.Properties.EnvironmentVariables ?? []).some((variable) => variable.Name === "_BUILD_TIMEOUT"), "a branch variable would override the app's");
33
+ }
34
+ });
35
+ test("the timeout defaults to 120 and is the only variable added to the app", () => {
36
+ const variables = appVariables(synth(example()));
37
+ assert.equal(variables._BUILD_TIMEOUT, "120");
38
+ assert.deepEqual(Object.keys(variables), ["_BUILD_TIMEOUT"]);
39
+ });
40
+ test("every example site gets _BUILD_TIMEOUT 120 unless it sets its own", () => {
41
+ const dir = path.join(repo, "infra/amplify-app-shell/examples");
42
+ for (const file of fs.readdirSync(dir).filter((name) => name.endsWith(".site.json"))) {
43
+ const config = JSON.parse(fs.readFileSync(path.join(dir, file), "utf8"));
44
+ if (!config.cms)
45
+ continue;
46
+ assert.equal(appVariables(synth(config))._BUILD_TIMEOUT, String(config.cms.buildTimeoutMinutes ?? 120), file);
47
+ }
48
+ });
49
+ test("a value outside Amplify's range, or not a whole number, is refused naming the range", () => {
50
+ for (const bad of [121, 4, 0, -5, 90.5, "90", null]) {
51
+ assert.throws(() => parseSiteConfig(example((c) => (c.cms.buildTimeoutMinutes = bad))), /cms\.buildTimeoutMinutes must be a whole number of minutes from 5 to 120/, String(bad));
52
+ }
53
+ for (const good of [5, 30, 120])
54
+ assert.equal(parseSiteConfig(example((c) => (c.cms.buildTimeoutMinutes = good))).cms?.buildTimeoutMinutes, good);
55
+ });
56
+ test("the deploy workflow waits, and its job runs, longer than the longest build", () => {
57
+ const workflow = parse(fs.readFileSync(path.join(repo, ".github/workflows/amplify-deploy.yml"), "utf8"));
58
+ const wait = workflow.on.workflow_call.inputs["timeout-minutes"].default;
59
+ assert.ok(wait > MAX_BUILD_TIMEOUT_MINUTES, `the wait is ${wait}`);
60
+ // The job timeout is the wait plus a positive margin, so any wait a caller passes stays inside it: it is always above the build timeout too.
61
+ const match = /^\$\{\{ inputs\.timeout-minutes \+ (\d+) \}\}$/.exec(workflow.jobs.deploy["timeout-minutes"]);
62
+ assert.ok(match && Number(match[1]) > 0, `the job timeout is ${workflow.jobs.deploy["timeout-minutes"]}`);
63
+ assert.ok(wait + Number(match[1]) > MAX_BUILD_TIMEOUT_MINUTES);
64
+ });
@@ -0,0 +1,68 @@
1
+ // Executes infra/amplify-app-shell/features/build-timeout.feature: the app shell sets Amplify's _BUILD_TIMEOUT from cms.buildTimeoutMinutes.
2
+ // Run by scripts/test-build-timeout.ts, which starts it inside the infrastructure package (one copy of aws-cdk-lib).
3
+ import assert from "node:assert/strict";
4
+ import fs from "node:fs";
5
+ import path from "node:path";
6
+ import { test } from "node:test";
7
+ import { App } from "aws-cdk-lib";
8
+ import { Template } from "aws-cdk-lib/assertions";
9
+ import { parse } from "yaml";
10
+ import { AmplifyAppShellStack } from "./amplify-app-shell";
11
+ import { MAX_BUILD_TIMEOUT_MINUTES, parseSiteConfig } from "./site-config";
12
+
13
+ const repo = path.resolve(__dirname, "../../..");
14
+ const env = { account: "111122223333", region: "us-east-1" };
15
+ const example = (change: (config: any) => void = () => {}) => {
16
+ const config = JSON.parse(fs.readFileSync(path.join(repo, "infra/amplify-app-shell/examples/shipped.site.json"), "utf8"));
17
+ change(config);
18
+ return config;
19
+ };
20
+ const synth = (config: unknown) => Template.fromStack(new AmplifyAppShellStack(new App(), "Shell", parseSiteConfig(config), { env })).toJSON();
21
+ const appVariables = (template: any) => {
22
+ // The CMS app is the WEB_COMPUTE one; a split site also has a reader app, which runs no backend build.
23
+ const apps = Object.values<any>(template.Resources).filter((resource) => resource.Type === "AWS::Amplify::App" && resource.Properties.Platform === "WEB_COMPUTE");
24
+ assert.equal(apps.length, 1);
25
+ return Object.fromEntries((apps[0].Properties.EnvironmentVariables ?? []).map((variable: any) => [variable.Name, variable.Value]));
26
+ };
27
+
28
+ test("the app shell sets the build timeout from the site config, on the app and on no branch", () => {
29
+ const template = synth(example((c) => (c.cms.buildTimeoutMinutes = 90)));
30
+ assert.equal(appVariables(template)._BUILD_TIMEOUT, "90");
31
+ const branches = Object.values<any>(template.Resources).filter((resource) => resource.Type === "AWS::Amplify::Branch");
32
+ assert.ok(branches.length > 0);
33
+ for (const branch of branches) {
34
+ assert.ok(!(branch.Properties.EnvironmentVariables ?? []).some((variable: any) => variable.Name === "_BUILD_TIMEOUT"), "a branch variable would override the app's");
35
+ }
36
+ });
37
+
38
+ test("the timeout defaults to 120 and is the only variable added to the app", () => {
39
+ const variables = appVariables(synth(example()));
40
+ assert.equal(variables._BUILD_TIMEOUT, "120");
41
+ assert.deepEqual(Object.keys(variables), ["_BUILD_TIMEOUT"]);
42
+ });
43
+
44
+ test("every example site gets _BUILD_TIMEOUT 120 unless it sets its own", () => {
45
+ const dir = path.join(repo, "infra/amplify-app-shell/examples");
46
+ for (const file of fs.readdirSync(dir).filter((name) => name.endsWith(".site.json"))) {
47
+ const config = JSON.parse(fs.readFileSync(path.join(dir, file), "utf8"));
48
+ if (!config.cms) continue;
49
+ assert.equal(appVariables(synth(config))._BUILD_TIMEOUT, String(config.cms.buildTimeoutMinutes ?? 120), file);
50
+ }
51
+ });
52
+
53
+ test("a value outside Amplify's range, or not a whole number, is refused naming the range", () => {
54
+ for (const bad of [121, 4, 0, -5, 90.5, "90", null]) {
55
+ assert.throws(() => parseSiteConfig(example((c) => (c.cms.buildTimeoutMinutes = bad))), /cms\.buildTimeoutMinutes must be a whole number of minutes from 5 to 120/, String(bad));
56
+ }
57
+ for (const good of [5, 30, 120]) assert.equal(parseSiteConfig(example((c) => (c.cms.buildTimeoutMinutes = good))).cms?.buildTimeoutMinutes, good);
58
+ });
59
+
60
+ test("the deploy workflow waits, and its job runs, longer than the longest build", () => {
61
+ const workflow = parse(fs.readFileSync(path.join(repo, ".github/workflows/amplify-deploy.yml"), "utf8"));
62
+ const wait = workflow.on.workflow_call.inputs["timeout-minutes"].default;
63
+ assert.ok(wait > MAX_BUILD_TIMEOUT_MINUTES, `the wait is ${wait}`);
64
+ // The job timeout is the wait plus a positive margin, so any wait a caller passes stays inside it: it is always above the build timeout too.
65
+ const match = /^\$\{\{ inputs\.timeout-minutes \+ (\d+) \}\}$/.exec(workflow.jobs.deploy["timeout-minutes"]);
66
+ assert.ok(match && Number(match[1]) > 0, `the job timeout is ${workflow.jobs.deploy["timeout-minutes"]}`);
67
+ assert.ok(wait + Number(match![1]) > MAX_BUILD_TIMEOUT_MINUTES);
68
+ });
@@ -286,13 +286,25 @@ function parseStagingPreview(value) {
286
286
  baseDirectory: requireString(record.baseDirectory, "cms.stagingPreview.baseDirectory"),
287
287
  };
288
288
  }
289
+ /** Amplify's documented range for `_BUILD_TIMEOUT` (AWS Amplify Hosting user guide, "Troubleshooting build issues"). */
290
+ export const MIN_BUILD_TIMEOUT_MINUTES = 5;
291
+ export const MAX_BUILD_TIMEOUT_MINUTES = 120;
292
+ export const DEFAULT_BUILD_TIMEOUT_MINUTES = MAX_BUILD_TIMEOUT_MINUTES;
293
+ /** The build timeout a CMS app gets: the site's setting, else the maximum. */
294
+ export function resolveBuildTimeoutMinutes(cms) {
295
+ return cms.buildTimeoutMinutes ?? DEFAULT_BUILD_TIMEOUT_MINUTES;
296
+ }
289
297
  function parseCms(value, environment) {
290
298
  const cmsRecord = requireObject(value, "cms");
291
- rejectUnknownKeys(cmsRecord, ["appName", "domainName", "staging", "cognitoDomainPrefix", "applyCognitoDomainPrefix", "buildComputeType", "environment", "stagingDomainName", "domainPrefix", "siteOrigin", "consoleOrigin", "stagingDomainPrefix", "redirects", "stagingPreview", "prospectusAccountsApiStageArn", "readerRetirementPoll", "cliRemoteLogin", "deployStackInBuild", "cms", "alarmTopicArn", "cms", "cliOnFederationClient"], "cms");
299
+ rejectUnknownKeys(cmsRecord, ["appName", "domainName", "staging", "cognitoDomainPrefix", "applyCognitoDomainPrefix", "buildComputeType", "buildTimeoutMinutes", "environment", "stagingDomainName", "domainPrefix", "siteOrigin", "consoleOrigin", "stagingDomainPrefix", "redirects", "stagingPreview", "prospectusAccountsApiStageArn", "readerRetirementPoll", "cliRemoteLogin", "deployStackInBuild", "cms", "alarmTopicArn", "cms", "cliOnFederationClient"], "cms");
292
300
  const buildComputeType = cmsRecord.buildComputeType;
293
301
  if (buildComputeType !== undefined && buildComputeType !== "STANDARD" && buildComputeType !== "STANDARD_8GB") {
294
302
  fail("cms.buildComputeType", `must be "STANDARD" or "STANDARD_8GB", got ${JSON.stringify(buildComputeType)}`);
295
303
  }
304
+ const buildTimeoutMinutes = cmsRecord.buildTimeoutMinutes;
305
+ if (buildTimeoutMinutes !== undefined && (!Number.isInteger(buildTimeoutMinutes) || buildTimeoutMinutes < MIN_BUILD_TIMEOUT_MINUTES || buildTimeoutMinutes > MAX_BUILD_TIMEOUT_MINUTES)) {
306
+ fail("cms.buildTimeoutMinutes", `must be a whole number of minutes from ${MIN_BUILD_TIMEOUT_MINUTES} to ${MAX_BUILD_TIMEOUT_MINUTES} (Amplify's range for _BUILD_TIMEOUT), got ${JSON.stringify(buildTimeoutMinutes)}`);
307
+ }
296
308
  if (cmsRecord.staging !== undefined && typeof cmsRecord.staging !== "boolean") {
297
309
  fail("cms.staging", `must be a boolean, got ${JSON.stringify(cmsRecord.staging)}`);
298
310
  }
@@ -330,6 +342,7 @@ function parseCms(value, environment) {
330
342
  cognitoDomainPrefix: requireString(cmsRecord.cognitoDomainPrefix, "cms.cognitoDomainPrefix", COGNITO_DOMAIN_PREFIX_PATTERN, "lowercase letters, digits and hyphens; globally unique per region"),
331
343
  applyCognitoDomainPrefix: cmsRecord.applyCognitoDomainPrefix,
332
344
  buildComputeType: buildComputeType,
345
+ buildTimeoutMinutes: buildTimeoutMinutes,
333
346
  environment: requireStringRecord(cmsRecord.environment, "cms.environment"),
334
347
  stagingDomainName: optionalString(cmsRecord.stagingDomainName, "cms.stagingDomainName", HOST_NAME_PATTERN, "host name"),
335
348
  stagingDomainPrefix: optionalString(cmsRecord.stagingDomainPrefix, "cms.stagingDomainPrefix", DOMAIN_PREFIX_PATTERN, "single DNS label"),
@@ -61,6 +61,12 @@ export type CmsConfig = {
61
61
  cognitoDomainPrefix: string;
62
62
  applyCognitoDomainPrefix?: boolean;
63
63
  buildComputeType?: "STANDARD" | "STANDARD_8GB";
64
+ /**
65
+ * How long Amplify lets one build job run, in whole minutes (Amplify's `_BUILD_TIMEOUT`, set on the app so every branch gets it).
66
+ * Amplify allows 5 to 120 and stops a job at 30 without it. Defaults to the maximum, 120, because a large backend release
67
+ * can need more than 30 minutes (docs/site-hosting.md, "Build timeout").
68
+ */
69
+ buildTimeoutMinutes?: number;
64
70
  environment: Record<string, string>;
65
71
  stagingDomainName?: string;
66
72
  stagingDomainPrefix?: string;
@@ -479,13 +485,27 @@ function parseStagingPreview(value: unknown): StagingPreviewConfig | undefined {
479
485
  };
480
486
  }
481
487
 
488
+ /** Amplify's documented range for `_BUILD_TIMEOUT` (AWS Amplify Hosting user guide, "Troubleshooting build issues"). */
489
+ export const MIN_BUILD_TIMEOUT_MINUTES = 5;
490
+ export const MAX_BUILD_TIMEOUT_MINUTES = 120;
491
+ export const DEFAULT_BUILD_TIMEOUT_MINUTES = MAX_BUILD_TIMEOUT_MINUTES;
492
+
493
+ /** The build timeout a CMS app gets: the site's setting, else the maximum. */
494
+ export function resolveBuildTimeoutMinutes(cms: Pick<CmsConfig, "buildTimeoutMinutes">): number {
495
+ return cms.buildTimeoutMinutes ?? DEFAULT_BUILD_TIMEOUT_MINUTES;
496
+ }
497
+
482
498
  function parseCms(value: unknown, environment: Record<string, string | undefined>): CmsConfig {
483
499
  const cmsRecord = requireObject(value, "cms");
484
- rejectUnknownKeys(cmsRecord, ["appName", "domainName", "staging", "cognitoDomainPrefix", "applyCognitoDomainPrefix", "buildComputeType", "environment", "stagingDomainName", "domainPrefix", "siteOrigin", "consoleOrigin", "stagingDomainPrefix", "redirects", "stagingPreview", "prospectusAccountsApiStageArn", "readerRetirementPoll", "cliRemoteLogin", "deployStackInBuild", "cms", "alarmTopicArn", "cms", "cliOnFederationClient"], "cms");
500
+ rejectUnknownKeys(cmsRecord, ["appName", "domainName", "staging", "cognitoDomainPrefix", "applyCognitoDomainPrefix", "buildComputeType", "buildTimeoutMinutes", "environment", "stagingDomainName", "domainPrefix", "siteOrigin", "consoleOrigin", "stagingDomainPrefix", "redirects", "stagingPreview", "prospectusAccountsApiStageArn", "readerRetirementPoll", "cliRemoteLogin", "deployStackInBuild", "cms", "alarmTopicArn", "cms", "cliOnFederationClient"], "cms");
485
501
  const buildComputeType = cmsRecord.buildComputeType;
486
502
  if (buildComputeType !== undefined && buildComputeType !== "STANDARD" && buildComputeType !== "STANDARD_8GB") {
487
503
  fail("cms.buildComputeType", `must be "STANDARD" or "STANDARD_8GB", got ${JSON.stringify(buildComputeType)}`);
488
504
  }
505
+ const buildTimeoutMinutes = cmsRecord.buildTimeoutMinutes;
506
+ if (buildTimeoutMinutes !== undefined && (!Number.isInteger(buildTimeoutMinutes) || (buildTimeoutMinutes as number) < MIN_BUILD_TIMEOUT_MINUTES || (buildTimeoutMinutes as number) > MAX_BUILD_TIMEOUT_MINUTES)) {
507
+ fail("cms.buildTimeoutMinutes", `must be a whole number of minutes from ${MIN_BUILD_TIMEOUT_MINUTES} to ${MAX_BUILD_TIMEOUT_MINUTES} (Amplify's range for _BUILD_TIMEOUT), got ${JSON.stringify(buildTimeoutMinutes)}`);
508
+ }
489
509
  if (cmsRecord.staging !== undefined && typeof cmsRecord.staging !== "boolean") {
490
510
  fail("cms.staging", `must be a boolean, got ${JSON.stringify(cmsRecord.staging)}`);
491
511
  }
@@ -528,6 +548,7 @@ function parseCms(value: unknown, environment: Record<string, string | undefined
528
548
  ),
529
549
  applyCognitoDomainPrefix: cmsRecord.applyCognitoDomainPrefix as boolean | undefined,
530
550
  buildComputeType: buildComputeType as "STANDARD" | "STANDARD_8GB" | undefined,
551
+ buildTimeoutMinutes: buildTimeoutMinutes as number | undefined,
531
552
  environment: requireStringRecord(cmsRecord.environment, "cms.environment"),
532
553
  stagingDomainName: optionalString(cmsRecord.stagingDomainName, "cms.stagingDomainName", HOST_NAME_PATTERN, "host name"),
533
554
  stagingDomainPrefix: optionalString(cmsRecord.stagingDomainPrefix, "cms.stagingDomainPrefix", DOMAIN_PREFIX_PATTERN, "single DNS label"),
package/package.json CHANGED
@@ -638,7 +638,7 @@
638
638
  "optional": true
639
639
  }
640
640
  },
641
- "version": "5.112.0-next.2",
641
+ "version": "5.112.0-next.3",
642
642
  "dependencies": {
643
643
  "@aws-amplify/adapter-nextjs": "^1.7.3",
644
644
  "@aws-crypto/sha256-js": "5.2.0",
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "5.112.0-next.2",
2
+ "version": "5.112.0-next.3",
3
3
  "routes": [
4
4
  {
5
5
  "file": "app/%5F_preview/[[...path]]/route.ts",
@@ -18,7 +18,11 @@ export const COST_TAG_WAVE_OUTPUT = "PapyrusCostTagWave";
18
18
  export const COST_TAG_WAVES_COMPLETE = "complete";
19
19
  /** More passes than any backend needs; a plan that never completes stops here instead of deploying forever. */
20
20
  export const MAX_PASSES = 12;
21
- /** Amplify's default build timeout, and what the frontend build and the steps around the deploy need after it. */
21
+ /**
22
+ * What Amplify allows a job when `_BUILD_TIMEOUT` is unset (30 minutes), used only for a build whose app has no such variable. The app shell
23
+ * sets `_BUILD_TIMEOUT` from `cms.buildTimeoutMinutes` (default 120), which `deployMinutes` reads. RESERVED_MINUTES is what the frontend
24
+ * build and the steps around the deploy need.
25
+ */
22
26
  export const DEFAULT_BUILD_TIMEOUT_MINUTES = 30;
23
27
  export const RESERVED_MINUTES = 10;
24
28
 
@@ -37,7 +41,7 @@ export function firstPassWave(deployed) {
37
41
  return deployed ? String(deployed.wave) : null;
38
42
  }
39
43
 
40
- /** Minutes this command may spend deploying: the build timeout (_BUILD_TIMEOUT, else 30) less what the rest needs. */
44
+ /** Minutes this command may spend deploying: the build timeout (_BUILD_TIMEOUT, which the app shell sets from cms.buildTimeoutMinutes; else Amplify's 30) less what the rest needs. */
41
45
  export function deployMinutes(environment = process.env) {
42
46
  const timeout = Number(environment._BUILD_TIMEOUT) || DEFAULT_BUILD_TIMEOUT_MINUTES;
43
47
  return Math.max(timeout - RESERVED_MINUTES, 0);