@anthusai/papyrus 5.110.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.
Files changed (92) hide show
  1. package/amplify/auth/resource.js +3 -0
  2. package/amplify/auth/resource.ts +3 -0
  3. package/amplify/auth/tenant-session-claims.js +27 -0
  4. package/amplify/auth/tenant-session-claims.ts +31 -0
  5. package/amplify/cost-attribution.js +12 -0
  6. package/amplify/cost-attribution.ts +12 -0
  7. package/amplify/data/resource.js +79 -0
  8. package/amplify/data/resource.ts +82 -0
  9. package/amplify/data/schema.js +82 -1
  10. package/amplify/data/schema.ts +85 -1
  11. package/amplify/functions/assignment-action/handler.ts +14 -9
  12. package/amplify/functions/automation-view/wire.js +2 -1
  13. package/amplify/functions/automation-view/wire.ts +2 -1
  14. package/amplify/functions/category-action/handler.ts +24 -18
  15. package/amplify/functions/category-action/message-hashtags.js +2 -1
  16. package/amplify/functions/category-action/message-hashtags.ts +2 -1
  17. package/amplify/functions/category-action/reference-links.js +3 -2
  18. package/amplify/functions/category-action/reference-links.ts +3 -2
  19. package/amplify/functions/console-chat-responder/resource.js +2 -1
  20. package/amplify/functions/console-chat-responder/resource.ts +2 -1
  21. package/amplify/functions/content-actions/handler.py +54 -22
  22. package/amplify/functions/content-actions/resource.js +4 -0
  23. package/amplify/functions/content-actions/resource.ts +5 -0
  24. package/amplify/functions/editorial-checks/handler.py +5 -1
  25. package/amplify/functions/editorial-checks/schema.js +10 -2
  26. package/amplify/functions/editorial-checks/schema.ts +10 -2
  27. package/amplify/functions/editorial-checks/wire.js +2 -1
  28. package/amplify/functions/editorial-checks/wire.ts +2 -1
  29. package/amplify/functions/image-service/wire.js +2 -1
  30. package/amplify/functions/image-service/wire.ts +2 -1
  31. package/amplify/functions/monitoring-view/wire.js +2 -1
  32. package/amplify/functions/monitoring-view/wire.ts +2 -1
  33. package/amplify/functions/newsroom-summary/handler.ts +16 -12
  34. package/amplify/functions/shared/tenant-context.js +98 -0
  35. package/amplify/functions/shared/tenant-context.ts +33 -0
  36. package/amplify/functions/shared/tenant-scoped-client.ts +80 -0
  37. package/amplify/functions/tenant-claims/claims.ts +90 -0
  38. package/amplify/functions/tenant-claims/environment.js +7 -0
  39. package/amplify/functions/tenant-claims/environment.ts +7 -0
  40. package/amplify/functions/tenant-claims/handler.ts +56 -0
  41. package/amplify/functions/tenant-claims/resource.js +12 -0
  42. package/amplify/functions/tenant-claims/resource.ts +13 -0
  43. package/amplify/plugins/newsletter/sending.js +2 -1
  44. package/amplify/plugins/newsletter/sending.ts +2 -1
  45. package/amplify/plugins/notifications/papyrus.plugin.js +2 -1
  46. package/amplify/plugins/notifications/papyrus.plugin.ts +2 -1
  47. package/amplify/plugins/reader-steering/schema.js +15 -3
  48. package/amplify/plugins/reader-steering/schema.ts +15 -3
  49. package/amplify/plugins/signup/papyrus.plugin.js +2 -1
  50. package/amplify/plugins/signup/papyrus.plugin.ts +2 -1
  51. package/amplify/plugins/signup/schema.js +1 -0
  52. package/amplify/plugins/signup/schema.ts +1 -0
  53. package/amplify/shared-stack/alarms.js +53 -0
  54. package/amplify/shared-stack/alarms.ts +109 -0
  55. package/amplify/shared-stack/define.js +15 -0
  56. package/amplify/shared-stack/define.ts +17 -0
  57. package/amplify/shared-stack/deny.js +27 -0
  58. package/amplify/shared-stack/deny.ts +28 -0
  59. package/amplify/shared-stack/inline-policy.js +53 -0
  60. package/amplify/shared-stack/inline-policy.ts +65 -0
  61. package/amplify/shared-stack/isolation.js +161 -0
  62. package/amplify/shared-stack/isolation.ts +204 -0
  63. package/amplify/shared-stack/names.js +95 -0
  64. package/amplify/shared-stack/names.ts +133 -0
  65. package/amplify/shared-stack/settings.js +70 -0
  66. package/amplify/shared-stack/settings.ts +95 -0
  67. package/amplify/site-api-access.js +13 -0
  68. package/amplify/site-api-access.ts +14 -0
  69. package/amplify/site-backend-config.js +7 -1
  70. package/amplify/site-backend-config.ts +8 -2
  71. package/amplify/site-backend.js +65 -13
  72. package/amplify/site-backend.ts +75 -19
  73. package/components/news-desk-taxonomy-client.ts +5 -0
  74. package/components/newsroom-article-editor.tsx +7 -3
  75. package/components/newsroom-board-view.tsx +4 -2
  76. package/components/newsroom-organizer.css +2 -2
  77. package/components/use-newsroom-desk-sections.ts +31 -0
  78. package/infra/amplify-app-shell.js +4 -1
  79. package/infra/amplify-app-shell.ts +4 -1
  80. package/infra/build-specs.js +4 -1
  81. package/infra/build-specs.ts +5 -1
  82. package/infra/cost-tags.test.js +1 -1
  83. package/infra/cost-tags.test.ts +1 -1
  84. package/infra/shared-stack-deny.js +80 -0
  85. package/infra/shared-stack-deny.test.js +56 -0
  86. package/infra/shared-stack-deny.test.ts +66 -0
  87. package/infra/shared-stack-deny.ts +86 -0
  88. package/lib/newsroom-sections.ts +14 -0
  89. package/lib/tenant-keys.js +16 -0
  90. package/lib/tenant-keys.ts +19 -0
  91. package/package.json +2 -1
  92. package/routes.manifest.json +1 -1
@@ -13,6 +13,7 @@ import { monitoringViewSchemaDefinitions } from "../functions/monitoring-view/sc
13
13
  import { contentActions } from "../functions/content-actions/resource.js";
14
14
  import { knowledgeQuery } from "../functions/knowledge-query/resource.js";
15
15
  import { manageUserRole } from "../functions/manage-user-role/resource.js";
