@anthusai/papyrus 5.112.0-next.3 → 5.112.1-next.1
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/amplify/site-backend-names.js +32 -5
- package/amplify/site-backend-names.ts +36 -8
- package/amplify/site-backend.js +2 -8
- package/amplify/site-backend.ts +2 -10
- package/infra/build-specs.js +0 -1
- package/infra/build-specs.ts +0 -1
- package/infra/site-config.js +27 -0
- package/infra/site-config.ts +26 -0
- package/package.json +1 -1
- package/routes.manifest.json +1 -1
|
@@ -39,18 +39,45 @@ export function isLegacyProductionApp(identity) {
|
|
|
39
39
|
export function isLegacyProductionPipeline(identity) {
|
|
40
40
|
return isLegacyProductionApp(identity) && identity.amplifyBranch === "main";
|
|
41
41
|
}
|
|
42
|
-
export function resolveSiteBackendFeatureFlags(features, environment,
|
|
43
|
-
|
|
42
|
+
export function resolveSiteBackendFeatureFlags(features, environment, _identity) {
|
|
43
|
+
// Every optional feature is off unless the site turns it on (`features` in papyrus.config.ts, or the PAPYRUS_ENABLE_* branch variable). No site, the
|
|
44
|
+
// original production pipeline included, gets one by default: a feature that is on must say so, and `assertFeaturePrerequisites` checks what it needs.
|
|
44
45
|
return {
|
|
45
|
-
consoleResponder: features?.consoleResponder ?? readBooleanEnvFlag(environment, "PAPYRUS_ENABLE_CONSOLE_RESPONDER",
|
|
46
|
-
inboundEmail: features?.inboundEmail ?? readBooleanEnvFlag(environment, "PAPYRUS_ENABLE_INBOUND_EMAIL",
|
|
46
|
+
consoleResponder: features?.consoleResponder ?? readBooleanEnvFlag(environment, "PAPYRUS_ENABLE_CONSOLE_RESPONDER", false),
|
|
47
|
+
inboundEmail: features?.inboundEmail ?? readBooleanEnvFlag(environment, "PAPYRUS_ENABLE_INBOUND_EMAIL", false),
|
|
47
48
|
slack: features?.slack ?? readBooleanEnvFlag(environment, "PAPYRUS_ENABLE_SLACK", false),
|
|
48
|
-
storageBackups: features?.storageBackups ?? readBooleanEnvFlag(environment, "PAPYRUS_ENABLE_STORAGE_BACKUPS",
|
|
49
|
+
storageBackups: features?.storageBackups ?? readBooleanEnvFlag(environment, "PAPYRUS_ENABLE_STORAGE_BACKUPS", false),
|
|
49
50
|
// Off for every site, the legacy production pipeline included: it adds a public function URL and a Cognito callback.
|
|
50
51
|
cliRemoteLogin: features?.cliRemoteLogin ?? readBooleanEnvFlag(environment, "PAPYRUS_ENABLE_CLI_REMOTE_LOGIN", false),
|
|
51
52
|
cliOnFederationClient: features?.cliOnFederationClient ?? readBooleanEnvFlag(environment, "PAPYRUS_ENABLE_CLI_ON_FEDERATION_CLIENT", false),
|
|
52
53
|
};
|
|
53
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* What each optional feature needs in the environment before it can be built, by the flag that turns it on. Inbound email is not listed: the build
|
|
57
|
+
* resolves its settings once, in `resolveInboundEmailSettings` (amplify/inbound-email/settings.ts), and stops there naming the missing variable.
|
|
58
|
+
*/
|
|
59
|
+
export const FEATURE_PREREQUISITES = [
|
|
60
|
+
{
|
|
61
|
+
flag: "PAPYRUS_ENABLE_CONSOLE_RESPONDER",
|
|
62
|
+
feature: "consoleResponder",
|
|
63
|
+
needs: ["PAPYRUS_CONSOLE_RESPONDER_IMAGE_URI"],
|
|
64
|
+
why: "the console responder runs a container image that this package does not build: publish an ARM64 image to ECR and name it (repo:tag or repo@digest)",
|
|
65
|
+
},
|
|
66
|
+
];
|
|
67
|
+
/**
|
|
68
|
+
* Throws, naming the flag and each variable that is missing, when a feature is on without what it needs. The variables are read from `environment`
|
|
69
|
+
* whichever way the feature was turned on, so a `features` entry in papyrus.config.ts is held to the same rule. Nothing is defaulted or skipped.
|
|
70
|
+
*/
|
|
71
|
+
export function assertFeaturePrerequisites(flags, environment) {
|
|
72
|
+
for (const { flag, feature, needs, why } of FEATURE_PREREQUISITES) {
|
|
73
|
+
if (!flags[feature])
|
|
74
|
+
continue;
|
|
75
|
+
const missing = needs.filter((name) => (environment[name] ?? "").trim() === "");
|
|
76
|
+
if (missing.length > 0) {
|
|
77
|
+
throw new Error(`${flag} is on but ${missing.join(", ")} ${missing.length === 1 ? "is" : "are"} not set: ${why}. Set ${missing.length === 1 ? "it" : "them"} or turn the feature off.`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
54
81
|
export function deriveKnowledgeVectorIndexName(identity) {
|
|
55
82
|
const name = isLegacyProductionApp(identity)
|
|
56
83
|
? "papyrus-knowledge"
|
|
@@ -72,23 +72,51 @@ export function isLegacyProductionPipeline(identity: SiteBackendIdentity): boole
|
|
|
72
72
|
export function resolveSiteBackendFeatureFlags(
|
|
73
73
|
features: SiteBackendFeatureInput,
|
|
74
74
|
environment: Record<string, string | undefined>,
|
|
75
|
-
|
|
75
|
+
_identity: SiteBackendIdentity,
|
|
76
76
|
): SiteBackendFeatureFlags {
|
|
77
|
-
|
|
77
|
+
// Every optional feature is off unless the site turns it on (`features` in papyrus.config.ts, or the PAPYRUS_ENABLE_* branch variable). No site, the
|
|
78
|
+
// original production pipeline included, gets one by default: a feature that is on must say so, and `assertFeaturePrerequisites` checks what it needs.
|
|
78
79
|
return {
|
|
79
|
-
consoleResponder:
|
|
80
|
-
|
|
81
|
-
inboundEmail:
|
|
82
|
-
features?.inboundEmail ?? readBooleanEnvFlag(environment, "PAPYRUS_ENABLE_INBOUND_EMAIL", legacyPipeline),
|
|
80
|
+
consoleResponder: features?.consoleResponder ?? readBooleanEnvFlag(environment, "PAPYRUS_ENABLE_CONSOLE_RESPONDER", false),
|
|
81
|
+
inboundEmail: features?.inboundEmail ?? readBooleanEnvFlag(environment, "PAPYRUS_ENABLE_INBOUND_EMAIL", false),
|
|
83
82
|
slack: features?.slack ?? readBooleanEnvFlag(environment, "PAPYRUS_ENABLE_SLACK", false),
|
|
84
|
-
storageBackups:
|
|
85
|
-
features?.storageBackups ?? readBooleanEnvFlag(environment, "PAPYRUS_ENABLE_STORAGE_BACKUPS", legacyPipeline),
|
|
83
|
+
storageBackups: features?.storageBackups ?? readBooleanEnvFlag(environment, "PAPYRUS_ENABLE_STORAGE_BACKUPS", false),
|
|
86
84
|
// Off for every site, the legacy production pipeline included: it adds a public function URL and a Cognito callback.
|
|
87
85
|
cliRemoteLogin: features?.cliRemoteLogin ?? readBooleanEnvFlag(environment, "PAPYRUS_ENABLE_CLI_REMOTE_LOGIN", false),
|
|
88
86
|
cliOnFederationClient: features?.cliOnFederationClient ?? readBooleanEnvFlag(environment, "PAPYRUS_ENABLE_CLI_ON_FEDERATION_CLIENT", false),
|
|
89
87
|
};
|
|
90
88
|
}
|
|
91
89
|
|
|
90
|
+
/**
|
|
91
|
+
* What each optional feature needs in the environment before it can be built, by the flag that turns it on. Inbound email is not listed: the build
|
|
92
|
+
* resolves its settings once, in `resolveInboundEmailSettings` (amplify/inbound-email/settings.ts), and stops there naming the missing variable.
|
|
93
|
+
*/
|
|
94
|
+
export const FEATURE_PREREQUISITES: ReadonlyArray<{ flag: string; feature: keyof SiteBackendFeatureFlags; needs: readonly string[]; why: string }> = [
|
|
95
|
+
{
|
|
96
|
+
flag: "PAPYRUS_ENABLE_CONSOLE_RESPONDER",
|
|
97
|
+
feature: "consoleResponder",
|
|
98
|
+
needs: ["PAPYRUS_CONSOLE_RESPONDER_IMAGE_URI"],
|
|
99
|
+
why: "the console responder runs a container image that this package does not build: publish an ARM64 image to ECR and name it (repo:tag or repo@digest)",
|
|
100
|
+
},
|
|
101
|
+
];
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Throws, naming the flag and each variable that is missing, when a feature is on without what it needs. The variables are read from `environment`
|
|
105
|
+
* whichever way the feature was turned on, so a `features` entry in papyrus.config.ts is held to the same rule. Nothing is defaulted or skipped.
|
|
106
|
+
*/
|
|
107
|
+
export function assertFeaturePrerequisites(
|
|
108
|
+
flags: SiteBackendFeatureFlags,
|
|
109
|
+
environment: Record<string, string | undefined>,
|
|
110
|
+
): void {
|
|
111
|
+
for (const { flag, feature, needs, why } of FEATURE_PREREQUISITES) {
|
|
112
|
+
if (!flags[feature]) continue;
|
|
113
|
+
const missing = needs.filter((name) => (environment[name] ?? "").trim() === "");
|
|
114
|
+
if (missing.length > 0) {
|
|
115
|
+
throw new Error(`${flag} is on but ${missing.join(", ")} ${missing.length === 1 ? "is" : "are"} not set: ${why}. Set ${missing.length === 1 ? "it" : "them"} or turn the feature off.`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
92
120
|
export function deriveKnowledgeVectorIndexName(identity: SiteBackendIdentity): string {
|
|
93
121
|
const name = isLegacyProductionApp(identity)
|
|
94
122
|
? "papyrus-knowledge"
|
package/amplify/site-backend.js
CHANGED
|
@@ -72,7 +72,7 @@ import { slackEvents } from "./functions/slack-events/resource.js";
|
|
|
72
72
|
import { addInboundEmailSesIntake } from "./inbound-email/ses-intake.js";
|
|
73
73
|
import { inboundDnsRecordName, resolveInboundEmailSettings } from "./inbound-email/settings.js";
|
|
74
74
|
import { InboundEmailStack } from "./inbound-email/stack.js";
|
|
75
|
-
import { deriveKnowledgeVectorIndexName, deriveReceiptRuleName, deriveReceiptRuleSetName, deriveStorageBackupVaultName,
|
|
75
|
+
import { deriveKnowledgeVectorIndexName, deriveReceiptRuleName, deriveReceiptRuleSetName, deriveStorageBackupVaultName, planInboundEmailSes, assertFeaturePrerequisites, resolveSiteBackendFeatureFlags, sanitizeAwsName, } from "./site-backend-names.js";
|
|
76
76
|
import { addStorageBackups } from "./storage-backups/construct.js";
|
|
77
77
|
import { storage } from "./storage/resource.js";
|
|
78
78
|
import { connectToSiteApi } from "./site-api-access.js";
|
|
@@ -98,9 +98,9 @@ export function defineSiteBackend(papyrusSite, options = {}) {
|
|
|
98
98
|
amplifyBranch,
|
|
99
99
|
productionAppId,
|
|
100
100
|
};
|
|
101
|
-
const isAmplifyProductionPipeline = isLegacyProductionPipeline(siteBackendIdentity);
|
|
102
101
|
const knowledgeVectorIndexName = deriveKnowledgeVectorIndexName(siteBackendIdentity);
|
|
103
102
|
const featureFlags = resolveSiteBackendFeatureFlags(site.features, process.env, siteBackendIdentity);
|
|
103
|
+
assertFeaturePrerequisites(featureFlags, process.env);
|
|
104
104
|
const enableInboundEmail = featureFlags.inboundEmail;
|
|
105
105
|
const enableSlackAgent = featureFlags.slack;
|
|
106
106
|
const enableStorageBackups = featureFlags.storageBackups;
|
|
@@ -220,12 +220,6 @@ export function defineSiteBackend(papyrusSite, options = {}) {
|
|
|
220
220
|
// Repo root in a Papyrus checkout; package root when installed from npm.
|
|
221
221
|
const projectRoot = resolve(amplifyBackendDir, "..");
|
|
222
222
|
const enableConsoleResponder = featureFlags.consoleResponder;
|
|
223
|
-
if (enableConsoleResponder
|
|
224
|
-
&& !process.env.PAPYRUS_CONSOLE_RESPONDER_IMAGE_URI?.trim()
|
|
225
|
-
&& !process.env.PAPYRUS_CONSOLE_RESPONDER_ALLOW_LOCAL_BUILD?.trim()
|
|
226
|
-
&& !isAmplifyProductionPipeline) {
|
|
227
|
-
process.env.PAPYRUS_CONSOLE_RESPONDER_ALLOW_LOCAL_BUILD = "true";
|
|
228
|
-
}
|
|
229
223
|
const inboundEmailLocalParts = (process.env.PAPYRUS_INBOUND_EMAIL_LOCAL_PARTS ?? "submissions,suggestions")
|
|
230
224
|
.split(",")
|
|
231
225
|
.map((entry) => entry.trim().toLowerCase())
|
package/amplify/site-backend.ts
CHANGED
|
@@ -84,8 +84,8 @@ import {
|
|
|
84
84
|
deriveReceiptRuleName,
|
|
85
85
|
deriveReceiptRuleSetName,
|
|
86
86
|
deriveStorageBackupVaultName,
|
|
87
|
-
isLegacyProductionPipeline,
|
|
88
87
|
planInboundEmailSes,
|
|
88
|
+
assertFeaturePrerequisites,
|
|
89
89
|
resolveSiteBackendFeatureFlags,
|
|
90
90
|
sanitizeAwsName,
|
|
91
91
|
type SiteBackendIdentity,
|
|
@@ -128,9 +128,9 @@ export function defineSiteBackend(papyrusSite: PapyrusSite, options: DefineSiteB
|
|
|
128
128
|
amplifyBranch,
|
|
129
129
|
productionAppId,
|
|
130
130
|
};
|
|
131
|
-
const isAmplifyProductionPipeline = isLegacyProductionPipeline(siteBackendIdentity);
|
|
132
131
|
const knowledgeVectorIndexName = deriveKnowledgeVectorIndexName(siteBackendIdentity);
|
|
133
132
|
const featureFlags = resolveSiteBackendFeatureFlags(site.features, process.env, siteBackendIdentity);
|
|
133
|
+
assertFeaturePrerequisites(featureFlags, process.env);
|
|
134
134
|
const enableInboundEmail = featureFlags.inboundEmail;
|
|
135
135
|
const enableSlackAgent = featureFlags.slack;
|
|
136
136
|
const enableStorageBackups = featureFlags.storageBackups;
|
|
@@ -273,14 +273,6 @@ export function defineSiteBackend(papyrusSite: PapyrusSite, options: DefineSiteB
|
|
|
273
273
|
const projectRoot = resolve(amplifyBackendDir, "..");
|
|
274
274
|
const enableConsoleResponder = featureFlags.consoleResponder;
|
|
275
275
|
|
|
276
|
-
if (
|
|
277
|
-
enableConsoleResponder
|
|
278
|
-
&& !process.env.PAPYRUS_CONSOLE_RESPONDER_IMAGE_URI?.trim()
|
|
279
|
-
&& !process.env.PAPYRUS_CONSOLE_RESPONDER_ALLOW_LOCAL_BUILD?.trim()
|
|
280
|
-
&& !isAmplifyProductionPipeline
|
|
281
|
-
) {
|
|
282
|
-
process.env.PAPYRUS_CONSOLE_RESPONDER_ALLOW_LOCAL_BUILD = "true";
|
|
283
|
-
}
|
|
284
276
|
const inboundEmailLocalParts = (process.env.PAPYRUS_INBOUND_EMAIL_LOCAL_PARTS ?? "submissions,suggestions")
|
|
285
277
|
.split(",")
|
|
286
278
|
.map((entry) => entry.trim().toLowerCase())
|
package/infra/build-specs.js
CHANGED
|
@@ -85,7 +85,6 @@ export function cmsProductionBuildSpec(config) {
|
|
|
85
85
|
...ciReceiptGateCommands(config),
|
|
86
86
|
NPM_CLEAN_INSTALL,
|
|
87
87
|
...deployStackCommands,
|
|
88
|
-
"if [ -z \"${PAPYRUS_CONSOLE_RESPONDER_IMAGE_URI:-}\" ]; then export PAPYRUS_CONSOLE_RESPONDER_ALLOW_LOCAL_BUILD=true; fi",
|
|
89
88
|
// One pass per cost tag wave until the tags are complete (amplify/cost-tag-waves.ts); one pass after that.
|
|
90
89
|
"npx papyrus-infra backend-deploy",
|
|
91
90
|
ALEXA_SKILL_SYNC,
|
package/infra/build-specs.ts
CHANGED
|
@@ -114,7 +114,6 @@ export function cmsProductionBuildSpec(config: AmplifyAppShellSiteConfig): strin
|
|
|
114
114
|
...ciReceiptGateCommands(config),
|
|
115
115
|
NPM_CLEAN_INSTALL,
|
|
116
116
|
...deployStackCommands,
|
|
117
|
-
"if [ -z \"${PAPYRUS_CONSOLE_RESPONDER_IMAGE_URI:-}\" ]; then export PAPYRUS_CONSOLE_RESPONDER_ALLOW_LOCAL_BUILD=true; fi",
|
|
118
117
|
// One pass per cost tag wave until the tags are complete (amplify/cost-tag-waves.ts); one pass after that.
|
|
119
118
|
"npx papyrus-infra backend-deploy",
|
|
120
119
|
ALEXA_SKILL_SYNC,
|
package/infra/site-config.js
CHANGED
|
@@ -364,6 +364,7 @@ function parseCms(value, environment) {
|
|
|
364
364
|
fail(`cms.environment.${key}`, "is managed by the template: Google sign-in is always on, the Cognito domain comes from cms.cognitoDomainPrefix, the revalidation secret parameter is derived from siteId and the Prospectus endpoint comes from cms.prospectusAccountsApiStageArn and the public site origin comes from the site host");
|
|
365
365
|
}
|
|
366
366
|
}
|
|
367
|
+
assertOptionalFeatures(cms.environment);
|
|
367
368
|
const privateChatEnabled = cms.environment.PAPYRUS_PRIVATE_CHAT_ENABLED;
|
|
368
369
|
if (privateChatEnabled !== undefined && privateChatEnabled !== "true" && privateChatEnabled !== "false") {
|
|
369
370
|
fail("cms.environment.PAPYRUS_PRIVATE_CHAT_ENABLED", "must be the string \"true\" or \"false\"");
|
|
@@ -476,6 +477,32 @@ function parseCi(raw, autoDeploy) {
|
|
|
476
477
|
fail("ci.requireSignature", "true is not supported yet: signature verification arrives with the LeftBlock verify-ci story (PPY-466bdd)");
|
|
477
478
|
return { gate: gate, statusContext, requireSignature: false };
|
|
478
479
|
}
|
|
480
|
+
/**
|
|
481
|
+
* The four optional backend features are off unless a site turns them on. A flag must be exactly "true" or "false", and a feature that is on must carry what
|
|
482
|
+
* it needs, so a missing prerequisite fails here, at synth, and not as a half-built backend: the console responder needs a prebuilt image, inbound email its
|
|
483
|
+
* own domain and hosted zone. The same rule is `assertFeaturePrerequisites` in amplify/site-backend-names.ts, which the backend build applies.
|
|
484
|
+
*/
|
|
485
|
+
const OPTIONAL_FEATURES = [
|
|
486
|
+
{ flag: "PAPYRUS_ENABLE_CONSOLE_RESPONDER", needs: ["PAPYRUS_CONSOLE_RESPONDER_IMAGE_URI"], why: "the console responder runs a container image that this package does not build: publish an ARM64 image to ECR and name it" },
|
|
487
|
+
{ flag: "PAPYRUS_ENABLE_INBOUND_EMAIL", needs: ["PAPYRUS_INBOUND_EMAIL_DOMAIN", "PAPYRUS_INBOUND_EMAIL_CORPUS_KEY", "PAPYRUS_PUBLIC_SITE_BASE_URL"], why: "inbound email receives mail for a domain of the site's own, files it into a corpus and links reply emails to the site's public origin (a hosted zone is also needed when the stack verifies the domain: amplify/inbound-email/settings.ts)" },
|
|
488
|
+
{ flag: "PAPYRUS_ENABLE_SLACK", needs: [], why: "" },
|
|
489
|
+
{ flag: "PAPYRUS_ENABLE_STORAGE_BACKUPS", needs: [], why: "" },
|
|
490
|
+
];
|
|
491
|
+
function assertOptionalFeatures(environment) {
|
|
492
|
+
for (const { flag, needs, why } of OPTIONAL_FEATURES) {
|
|
493
|
+
const value = environment[flag];
|
|
494
|
+
if (value === undefined)
|
|
495
|
+
continue;
|
|
496
|
+
if (value !== "true" && value !== "false")
|
|
497
|
+
fail(`cms.environment.${flag}`, `must be the string "true" or "false", got ${JSON.stringify(value)}`);
|
|
498
|
+
if (value !== "true")
|
|
499
|
+
continue;
|
|
500
|
+
const missing = needs.filter((name) => (environment[name] ?? "").trim() === "");
|
|
501
|
+
if (missing.length > 0) {
|
|
502
|
+
fail(`cms.environment.${flag}`, `is "true" but ${missing.join(", ")} ${missing.length === 1 ? "is" : "are"} missing from cms.environment: ${why}. Add ${missing.length === 1 ? "it" : "them"} or set the flag to "false"`);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}
|
|
479
506
|
export function parseSiteConfig(raw, environment = process.env) {
|
|
480
507
|
const record = requireObject(raw, "site");
|
|
481
508
|
rejectUnknownKeys(record, ["siteId", "repository", "repositoryAccessTokenSecretArn", "brand", "frontend", "hostedZoneId", "stackName", "aws", "cms", "email", "reader", "papyrusVersion", "storagePreviewPrefix", "chat", "knowledgeRun", "autoDeploy", "costAccounting", "ci", "github"], "site");
|
package/infra/site-config.ts
CHANGED
|
@@ -576,6 +576,7 @@ function parseCms(value: unknown, environment: Record<string, string | undefined
|
|
|
576
576
|
fail(`cms.environment.${key}`, "is managed by the template: Google sign-in is always on, the Cognito domain comes from cms.cognitoDomainPrefix, the revalidation secret parameter is derived from siteId and the Prospectus endpoint comes from cms.prospectusAccountsApiStageArn and the public site origin comes from the site host");
|
|
577
577
|
}
|
|
578
578
|
}
|
|
579
|
+
assertOptionalFeatures(cms.environment);
|
|
579
580
|
const privateChatEnabled = cms.environment.PAPYRUS_PRIVATE_CHAT_ENABLED;
|
|
580
581
|
if (privateChatEnabled !== undefined && privateChatEnabled !== "true" && privateChatEnabled !== "false") {
|
|
581
582
|
fail("cms.environment.PAPYRUS_PRIVATE_CHAT_ENABLED", "must be the string \"true\" or \"false\"");
|
|
@@ -688,6 +689,31 @@ function parseCi(raw: unknown, autoDeploy: boolean): CiGateConfig | undefined {
|
|
|
688
689
|
return { gate: gate as CiGateConfig["gate"], statusContext, requireSignature: false };
|
|
689
690
|
}
|
|
690
691
|
|
|
692
|
+
/**
|
|
693
|
+
* The four optional backend features are off unless a site turns them on. A flag must be exactly "true" or "false", and a feature that is on must carry what
|
|
694
|
+
* it needs, so a missing prerequisite fails here, at synth, and not as a half-built backend: the console responder needs a prebuilt image, inbound email its
|
|
695
|
+
* own domain and hosted zone. The same rule is `assertFeaturePrerequisites` in amplify/site-backend-names.ts, which the backend build applies.
|
|
696
|
+
*/
|
|
697
|
+
const OPTIONAL_FEATURES: ReadonlyArray<{ flag: string; needs: readonly string[]; why: string }> = [
|
|
698
|
+
{ flag: "PAPYRUS_ENABLE_CONSOLE_RESPONDER", needs: ["PAPYRUS_CONSOLE_RESPONDER_IMAGE_URI"], why: "the console responder runs a container image that this package does not build: publish an ARM64 image to ECR and name it" },
|
|
699
|
+
{ flag: "PAPYRUS_ENABLE_INBOUND_EMAIL", needs: ["PAPYRUS_INBOUND_EMAIL_DOMAIN", "PAPYRUS_INBOUND_EMAIL_CORPUS_KEY", "PAPYRUS_PUBLIC_SITE_BASE_URL"], why: "inbound email receives mail for a domain of the site's own, files it into a corpus and links reply emails to the site's public origin (a hosted zone is also needed when the stack verifies the domain: amplify/inbound-email/settings.ts)" },
|
|
700
|
+
{ flag: "PAPYRUS_ENABLE_SLACK", needs: [], why: "" },
|
|
701
|
+
{ flag: "PAPYRUS_ENABLE_STORAGE_BACKUPS", needs: [], why: "" },
|
|
702
|
+
];
|
|
703
|
+
|
|
704
|
+
function assertOptionalFeatures(environment: Record<string, string>): void {
|
|
705
|
+
for (const { flag, needs, why } of OPTIONAL_FEATURES) {
|
|
706
|
+
const value = environment[flag];
|
|
707
|
+
if (value === undefined) continue;
|
|
708
|
+
if (value !== "true" && value !== "false") fail(`cms.environment.${flag}`, `must be the string "true" or "false", got ${JSON.stringify(value)}`);
|
|
709
|
+
if (value !== "true") continue;
|
|
710
|
+
const missing = needs.filter((name) => (environment[name] ?? "").trim() === "");
|
|
711
|
+
if (missing.length > 0) {
|
|
712
|
+
fail(`cms.environment.${flag}`, `is "true" but ${missing.join(", ")} ${missing.length === 1 ? "is" : "are"} missing from cms.environment: ${why}. Add ${missing.length === 1 ? "it" : "them"} or set the flag to "false"`);
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
|
|
691
717
|
export function parseSiteConfig(raw: unknown, environment: Record<string, string | undefined> = process.env): AmplifyAppShellSiteConfig {
|
|
692
718
|
const record = requireObject(raw, "site");
|
|
693
719
|
rejectUnknownKeys(
|
package/package.json
CHANGED
package/routes.manifest.json
CHANGED