@anthusai/papyrus 5.111.0 → 5.112.0-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/auth/resource.js +3 -0
- package/amplify/auth/resource.ts +3 -0
- package/amplify/auth/tenant-session-claims.js +27 -0
- package/amplify/auth/tenant-session-claims.ts +31 -0
- package/amplify/cost-attribution.js +12 -0
- package/amplify/cost-attribution.ts +12 -0
- package/amplify/data/resource.js +16 -0
- package/amplify/data/resource.ts +17 -0
- package/amplify/data/schema.js +20 -1
- package/amplify/data/schema.ts +21 -1
- package/amplify/functions/assignment-action/handler.ts +14 -9
- package/amplify/functions/automation-view/wire.js +2 -1
- package/amplify/functions/automation-view/wire.ts +2 -1
- package/amplify/functions/category-action/handler.ts +24 -18
- package/amplify/functions/category-action/message-hashtags.js +2 -1
- package/amplify/functions/category-action/message-hashtags.ts +2 -1
- package/amplify/functions/category-action/reference-links.js +3 -2
- package/amplify/functions/category-action/reference-links.ts +3 -2
- package/amplify/functions/console-chat-responder/resource.js +2 -1
- package/amplify/functions/console-chat-responder/resource.ts +2 -1
- package/amplify/functions/content-actions/handler.py +49 -21
- package/amplify/functions/content-actions/resource.js +4 -0
- package/amplify/functions/content-actions/resource.ts +5 -0
- package/amplify/functions/editorial-checks/handler.py +5 -1
- package/amplify/functions/editorial-checks/wire.js +2 -1
- package/amplify/functions/editorial-checks/wire.ts +2 -1
- package/amplify/functions/image-service/wire.js +2 -1
- package/amplify/functions/image-service/wire.ts +2 -1
- package/amplify/functions/monitoring-view/wire.js +2 -1
- package/amplify/functions/monitoring-view/wire.ts +2 -1
- package/amplify/functions/newsroom-summary/handler.ts +16 -12
- package/amplify/functions/shared/tenant-context.js +98 -0
- package/amplify/functions/shared/tenant-context.ts +33 -0
- package/amplify/functions/shared/tenant-scoped-client.ts +80 -0
- package/amplify/functions/tenant-claims/claims.ts +90 -0
- package/amplify/functions/tenant-claims/environment.js +7 -0
- package/amplify/functions/tenant-claims/environment.ts +7 -0
- package/amplify/functions/tenant-claims/handler.ts +56 -0
- package/amplify/functions/tenant-claims/resource.js +12 -0
- package/amplify/functions/tenant-claims/resource.ts +13 -0
- package/amplify/plugins/newsletter/sending.js +2 -1
- package/amplify/plugins/newsletter/sending.ts +2 -1
- package/amplify/plugins/notifications/papyrus.plugin.js +2 -1
- package/amplify/plugins/notifications/papyrus.plugin.ts +2 -1
- package/amplify/plugins/signup/papyrus.plugin.js +2 -1
- package/amplify/plugins/signup/papyrus.plugin.ts +2 -1
- package/amplify/shared-stack/alarms.js +53 -0
- package/amplify/shared-stack/alarms.ts +109 -0
- package/amplify/shared-stack/define.js +15 -0
- package/amplify/shared-stack/define.ts +17 -0
- package/amplify/shared-stack/deny.js +27 -0
- package/amplify/shared-stack/deny.ts +28 -0
- package/amplify/shared-stack/inline-policy.js +53 -0
- package/amplify/shared-stack/inline-policy.ts +65 -0
- package/amplify/shared-stack/isolation.js +161 -0
- package/amplify/shared-stack/isolation.ts +204 -0
- package/amplify/shared-stack/names.js +95 -0
- package/amplify/shared-stack/names.ts +133 -0
- package/amplify/shared-stack/settings.js +70 -0
- package/amplify/shared-stack/settings.ts +95 -0
- package/amplify/site-api-access.js +13 -0
- package/amplify/site-api-access.ts +14 -0
- package/amplify/site-backend-config.js +7 -1
- package/amplify/site-backend-config.ts +8 -2
- package/amplify/site-backend.js +65 -13
- package/amplify/site-backend.ts +75 -19
- package/components/news-desk-taxonomy-client.ts +5 -0
- package/components/newsroom-article-editor.tsx +7 -3
- package/components/newsroom-board-view.tsx +4 -2
- package/components/newsroom-organizer.css +2 -2
- package/components/use-newsroom-desk-sections.ts +31 -0
- package/infra/amplify-app-shell.js +4 -1
- package/infra/amplify-app-shell.ts +4 -1
- package/infra/build-specs.js +4 -1
- package/infra/build-specs.ts +5 -1
- package/infra/cost-tags.test.js +1 -1
- package/infra/cost-tags.test.ts +1 -1
- package/infra/shared-stack-deny.js +80 -0
- package/infra/shared-stack-deny.test.js +56 -0
- package/infra/shared-stack-deny.test.ts +66 -0
- package/infra/shared-stack-deny.ts +86 -0
- package/lib/newsroom-sections.ts +14 -0
- package/lib/tenant-keys.js +16 -0
- package/lib/tenant-keys.ts +19 -0
- package/package.json +2 -1
- package/routes.manifest.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { PluginRequest } from "./plugins/types";
|
|
2
|
+
import { isSharedTier, type SharedTier } from "./shared-stack/names";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Per-site backend configuration: the argument of `defineSiteBackend(site)`.
|
|
@@ -209,17 +210,22 @@ export function assertValidPublicationConfig(publication: unknown): void {
|
|
|
209
210
|
* helpers `papyrus_content.tenancy` (Python) and `lib/tenant-keys.ts` (TypeScript) may read.
|
|
210
211
|
*/
|
|
211
212
|
export type PapyrusTenancyMode = "dedicated" | "shared";
|
|
212
|
-
|
|
213
|
+
/** `tier` names which shared stack this backend is (docs/shared-stack.md); required with mode "shared", refused without it. */
|
|
214
|
+
export type PapyrusTenancyConfig = { mode?: PapyrusTenancyMode; tier?: SharedTier };
|
|
213
215
|
|
|
214
216
|
export const TENANCY_MODE_ENVIRONMENT_VARIABLE = "PAPYRUS_TENANCY_MODE";
|
|
215
217
|
|
|
216
218
|
export function validateTenancyConfig(tenancy: unknown): string[] {
|
|
217
219
|
if (tenancy === undefined) return [];
|
|
218
220
|
if (typeof tenancy !== "object" || tenancy === null || Array.isArray(tenancy)) return ["tenancy must be an object"];
|
|
219
|
-
const mode =
|
|
221
|
+
const { mode, tier } = tenancy as { mode?: unknown; tier?: unknown };
|
|
220
222
|
if (mode !== undefined && mode !== "dedicated" && mode !== "shared") {
|
|
221
223
|
return [`tenancy.mode must be "dedicated" or "shared" (got ${JSON.stringify(mode)})`];
|
|
222
224
|
}
|
|
225
|
+
if (mode === "shared" && !isSharedTier(tier)) {
|
|
226
|
+
return [`tenancy.tier must be "production" or "staging" for a shared stack (got ${JSON.stringify(tier)})`];
|
|
227
|
+
}
|
|
228
|
+
if (mode !== "shared" && tier !== undefined) return ["tenancy.tier is only for tenancy.mode \"shared\""];
|
|
223
229
|
return [];
|
|
224
230
|
}
|
|
225
231
|
|
package/amplify/site-backend.js
CHANGED
|
@@ -19,7 +19,13 @@ import { assertValidMonitoringConfig, assertValidPublicationConfig, assertValidT
|
|
|
19
19
|
import { revalidateSecretReadStatement } from "./revalidate-secret-policy.js";
|
|
20
20
|
import { revalidateDistributionEnvironment, revalidateInvalidationStatement, validateRevalidateDistributionIds, } from "./revalidate-invalidation-settings.js";
|
|
21
21
|
import { enablePointInTimeRecoveryOnDataTables } from "./data-table-recovery.js";
|
|
22
|
-
import { applySiteBackendCostTags, siteCostAttribution, wireSiteUsageSender } from "./cost-attribution.js";
|
|
22
|
+
import { applySiteBackendCostTags, sharedStackCostAttribution, siteCostAttribution, wireSiteUsageSender } from "./cost-attribution.js";
|
|
23
|
+
import { addSharedStackAlarms } from "./shared-stack/alarms.js";
|
|
24
|
+
import { addSharedStackDeny, isModelDataStack } from "./shared-stack/deny.js";
|
|
25
|
+
import { isInfrastructureConstructId } from "./shared-stack/inline-policy.js";
|
|
26
|
+
import { applySharedStackIsolation } from "./shared-stack/isolation.js";
|
|
27
|
+
import { sharedTierPlan } from "./shared-stack/names.js";
|
|
28
|
+
import { sharedStackSettings } from "./shared-stack/settings.js";
|
|
23
29
|
import { addInvalidationPathAlarm } from "./publication/invalidation-alarm.js";
|
|
24
30
|
import { applyCognitoDomainPrefix, applyGoogleEmailVerifiedMapping, authConfigFromEnv, defineSiteAuth, siteAuthRedirectUrls } from "./auth/resource.js";
|
|
25
31
|
import { PROSPECTUS_SIGN_IN_CALLBACK_PATH, CLI_FEDERATION_REFRESH_TOKEN_VALIDITY_DAYS, addProspectusGoogleOnlyClient, cliFederationClientCallbackUrls, trustClientOnIdentityPool } from "./auth/prospectus-google-client.js";
|
|
@@ -50,6 +56,8 @@ import { contentActions, setSiteFilesForContentActionsBundle } from "./functions
|
|
|
50
56
|
import { knowledgeQuery } from "./functions/knowledge-query/resource.js";
|
|
51
57
|
import { wireReferenceWordIndex } from "./functions/reference-word-index/wire.js";
|
|
52
58
|
import { manageUserRole } from "./functions/manage-user-role/resource.js";
|
|
59
|
+
import { tenantClaims } from "./functions/tenant-claims/resource.js";
|
|
60
|
+
import { applyTenantSessionClaims } from "./auth/tenant-session-claims.js";
|
|
53
61
|
import { modelAttachmentUpload } from "./functions/model-attachment-upload/resource.js";
|
|
54
62
|
import { newsroomSummary } from "./functions/newsroom-summary/resource.js";
|
|
55
63
|
import { derivePublicFormOrigins } from "./functions/public-forms/origins.js";
|
|
@@ -67,13 +75,13 @@ import { InboundEmailStack } from "./inbound-email/stack.js";
|
|
|
67
75
|
import { deriveKnowledgeVectorIndexName, deriveReceiptRuleName, deriveReceiptRuleSetName, deriveStorageBackupVaultName, isLegacyProductionPipeline, planInboundEmailSes, resolveSiteBackendFeatureFlags, sanitizeAwsName, } from "./site-backend-names.js";
|
|
68
76
|
import { addStorageBackups } from "./storage-backups/construct.js";
|
|
69
77
|
import { storage } from "./storage/resource.js";
|
|
70
|
-
|
|
78
|
+
import { connectToSiteApi } from "./site-api-access.js";
|
|
79
|
+
export function defineSiteBackend(papyrusSite, options = {}) {
|
|
71
80
|
// `papyrus.config.ts`'s default export. Backend options live under `backend`;
|
|
72
81
|
// the default brand id namespaces account-global resources.
|
|
73
82
|
const site = { brandId: papyrusSite.defaultBrand, ...papyrusSite.backend };
|
|
74
83
|
// Prospectus cost accounting: on when `papyrus-infra backend-deploy` asks for a cost tag wave (PAPYRUS_COST_TAG_WAVE).
|
|
75
|
-
// Null, from a plain `ampx pipeline-deploy`, leaves the backend untouched.
|
|
76
|
-
const costAttribution = siteCostAttribution();
|
|
84
|
+
// Null, from a plain `ampx pipeline-deploy`, leaves the backend untouched. A shared stack is always tagged (see below).
|
|
77
85
|
const knowledgeVectorDimension = 1536;
|
|
78
86
|
const knowledgeEmbeddingModel = "text-embedding-3-small";
|
|
79
87
|
const amplifyBranch = (process.env.AWS_BRANCH ?? "").trim();
|
|
@@ -108,10 +116,19 @@ export function defineSiteBackend(papyrusSite) {
|
|
|
108
116
|
assertValidMonitoringConfig(site.monitoring);
|
|
109
117
|
assertValidTenancyConfig(site.tenancy);
|
|
110
118
|
const tenancyMode = resolveTenancyMode(site.tenancy);
|
|
119
|
+
// A shared stack is one of two fixed tiers (docs/shared-stack.md). Its settings (reserved concurrency, alarm thresholds) come from
|
|
120
|
+
// amplify/shared-stack/settings.json, and a tier whose numbers are not measured yet refuses to synthesise.
|
|
121
|
+
const sharedTier = tenancyMode === "shared" ? sharedTierPlan(site.tenancy.tier) : undefined;
|
|
122
|
+
const sharedSettings = sharedTier ? sharedStackSettings(sharedTier.tier) : undefined;
|
|
123
|
+
const costAttribution = sharedTier ? sharedStackCostAttribution(sharedTier) : siteCostAttribution();
|
|
124
|
+
if (sharedTier && (publication?.projector !== undefined || publication?.staticDir !== undefined)) {
|
|
125
|
+
throw new Error("A shared stack serves many sites, so its publication cannot name one site's projector or static directory.");
|
|
126
|
+
}
|
|
111
127
|
const emailMonitorId = site.monitoring?.emailMonitorId ?? "hn";
|
|
112
128
|
const publicationPlan = planS3ProjectionBackend(publication);
|
|
113
129
|
const renditionsPlan = planRenditions(publication, process.cwd());
|
|
114
|
-
|
|
130
|
+
// The shared stack bundles no site's files: its configuration comes from the site store, one site per tenant.
|
|
131
|
+
setSiteFilesForContentActionsBundle(sharedTier ? [] : publicationPlan.enabled ? publicationPlan.siteFiles : undefined);
|
|
115
132
|
const plugins = resolvePlugins(site.plugins, { staticDir: publication?.staticDir });
|
|
116
133
|
const pluginDefinitions = Object.assign({}, ...plugins.map(({ plugin }) => plugin.schemaDefinitions()));
|
|
117
134
|
const pluginFunctions = Object.assign({}, ...plugins.map(({ plugin }) => plugin.functions()));
|
|
@@ -149,6 +166,7 @@ export function defineSiteBackend(papyrusSite) {
|
|
|
149
166
|
slackEvents,
|
|
150
167
|
slackDelivery,
|
|
151
168
|
storage,
|
|
169
|
+
tenantClaims,
|
|
152
170
|
});
|
|
153
171
|
// Tenancy mode reaches every function; dedicated adds nothing, so an existing site's template is unchanged.
|
|
154
172
|
for (const resource of Object.values(backend)) {
|
|
@@ -163,6 +181,9 @@ export function defineSiteBackend(papyrusSite) {
|
|
|
163
181
|
applyGoogleEmailVerifiedMapping(backend.auth.stack);
|
|
164
182
|
}
|
|
165
183
|
orderModelStacksInWaves(backend.data.resources.graphqlApi.node.scope, Object.keys(backend.data.resources.tables), site.resolverWaveSize ?? DEFAULT_RESOLVER_WAVE_SIZE);
|
|
184
|
+
// Session role claims (PPY-0bb0fd): the pre-token trigger moves to event version 2 on the Essentials plan and reads the two
|
|
185
|
+
// tenancy models when the `tenancy` model group is deployed. Dark: no authorization rule reads the claims yet.
|
|
186
|
+
applyTenantSessionClaims(backend.auth.resources.cfnResources.cfnUserPool, backend.tenantClaims.resources.lambda, "TenantMembership" in backend.data.resources.tables && "TenantSelection" in backend.data.resources.tables);
|
|
166
187
|
const requestedCognitoDomainPrefix = (authConfig.cognitoDomainPrefix ?? "").trim();
|
|
167
188
|
if (authConfig.applyCognitoDomainPrefix === true
|
|
168
189
|
&& requestedCognitoDomainPrefix !== ""
|
|
@@ -256,14 +277,14 @@ export function defineSiteBackend(papyrusSite) {
|
|
|
256
277
|
actions: ["appsync:GraphQL"],
|
|
257
278
|
resources: ["*"],
|
|
258
279
|
}));
|
|
259
|
-
backend.slackEvents
|
|
280
|
+
connectToSiteApi(backend.slackEvents, graphqlEndpoint);
|
|
260
281
|
backend.slackEvents.addEnvironment("PAPYRUS_CONSOLE_RESPONSE_TARGET", (process.env.PAPYRUS_CONSOLE_RESPONSE_TARGET ?? "cloud").trim() || "cloud");
|
|
261
282
|
backend.slackEvents.addEnvironment("PAPYRUS_SLACK_ALLOWED_USER_IDS", (process.env.PAPYRUS_SLACK_ALLOWED_USER_IDS ?? "").trim());
|
|
262
283
|
if (amplifySsmEnvConfig) {
|
|
263
284
|
backend.slackEvents.addEnvironment("AMPLIFY_SSM_ENV_CONFIG", amplifySsmEnvConfig);
|
|
264
285
|
backend.slackDelivery.addEnvironment("AMPLIFY_SSM_ENV_CONFIG", amplifySsmEnvConfig);
|
|
265
286
|
}
|
|
266
|
-
backend.slackDelivery
|
|
287
|
+
connectToSiteApi(backend.slackDelivery, graphqlEndpoint);
|
|
267
288
|
backend.slackDelivery.addEnvironment("PAPYRUS_CONSOLE_RESPONSE_TARGET", (process.env.PAPYRUS_CONSOLE_RESPONSE_TARGET ?? "cloud").trim() || "cloud");
|
|
268
289
|
const slackBotTokenName = (process.env.PAPYRUS_SLACK_BOT_TOKEN_NAME ?? "PAPYRUS_SLACK_BOT_TOKEN").trim();
|
|
269
290
|
backend.slackDelivery.addEnvironment("PAPYRUS_SLACK_BOT_TOKEN", secret(slackBotTokenName));
|
|
@@ -398,7 +419,8 @@ export function defineSiteBackend(papyrusSite) {
|
|
|
398
419
|
if (backendTenantId !== "") {
|
|
399
420
|
// editorialChecks too: it compares the site's editorial context (a tenant's publication) with its own tenant and refuses a mismatch,
|
|
400
421
|
// so without the variable every check after a save-version on a tenant site fails with "Editorial context tenant mismatch" (PPY-49303f).
|
|
401
|
-
|
|
422
|
+
// tenantClaims: a dedicated stack's fixed tenant is the one its session claims name (PPY-0bb0fd).
|
|
423
|
+
for (const tenantLambda of [contentActionsLambda, backend.categoryAction.resources.lambda, backend.assignmentAction.resources.lambda, backend.newsroomSummary.resources.lambda, backend.editorialChecks.resources.lambda, backend.tenantClaims.resources.lambda]) {
|
|
402
424
|
tenantLambda.addEnvironment("PAPYRUS_TENANT_ID", backendTenantId);
|
|
403
425
|
}
|
|
404
426
|
}
|
|
@@ -421,7 +443,7 @@ export function defineSiteBackend(papyrusSite) {
|
|
|
421
443
|
// AppSync validates the token; pending intake additionally binds its actor
|
|
422
444
|
// and publication to this deployment's pool and existing API endpoint.
|
|
423
445
|
contentActionsLambda.addEnvironment("PAPYRUS_USER_POOL_ISSUER", `https://cognito-idp.${Stack.of(contentActionsLambda).region}.amazonaws.com/${backend.auth.resources.userPool.userPoolId}`);
|
|
424
|
-
contentActionsLambda
|
|
446
|
+
connectToSiteApi(contentActionsLambda, backend.data.resources.cfnResources.cfnGraphqlApi.attrGraphQlUrl);
|
|
425
447
|
wireEmailReferenceIntake(contentActionsLambda, emailMonitorId);
|
|
426
448
|
contentActionsLambda.addToRolePolicy(new PolicyStatement({
|
|
427
449
|
actions: ["appsync:GraphQL"],
|
|
@@ -526,13 +548,13 @@ export function defineSiteBackend(papyrusSite) {
|
|
|
526
548
|
inboundReceive.addEnvironment("PAPYRUS_INBOUND_EMAIL_DOMAIN", inboundEmailDomain);
|
|
527
549
|
inboundReceive.addEnvironment("PAPYRUS_INBOUND_EMAIL_LOCAL_PARTS", inboundEmailLocalParts.join(","));
|
|
528
550
|
inboundReceive.addEnvironment("PAPYRUS_INBOUND_EMAIL_CORPUS_KEY", inboundEmailCorpusKey);
|
|
529
|
-
inboundReceive
|
|
551
|
+
connectToSiteApi(inboundReceive, graphqlEndpoint);
|
|
530
552
|
inboundProcessor.addEnvironment("PAPYRUS_INBOUND_EMAIL_CORPUS_KEY", inboundEmailCorpusKey);
|
|
531
553
|
inboundProcessor.addEnvironment("PAPYRUS_INBOUND_EMAIL_DOMAIN", inboundEmailDomain);
|
|
532
554
|
inboundProcessor.addEnvironment("PAPYRUS_INBOUND_FEEDBACK_EMAIL_ENABLED", "true");
|
|
533
555
|
inboundProcessor.addEnvironment("PAPYRUS_INBOUND_FEEDBACK_FROM_EMAIL", `Papyrus Submissions <submissions@${inboundEmailDomain}>`);
|
|
534
556
|
inboundProcessor.addEnvironment("PAPYRUS_PUBLIC_SITE_BASE_URL", inbound.publicSiteBaseUrl);
|
|
535
|
-
inboundProcessor
|
|
557
|
+
connectToSiteApi(inboundProcessor, graphqlEndpoint);
|
|
536
558
|
receiveLambda.addToRolePolicy(new PolicyStatement({
|
|
537
559
|
actions: ["lambda:InvokeFunction"],
|
|
538
560
|
resources: [processorLambda.functionArn],
|
|
@@ -645,7 +667,7 @@ export function defineSiteBackend(papyrusSite) {
|
|
|
645
667
|
const knowledgeQueryLambda = backend.knowledgeQuery.resources.lambda;
|
|
646
668
|
backend.knowledgeQuery.addEnvironment("OPENAI_API_KEY", secret("OPENAI_API_KEY"));
|
|
647
669
|
knowledgeQueryLambda.addEnvironment("PAPYRUS_STORAGE_BUCKET_NAME", storageBucket.bucketName);
|
|
648
|
-
knowledgeQueryLambda
|
|
670
|
+
connectToSiteApi(knowledgeQueryLambda, backend.data.resources.cfnResources.cfnGraphqlApi.attrGraphQlUrl);
|
|
649
671
|
knowledgeQueryLambda.addEnvironment("PAPYRUS_S3_VECTOR_INDEX_ARN", knowledgeVectorIndex.attrIndexArn);
|
|
650
672
|
knowledgeQueryLambda.addEnvironment("PAPYRUS_S3_VECTOR_INDEX_NAME", knowledgeVectorIndexName);
|
|
651
673
|
knowledgeQueryLambda.addEnvironment("PAPYRUS_EMBEDDING_MODEL", knowledgeEmbeddingModel);
|
|
@@ -740,7 +762,7 @@ export function defineSiteBackend(papyrusSite) {
|
|
|
740
762
|
});
|
|
741
763
|
wireEditorialChecks(backend);
|
|
742
764
|
// The functions that call models report their tokens to the site's Prospectus usage queue.
|
|
743
|
-
if (costAttribution) {
|
|
765
|
+
if (costAttribution && !sharedTier) {
|
|
744
766
|
const editorialChecksLambda = backend.editorialChecks.resources.lambda;
|
|
745
767
|
wireSiteUsageSender(editorialChecksLambda, costAttribution);
|
|
746
768
|
wireSiteUsageSender(knowledgeQueryLambda, costAttribution);
|
|
@@ -748,6 +770,9 @@ export function defineSiteBackend(papyrusSite) {
|
|
|
748
770
|
// each fit one CloudFormation operation; the usage senders' stacks change in the first pass, so they go first.
|
|
749
771
|
applySiteBackendCostTags(backend.stack, costAttribution, [Stack.of(editorialChecksLambda), Stack.of(knowledgeQueryLambda)]);
|
|
750
772
|
}
|
|
773
|
+
// The shared stack reports usage per tenant through Prospectus later (kanbus-f45f7f); until then its resources are only tagged.
|
|
774
|
+
if (costAttribution && sharedTier)
|
|
775
|
+
applySiteBackendCostTags(backend.stack, costAttribution);
|
|
751
776
|
wireMonitoringView(backend, emailMonitorId);
|
|
752
777
|
wireAutomationView(backend);
|
|
753
778
|
wireImageService(backend);
|
|
@@ -755,5 +780,32 @@ export function defineSiteBackend(papyrusSite) {
|
|
|
755
780
|
// Announcements are off until the owner turns them on; the parameters and the lease are per site (the brand id names the site).
|
|
756
781
|
wireAnnouncements(backend, siteBackendIdentity.brandId);
|
|
757
782
|
wirePlugins(backend, plugins, contentActionsLambda, s3ProjectionPublication !== undefined);
|
|
783
|
+
if (tenancyMode === "shared") {
|
|
784
|
+
// The loop at the top reaches the functions Amplify defines. A shared stack also has functions that wires and plugins make with `new Function`
|
|
785
|
+
// (the console chat responder, the reference word index consumer, the public forms handler); each must know it is shared.
|
|
786
|
+
for (const node of backend.stack.node.findAll()) {
|
|
787
|
+
if (!(node instanceof LambdaFunction) || isInfrastructureConstructId(node.node.id))
|
|
788
|
+
continue;
|
|
789
|
+
for (const [name, value] of Object.entries(tenancyFunctionEnvironment(tenancyMode)))
|
|
790
|
+
node.addEnvironment(name, value);
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
if (sharedTier && sharedSettings) {
|
|
794
|
+
// Layers 2, 3 and 5 of the shared tier's isolation (the key, the boundary, reserved concurrency, alarms); the foundation stack holds the key and the boundary policy.
|
|
795
|
+
const isolation = applySharedStackIsolation(backend, sharedTier, sharedSettings);
|
|
796
|
+
const alarmsStack = backend.createStack("shared-alarms");
|
|
797
|
+
addSharedStackAlarms(alarmsStack, sharedTier, sharedSettings, {
|
|
798
|
+
functions: isolation.functionTargets,
|
|
799
|
+
appSyncApiId: backend.data.resources.graphqlApi.apiId,
|
|
800
|
+
tableNames: Object.values(backend.data.resources.tables).map((table) => table.tableName),
|
|
801
|
+
projectionDeadLetterQueueName: s3ProjectionPublication?.deadLetterQueue.queueName,
|
|
802
|
+
distributionId: s3ProjectionPublication?.distributionId,
|
|
803
|
+
});
|
|
804
|
+
}
|
|
805
|
+
else if (options.dedicatedSharedStackDeny !== false) {
|
|
806
|
+
// A dedicated site's roles may not touch the shared tier. Roles of the per-model data stacks are left alone (see addSharedStackDeny).
|
|
807
|
+
const modelNames = new Set(Object.keys(backend.data.resources.tables));
|
|
808
|
+
addSharedStackDeny(backend.stack, (stack) => isModelDataStack(stack, modelNames));
|
|
809
|
+
}
|
|
758
810
|
return backend;
|
|
759
811
|
}
|
package/amplify/site-backend.ts
CHANGED
|
@@ -26,7 +26,13 @@ import {
|
|
|
26
26
|
validateRevalidateDistributionIds,
|
|
27
27
|
} from "./revalidate-invalidation-settings";
|
|
28
28
|
import { enablePointInTimeRecoveryOnDataTables } from "./data-table-recovery";
|
|
29
|
-
import { applySiteBackendCostTags, siteCostAttribution, wireSiteUsageSender } from "./cost-attribution";
|
|
29
|
+
import { applySiteBackendCostTags, sharedStackCostAttribution, siteCostAttribution, wireSiteUsageSender } from "./cost-attribution";
|
|
30
|
+
import { addSharedStackAlarms } from "./shared-stack/alarms";
|
|
31
|
+
import { addSharedStackDeny, isModelDataStack } from "./shared-stack/deny";
|
|
32
|
+
import { isInfrastructureConstructId } from "./shared-stack/inline-policy";
|
|
33
|
+
import { applySharedStackIsolation } from "./shared-stack/isolation";
|
|
34
|
+
import { sharedTierPlan } from "./shared-stack/names";
|
|
35
|
+
import { sharedStackSettings } from "./shared-stack/settings";
|
|
30
36
|
import { addInvalidationPathAlarm } from "./publication/invalidation-alarm";
|
|
31
37
|
import { applyCognitoDomainPrefix, applyGoogleEmailVerifiedMapping, authConfigFromEnv, defineSiteAuth, siteAuthRedirectUrls } from "./auth/resource";
|
|
32
38
|
import { PROSPECTUS_SIGN_IN_CALLBACK_PATH, CLI_FEDERATION_REFRESH_TOKEN_VALIDITY_DAYS, addProspectusGoogleOnlyClient, cliFederationClientCallbackUrls, trustClientOnIdentityPool } from "./auth/prospectus-google-client";
|
|
@@ -57,6 +63,8 @@ import { contentActions, setSiteFilesForContentActionsBundle } from "./functions
|
|
|
57
63
|
import { knowledgeQuery } from "./functions/knowledge-query/resource";
|
|
58
64
|
import { wireReferenceWordIndex } from "./functions/reference-word-index/wire";
|
|
59
65
|
import { manageUserRole } from "./functions/manage-user-role/resource";
|
|
66
|
+
import { tenantClaims } from "./functions/tenant-claims/resource";
|
|
67
|
+
import { applyTenantSessionClaims } from "./auth/tenant-session-claims";
|
|
60
68
|
import { modelAttachmentUpload } from "./functions/model-attachment-upload/resource";
|
|
61
69
|
import { newsroomSummary } from "./functions/newsroom-summary/resource";
|
|
62
70
|
import { derivePublicFormOrigins } from "./functions/public-forms/origins";
|
|
@@ -85,14 +93,22 @@ import {
|
|
|
85
93
|
import { addStorageBackups } from "./storage-backups/construct";
|
|
86
94
|
import { storage } from "./storage/resource";
|
|
87
95
|
import type { PapyrusSite } from "../lib/define-site";
|
|
96
|
+
import { connectToSiteApi } from "./site-api-access";
|
|
88
97
|
|
|
89
|
-
export
|
|
98
|
+
export type DefineSiteBackendOptions = {
|
|
99
|
+
/**
|
|
100
|
+
* Add the deny on the shared tier's resources to every dedicated role (default true). Only the synth test that proves the deny is
|
|
101
|
+
* the whole difference turns it off, to get the template without it.
|
|
102
|
+
*/
|
|
103
|
+
dedicatedSharedStackDeny?: boolean;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export function defineSiteBackend(papyrusSite: PapyrusSite, options: DefineSiteBackendOptions = {}) {
|
|
90
107
|
// `papyrus.config.ts`'s default export. Backend options live under `backend`;
|
|
91
108
|
// the default brand id namespaces account-global resources.
|
|
92
109
|
const site = { brandId: papyrusSite.defaultBrand, ...papyrusSite.backend };
|
|
93
110
|
// Prospectus cost accounting: on when `papyrus-infra backend-deploy` asks for a cost tag wave (PAPYRUS_COST_TAG_WAVE).
|
|
94
|
-
// Null, from a plain `ampx pipeline-deploy`, leaves the backend untouched.
|
|
95
|
-
const costAttribution = siteCostAttribution();
|
|
111
|
+
// Null, from a plain `ampx pipeline-deploy`, leaves the backend untouched. A shared stack is always tagged (see below).
|
|
96
112
|
const knowledgeVectorDimension = 1536;
|
|
97
113
|
const knowledgeEmbeddingModel = "text-embedding-3-small";
|
|
98
114
|
|
|
@@ -130,10 +146,19 @@ export function defineSiteBackend(papyrusSite: PapyrusSite) {
|
|
|
130
146
|
assertValidMonitoringConfig(site.monitoring);
|
|
131
147
|
assertValidTenancyConfig(site.tenancy);
|
|
132
148
|
const tenancyMode = resolveTenancyMode(site.tenancy);
|
|
149
|
+
// A shared stack is one of two fixed tiers (docs/shared-stack.md). Its settings (reserved concurrency, alarm thresholds) come from
|
|
150
|
+
// amplify/shared-stack/settings.json, and a tier whose numbers are not measured yet refuses to synthesise.
|
|
151
|
+
const sharedTier = tenancyMode === "shared" ? sharedTierPlan(site.tenancy!.tier!) : undefined;
|
|
152
|
+
const sharedSettings = sharedTier ? sharedStackSettings(sharedTier.tier) : undefined;
|
|
153
|
+
const costAttribution = sharedTier ? sharedStackCostAttribution(sharedTier) : siteCostAttribution();
|
|
154
|
+
if (sharedTier && (publication?.projector !== undefined || publication?.staticDir !== undefined)) {
|
|
155
|
+
throw new Error("A shared stack serves many sites, so its publication cannot name one site's projector or static directory.");
|
|
156
|
+
}
|
|
133
157
|
const emailMonitorId = site.monitoring?.emailMonitorId ?? "hn";
|
|
134
158
|
const publicationPlan = planS3ProjectionBackend(publication);
|
|
135
159
|
const renditionsPlan = planRenditions(publication, process.cwd());
|
|
136
|
-
|
|
160
|
+
// The shared stack bundles no site's files: its configuration comes from the site store, one site per tenant.
|
|
161
|
+
setSiteFilesForContentActionsBundle(sharedTier ? [] : publicationPlan.enabled ? publicationPlan.siteFiles : undefined);
|
|
137
162
|
const plugins = resolvePlugins(site.plugins, { staticDir: publication?.staticDir });
|
|
138
163
|
const pluginDefinitions = Object.assign({}, ...plugins.map(({ plugin }) => plugin.schemaDefinitions()));
|
|
139
164
|
const pluginFunctions: Record<never, never> = Object.assign({}, ...plugins.map(({ plugin }) => plugin.functions()));
|
|
@@ -171,6 +196,7 @@ export function defineSiteBackend(papyrusSite: PapyrusSite) {
|
|
|
171
196
|
slackEvents,
|
|
172
197
|
slackDelivery,
|
|
173
198
|
storage,
|
|
199
|
+
tenantClaims,
|
|
174
200
|
});
|
|
175
201
|
|
|
176
202
|
// Tenancy mode reaches every function; dedicated adds nothing, so an existing site's template is unchanged.
|
|
@@ -192,6 +218,14 @@ export function defineSiteBackend(papyrusSite: PapyrusSite) {
|
|
|
192
218
|
site.resolverWaveSize ?? DEFAULT_RESOLVER_WAVE_SIZE,
|
|
193
219
|
);
|
|
194
220
|
|
|
221
|
+
// Session role claims (PPY-0bb0fd): the pre-token trigger moves to event version 2 on the Essentials plan and reads the two
|
|
222
|
+
// tenancy models when the `tenancy` model group is deployed. Dark: no authorization rule reads the claims yet.
|
|
223
|
+
applyTenantSessionClaims(
|
|
224
|
+
backend.auth.resources.cfnResources.cfnUserPool,
|
|
225
|
+
backend.tenantClaims.resources.lambda,
|
|
226
|
+
"TenantMembership" in backend.data.resources.tables && "TenantSelection" in backend.data.resources.tables,
|
|
227
|
+
);
|
|
228
|
+
|
|
195
229
|
const requestedCognitoDomainPrefix = (authConfig.cognitoDomainPrefix ?? "").trim();
|
|
196
230
|
if (
|
|
197
231
|
authConfig.applyCognitoDomainPrefix === true
|
|
@@ -308,7 +342,7 @@ export function defineSiteBackend(papyrusSite: PapyrusSite) {
|
|
|
308
342
|
resources: ["*"],
|
|
309
343
|
}),
|
|
310
344
|
);
|
|
311
|
-
backend.slackEvents
|
|
345
|
+
connectToSiteApi(backend.slackEvents, graphqlEndpoint);
|
|
312
346
|
backend.slackEvents.addEnvironment(
|
|
313
347
|
"PAPYRUS_CONSOLE_RESPONSE_TARGET",
|
|
314
348
|
(process.env.PAPYRUS_CONSOLE_RESPONSE_TARGET ?? "cloud").trim() || "cloud",
|
|
@@ -321,7 +355,7 @@ export function defineSiteBackend(papyrusSite: PapyrusSite) {
|
|
|
321
355
|
backend.slackEvents.addEnvironment("AMPLIFY_SSM_ENV_CONFIG", amplifySsmEnvConfig);
|
|
322
356
|
backend.slackDelivery.addEnvironment("AMPLIFY_SSM_ENV_CONFIG", amplifySsmEnvConfig);
|
|
323
357
|
}
|
|
324
|
-
backend.slackDelivery
|
|
358
|
+
connectToSiteApi(backend.slackDelivery, graphqlEndpoint);
|
|
325
359
|
backend.slackDelivery.addEnvironment(
|
|
326
360
|
"PAPYRUS_CONSOLE_RESPONSE_TARGET",
|
|
327
361
|
(process.env.PAPYRUS_CONSOLE_RESPONSE_TARGET ?? "cloud").trim() || "cloud",
|
|
@@ -492,7 +526,8 @@ export function defineSiteBackend(papyrusSite: PapyrusSite) {
|
|
|
492
526
|
if (backendTenantId !== "") {
|
|
493
527
|
// editorialChecks too: it compares the site's editorial context (a tenant's publication) with its own tenant and refuses a mismatch,
|
|
494
528
|
// so without the variable every check after a save-version on a tenant site fails with "Editorial context tenant mismatch" (PPY-49303f).
|
|
495
|
-
|
|
529
|
+
// tenantClaims: a dedicated stack's fixed tenant is the one its session claims name (PPY-0bb0fd).
|
|
530
|
+
for (const tenantLambda of [contentActionsLambda, backend.categoryAction.resources.lambda, backend.assignmentAction.resources.lambda, backend.newsroomSummary.resources.lambda, backend.editorialChecks.resources.lambda, backend.tenantClaims.resources.lambda]) {
|
|
496
531
|
(tenantLambda as LambdaFunction).addEnvironment("PAPYRUS_TENANT_ID", backendTenantId);
|
|
497
532
|
}
|
|
498
533
|
}
|
|
@@ -518,10 +553,7 @@ export function defineSiteBackend(papyrusSite: PapyrusSite) {
|
|
|
518
553
|
"PAPYRUS_USER_POOL_ISSUER",
|
|
519
554
|
`https://cognito-idp.${Stack.of(contentActionsLambda).region}.amazonaws.com/${backend.auth.resources.userPool.userPoolId}`,
|
|
520
555
|
);
|
|
521
|
-
contentActionsLambda.
|
|
522
|
-
"PAPYRUS_GRAPHQL_ENDPOINT",
|
|
523
|
-
backend.data.resources.cfnResources.cfnGraphqlApi.attrGraphQlUrl,
|
|
524
|
-
);
|
|
556
|
+
connectToSiteApi(contentActionsLambda, backend.data.resources.cfnResources.cfnGraphqlApi.attrGraphQlUrl);
|
|
525
557
|
wireEmailReferenceIntake(contentActionsLambda, emailMonitorId);
|
|
526
558
|
contentActionsLambda.addToRolePolicy(
|
|
527
559
|
new PolicyStatement({
|
|
@@ -643,7 +675,7 @@ export function defineSiteBackend(papyrusSite: PapyrusSite) {
|
|
|
643
675
|
inboundReceive.addEnvironment("PAPYRUS_INBOUND_EMAIL_DOMAIN", inboundEmailDomain);
|
|
644
676
|
inboundReceive.addEnvironment("PAPYRUS_INBOUND_EMAIL_LOCAL_PARTS", inboundEmailLocalParts.join(","));
|
|
645
677
|
inboundReceive.addEnvironment("PAPYRUS_INBOUND_EMAIL_CORPUS_KEY", inboundEmailCorpusKey);
|
|
646
|
-
inboundReceive
|
|
678
|
+
connectToSiteApi(inboundReceive, graphqlEndpoint);
|
|
647
679
|
|
|
648
680
|
inboundProcessor.addEnvironment("PAPYRUS_INBOUND_EMAIL_CORPUS_KEY", inboundEmailCorpusKey);
|
|
649
681
|
inboundProcessor.addEnvironment("PAPYRUS_INBOUND_EMAIL_DOMAIN", inboundEmailDomain);
|
|
@@ -653,7 +685,7 @@ export function defineSiteBackend(papyrusSite: PapyrusSite) {
|
|
|
653
685
|
`Papyrus Submissions <submissions@${inboundEmailDomain}>`,
|
|
654
686
|
);
|
|
655
687
|
inboundProcessor.addEnvironment("PAPYRUS_PUBLIC_SITE_BASE_URL", inbound.publicSiteBaseUrl);
|
|
656
|
-
inboundProcessor
|
|
688
|
+
connectToSiteApi(inboundProcessor, graphqlEndpoint);
|
|
657
689
|
|
|
658
690
|
receiveLambda.addToRolePolicy(
|
|
659
691
|
new PolicyStatement({
|
|
@@ -788,10 +820,7 @@ export function defineSiteBackend(papyrusSite: PapyrusSite) {
|
|
|
788
820
|
const knowledgeQueryLambda = backend.knowledgeQuery.resources.lambda as LambdaFunction;
|
|
789
821
|
backend.knowledgeQuery.addEnvironment("OPENAI_API_KEY", secret("OPENAI_API_KEY"));
|
|
790
822
|
knowledgeQueryLambda.addEnvironment("PAPYRUS_STORAGE_BUCKET_NAME", storageBucket.bucketName);
|
|
791
|
-
knowledgeQueryLambda.
|
|
792
|
-
"PAPYRUS_GRAPHQL_ENDPOINT",
|
|
793
|
-
backend.data.resources.cfnResources.cfnGraphqlApi.attrGraphQlUrl,
|
|
794
|
-
);
|
|
823
|
+
connectToSiteApi(knowledgeQueryLambda, backend.data.resources.cfnResources.cfnGraphqlApi.attrGraphQlUrl);
|
|
795
824
|
knowledgeQueryLambda.addEnvironment("PAPYRUS_S3_VECTOR_INDEX_ARN", knowledgeVectorIndex.attrIndexArn);
|
|
796
825
|
knowledgeQueryLambda.addEnvironment("PAPYRUS_S3_VECTOR_INDEX_NAME", knowledgeVectorIndexName);
|
|
797
826
|
knowledgeQueryLambda.addEnvironment("PAPYRUS_EMBEDDING_MODEL", knowledgeEmbeddingModel);
|
|
@@ -896,7 +925,7 @@ export function defineSiteBackend(papyrusSite: PapyrusSite) {
|
|
|
896
925
|
});
|
|
897
926
|
wireEditorialChecks(backend);
|
|
898
927
|
// The functions that call models report their tokens to the site's Prospectus usage queue.
|
|
899
|
-
if (costAttribution) {
|
|
928
|
+
if (costAttribution && !sharedTier) {
|
|
900
929
|
const editorialChecksLambda = backend.editorialChecks.resources.lambda as LambdaFunction;
|
|
901
930
|
wireSiteUsageSender(editorialChecksLambda, costAttribution);
|
|
902
931
|
wireSiteUsageSender(knowledgeQueryLambda, costAttribution);
|
|
@@ -904,6 +933,8 @@ export function defineSiteBackend(papyrusSite: PapyrusSite) {
|
|
|
904
933
|
// each fit one CloudFormation operation; the usage senders' stacks change in the first pass, so they go first.
|
|
905
934
|
applySiteBackendCostTags(backend.stack, costAttribution, [Stack.of(editorialChecksLambda), Stack.of(knowledgeQueryLambda)]);
|
|
906
935
|
}
|
|
936
|
+
// The shared stack reports usage per tenant through Prospectus later (kanbus-f45f7f); until then its resources are only tagged.
|
|
937
|
+
if (costAttribution && sharedTier) applySiteBackendCostTags(backend.stack, costAttribution);
|
|
907
938
|
wireMonitoringView(backend, emailMonitorId);
|
|
908
939
|
wireAutomationView(backend);
|
|
909
940
|
wireImageService(backend);
|
|
@@ -912,5 +943,30 @@ export function defineSiteBackend(papyrusSite: PapyrusSite) {
|
|
|
912
943
|
wireAnnouncements(backend, siteBackendIdentity.brandId);
|
|
913
944
|
wirePlugins(backend, plugins, contentActionsLambda, s3ProjectionPublication !== undefined);
|
|
914
945
|
|
|
946
|
+
if (tenancyMode === "shared") {
|
|
947
|
+
// The loop at the top reaches the functions Amplify defines. A shared stack also has functions that wires and plugins make with `new Function`
|
|
948
|
+
// (the console chat responder, the reference word index consumer, the public forms handler); each must know it is shared.
|
|
949
|
+
for (const node of backend.stack.node.findAll()) {
|
|
950
|
+
if (!(node instanceof LambdaFunction) || isInfrastructureConstructId(node.node.id)) continue;
|
|
951
|
+
for (const [name, value] of Object.entries(tenancyFunctionEnvironment(tenancyMode))) node.addEnvironment(name, value);
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
if (sharedTier && sharedSettings) {
|
|
955
|
+
// Layers 2, 3 and 5 of the shared tier's isolation (the key, the boundary, reserved concurrency, alarms); the foundation stack holds the key and the boundary policy.
|
|
956
|
+
const isolation = applySharedStackIsolation(backend, sharedTier, sharedSettings);
|
|
957
|
+
const alarmsStack = backend.createStack("shared-alarms");
|
|
958
|
+
addSharedStackAlarms(alarmsStack, sharedTier, sharedSettings, {
|
|
959
|
+
functions: isolation.functionTargets,
|
|
960
|
+
appSyncApiId: backend.data.resources.graphqlApi.apiId,
|
|
961
|
+
tableNames: Object.values(backend.data.resources.tables).map((table) => table.tableName),
|
|
962
|
+
projectionDeadLetterQueueName: s3ProjectionPublication?.deadLetterQueue.queueName,
|
|
963
|
+
distributionId: s3ProjectionPublication?.distributionId,
|
|
964
|
+
});
|
|
965
|
+
} else if (options.dedicatedSharedStackDeny !== false) {
|
|
966
|
+
// A dedicated site's roles may not touch the shared tier. Roles of the per-model data stacks are left alone (see addSharedStackDeny).
|
|
967
|
+
const modelNames = new Set(Object.keys(backend.data.resources.tables));
|
|
968
|
+
addSharedStackDeny(backend.stack, (stack) => isModelDataStack(stack, modelNames));
|
|
969
|
+
}
|
|
970
|
+
|
|
915
971
|
return backend;
|
|
916
972
|
}
|
|
@@ -3191,6 +3191,11 @@ async function listUserPoolModel<T>(modelName: string): Promise<T[]> {
|
|
|
3191
3191
|
return items;
|
|
3192
3192
|
}
|
|
3193
3193
|
|
|
3194
|
+
/** The site's Sections, read on their own (the shell dashboard is a summary that holds none). */
|
|
3195
|
+
export async function loadEditorNewsroomSections(): Promise<NewsroomSectionRecord[]> {
|
|
3196
|
+
return listOptionalUserPoolModel<NewsroomSectionRecord>("NewsroomSection");
|
|
3197
|
+
}
|
|
3198
|
+
|
|
3194
3199
|
async function listOptionalUserPoolModel<T>(modelName: string): Promise<T[]> {
|
|
3195
3200
|
const client = generateClient<Schema>();
|
|
3196
3201
|
const model = (client.models as Record<string, ListableModel<T>>)[modelName];
|
|
@@ -15,7 +15,8 @@ import {
|
|
|
15
15
|
} from "./ui/dialog";
|
|
16
16
|
import { Input } from "./ui/input";
|
|
17
17
|
import { isLocalPreviewEnabled } from "../lib/local-preview";
|
|
18
|
-
import {
|
|
18
|
+
import { newsroomDeskPickerOptions } from "../lib/newsroom-sections";
|
|
19
|
+
import { useNewsroomDeskSections } from "./use-newsroom-desk-sections";
|
|
19
20
|
import { StoryReportingTrailView } from "./story-reporting-trail";
|
|
20
21
|
import { loadNewestStoryVersion } from "./story-reporting-trail-client";
|
|
21
22
|
import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue } from "./ui/select";
|
|
@@ -173,7 +174,8 @@ export function NewsroomArticleEditor({ articleId, demo, embedded = false, stars
|
|
|
173
174
|
const latestVersionNumber = latestVersion?.number ?? null;
|
|
174
175
|
const [changeReason, setChangeReason] = useState("");
|
|
175
176
|
const citedKeys = useMemo(() => Object.values(((bodyIr as { papyrus?: { citations?: Record<string, string[]> } } | null)?.papyrus?.citations) ?? {}).flat(), [bodyIr]);
|
|
176
|
-
const
|
|
177
|
+
const { sections: deskSections, loading: deskSectionsLoading, error: deskSectionsError } = useNewsroomDeskSections();
|
|
178
|
+
const deskOptions = useMemo(() => newsroomDeskPickerOptions(deskSections, editor?.section), [deskSections, editor?.section]);
|
|
177
179
|
const [reloadToken, setReloadToken] = useState(0);
|
|
178
180
|
const [imageUrls, setImageUrls] = useState<Record<string, string>>({});
|
|
179
181
|
const [mediaIndex, setMediaIndex] = useState<MediaIndex>({ loaded: false, failed: false, assets: [] });
|
|
@@ -879,7 +881,9 @@ export function NewsroomArticleEditor({ articleId, demo, embedded = false, stars
|
|
|
879
881
|
) : null)}
|
|
880
882
|
</SelectContent>
|
|
881
883
|
</Select>
|
|
882
|
-
|
|
884
|
+
<small data-newsroom-article-section-status role="status" className="block h-6 overflow-hidden text-xs leading-6">
|
|
885
|
+
{deskSectionsLoading ? "Loading the site's sections…" : deskSectionsError ? `Could not load the site's sections: ${deskSectionsError}` : ""}
|
|
886
|
+
</small>
|
|
883
887
|
</label>
|
|
884
888
|
<label className="space-y-1 text-sm font-medium">
|
|
885
889
|
<span>Slug</span>
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
type NativeBoardIssue,
|
|
22
22
|
} from "../lib/newsroom-board";
|
|
23
23
|
import type { AssignmentRecord } from "../lib/category-repository";
|
|
24
|
+
import { useNewsroomDeskSections } from "./use-newsroom-desk-sections";
|
|
24
25
|
import { newsroomDeskOptions } from "../lib/newsroom-sections";
|
|
25
26
|
import { getContentItemName, getContentItemStageDefinitions, SITE_BRAND } from "../lib/site-brand";
|
|
26
27
|
import { getNewsroomNavHref } from "../lib/newsroom-nav";
|
|
@@ -63,6 +64,7 @@ export type NewsroomBoardSubject = "contentItem" | "assignment" | "desk";
|
|
|
63
64
|
/** Read-only board of one record kind over authenticated CMS records; existing workspaces own every mutation. */
|
|
64
65
|
export function NewsroomBoardView({ subject, deskId }: { subject: NewsroomBoardSubject; deskId?: string }) {
|
|
65
66
|
const session = useOptionalNewsDeskClient();
|
|
67
|
+
const { sections: deskSections } = useNewsroomDeskSections();
|
|
66
68
|
const allowed = canReadNewsroomBoard(session?.shell.phase);
|
|
67
69
|
const [lowMotion, setLowMotion] = useState(false);
|
|
68
70
|
const [assignmentBoardIssues, setAssignmentBoardIssues] = useState<NativeBoardIssue[]>([]);
|
|
@@ -149,9 +151,9 @@ export function NewsroomBoardView({ subject, deskId }: { subject: NewsroomBoardS
|
|
|
149
151
|
const loadMoreWhenColumnIsNearItsEnd = (columnKey: string) => {
|
|
150
152
|
if (showsContentItems && columnKey.startsWith(contentItemColumnKeyPrefix)) pagedContentItems.loadMoreForStage(columnKey.slice(contentItemColumnKeyPrefix.length));
|
|
151
153
|
};
|
|
152
|
-
const deskTitle =
|
|
154
|
+
const deskTitle = deskSections.find(section => section.id === deskId)?.title ?? deskId ?? "Desk";
|
|
153
155
|
const pageTitle = subject === "contentItem" ? getContentItemName().plural : subject === "desk" ? deskTitle : "Assignments";
|
|
154
|
-
const deskOptions = useMemo(() => newsroomDeskOptions(
|
|
156
|
+
const deskOptions = useMemo(() => newsroomDeskOptions(deskSections), [deskSections]);
|
|
155
157
|
const changeAssignmentDesk = async (record: AssignmentRecord, deskId: string | null) => {
|
|
156
158
|
await saveNewsroomAssignmentDesk(record.id, deskId);
|
|
157
159
|
const moved = { ...record, sectionId: deskId, sectionKey: deskId };
|
|
@@ -78,10 +78,10 @@ body:has(.newsroom-organizer)>[data-staging-banner]{flex-shrink:0}
|
|
|
78
78
|
.newsroom-embedded-article :is([data-newsroom-article-preview],[data-skeleton-preview]){min-height:min(28rem,55dvh)}
|
|
79
79
|
/* The loading skeleton is the loaded editor's size block for block: the toolbar wraps onto more rows as the panel narrows (a container query,
|
|
80
80
|
because the panel's width, not the window's, decides), and the three fields stack when it is narrow. */
|
|
81
|
-
[data-skeleton-schedule]{height:92px}[data-skeleton-toolbar]{height:44px}[data-skeleton-stars]{height:59px}[data-skeleton-fields]{height:
|
|
81
|
+
[data-skeleton-schedule]{height:92px}[data-skeleton-toolbar]{height:44px}[data-skeleton-stars]{height:59px}[data-skeleton-fields]{height:262px}[data-skeleton-preview]{height:min(28rem,55dvh)}
|
|
82
82
|
/* The headline image block is one fixed height in every state (loading, none, processing, missing, loaded), and the skeleton reserves it. */
|
|
83
83
|
[data-story-headline-frame],[data-skeleton-headline]{height:11rem}
|
|
84
|
-
@container (max-width:719px){[data-skeleton-toolbar]{height:80px}[data-skeleton-fields]{height:
|
|
84
|
+
@container (max-width:719px){[data-skeleton-toolbar]{height:80px}[data-skeleton-fields]{height:282px}[data-skeleton-schedule]{height:113px}}
|
|
85
85
|
@container (max-width:399px){[data-skeleton-toolbar]{height:116px}[data-skeleton-schedule]{height:134px}}
|
|
86
86
|
.organizer-board-body .kb-issue-detail a:not(.organizer-header-button){display:block;min-height:44px;text-decoration:underline;padding:12px 0}
|
|
87
87
|
.organizer-menu{height:min(85dvh,760px);max-height:85dvh;display:flex;flex-direction:column;padding:16px;border-radius:24px 24px 0 0;gap:20px}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import type { NewsroomSectionRecord } from "../lib/category-repository";
|
|
5
|
+
import { loadEditorNewsroomSections } from "./news-desk-taxonomy-client";
|
|
6
|
+
import { useOptionalNewsDeskClient } from "./news-desk-client-provider";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The site's Sections for a picker. The shell dashboard is only a summary and carries none, so when it has none this reads them
|
|
10
|
+
* once, with the signed-in session, as the Sections page does. Reading fails soft: the picker then shows the Story's own value.
|
|
11
|
+
*/
|
|
12
|
+
export function useNewsroomDeskSections(): { sections: NewsroomSectionRecord[]; loading: boolean; error: string | null } {
|
|
13
|
+
const session = useOptionalNewsDeskClient();
|
|
14
|
+
const shellSections = session?.shell.dashboard?.newsroomSections ?? [];
|
|
15
|
+
const signedIn = session?.shell.auth.status === "signedIn" && Boolean(session.shell.dashboard);
|
|
16
|
+
const [loaded, setLoaded] = useState<NewsroomSectionRecord[] | null>(null);
|
|
17
|
+
const [error, setError] = useState<string | null>(null);
|
|
18
|
+
const needsLoad = shellSections.length === 0 && signedIn;
|
|
19
|
+
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (!needsLoad) return;
|
|
22
|
+
let cancelled = false;
|
|
23
|
+
loadEditorNewsroomSections()
|
|
24
|
+
.then((rows) => { if (!cancelled) { setLoaded(rows); setError(null); } })
|
|
25
|
+
.catch((reason: unknown) => { if (!cancelled) setError(reason instanceof Error ? reason.message : "Could not load the sections."); });
|
|
26
|
+
return () => { cancelled = true; };
|
|
27
|
+
}, [needsLoad]);
|
|
28
|
+
|
|
29
|
+
if (shellSections.length > 0) return { sections: shellSections, loading: false, error: null };
|
|
30
|
+
return { sections: loaded ?? [], loading: needsLoad && loaded === null && error === null, error };
|
|
31
|
+
}
|
|
@@ -7,6 +7,7 @@ import { parseCloudEmail } from "./cloud-email-config.js";
|
|
|
7
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
|
+
import { addSharedStackDeny } from "./shared-stack-deny.js";
|
|
10
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
12
|
function environmentVariables(variables) {
|
|
12
13
|
return Object.entries(variables).map(([name, value]) => ({ name, value }));
|
|
@@ -101,8 +102,10 @@ function addCiReceiptGate(scope, config, buildServiceRole) {
|
|
|
101
102
|
export class AmplifyAppShellStack extends Stack {
|
|
102
103
|
cmsAppId;
|
|
103
104
|
readerAppId;
|
|
104
|
-
constructor(scope, id, config, props) {
|
|
105
|
+
constructor(scope, id, config, props, options = {}) {
|
|
105
106
|
super(scope, id, props);
|
|
107
|
+
// Every role of a dedicated site denies the shared tier's resources (PPY-daf673); no resource is added.
|
|
108
|
+
addSharedStackDeny(this, options.sharedStackDeny);
|
|
106
109
|
// Prospectus cost accounting: every resource carries the site's owner Account, app papyrus and the site ID.
|
|
107
110
|
// On unless site.json says costAccounting false. These stacks are small; the backend's tags go in waves.
|
|
108
111
|
if (config.costAccounting)
|
|
@@ -8,6 +8,7 @@ import { parseCloudEmail } from "./cloud-email-config";
|
|
|
8
8
|
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
|
+
import { addSharedStackDeny } from "./shared-stack-deny";
|
|
11
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
13
|
|
|
13
14
|
function environmentVariables(variables: Record<string, string>): amplify.CfnBranch.EnvironmentVariableProperty[] {
|
|
@@ -107,8 +108,10 @@ export class AmplifyAppShellStack extends Stack {
|
|
|
107
108
|
public readonly cmsAppId?: string;
|
|
108
109
|
public readonly readerAppId?: string;
|
|
109
110
|
|
|
110
|
-
constructor(scope: Construct, id: string, config: AmplifyAppShellSiteConfig, props?: StackProps) {
|
|
111
|
+
constructor(scope: Construct, id: string, config: AmplifyAppShellSiteConfig, props?: StackProps, options: { sharedStackDeny?: boolean } = {}) {
|
|
111
112
|
super(scope, id, props);
|
|
113
|
+
// Every role of a dedicated site denies the shared tier's resources (PPY-daf673); no resource is added.
|
|
114
|
+
addSharedStackDeny(this, options.sharedStackDeny);
|
|
112
115
|
// Prospectus cost accounting: every resource carries the site's owner Account, app papyrus and the site ID.
|
|
113
116
|
// On unless site.json says costAccounting false. These stacks are small; the backend's tags go in waves.
|
|
114
117
|
if (config.costAccounting) applySiteCostTags(this, config.siteId);
|
package/infra/build-specs.js
CHANGED
|
@@ -15,6 +15,9 @@ function commandLines(commands, indent) {
|
|
|
15
15
|
const NPM_CLEAN_INSTALL = "npm ci --cache .npm --prefer-offline";
|
|
16
16
|
const FRONTEND_ENVIRONMENT_CAPTURE = "env | grep -e '^PAPYRUS_' -e '^SITE_ENV=' -e '^NEXT_PUBLIC_' >> .env.production";
|
|
17
17
|
const CHECKOUT_AS_PAPYRUS_ROOT = "PAPYRUS_ROOT=\"$PWD\"";
|
|
18
|
+
/** The staging export reads drafts as the Amplify build role, so it declares the operator lane; the CLI's default is a signed-in person (PPY-5f119a).
|
|
19
|
+
* The environment form, not `papyrus --auth iam`, so the line works with every engine version a site may pin. */
|
|
20
|
+
const BUILD_ROLE_LANE = "PAPYRUS_GRAPHQL_AUTH=iam";
|
|
18
21
|
const RUNTIME_OUTPUTS_COPY = "cp amplify_outputs.json .next/amplify_outputs.json";
|
|
19
22
|
function pythonProvisioningCommands(config) {
|
|
20
23
|
return [
|
|
@@ -99,7 +102,7 @@ export function cmsStagingBuildSpec(config) {
|
|
|
99
102
|
const cachePaths = [".next/cache/**/*", ".npm/**/*"];
|
|
100
103
|
const preview = config.frontend === "markus-static" ? stagingPreviewFor(config) : undefined;
|
|
101
104
|
if (preview !== undefined) {
|
|
102
|
-
preBuild.push(...pythonProvisioningCommands(config), `${CHECKOUT_AS_PAPYRUS_ROOT} papyrus ops content export-published --drafts --out content-export --clean`, preview.buildCommand, `${CHECKOUT_AS_PAPYRUS_ROOT} papyrus ops content upload-preview --dir ${preview.baseDirectory} --prefix ${resolveStoragePreviewPrefix(config)}`);
|
|
105
|
+
preBuild.push(...pythonProvisioningCommands(config), `${CHECKOUT_AS_PAPYRUS_ROOT} ${BUILD_ROLE_LANE} papyrus ops content export-published --drafts --out content-export --clean`, preview.buildCommand, `${CHECKOUT_AS_PAPYRUS_ROOT} papyrus ops content upload-preview --dir ${preview.baseDirectory} --prefix ${resolveStoragePreviewPrefix(config)}`);
|
|
103
106
|
cachePaths.push(".uv-cache/**/*");
|
|
104
107
|
}
|
|
105
108
|
return [
|