16
+ import { tenantClaims } from "../functions/tenant-claims/resource.js";
16
17
  import { modelAttachmentUpload } from "../functions/model-attachment-upload/resource.js";
17
18
  import { newsroomSummary } from "../functions/newsroom-summary/resource.js";
18
19
  import { publicForms } from "../functions/public-forms/resource.js";
@@ -49,7 +50,8 @@ export const OPTIONAL_MODEL_GROUPS = {
49
50
  editorial: ["EditorialCheckRun", "EditorialFeedback", "EditorialPolicy", "EditorialCheckSettings"],
50
51
  steering: ["SteeringProposal", "SteeringDecision", "LexicalSteeringRule"],
51
52
  variations: ["StoryVariation"],
52
- tenancy: ["Tenant", "TenantMembership", "TenantDomain"],
53
+ tenancy: ["Tenant", "TenantMembership", "TenantSelection", "TenantDomain", "SiteDocument", "SiteDocumentVersion"],
54
+ localization: ["LocalizationRequest"],
53
55
  };
54
56
  /**
55
57
  * The groups a bootstrap deploy leaves out (`PAPYRUS_BOOTSTRAP_STAGE=1`, docs/site-hosting.md). Every group is deferred,
@@ -1089,6 +1091,7 @@ function buildBaseDefinitions(excludedGroups = []) {
1089
1091
  assignmentId: a.id(),
1090
1092
  maxCharacters: a.integer(),
1091
1093
  optionalPublicationDoctrine: a.boolean(),
1094
+ tenantId: a.string(), // an IAM caller (the editorial-checks function) names its tenant; a signed-in caller's comes from its token
1092
1095
  })
1093
1096
  .returns(a.json().required())
1094
1097
  .authorization((allow) => [allow.groups(categoryWriteGroups)])
@@ -1412,6 +1415,9 @@ function buildBaseDefinitions(excludedGroups = []) {
1412
1415
  updatedBy: a.string(),
1413
1416
  updatedAt: a.datetime().required(),
1414
1417
  })
1418
+ .secondaryIndexes((index) => [
1419
+ index("tenantId").sortKeys(["id"]).queryField("listAutomationsByTenant"),
1420
+ ])
1415
1421
  .authorization((allow) => [
1416
1422
  allow.group("editor").to(["read", "create", "update"]),
1417
1423
  allow.group(adminGroup).to(authoringOperations),
@@ -1434,6 +1440,9 @@ function buildBaseDefinitions(excludedGroups = []) {
1434
1440
  appliedIn: a.json(),
1435
1441
  updatedAt: a.datetime().required(),
1436
1442
  })
1443
+ .secondaryIndexes((index) => [
1444
+ index("tenantId").sortKeys(["id"]).queryField("listReviewRequestsByTenant"),
1445
+ ])
1437
1446
  .authorization((allow) => [
1438
1447
  allow.group("editor").to(["read", "create", "update"]),
1439
1448
  allow.group(adminGroup).to(authoringOperations),
@@ -1446,6 +1455,9 @@ function buildBaseDefinitions(excludedGroups = []) {
1446
1455
  userKey: a.string().required(),
1447
1456
  readAt: a.datetime().required(),
1448
1457
  })
1458
+ .secondaryIndexes((index) => [
1459
+ index("tenantId").sortKeys(["id"]).queryField("listReviewReadMarksByTenant"),
1460
+ ])
1449
1461
  .authorization((allow) => [
1450
1462
  allow.groups(["editor", adminGroup]).to(["read", "create", "update"]),
1451
1463
  ]),
@@ -1478,6 +1490,7 @@ function buildBaseDefinitions(excludedGroups = []) {
1478
1490
  })
1479
1491
  .secondaryIndexes((index) => [
1480
1492
  index("storyLineageId").sortKeys(["variationNumber"]).queryField("listStoryVariationsByStoryAndNumber"),
1493
+ index("tenantId").sortKeys(["id"]).queryField("listStoryVariationsByTenant"),
1481
1494
  ])
1482
1495
  .authorization((allow) => [
1483
1496
  allow.groups(contentWriteGroups).to(["read", "create", "update"]),
@@ -1493,6 +1506,9 @@ function buildBaseDefinitions(excludedGroups = []) {
1493
1506
  updatedBy: a.string(),
1494
1507
  updatedAt: a.datetime().required(),
1495
1508
  })
1509
+ .secondaryIndexes((index) => [
1510
+ index("tenantId").sortKeys(["id"]).queryField("listReviewRecipientRulesByTenant"),
1511
+ ])
1496
1512
  .authorization((allow) => [
1497
1513
  allow.group("editor").to(["read"]),
1498
1514
  allow.group(adminGroup).to(authoringOperations),
@@ -1584,6 +1600,7 @@ function buildBaseDefinitions(excludedGroups = []) {
1584
1600
  .secondaryIndexes((index) => [
1585
1601
  index("ownerId").sortKeys(["payloadKind"]).queryField("listKnowledgeRawPayloadsByOwnerAndKind"),
1586
1602
  index("importRunId").sortKeys(["ownerType"]).queryField("listKnowledgeRawPayloadsByImportRunAndOwner"),
1603
+ index("tenantId").sortKeys(["id"]).queryField("listKnowledgeRawPayloadsByTenant"),
1587
1604
  ])
1588
1605
  .authorization((allow) => [
1589
1606
  allow.groups(categoryWriteGroups),
@@ -1601,6 +1618,7 @@ function buildBaseDefinitions(excludedGroups = []) {
1601
1618
  })
1602
1619
  .secondaryIndexes((index) => [
1603
1620
  index("grantorSub").sortKeys(["createdAt"]).queryField("listCurationDelegationRecordsByGrantor"),
1621
+ index("tenantId").sortKeys(["id"]).queryField("listCurationDelegationRecordsByTenant"),
1604
1622
  ])
1605
1623
  .authorization((allow) => [allow.groups([adminGroup]).to(["read"])]),
1606
1624
  KnowledgeArtifact: modelWithoutSubscriptions({
@@ -1716,6 +1734,7 @@ function buildBaseDefinitions(excludedGroups = []) {
1716
1734
  index("categoryKey").sortKeys(["rank"]).queryField("listCategoryKeywordsByCategoryKeyAndRank"),
1717
1735
  index("normalizedKeyword").sortKeys(["categorySetId"]).queryField("listCategoryKeywordsByNormalizedKeywordAndSet"),
1718
1736
  index("importRunId").sortKeys(["rank"]).queryField("listCategoryKeywordsByImportRunAndRank"),
1737
+ index("tenantId").sortKeys(["id"]).queryField("listCategoryKeywordsByTenant"),
1719
1738
  ])
1720
1739
  .authorization((allow) => [
1721
1740
  allow.groups(categoryWriteGroups),
@@ -1800,6 +1819,7 @@ function buildBaseDefinitions(excludedGroups = []) {
1800
1819
  .secondaryIndexes((index) => [
1801
1820
  index("proposalId").sortKeys(["createdAt"]).queryField("listSteeringDecisionsByProposalAndCreatedAt"),
1802
1821
  index("categorySetId").sortKeys(["createdAt"]).queryField("listSteeringDecisionsBySetAndCreatedAt"),
1822
+ index("tenantId").sortKeys(["id"]).queryField("listSteeringDecisionsByTenant"),
1803
1823
  ])
1804
1824
  .authorization((allow) => [
1805
1825
  allow.groups(categoryWriteGroups).to(categoryAppendOnlyOperations),
@@ -1956,6 +1976,7 @@ function buildBaseDefinitions(excludedGroups = []) {
1956
1976
  index("referenceLineageId").sortKeys(["sortKey"]).queryField("listReferenceAttachmentsByReferenceLineageAndSortKey"),
1957
1977
  index("storagePath").queryField("referenceAttachmentByStoragePath"),
1958
1978
  index("importRunId").sortKeys(["sortKey"]).queryField("listReferenceAttachmentsByImportRunAndSortKey"),
1979
+ index("tenantId").sortKeys(["id"]).queryField("listReferenceAttachmentsByTenant"),
1959
1980
  ])
1960
1981
  .authorization((allow) => [
1961
1982
  allow.groups(categoryWriteGroups).to(["read"]),
@@ -2000,6 +2021,7 @@ function buildBaseDefinitions(excludedGroups = []) {
2000
2021
  index("corpusId").sortKeys(["nodeKey"]).queryField("listSemanticNodesByCorpusAndNodeKey"),
2001
2022
  index("importRunId").sortKeys(["nodeKey"]).queryField("listSemanticNodesByImportRunAndNodeKey"),
2002
2023
  index("versionState").sortKeys(["updatedAt"]).queryField("listSemanticNodesByVersionStateAndUpdatedAt"),
2024
+ index("tenantId").sortKeys(["id"]).queryField("listSemanticNodesByTenant"),
2003
2025
  ])
2004
2026
  .authorization((allow) => [
2005
2027
  allow.groups(categoryWriteGroups).to(["read"]),
@@ -2204,6 +2226,7 @@ function buildBaseDefinitions(excludedGroups = []) {
2204
2226
  index("importRunId").sortKeys(["importedAt"]).queryField("listSemanticRelationsByImportRunAndImportedAt"),
2205
2227
  index("relationTypeKey").sortKeys(["importedAt"]).queryField("listSemanticRelationsByTypeAndImportedAt"),
2206
2228
  index("relationDomain").sortKeys(["importedAt"]).queryField("listSemanticRelationsByDomainAndImportedAt"),
2229
+ index("tenantId").sortKeys(["id"]).queryField("listSemanticRelationsByTenant"),
2207
2230
  ])
2208
2231
  .authorization((allow) => [
2209
2232
  allow.groups(categoryWriteGroups).to(categoryAppendOnlyOperations),
@@ -2328,6 +2351,7 @@ function buildBaseDefinitions(excludedGroups = []) {
2328
2351
  .secondaryIndexes((index) => [
2329
2352
  index("slug").queryField("tagBySlug"),
2330
2353
  index("type").sortKeys(["label"]).queryField("listTagsByTypeAndLabel"),
2354
+ index("tenantId").sortKeys(["id"]).queryField("listTagsByTenant"),
2331
2355
  ])
2332
2356
  .authorization((allow) => [
2333
2357
  allow.groups(contentWriteGroups),
@@ -2347,6 +2371,7 @@ function buildBaseDefinitions(excludedGroups = []) {
2347
2371
  .secondaryIndexes((index) => [
2348
2372
  index("itemId").sortKeys(["tagSlug"]).queryField("listItemTagsByItemAndTag"),
2349
2373
  index("tagId").sortKeys(["publishedAt"]).queryField("listItemTagsByTagAndPublishedAt"),
2374
+ index("tenantId").sortKeys(["id"]).queryField("listItemTagsByTenant"),
2350
2375
  ])
2351
2376
  .authorization((allow) => [
2352
2377
  allow.groups(contentWriteGroups),
@@ -2432,6 +2457,7 @@ function buildBaseDefinitions(excludedGroups = []) {
2432
2457
  .secondaryIndexes((index) => [
2433
2458
  index("editionId").sortKeys(["sortKey"]).queryField("listEditionItemsByEditionAndSortKey"),
2434
2459
  index("itemId").sortKeys(["editionId"]).queryField("listEditionItemsByItemAndEdition"),
2460
+ index("tenantId").sortKeys(["id"]).queryField("listEditionItemsByTenant"),
2435
2461
  ])
2436
2462
  .authorization((allow) => [
2437
2463
  allow.groups(contentWriteGroups),
@@ -2480,6 +2506,7 @@ function buildBaseDefinitions(excludedGroups = []) {
2480
2506
  index("typeStatus").sortKeys(["publishedAt"]).queryField("listPublishedItemsByTypeStatusAndPublishedAt"),
2481
2507
  index("sectionStatus").sortKeys(["publishedAt"]).queryField("listPublishedItemsBySectionStatusAndPublishedAt"),
2482
2508
  index("itemLineageId").sortKeys(["versionNumber"]).queryField("listPublishedItemsByLineageAndVersion"),
2509
+ index("tenantId").sortKeys(["id"]).queryField("listPublishedItemsByTenant"),
2483
2510
  ])
2484
2511
  .authorization((allow) => [
2485
2512
  allow.guest().to(["read"]),
@@ -2564,6 +2591,7 @@ function buildBaseDefinitions(excludedGroups = []) {
2564
2591
  .secondaryIndexes((index) => [
2565
2592
  index("publishedEditionId").sortKeys(["sortKey"]).queryField("listPublishedEditionItemsByEditionAndSortKey"),
2566
2593
  index("publishedItemId").sortKeys(["publishedEditionId"]).queryField("listPublishedEditionItemsByItemAndEdition"),
2594
+ index("tenantId").sortKeys(["id"]).queryField("listPublishedEditionItemsByTenant"),
2567
2595
  ])
2568
2596
  .authorization((allow) => [
2569
2597
  allow.guest().to(["read"]),
@@ -2624,6 +2652,7 @@ function buildBaseDefinitions(excludedGroups = []) {
2624
2652
  index("parentCategoryId").sortKeys(["rank"]).queryField("listPublishedCategoriesByParentAndRank"),
2625
2653
  index("parentCategoryKey").sortKeys(["rank"]).queryField("listPublishedCategoriesByParentKeyAndRank"),
2626
2654
  index("categoryKey").sortKeys(["publishedCategorySetId"]).queryField("listPublishedCategoriesByKeyAndSet"),
2655
+ index("tenantId").sortKeys(["id"]).queryField("listPublishedCategoriesByTenant"),
2627
2656
  ])
2628
2657
  .authorization((allow) => [
2629
2658
  allow.guest().to(["read"]),
@@ -2668,6 +2697,21 @@ function buildBaseDefinitions(excludedGroups = []) {
2668
2697
  allow.group(adminGroup),
2669
2698
  allow.ownerDefinedIn("tenantId").identityClaim("papyrus_tenant_admin").to(["read"]),
2670
2699
  ]),
2700
+ /**
2701
+ * The site a person's session acts for; id = the person's Cognito sub. The Google sign-in flow cannot tell the token trigger
2702
+ * which site was chosen, so the choice is stored here and the trigger reads it (PPY-0bb0fd). A person writes only their
2703
+ * own row (the owner is the id itself, so nobody can write another person's), and a selection without an active
2704
+ * TenantMembership grants nothing. Group "tenancy".
2705
+ */
2706
+ TenantSelection: modelWithoutSubscriptions({
2707
+ id: a.id().required(),
2708
+ selectedTenantId: a.string().required(),
2709
+ selectedAt: a.datetime().required(),
2710
+ })
2711
+ .authorization((allow) => [
2712
+ allow.group(adminGroup),
2713
+ allow.ownerDefinedIn("id").identityClaim("sub").to(["create", "read", "update"]),
2714
+ ]),
2671
2715
  /** A hostname served for a tenant; id = the lowercase hostname, so it can belong to one tenant only (PPY-31c45c). Group "tenancy". */
2672
2716
  TenantDomain: modelWithoutSubscriptions({
2673
2717
  id: a.id().required(),
@@ -2684,6 +2728,41 @@ function buildBaseDefinitions(excludedGroups = []) {
2684
2728
  allow.group(adminGroup),
2685
2729
  allow.ownerDefinedIn("tenantId").identityClaim("papyrus_tenant_admin").to(["read"]),
2686
2730
  ]),
2731
+ /** The catalogue row of one site document (kind: site | brand | nav); id = "<tenant>#<kind>". The body lives in S3 (PPY-c020ce). Group "tenancy". */
2732
+ SiteDocument: modelWithoutSubscriptions({
2733
+ id: a.id().required(),
2734
+ tenantId: a.string().required(),
2735
+ kind: a.string().required(),
2736
+ currentVersion: a.integer().required(),
2737
+ s3Key: a.string().required(),
2738
+ sha256: a.string().required(),
2739
+ schemaVersion: a.integer().required(),
2740
+ updatedBy: a.string(),
2741
+ updatedAt: a.datetime().required(),
2742
+ })
2743
+ .authorization((allow) => [
2744
+ allow.group(adminGroup),
2745
+ allow.ownerDefinedIn("tenantId").identityClaim("papyrus_tenant_admin").to(["read"]),
2746
+ ]),
2747
+ /** One saved version of a site document; id = "<tenant>#<kind>#<version>". Body in S3 (PPY-c020ce). Group "tenancy". */
2748
+ SiteDocumentVersion: modelWithoutSubscriptions({
2749
+ id: a.id().required(),
2750
+ tenantId: a.string().required(),
2751
+ documentId: a.string().required(),
2752
+ version: a.integer().required(),
2753
+ s3Key: a.string().required(),
2754
+ sha256: a.string().required(),
2755
+ createdBy: a.string(),
2756
+ createdAt: a.datetime().required(),
2757
+ note: a.string(),
2758
+ })
2759
+ .secondaryIndexes((index) => [
2760
+ index("documentId").sortKeys(["version"]).queryField("listSiteDocumentVersionsByDocument"),
2761
+ ])
2762
+ .authorization((allow) => [
2763
+ allow.group(adminGroup),
2764
+ allow.ownerDefinedIn("tenantId").identityClaim("papyrus_tenant_admin").to(["read"]),
2765
+ ]),
2687
2766
  ...editorialChecksSchemaDefinitions,
2688
2767
  ...monitoringViewSchemaDefinitions,
2689
2768
  ...automationViewSchemaDefinitions,
@@ -2716,6 +2795,8 @@ function functionGrants(allow) {
2716
2795
  allow.resource(newsroomSummary),
2717
2796
  allow.resource(procedureAction),
2718
2797
  allow.resource(publicForms).to(["mutate"]),
2798
+ // The token trigger reads TenantMembership and TenantSelection by id; it can query, never write (PPY-0bb0fd).
2799
+ allow.resource(tenantClaims).to(["query"]),
2719
2800
  ];
2720
2801
  }
2721
2802
  /**
@@ -13,6 +13,7 @@ import { monitoringViewSchemaDefinitions } from "../functions/monitoring-view/sc
13
13
  import { contentActions } from "../functions/content-actions/resource";
14
14
  import { knowledgeQuery } from "../functions/knowledge-query/resource";
15
15
  import { manageUserRole } from "../functions/manage-user-role/resource";
16
+ import { tenantClaims } from "../functions/tenant-claims/resource";
16
17
  import { modelAttachmentUpload } from "../functions/model-attachment-upload/resource";
17
18
  import { newsroomSummary } from "../functions/newsroom-summary/resource";
18
19
  import { publicForms } from "../functions/public-forms/resource";
@@ -52,7 +53,8 @@ export const OPTIONAL_MODEL_GROUPS = {
52
53
  editorial: ["EditorialCheckRun", "EditorialFeedback", "EditorialPolicy", "EditorialCheckSettings"],
53
54
  steering: ["SteeringProposal", "SteeringDecision", "LexicalSteeringRule"],
54
55
  variations: ["StoryVariation"],
55
- tenancy: ["Tenant", "TenantMembership", "TenantDomain"],
56
+ tenancy: ["Tenant", "TenantMembership", "TenantSelection", "TenantDomain", "SiteDocument", "SiteDocumentVersion"],
57
+ localization: ["LocalizationRequest"],
56
58
  } as const;
57
59
 
58
60
  /**
@@ -1197,6 +1199,7 @@ const definitions = {
1197
1199
  assignmentId: a.id(),
1198
1200
  maxCharacters: a.integer(),
1199
1201
  optionalPublicationDoctrine: a.boolean(),
1202
+ tenantId: a.string(), // an IAM caller (the editorial-checks function) names its tenant; a signed-in caller's comes from its token
1200
1203
  })
1201
1204
  .returns(a.json().required())
1202
1205
  .authorization((allow) => [allow.groups(categoryWriteGroups)])
@@ -1541,6 +1544,9 @@ const definitions = {
1541
1544
  updatedBy: a.string(),
1542
1545
  updatedAt: a.datetime().required(),
1543
1546
  })
1547
+ .secondaryIndexes((index) => [
1548
+ index("tenantId").sortKeys(["id"]).queryField("listAutomationsByTenant"),
1549
+ ])
1544
1550
  .authorization((allow) => [
1545
1551
  allow.group("editor").to(["read", "create", "update"]),
1546
1552
  allow.group(adminGroup).to(authoringOperations),
@@ -1564,6 +1570,9 @@ const definitions = {
1564
1570
  appliedIn: a.json(),
1565
1571
  updatedAt: a.datetime().required(),
1566
1572
  })
1573
+ .secondaryIndexes((index) => [
1574
+ index("tenantId").sortKeys(["id"]).queryField("listReviewRequestsByTenant"),
1575
+ ])
1567
1576
  .authorization((allow) => [
1568
1577
  allow.group("editor").to(["read", "create", "update"]),
1569
1578
  allow.group(adminGroup).to(authoringOperations),
@@ -1577,6 +1586,9 @@ const definitions = {
1577
1586
  userKey: a.string().required(),
1578
1587
  readAt: a.datetime().required(),
1579
1588
  })
1589
+ .secondaryIndexes((index) => [
1590
+ index("tenantId").sortKeys(["id"]).queryField("listReviewReadMarksByTenant"),
1591
+ ])
1580
1592
  .authorization((allow) => [
1581
1593
  allow.groups(["editor", adminGroup]).to(["read", "create", "update"]),
1582
1594
  ]),
@@ -1610,6 +1622,7 @@ const definitions = {
1610
1622
  })
1611
1623
  .secondaryIndexes((index) => [
1612
1624
  index("storyLineageId").sortKeys(["variationNumber"]).queryField("listStoryVariationsByStoryAndNumber"),
1625
+ index("tenantId").sortKeys(["id"]).queryField("listStoryVariationsByTenant"),
1613
1626
  ])
1614
1627
  .authorization((allow) => [
1615
1628
  allow.groups(contentWriteGroups).to(["read", "create", "update"]),
@@ -1626,6 +1639,9 @@ const definitions = {
1626
1639
  updatedBy: a.string(),
1627
1640
  updatedAt: a.datetime().required(),
1628
1641
  })
1642
+ .secondaryIndexes((index) => [
1643
+ index("tenantId").sortKeys(["id"]).queryField("listReviewRecipientRulesByTenant"),
1644
+ ])
1629
1645
  .authorization((allow) => [
1630
1646
  allow.group("editor").to(["read"]),
1631
1647
  allow.group(adminGroup).to(authoringOperations),
@@ -1721,6 +1737,7 @@ const definitions = {
1721
1737
  .secondaryIndexes((index) => [
1722
1738
  index("ownerId").sortKeys(["payloadKind"]).queryField("listKnowledgeRawPayloadsByOwnerAndKind"),
1723
1739
  index("importRunId").sortKeys(["ownerType"]).queryField("listKnowledgeRawPayloadsByImportRunAndOwner"),
1740
+ index("tenantId").sortKeys(["id"]).queryField("listKnowledgeRawPayloadsByTenant"),
1724
1741
  ])
1725
1742
  .authorization((allow) => [
1726
1743
  allow.groups(categoryWriteGroups),
@@ -1739,6 +1756,7 @@ const definitions = {
1739
1756
  })
1740
1757
  .secondaryIndexes((index) => [
1741
1758
  index("grantorSub").sortKeys(["createdAt"]).queryField("listCurationDelegationRecordsByGrantor"),
1759
+ index("tenantId").sortKeys(["id"]).queryField("listCurationDelegationRecordsByTenant"),
1742
1760
  ])
1743
1761
  .authorization((allow) => [allow.groups([adminGroup]).to(["read"])]),
1744
1762
 
@@ -1858,6 +1876,7 @@ const definitions = {
1858
1876
  index("categoryKey").sortKeys(["rank"]).queryField("listCategoryKeywordsByCategoryKeyAndRank"),
1859
1877
  index("normalizedKeyword").sortKeys(["categorySetId"]).queryField("listCategoryKeywordsByNormalizedKeywordAndSet"),
1860
1878
  index("importRunId").sortKeys(["rank"]).queryField("listCategoryKeywordsByImportRunAndRank"),
1879
+ index("tenantId").sortKeys(["id"]).queryField("listCategoryKeywordsByTenant"),
1861
1880
  ])
1862
1881
  .authorization((allow) => [
1863
1882
  allow.groups(categoryWriteGroups),
@@ -1945,6 +1964,7 @@ const definitions = {
1945
1964
  .secondaryIndexes((index) => [
1946
1965
  index("proposalId").sortKeys(["createdAt"]).queryField("listSteeringDecisionsByProposalAndCreatedAt"),
1947
1966
  index("categorySetId").sortKeys(["createdAt"]).queryField("listSteeringDecisionsBySetAndCreatedAt"),
1967
+ index("tenantId").sortKeys(["id"]).queryField("listSteeringDecisionsByTenant"),
1948
1968
  ])
1949
1969
  .authorization((allow) => [
1950
1970
  allow.groups(categoryWriteGroups).to(categoryAppendOnlyOperations),
@@ -2103,6 +2123,7 @@ const definitions = {
2103
2123
  index("referenceLineageId").sortKeys(["sortKey"]).queryField("listReferenceAttachmentsByReferenceLineageAndSortKey"),
2104
2124
  index("storagePath").queryField("referenceAttachmentByStoragePath"),
2105
2125
  index("importRunId").sortKeys(["sortKey"]).queryField("listReferenceAttachmentsByImportRunAndSortKey"),
2126
+ index("tenantId").sortKeys(["id"]).queryField("listReferenceAttachmentsByTenant"),
2106
2127
  ])
2107
2128
  .authorization((allow) => [
2108
2129
  allow.groups(categoryWriteGroups).to(["read"]),
@@ -2148,6 +2169,7 @@ const definitions = {
2148
2169
  index("corpusId").sortKeys(["nodeKey"]).queryField("listSemanticNodesByCorpusAndNodeKey"),
2149
2170
  index("importRunId").sortKeys(["nodeKey"]).queryField("listSemanticNodesByImportRunAndNodeKey"),
2150
2171
  index("versionState").sortKeys(["updatedAt"]).queryField("listSemanticNodesByVersionStateAndUpdatedAt"),
2172
+ index("tenantId").sortKeys(["id"]).queryField("listSemanticNodesByTenant"),
2151
2173
  ])
2152
2174
  .authorization((allow) => [
2153
2175
  allow.groups(categoryWriteGroups).to(["read"]),
@@ -2357,6 +2379,7 @@ const definitions = {
2357
2379
  index("importRunId").sortKeys(["importedAt"]).queryField("listSemanticRelationsByImportRunAndImportedAt"),
2358
2380
  index("relationTypeKey").sortKeys(["importedAt"]).queryField("listSemanticRelationsByTypeAndImportedAt"),
2359
2381
  index("relationDomain").sortKeys(["importedAt"]).queryField("listSemanticRelationsByDomainAndImportedAt"),
2382
+ index("tenantId").sortKeys(["id"]).queryField("listSemanticRelationsByTenant"),
2360
2383
  ])
2361
2384
  .authorization((allow) => [
2362
2385
  allow.groups(categoryWriteGroups).to(categoryAppendOnlyOperations),
@@ -2484,6 +2507,7 @@ const definitions = {
2484
2507
  .secondaryIndexes((index) => [
2485
2508
  index("slug").queryField("tagBySlug"),
2486
2509
  index("type").sortKeys(["label"]).queryField("listTagsByTypeAndLabel"),
2510
+ index("tenantId").sortKeys(["id"]).queryField("listTagsByTenant"),
2487
2511
  ])
2488
2512
  .authorization((allow) => [
2489
2513
  allow.groups(contentWriteGroups),
@@ -2504,6 +2528,7 @@ const definitions = {
2504
2528
  .secondaryIndexes((index) => [
2505
2529
  index("itemId").sortKeys(["tagSlug"]).queryField("listItemTagsByItemAndTag"),
2506
2530
  index("tagId").sortKeys(["publishedAt"]).queryField("listItemTagsByTagAndPublishedAt"),
2531
+ index("tenantId").sortKeys(["id"]).queryField("listItemTagsByTenant"),
2507
2532
  ])
2508
2533
  .authorization((allow) => [
2509
2534
  allow.groups(contentWriteGroups),
@@ -2592,6 +2617,7 @@ const definitions = {
2592
2617
  .secondaryIndexes((index) => [
2593
2618
  index("editionId").sortKeys(["sortKey"]).queryField("listEditionItemsByEditionAndSortKey"),
2594
2619
  index("itemId").sortKeys(["editionId"]).queryField("listEditionItemsByItemAndEdition"),
2620
+ index("tenantId").sortKeys(["id"]).queryField("listEditionItemsByTenant"),
2595
2621
  ])
2596
2622
  .authorization((allow) => [
2597
2623
  allow.groups(contentWriteGroups),
@@ -2641,6 +2667,7 @@ const definitions = {
2641
2667
  index("typeStatus").sortKeys(["publishedAt"]).queryField("listPublishedItemsByTypeStatusAndPublishedAt"),
2642
2668
  index("sectionStatus").sortKeys(["publishedAt"]).queryField("listPublishedItemsBySectionStatusAndPublishedAt"),
2643
2669
  index("itemLineageId").sortKeys(["versionNumber"]).queryField("listPublishedItemsByLineageAndVersion"),
2670
+ index("tenantId").sortKeys(["id"]).queryField("listPublishedItemsByTenant"),
2644
2671
  ])
2645
2672
  .authorization((allow) => [
2646
2673
  allow.guest().to(["read"]),
@@ -2728,6 +2755,7 @@ const definitions = {
2728
2755
  .secondaryIndexes((index) => [
2729
2756
  index("publishedEditionId").sortKeys(["sortKey"]).queryField("listPublishedEditionItemsByEditionAndSortKey"),
2730
2757
  index("publishedItemId").sortKeys(["publishedEditionId"]).queryField("listPublishedEditionItemsByItemAndEdition"),
2758
+ index("tenantId").sortKeys(["id"]).queryField("listPublishedEditionItemsByTenant"),
2731
2759
  ])
2732
2760
  .authorization((allow) => [
2733
2761
  allow.guest().to(["read"]),
@@ -2790,6 +2818,7 @@ const definitions = {
2790
2818
  index("parentCategoryId").sortKeys(["rank"]).queryField("listPublishedCategoriesByParentAndRank"),
2791
2819
  index("parentCategoryKey").sortKeys(["rank"]).queryField("listPublishedCategoriesByParentKeyAndRank"),
2792
2820
  index("categoryKey").sortKeys(["publishedCategorySetId"]).queryField("listPublishedCategoriesByKeyAndSet"),
2821
+ index("tenantId").sortKeys(["id"]).queryField("listPublishedCategoriesByTenant"),
2793
2822
  ])
2794
2823
  .authorization((allow) => [
2795
2824
  allow.guest().to(["read"]),
@@ -2836,6 +2865,22 @@ const definitions = {
2836
2865
  allow.ownerDefinedIn("tenantId").identityClaim("papyrus_tenant_admin").to(["read"]),
2837
2866
  ]),
2838
2867
 
2868
+ /**
2869
+ * The site a person's session acts for; id = the person's Cognito sub. The Google sign-in flow cannot tell the token trigger
2870
+ * which site was chosen, so the choice is stored here and the trigger reads it (PPY-0bb0fd). A person writes only their
2871
+ * own row (the owner is the id itself, so nobody can write another person's), and a selection without an active
2872
+ * TenantMembership grants nothing. Group "tenancy".
2873
+ */
2874
+ TenantSelection: modelWithoutSubscriptions({
2875
+ id: a.id().required(),
2876
+ selectedTenantId: a.string().required(),
2877
+ selectedAt: a.datetime().required(),
2878
+ })
2879
+ .authorization((allow) => [
2880
+ allow.group(adminGroup),
2881
+ allow.ownerDefinedIn("id").identityClaim("sub").to(["create", "read", "update"]),
2882
+ ]),
2883
+
2839
2884
  /** A hostname served for a tenant; id = the lowercase hostname, so it can belong to one tenant only (PPY-31c45c). Group "tenancy". */
2840
2885
  TenantDomain: modelWithoutSubscriptions({
2841
2886
  id: a.id().required(),
@@ -2853,6 +2898,43 @@ const definitions = {
2853
2898
  allow.ownerDefinedIn("tenantId").identityClaim("papyrus_tenant_admin").to(["read"]),
2854
2899
  ]),
2855
2900
 
2901
+ /** The catalogue row of one site document (kind: site | brand | nav); id = "<tenant>#<kind>". The body lives in S3 (PPY-c020ce). Group "tenancy". */
2902
+ SiteDocument: modelWithoutSubscriptions({
2903
+ id: a.id().required(),
2904
+ tenantId: a.string().required(),
2905
+ kind: a.string().required(),
2906
+ currentVersion: a.integer().required(),
2907
+ s3Key: a.string().required(),
2908
+ sha256: a.string().required(),
2909
+ schemaVersion: a.integer().required(),
2910
+ updatedBy: a.string(),
2911
+ updatedAt: a.datetime().required(),
2912
+ })
2913
+ .authorization((allow) => [
2914
+ allow.group(adminGroup),
2915
+ allow.ownerDefinedIn("tenantId").identityClaim("papyrus_tenant_admin").to(["read"]),
2916
+ ]),
2917
+
2918
+ /** One saved version of a site document; id = "<tenant>#<kind>#<version>". Body in S3 (PPY-c020ce). Group "tenancy". */
2919
+ SiteDocumentVersion: modelWithoutSubscriptions({
2920
+ id: a.id().required(),
2921
+ tenantId: a.string().required(),
2922
+ documentId: a.string().required(),
2923
+ version: a.integer().required(),
2924
+ s3Key: a.string().required(),
2925
+ sha256: a.string().required(),
2926
+ createdBy: a.string(),
2927
+ createdAt: a.datetime().required(),
2928
+ note: a.string(),
2929
+ })
2930
+ .secondaryIndexes((index) => [
2931
+ index("documentId").sortKeys(["version"]).queryField("listSiteDocumentVersionsByDocument"),
2932
+ ])
2933
+ .authorization((allow) => [
2934
+ allow.group(adminGroup),
2935
+ allow.ownerDefinedIn("tenantId").identityClaim("papyrus_tenant_admin").to(["read"]),
2936
+ ]),
2937
+
2856
2938
  ...editorialChecksSchemaDefinitions,
2857
2939
  ...monitoringViewSchemaDefinitions,
2858
2940
  ...automationViewSchemaDefinitions,
@@ -2887,6 +2969,8 @@ function functionGrants(allow: any) {
2887
2969
  allow.resource(newsroomSummary),
2888
2970
  allow.resource(procedureAction),
2889
2971
  allow.resource(publicForms).to(["mutate"]),
2972
+ // The token trigger reads TenantMembership and TenantSelection by id; it can query, never write (PPY-0bb0fd).
2973
+ allow.resource(tenantClaims).to(["query"]),
2890
2974
  ];
2891
2975
  }
2892
2976
 
@@ -1,5 +1,6 @@
1
1
  import { assignmentDoctrine, resolveEditorialContext, type EditorialClient } from "../shared/editorial-context";
2
- import { tenantIdFromEnvironment } from "../../../lib/tenant-keys";
2
+ import { actingFor, buildEventTenantContext, currentTenantContext } from "../shared/tenant-context";
3
+ import { newsroomSummaryPayloadId, tenantScopedClient } from "../shared/tenant-scoped-client";
3
4
  import { randomUUID } from "node:crypto";
4
5
  import { spawnSync } from "node:child_process";
5
6
  import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
@@ -32,13 +33,17 @@ type DataClientResult<T = unknown> = {
32
33
 
33
34
  const FINAL_STATUSES = new Set(["completed", "canceled"]);
34
35
  const IMMEDIATE_ASSIGNMENT_TYPES = new Set(["procedure.run"]);
35
- const NEWSROOM_SUMMARY_PAYLOAD_ID = "knowledge-raw-payload-newsroom-summary-current";
36
36
  const NEWSROOM_SUMMARY_PAYLOAD_OWNER_KIND = "knowledgeRawPayload";
37
37
  const SUMMARY_STALE_AFTER_MS = 15 * 60 * 1000;
38
38
  let clientPromise: Promise<DataClient> | null = null;
39
39
  let editorialEndpoint: string | undefined;
40
40
 
41
41
  export const handler = async (event: any): Promise<any> => {
42
+ const context = buildEventTenantContext(event); // one context per call; a shared stack refuses before any read
43
+ return actingFor(context, () => handleField(event));
44
+ };
45
+
46
+ async function handleField(event: any): Promise<any> {
42
47
  const fieldName = normalizeRequiredString(event.info?.fieldName ?? event.fieldName, "fieldName");
43
48
  if (fieldName === "getEditorialContext") return getEditorialContext(event as Parameters<Schema["getEditorialContext"]["functionHandler"]>[0]);
44
49
  if (fieldName === "getAssignmentContext") return getAssignmentContext(event as Parameters<Schema["getAssignmentContext"]["functionHandler"]>[0]);
@@ -46,7 +51,7 @@ export const handler = async (event: any): Promise<any> => {
46
51
  if (fieldName === "listAssignmentsForObject") return listAssignmentsForObject(event as Parameters<Schema["listAssignmentsForObject"]["functionHandler"]>[0]);
47
52
  if (fieldName === "retryImmediateAssignment") return retryImmediateAssignment(event as Parameters<Schema["retryImmediateAssignment"]["functionHandler"]>[0]);
48
53
  return mutateAssignment(event as Parameters<Schema["claimAssignment"]["functionHandler"]>[0], fieldName);
49
- };
54
+ }
50
55
 
51
56
  async function mutateAssignment(event: Parameters<Schema["claimAssignment"]["functionHandler"]>[0], fieldName: string) {
52
57
  const client = await getDataClient();
@@ -231,7 +236,7 @@ async function updateNewsroomSummaryForAssignmentAction(
231
236
  client: DataClient,
232
237
  input: { assignmentTypeKey: string | null; sectionKey: string | null; previousStatus: string | null; nextStatus: string | null; now: string },
233
238
  ): Promise<void> {
234
- const response = await client.models.KnowledgeRawPayload.get({ id: NEWSROOM_SUMMARY_PAYLOAD_ID });
239
+ const response = await client.models.KnowledgeRawPayload.get({ id: newsroomSummaryPayloadId(currentTenantContext()) });
235
240
  assertNoDataErrors(response.errors, "get Newsroom summary snapshot");
236
241
  const payload = normalizeSummaryPayload(await readNewsroomSummaryPayload(client), input.now);
237
242
  payload.generatedAt = input.now;
@@ -319,7 +324,7 @@ async function listAssignmentsForObject(event: Parameters<Schema["listAssignment
319
324
  async function editorialContext(client: DataClient, scope: { publicationKey?: string; sectionId?: string | null; storyLineageId?: string | null; assignmentId?: string | null; maxCharacters?: number | null; optionalPublicationDoctrine?: boolean | null }) {
320
325
  if (!editorialEndpoint) throw new Error("Editorial context requires the configured backend endpoint.");
321
326
  return resolveEditorialContext(client as unknown as EditorialClient, {
322
- ...scope, endpoint: editorialEndpoint, tenantId: tenantIdFromEnvironment(), includeGuidelines: true, readAttachment: readEditorialAttachment,
327
+ ...scope, endpoint: editorialEndpoint, tenantId: currentTenantContext().tenantId ?? undefined, includeGuidelines: true, readAttachment: readEditorialAttachment,
323
328
  });
324
329
  }
325
330
 
@@ -1023,7 +1028,7 @@ async function getDataClient(): Promise<DataClient> {
1023
1028
  return generateClient<Schema>();
1024
1029
  })();
1025
1030
  }
1026
- return clientPromise;
1031
+ return tenantScopedClient(await clientPromise, currentTenantContext());
1027
1032
  }
1028
1033
 
1029
1034
  async function getRequiredRecord(
@@ -1201,7 +1206,7 @@ async function upsertNewsroomSummaryPayload(
1201
1206
  now: string,
1202
1207
  ): Promise<void> {
1203
1208
  const input = {
1204
- id: NEWSROOM_SUMMARY_PAYLOAD_ID,
1209
+ id: newsroomSummaryPayloadId(currentTenantContext()),
1205
1210
  ownerType: "newsroom",
1206
1211
  ownerId: "newsroom",
1207
1212
  payloadKind: "summary-snapshot",
@@ -1216,7 +1221,7 @@ async function upsertNewsroomSummaryPayload(
1216
1221
  }
1217
1222
  await putJsonModelPayload(
1218
1223
  client as any,
1219
- { ownerKind: NEWSROOM_SUMMARY_PAYLOAD_OWNER_KIND, ownerId: NEWSROOM_SUMMARY_PAYLOAD_ID, importRunId: input.importRunId },
1224
+ { ownerKind: NEWSROOM_SUMMARY_PAYLOAD_OWNER_KIND, ownerId: newsroomSummaryPayloadId(currentTenantContext()), importRunId: input.importRunId },
1220
1225
  "raw_payload",
1221
1226
  "summary-snapshot",
1222
1227
  payload,
@@ -1228,7 +1233,7 @@ async function readNewsroomSummaryPayload(client: DataClient): Promise<Record<st
1228
1233
  return readJsonModelPayload(
1229
1234
  client as any,
1230
1235
  NEWSROOM_SUMMARY_PAYLOAD_OWNER_KIND,
1231
- NEWSROOM_SUMMARY_PAYLOAD_ID,
1236
+ newsroomSummaryPayloadId(currentTenantContext()),
1232
1237
  "raw_payload",
1233
1238
  "summary-snapshot",
1234
1239
  );
@@ -1,6 +1,7 @@
1
1
  import { Stack } from "aws-cdk-lib";
2
2
  import { Effect, PolicyStatement } from "aws-cdk-lib/aws-iam";
3
3
  import { MONITORING_TABLE_PARAMETER, MONITORING_VIEW_TABLE_ACTIONS, monitoringViewParameterArn, monitoringViewTableArns, } from "../monitoring-view/wire.js";
4
+ import { connectToSiteApi } from "../../site-api-access.js";
4
5
  /** The reads the function makes of its own site's API with its own role. It writes nothing there. */
5
6
  export const AUTOMATION_VIEW_FUNCTION_FIELDS = [
6
7
  "Query/fields/getAutomation",
@@ -23,7 +24,7 @@ export const AUTOMATION_RUN_NOW_LEADING_KEYS = ["MONITOR#*"];
23
24
  export function wireAutomationView(backend) {
24
25
  const lambda = backend.automationView.resources.lambda;
25
26
  const stack = Stack.of(lambda);
26
- lambda.addEnvironment("PAPYRUS_GRAPHQL_ENDPOINT", backend.data.resources.cfnResources.cfnGraphqlApi.attrGraphQlUrl);
27
+ connectToSiteApi(lambda, backend.data.resources.cfnResources.cfnGraphqlApi.attrGraphQlUrl);
27
28
  lambda.addEnvironment("PAPYRUS_MONITORING_TABLE_PARAMETER", MONITORING_TABLE_PARAMETER);
28
29
  lambda.addEnvironment("PROCEDURE_RUNNER_FUNCTION", PROCEDURE_RUNNER_FUNCTION_NAME);
29
30
  const apiId = backend.data.resources.graphqlApi.apiId;
@@ -7,6 +7,7 @@ import {
7
7
  monitoringViewParameterArn,
8
8
  monitoringViewTableArns,
9
9
  } from "../monitoring-view/wire";
10
+ import { connectToSiteApi } from "../../site-api-access";
10
11
 
11
12
  /** The reads the function makes of its own site's API with its own role. It writes nothing there. */
12
13
  export const AUTOMATION_VIEW_FUNCTION_FIELDS = [
@@ -33,7 +34,7 @@ export const AUTOMATION_RUN_NOW_LEADING_KEYS = ["MONITOR#*"];
33
34
  export function wireAutomationView(backend: any): void {
34
35
  const lambda = backend.automationView.resources.lambda as LambdaFunction;
35
36
  const stack = Stack.of(lambda);
36
- lambda.addEnvironment("PAPYRUS_GRAPHQL_ENDPOINT", backend.data.resources.cfnResources.cfnGraphqlApi.attrGraphQlUrl as string);
37
+ connectToSiteApi(lambda, backend.data.resources.cfnResources.cfnGraphqlApi.attrGraphQlUrl as string);
37
38
  lambda.addEnvironment("PAPYRUS_MONITORING_TABLE_PARAMETER", MONITORING_TABLE_PARAMETER);
38
39
  lambda.addEnvironment("PROCEDURE_RUNNER_FUNCTION", PROCEDURE_RUNNER_FUNCTION_NAME);
39
40
  const apiId = backend.data.resources.graphqlApi.apiId as string;