@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
@@ -1,5 +1,6 @@
1
1
  import { defineAuth, secret } from "@aws-amplify/backend";
2
2
  import { manageUserRole } from "../functions/manage-user-role/resource.js";
3
+ import { tenantClaims } from "../functions/tenant-claims/resource.js";
3
4
  import { CfnUserPoolDomain, CfnUserPoolIdentityProvider } from "aws-cdk-lib/aws-cognito";
4
5
  import { expandNewsroomRedirectUrls } from "./redirect-urls.js";
5
6
  // Default OAuth redirect URLs for the p.apyr.us app. Other publications pass
@@ -76,6 +77,8 @@ export function defineSiteAuth(config, extraCallbackUrls = []) {
76
77
  }),
77
78
  },
78
79
  groups: ["admin", "editor", "curator"],
80
+ // Wired as version 1 by Amplify; amplify/auth/tenant-session-claims.ts moves it to version 2 (access-token claims).
81
+ triggers: { preTokenGeneration: tenantClaims },
79
82
  access: (allow) => [
80
83
  allow.resource(manageUserRole).to(["addUserToGroup", "removeUserFromGroup", "listUsers", "listGroupsForUser"]),
81
84
  ],
@@ -1,5 +1,6 @@
1
1
  import { defineAuth, secret } from "@aws-amplify/backend";
2
2
  import { manageUserRole } from "../functions/manage-user-role/resource";
3
+ import { tenantClaims } from "../functions/tenant-claims/resource";
3
4
  import { Stack } from "aws-cdk-lib";
4
5
  import { CfnUserPoolDomain, CfnUserPoolIdentityProvider } from "aws-cdk-lib/aws-cognito";
5
6
  import type { PapyrusAuthConfig } from "../site-backend-config";
@@ -88,6 +89,8 @@ export function defineSiteAuth(config: PapyrusAuthConfig, extraCallbackUrls: rea
88
89
  }),
89
90
  },
90
91
  groups: ["admin", "editor", "curator"],
92
+ // Wired as version 1 by Amplify; amplify/auth/tenant-session-claims.ts moves it to version 2 (access-token claims).
93
+ triggers: { preTokenGeneration: tenantClaims },
91
94
  access: (allow) => [
92
95
  allow.resource(manageUserRole).to(["addUserToGroup", "removeUserFromGroup", "listUsers", "listGroupsForUser"]),
93
96
  ],
@@ -0,0 +1,27 @@
1
+ import { TENANCY_MODELS_ENVIRONMENT_VARIABLE } from "../functions/tenant-claims/environment.js";
2
+ /** The Cognito feature plan that supports pre-token-generation event version 2 (access-token claims). Lite does not. */
3
+ export const TENANT_CLAIMS_USER_POOL_TIER = "ESSENTIALS";
4
+ /** The pre-token-generation event version that customises the access token as well as the ID token. */
5
+ export const TENANT_CLAIMS_TRIGGER_VERSION = "V2_0";
6
+ /**
7
+ * Wire the tenant claims function as the pool's pre-token-generation trigger at event version 2 (PPY-0bb0fd).
8
+ *
9
+ * Amplify's `triggers.preTokenGeneration` wires version 1, which customises only the ID token, and the Amplify data client
10
+ * sends the access token. The CDK escape hatch below moves the same function to `PreTokenGenerationConfig` at `V2_0` and
11
+ * removes the version 1 entry (the two must not both be set). Version 2 needs the Cognito Essentials plan, so the pool's
12
+ * `UserPoolTier` is set to it; that is a plan and cost change for every site that deploys this.
13
+ *
14
+ * `tenancyModelsDeployed` says whether TenantMembership and TenantSelection exist (the `tenancy` model group is deployed; a
15
+ * bootstrap deploy leaves it out). When they do not, the function reads nothing and emits only a dedicated stack's group claims.
16
+ */
17
+ export function applyTenantSessionClaims(cfnUserPool, trigger, tenancyModelsDeployed) {
18
+ cfnUserPool.userPoolTier = TENANT_CLAIMS_USER_POOL_TIER;
19
+ cfnUserPool.addPropertyDeletionOverride("LambdaConfig.PreTokenGeneration");
20
+ cfnUserPool.addPropertyOverride("LambdaConfig.PreTokenGenerationConfig", {
21
+ LambdaArn: trigger.functionArn,
22
+ LambdaVersion: TENANT_CLAIMS_TRIGGER_VERSION,
23
+ });
24
+ if (tenancyModelsDeployed) {
25
+ trigger.addEnvironment(TENANCY_MODELS_ENVIRONMENT_VARIABLE, "true");
26
+ }
27
+ }
@@ -0,0 +1,31 @@
1
+ import type { CfnUserPool } from "aws-cdk-lib/aws-cognito";
2
+ import type { IFunction } from "aws-cdk-lib/aws-lambda";
3
+ import { TENANCY_MODELS_ENVIRONMENT_VARIABLE } from "../functions/tenant-claims/environment";
4
+
5
+ /** The Cognito feature plan that supports pre-token-generation event version 2 (access-token claims). Lite does not. */
6
+ export const TENANT_CLAIMS_USER_POOL_TIER = "ESSENTIALS";
7
+ /** The pre-token-generation event version that customises the access token as well as the ID token. */
8
+ export const TENANT_CLAIMS_TRIGGER_VERSION = "V2_0";
9
+
10
+ /**
11
+ * Wire the tenant claims function as the pool's pre-token-generation trigger at event version 2 (PPY-0bb0fd).
12
+ *
13
+ * Amplify's `triggers.preTokenGeneration` wires version 1, which customises only the ID token, and the Amplify data client
14
+ * sends the access token. The CDK escape hatch below moves the same function to `PreTokenGenerationConfig` at `V2_0` and
15
+ * removes the version 1 entry (the two must not both be set). Version 2 needs the Cognito Essentials plan, so the pool's
16
+ * `UserPoolTier` is set to it; that is a plan and cost change for every site that deploys this.
17
+ *
18
+ * `tenancyModelsDeployed` says whether TenantMembership and TenantSelection exist (the `tenancy` model group is deployed; a
19
+ * bootstrap deploy leaves it out). When they do not, the function reads nothing and emits only a dedicated stack's group claims.
20
+ */
21
+ export function applyTenantSessionClaims(cfnUserPool: CfnUserPool, trigger: IFunction, tenancyModelsDeployed: boolean): void {
22
+ cfnUserPool.userPoolTier = TENANT_CLAIMS_USER_POOL_TIER;
23
+ cfnUserPool.addPropertyDeletionOverride("LambdaConfig.PreTokenGeneration");
24
+ cfnUserPool.addPropertyOverride("LambdaConfig.PreTokenGenerationConfig", {
25
+ LambdaArn: trigger.functionArn,
26
+ LambdaVersion: TENANT_CLAIMS_TRIGGER_VERSION,
27
+ });
28
+ if (tenancyModelsDeployed) {
29
+ (trigger as IFunction & { addEnvironment(key: string, value: string): unknown }).addEnvironment(TENANCY_MODELS_ENVIRONMENT_VARIABLE, "true");
30
+ }
31
+ }
@@ -5,6 +5,8 @@ import path from "node:path";
5
5
  import { applyCostTagWaves, costTagWave } from "./cost-tag-waves.js";
6
6
  import { costTags } from "./vendor/anthus-cost-accounting/tags.js";
7
7
  import { OWNER } from "./vendor/anthus-cost-accounting/cdk.js";
8
+ import { isReservedDeployment } from "./shared-stack/names.js";
9
+ import { SHARED } from "./vendor/anthus-cost-accounting/tags.js";
8
10
  /**
9
11
  * Prospectus cost accounting in a site's Amplify backend (Prospectus docs/COST_ACCOUNTING.md).
10
12
  *
@@ -49,8 +51,18 @@ export function siteCostAttribution(env = process.env, root = process.cwd()) {
49
51
  }
50
52
  if (!SITE_ID.test(siteId))
51
53
  throw new Error("The site ID must be lower-case letters, digits and hyphens.");
54
+ if (isReservedDeployment(siteId))
55
+ throw new Error(`The site ID ${siteId} is a deployment value of the shared tier (shared, shared-prod, shared-staging); a dedicated site cannot use it.`);
52
56
  return { account: OWNER, app: "papyrus", deployment: siteId, wave };
53
57
  }
58
+ /**
59
+ * A shared stack's cost attribution: account `shared` (Prospectus splits the cost by each tenant's reported usage) and the
60
+ * tier's own deployment value, so each stack has its own line in Cost Explorer and its own budget. Always every wave: a
61
+ * shared stack is created fresh by the pipeline, so there is no earlier release to split the tagging across.
62
+ */
63
+ export function sharedStackCostAttribution(plan) {
64
+ return { account: SHARED, app: "papyrus", deployment: plan.deployment, wave: Number.POSITIVE_INFINITY };
65
+ }
54
66
  /**
55
67
  * Tags the backend's resources, in every nested stack, up to the build's wave. `first` names stacks that change in
56
68
  * the first pass anyway (the usage senders'), so their tags arrive in the same operation.
@@ -6,6 +6,8 @@ import path from "node:path";
6
6
  import { applyCostTagWaves, costTagWave } from "./cost-tag-waves";
7
7
  import { costTags } from "./vendor/anthus-cost-accounting/tags";
8
8
  import { OWNER, type CostTagConfiguration } from "./vendor/anthus-cost-accounting/cdk";
9
+ import { isReservedDeployment, type SharedTierPlan } from "./shared-stack/names";
10
+ import { SHARED } from "./vendor/anthus-cost-accounting/tags";
9
11
 
10
12
  /**
11
13
  * Prospectus cost accounting in a site's Amplify backend (Prospectus docs/COST_ACCOUNTING.md).
@@ -54,9 +56,19 @@ export function siteCostAttribution(env: Record<string, string | undefined> = pr
54
56
  );
55
57
  }
56
58
  if (!SITE_ID.test(siteId)) throw new Error("The site ID must be lower-case letters, digits and hyphens.");
59
+ if (isReservedDeployment(siteId)) throw new Error(`The site ID ${siteId} is a deployment value of the shared tier (shared, shared-prod, shared-staging); a dedicated site cannot use it.`);
57
60
  return { account: OWNER, app: "papyrus", deployment: siteId, wave };
58
61
  }
59
62
 
63
+ /**
64
+ * A shared stack's cost attribution: account `shared` (Prospectus splits the cost by each tenant's reported usage) and the
65
+ * tier's own deployment value, so each stack has its own line in Cost Explorer and its own budget. Always every wave: a
66
+ * shared stack is created fresh by the pipeline, so there is no earlier release to split the tagging across.
67
+ */
68
+ export function sharedStackCostAttribution(plan: SharedTierPlan): SiteCostAttribution {
69
+ return { account: SHARED, app: "papyrus", deployment: plan.deployment, wave: Number.POSITIVE_INFINITY };
70
+ }
71
+
60
72
  /**
61
73
  * Tags the backend's resources, in every nested stack, up to the build's wave. `first` names stacks that change in
62
74
  * the first pass anyway (the usage senders'), so their tags arrive in the same operation.
@@ -1442,6 +1442,9 @@ const schema = a.schema({
1442
1442
  updatedBy: a.string(),
1443
1443
  updatedAt: a.datetime().required(),
1444
1444
  })
1445
+ .secondaryIndexes((index) => [
1446
+ index("tenantId").sortKeys(["id"]).queryField("listAutomationsByTenant"),
1447
+ ])
1445
1448
  .authorization((allow) => [
1446
1449
  allow.group("editor").to(["read", "create", "update"]),
1447
1450
  allow.group(adminGroup).to(authoringOperations),
@@ -1465,6 +1468,9 @@ const schema = a.schema({
1465
1468
  appliedIn: a.json(),
1466
1469
  updatedAt: a.datetime().required(),
1467
1470
  })
1471
+ .secondaryIndexes((index) => [
1472
+ index("tenantId").sortKeys(["id"]).queryField("listReviewRequestsByTenant"),
1473
+ ])
1468
1474
  .authorization((allow) => [
1469
1475
  allow.group("editor").to(["read", "create", "update"]),
1470
1476
  allow.group(adminGroup).to(authoringOperations),
@@ -1478,6 +1484,9 @@ const schema = a.schema({
1478
1484
  userKey: a.string().required(),
1479
1485
  readAt: a.datetime().required(),
1480
1486
  })
1487
+ .secondaryIndexes((index) => [
1488
+ index("tenantId").sortKeys(["id"]).queryField("listReviewReadMarksByTenant"),
1489
+ ])
1481
1490
  .authorization((allow) => [
1482
1491
  allow.groups(["editor", adminGroup]).to(["read", "create", "update"]),
1483
1492
  ]),
@@ -1511,6 +1520,7 @@ const schema = a.schema({
1511
1520
  })
1512
1521
  .secondaryIndexes((index) => [
1513
1522
  index("storyLineageId").sortKeys(["variationNumber"]).queryField("listStoryVariationsByStoryAndNumber"),
1523
+ index("tenantId").sortKeys(["id"]).queryField("listStoryVariationsByTenant"),
1514
1524
  ])
1515
1525
  .authorization((allow) => [
1516
1526
  allow.groups(contentWriteGroups).to(["read", "create", "update"]),
@@ -1556,6 +1566,22 @@ const schema = a.schema({
1556
1566
  allow.group(adminGroup),
1557
1567
  allow.ownerDefinedIn("tenantId").identityClaim("papyrus_tenant_admin").to(["read"]),
1558
1568
  ]),
1569
+ /**
1570
+ * The site a person's session acts for; id = the person's Cognito sub. The Google sign-in flow cannot tell the token trigger
1571
+ * which site was chosen, so the choice is stored here and the trigger reads it (PPY-0bb0fd). A person writes only their
1572
+ * own row (the owner is the id itself, so nobody can write another person's), and a selection without an active
1573
+ * TenantMembership grants nothing. Group "tenancy".
1574
+ */
1575
+ TenantSelection: a
1576
+ .model({
1577
+ id: a.id().required(),
1578
+ selectedTenantId: a.string().required(),
1579
+ selectedAt: a.datetime().required(),
1580
+ })
1581
+ .authorization((allow) => [
1582
+ allow.group(adminGroup),
1583
+ allow.ownerDefinedIn("id").identityClaim("sub").to(["create", "read", "update"]),
1584
+ ]),
1559
1585
  /** A hostname served for a tenant; id = the lowercase hostname, so it can belong to one tenant only (PPY-31c45c). Group "tenancy". */
1560
1586
  TenantDomain: a
1561
1587
  .model({
@@ -1573,6 +1599,43 @@ const schema = a.schema({
1573
1599
  allow.group(adminGroup),
1574
1600
  allow.ownerDefinedIn("tenantId").identityClaim("papyrus_tenant_admin").to(["read"]),
1575
1601
  ]),
1602
+ /** The catalogue row of one site document (kind: site | brand | nav); id = "<tenant>#<kind>". The body lives in S3 (PPY-c020ce). Group "tenancy". */
1603
+ SiteDocument: a
1604
+ .model({
1605
+ id: a.id().required(),
1606
+ tenantId: a.string().required(),
1607
+ kind: a.string().required(),
1608
+ currentVersion: a.integer().required(),
1609
+ s3Key: a.string().required(),
1610
+ sha256: a.string().required(),
1611
+ schemaVersion: a.integer().required(),
1612
+ updatedBy: a.string(),
1613
+ updatedAt: a.datetime().required(),
1614
+ })
1615
+ .authorization((allow) => [
1616
+ allow.group(adminGroup),
1617
+ allow.ownerDefinedIn("tenantId").identityClaim("papyrus_tenant_admin").to(["read"]),
1618
+ ]),
1619
+ /** One saved version of a site document; id = "<tenant>#<kind>#<version>". Body in S3 (PPY-c020ce). Group "tenancy". */
1620
+ SiteDocumentVersion: a
1621
+ .model({
1622
+ id: a.id().required(),
1623
+ tenantId: a.string().required(),
1624
+ documentId: a.string().required(),
1625
+ version: a.integer().required(),
1626
+ s3Key: a.string().required(),
1627
+ sha256: a.string().required(),
1628
+ createdBy: a.string(),
1629
+ createdAt: a.datetime().required(),
1630
+ note: a.string(),
1631
+ })
1632
+ .secondaryIndexes((index) => [
1633
+ index("documentId").sortKeys(["version"]).queryField("listSiteDocumentVersionsByDocument"),
1634
+ ])
1635
+ .authorization((allow) => [
1636
+ allow.group(adminGroup),
1637
+ allow.ownerDefinedIn("tenantId").identityClaim("papyrus_tenant_admin").to(["read"]),
1638
+ ]),
1576
1639
  /** Who is told about review requests: scope default, mode or automation. Changed by data, not code. */
1577
1640
  ReviewRecipientRule: a
1578
1641
  .model({
@@ -1585,6 +1648,9 @@ const schema = a.schema({
1585
1648
  updatedBy: a.string(),
1586
1649
  updatedAt: a.datetime().required(),
1587
1650
  })
1651
+ .secondaryIndexes((index) => [
1652
+ index("tenantId").sortKeys(["id"]).queryField("listReviewRecipientRulesByTenant"),
1653
+ ])
1588
1654
  .authorization((allow) => [
1589
1655
  allow.group("editor").to(["read"]),
1590
1656
  allow.group(adminGroup).to(authoringOperations),
@@ -1680,6 +1746,7 @@ const schema = a.schema({
1680
1746
  .secondaryIndexes((index) => [
1681
1747
  index("ownerId").sortKeys(["payloadKind"]).queryField("listKnowledgeRawPayloadsByOwnerAndKind"),
1682
1748
  index("importRunId").sortKeys(["ownerType"]).queryField("listKnowledgeRawPayloadsByImportRunAndOwner"),
1749
+ index("tenantId").sortKeys(["id"]).queryField("listKnowledgeRawPayloadsByTenant"),
1683
1750
  ])
1684
1751
  .authorization((allow) => [
1685
1752
  allow.groups(categoryWriteGroups),
@@ -1698,6 +1765,7 @@ const schema = a.schema({
1698
1765
  })
1699
1766
  .secondaryIndexes((index) => [
1700
1767
  index("grantorSub").sortKeys(["createdAt"]).queryField("listCurationDelegationRecordsByGrantor"),
1768
+ index("tenantId").sortKeys(["id"]).queryField("listCurationDelegationRecordsByTenant"),
1701
1769
  ])
1702
1770
  .authorization((allow) => [allow.groups([adminGroup]).to(["read"])]),
1703
1771
  KnowledgeArtifact: a
@@ -1817,6 +1885,7 @@ const schema = a.schema({
1817
1885
  index("categoryKey").sortKeys(["rank"]).queryField("listCategoryKeywordsByCategoryKeyAndRank"),
1818
1886
  index("normalizedKeyword").sortKeys(["categorySetId"]).queryField("listCategoryKeywordsByNormalizedKeywordAndSet"),
1819
1887
  index("importRunId").sortKeys(["rank"]).queryField("listCategoryKeywordsByImportRunAndRank"),
1888
+ index("tenantId").sortKeys(["id"]).queryField("listCategoryKeywordsByTenant"),
1820
1889
  ])
1821
1890
  .authorization((allow) => [
1822
1891
  allow.groups(categoryWriteGroups),
@@ -1904,6 +1973,7 @@ const schema = a.schema({
1904
1973
  .secondaryIndexes((index) => [
1905
1974
  index("proposalId").sortKeys(["createdAt"]).queryField("listSteeringDecisionsByProposalAndCreatedAt"),
1906
1975
  index("categorySetId").sortKeys(["createdAt"]).queryField("listSteeringDecisionsBySetAndCreatedAt"),
1976
+ index("tenantId").sortKeys(["id"]).queryField("listSteeringDecisionsByTenant"),
1907
1977
  ])
1908
1978
  .authorization((allow) => [
1909
1979
  allow.groups(categoryWriteGroups).to(categoryAppendOnlyOperations),
@@ -2056,6 +2126,7 @@ const schema = a.schema({
2056
2126
  index("referenceLineageId").sortKeys(["sortKey"]).queryField("listReferenceAttachmentsByReferenceLineageAndSortKey"),
2057
2127
  index("storagePath").queryField("referenceAttachmentByStoragePath"),
2058
2128
  index("importRunId").sortKeys(["sortKey"]).queryField("listReferenceAttachmentsByImportRunAndSortKey"),
2129
+ index("tenantId").sortKeys(["id"]).queryField("listReferenceAttachmentsByTenant"),
2059
2130
  ])
2060
2131
  .authorization((allow) => [
2061
2132
  allow.groups(categoryWriteGroups).to(["read"]),
@@ -2101,6 +2172,7 @@ const schema = a.schema({
2101
2172
  index("corpusId").sortKeys(["nodeKey"]).queryField("listSemanticNodesByCorpusAndNodeKey"),
2102
2173
  index("importRunId").sortKeys(["nodeKey"]).queryField("listSemanticNodesByImportRunAndNodeKey"),
2103
2174
  index("versionState").sortKeys(["updatedAt"]).queryField("listSemanticNodesByVersionStateAndUpdatedAt"),
2175
+ index("tenantId").sortKeys(["id"]).queryField("listSemanticNodesByTenant"),
2104
2176
  ])
2105
2177
  .authorization((allow) => [
2106
2178
  allow.groups(categoryWriteGroups).to(["read"]),
@@ -2310,6 +2382,7 @@ const schema = a.schema({
2310
2382
  index("importRunId").sortKeys(["importedAt"]).queryField("listSemanticRelationsByImportRunAndImportedAt"),
2311
2383
  index("relationTypeKey").sortKeys(["importedAt"]).queryField("listSemanticRelationsByTypeAndImportedAt"),
2312
2384
  index("relationDomain").sortKeys(["importedAt"]).queryField("listSemanticRelationsByDomainAndImportedAt"),
2385
+ index("tenantId").sortKeys(["id"]).queryField("listSemanticRelationsByTenant"),
2313
2386
  ])
2314
2387
  .authorization((allow) => [
2315
2388
  allow.groups(categoryWriteGroups).to(categoryAppendOnlyOperations),
@@ -2437,6 +2510,7 @@ const schema = a.schema({
2437
2510
  .secondaryIndexes((index) => [
2438
2511
  index("slug").queryField("tagBySlug"),
2439
2512
  index("type").sortKeys(["label"]).queryField("listTagsByTypeAndLabel"),
2513
+ index("tenantId").sortKeys(["id"]).queryField("listTagsByTenant"),
2440
2514
  ])
2441
2515
  .authorization((allow) => [
2442
2516
  allow.groups(contentWriteGroups),
@@ -2457,6 +2531,7 @@ const schema = a.schema({
2457
2531
  .secondaryIndexes((index) => [
2458
2532
  index("itemId").sortKeys(["tagSlug"]).queryField("listItemTagsByItemAndTag"),
2459
2533
  index("tagId").sortKeys(["publishedAt"]).queryField("listItemTagsByTagAndPublishedAt"),
2534
+ index("tenantId").sortKeys(["id"]).queryField("listItemTagsByTenant"),
2460
2535
  ])
2461
2536
  .authorization((allow) => [
2462
2537
  allow.groups(contentWriteGroups),
@@ -2571,6 +2646,7 @@ const schema = a.schema({
2571
2646
  .secondaryIndexes((index) => [
2572
2647
  index("editionId").sortKeys(["sortKey"]).queryField("listEditionItemsByEditionAndSortKey"),
2573
2648
  index("itemId").sortKeys(["editionId"]).queryField("listEditionItemsByItemAndEdition"),
2649
+ index("tenantId").sortKeys(["id"]).queryField("listEditionItemsByTenant"),
2574
2650
  ])
2575
2651
  .authorization((allow) => [
2576
2652
  allow.groups(contentWriteGroups),
@@ -2620,6 +2696,7 @@ const schema = a.schema({
2620
2696
  index("typeStatus").sortKeys(["publishedAt"]).queryField("listPublishedItemsByTypeStatusAndPublishedAt"),
2621
2697
  index("sectionStatus").sortKeys(["publishedAt"]).queryField("listPublishedItemsBySectionStatusAndPublishedAt"),
2622
2698
  index("itemLineageId").sortKeys(["versionNumber"]).queryField("listPublishedItemsByLineageAndVersion"),
2699
+ index("tenantId").sortKeys(["id"]).queryField("listPublishedItemsByTenant"),
2623
2700
  ])
2624
2701
  .authorization((allow) => [
2625
2702
  allow.guest().to(["read"]),
@@ -2707,6 +2784,7 @@ const schema = a.schema({
2707
2784
  .secondaryIndexes((index) => [
2708
2785
  index("publishedEditionId").sortKeys(["sortKey"]).queryField("listPublishedEditionItemsByEditionAndSortKey"),
2709
2786
  index("publishedItemId").sortKeys(["publishedEditionId"]).queryField("listPublishedEditionItemsByItemAndEdition"),
2787
+ index("tenantId").sortKeys(["id"]).queryField("listPublishedEditionItemsByTenant"),
2710
2788
  ])
2711
2789
  .authorization((allow) => [
2712
2790
  allow.guest().to(["read"]),
@@ -2769,6 +2847,7 @@ const schema = a.schema({
2769
2847
  index("parentCategoryId").sortKeys(["rank"]).queryField("listPublishedCategoriesByParentAndRank"),
2770
2848
  index("parentCategoryKey").sortKeys(["rank"]).queryField("listPublishedCategoriesByParentKeyAndRank"),
2771
2849
  index("categoryKey").sortKeys(["publishedCategorySetId"]).queryField("listPublishedCategoriesByKeyAndSet"),
2850
+ index("tenantId").sortKeys(["id"]).queryField("listPublishedCategoriesByTenant"),
2772
2851
  ])
2773
2852
  .authorization((allow) => [
2774
2853
  allow.guest().to(["read"]),
@@ -1568,6 +1568,9 @@ const schema = a.schema({
1568
1568
  updatedBy: a.string(),
1569
1569
  updatedAt: a.datetime().required(),
1570
1570
  })
1571
+ .secondaryIndexes((index) => [
1572
+ index("tenantId").sortKeys(["id"]).queryField("listAutomationsByTenant"),
1573
+ ])
1571
1574
  .authorization((allow) => [
1572
1575
  allow.group("editor").to(["read", "create", "update"]),
1573
1576
  allow.group(adminGroup).to(authoringOperations),
@@ -1592,6 +1595,9 @@ const schema = a.schema({
1592
1595
  appliedIn: a.json(),
1593
1596
  updatedAt: a.datetime().required(),
1594
1597
  })
1598
+ .secondaryIndexes((index) => [
1599
+ index("tenantId").sortKeys(["id"]).queryField("listReviewRequestsByTenant"),
1600
+ ])
1595
1601
  .authorization((allow) => [
1596
1602
  allow.group("editor").to(["read", "create", "update"]),
1597
1603
  allow.group(adminGroup).to(authoringOperations),
@@ -1606,6 +1612,9 @@ const schema = a.schema({
1606
1612
  userKey: a.string().required(),
1607
1613
  readAt: a.datetime().required(),
1608
1614
  })
1615
+ .secondaryIndexes((index) => [
1616
+ index("tenantId").sortKeys(["id"]).queryField("listReviewReadMarksByTenant"),
1617
+ ])
1609
1618
  .authorization((allow) => [
1610
1619
  allow.groups(["editor", adminGroup]).to(["read", "create", "update"]),
1611
1620
  ]),
@@ -1640,6 +1649,7 @@ const schema = a.schema({
1640
1649
  })
1641
1650
  .secondaryIndexes((index) => [
1642
1651
  index("storyLineageId").sortKeys(["variationNumber"]).queryField("listStoryVariationsByStoryAndNumber"),
1652
+ index("tenantId").sortKeys(["id"]).queryField("listStoryVariationsByTenant"),
1643
1653
  ])
1644
1654
  .authorization((allow) => [
1645
1655
  allow.groups(contentWriteGroups).to(["read", "create", "update"]),
@@ -1688,6 +1698,23 @@ const schema = a.schema({
1688
1698
  allow.ownerDefinedIn("tenantId").identityClaim("papyrus_tenant_admin").to(["read"]),
1689
1699
  ]),
1690
1700
 
1701
+ /**
1702
+ * The site a person's session acts for; id = the person's Cognito sub. The Google sign-in flow cannot tell the token trigger
1703
+ * which site was chosen, so the choice is stored here and the trigger reads it (PPY-0bb0fd). A person writes only their
1704
+ * own row (the owner is the id itself, so nobody can write another person's), and a selection without an active
1705
+ * TenantMembership grants nothing. Group "tenancy".
1706
+ */
1707
+ TenantSelection: a
1708
+ .model({
1709
+ id: a.id().required(),
1710
+ selectedTenantId: a.string().required(),
1711
+ selectedAt: a.datetime().required(),
1712
+ })
1713
+ .authorization((allow) => [
1714
+ allow.group(adminGroup),
1715
+ allow.ownerDefinedIn("id").identityClaim("sub").to(["create", "read", "update"]),
1716
+ ]),
1717
+
1691
1718
  /** A hostname served for a tenant; id = the lowercase hostname, so it can belong to one tenant only (PPY-31c45c). Group "tenancy". */
1692
1719
  TenantDomain: a
1693
1720
  .model({
@@ -1706,6 +1733,45 @@ const schema = a.schema({
1706
1733
  allow.ownerDefinedIn("tenantId").identityClaim("papyrus_tenant_admin").to(["read"]),
1707
1734
  ]),
1708
1735
 
1736
+ /** The catalogue row of one site document (kind: site | brand | nav); id = "<tenant>#<kind>". The body lives in S3 (PPY-c020ce). Group "tenancy". */
1737
+ SiteDocument: a
1738
+ .model({
1739
+ id: a.id().required(),
1740
+ tenantId: a.string().required(),
1741
+ kind: a.string().required(),
1742
+ currentVersion: a.integer().required(),
1743
+ s3Key: a.string().required(),
1744
+ sha256: a.string().required(),
1745
+ schemaVersion: a.integer().required(),
1746
+ updatedBy: a.string(),
1747
+ updatedAt: a.datetime().required(),
1748
+ })
1749
+ .authorization((allow) => [
1750
+ allow.group(adminGroup),
1751
+ allow.ownerDefinedIn("tenantId").identityClaim("papyrus_tenant_admin").to(["read"]),
1752
+ ]),
1753
+
1754
+ /** One saved version of a site document; id = "<tenant>#<kind>#<version>". Body in S3 (PPY-c020ce). Group "tenancy". */
1755
+ SiteDocumentVersion: a
1756
+ .model({
1757
+ id: a.id().required(),
1758
+ tenantId: a.string().required(),
1759
+ documentId: a.string().required(),
1760
+ version: a.integer().required(),
1761
+ s3Key: a.string().required(),
1762
+ sha256: a.string().required(),
1763
+ createdBy: a.string(),
1764
+ createdAt: a.datetime().required(),
1765
+ note: a.string(),
1766
+ })
1767
+ .secondaryIndexes((index) => [
1768
+ index("documentId").sortKeys(["version"]).queryField("listSiteDocumentVersionsByDocument"),
1769
+ ])
1770
+ .authorization((allow) => [
1771
+ allow.group(adminGroup),
1772
+ allow.ownerDefinedIn("tenantId").identityClaim("papyrus_tenant_admin").to(["read"]),
1773
+ ]),
1774
+
1709
1775
 
1710
1776
  /** Who is told about review requests: scope default, mode or automation. Changed by data, not code. */
1711
1777
  ReviewRecipientRule: a
@@ -1719,6 +1785,9 @@ const schema = a.schema({
1719
1785
  updatedBy: a.string(),
1720
1786
  updatedAt: a.datetime().required(),
1721
1787
  })
1788
+ .secondaryIndexes((index) => [
1789
+ index("tenantId").sortKeys(["id"]).queryField("listReviewRecipientRulesByTenant"),
1790
+ ])
1722
1791
  .authorization((allow) => [
1723
1792
  allow.group("editor").to(["read"]),
1724
1793
  allow.group(adminGroup).to(authoringOperations),
@@ -1818,6 +1887,7 @@ const schema = a.schema({
1818
1887
  .secondaryIndexes((index) => [
1819
1888
  index("ownerId").sortKeys(["payloadKind"]).queryField("listKnowledgeRawPayloadsByOwnerAndKind"),
1820
1889
  index("importRunId").sortKeys(["ownerType"]).queryField("listKnowledgeRawPayloadsByImportRunAndOwner"),
1890
+ index("tenantId").sortKeys(["id"]).queryField("listKnowledgeRawPayloadsByTenant"),
1821
1891
  ])
1822
1892
  .authorization((allow) => [
1823
1893
  allow.groups(categoryWriteGroups),
@@ -1837,6 +1907,7 @@ const schema = a.schema({
1837
1907
  })
1838
1908
  .secondaryIndexes((index) => [
1839
1909
  index("grantorSub").sortKeys(["createdAt"]).queryField("listCurationDelegationRecordsByGrantor"),
1910
+ index("tenantId").sortKeys(["id"]).queryField("listCurationDelegationRecordsByTenant"),
1840
1911
  ])
1841
1912
  .authorization((allow) => [allow.groups([adminGroup]).to(["read"])]),
1842
1913
 
@@ -1960,6 +2031,7 @@ const schema = a.schema({
1960
2031
  index("categoryKey").sortKeys(["rank"]).queryField("listCategoryKeywordsByCategoryKeyAndRank"),
1961
2032
  index("normalizedKeyword").sortKeys(["categorySetId"]).queryField("listCategoryKeywordsByNormalizedKeywordAndSet"),
1962
2033
  index("importRunId").sortKeys(["rank"]).queryField("listCategoryKeywordsByImportRunAndRank"),
2034
+ index("tenantId").sortKeys(["id"]).queryField("listCategoryKeywordsByTenant"),
1963
2035
  ])
1964
2036
  .authorization((allow) => [
1965
2037
  allow.groups(categoryWriteGroups),
@@ -2050,6 +2122,7 @@ const schema = a.schema({
2050
2122
  .secondaryIndexes((index) => [
2051
2123
  index("proposalId").sortKeys(["createdAt"]).queryField("listSteeringDecisionsByProposalAndCreatedAt"),
2052
2124
  index("categorySetId").sortKeys(["createdAt"]).queryField("listSteeringDecisionsBySetAndCreatedAt"),
2125
+ index("tenantId").sortKeys(["id"]).queryField("listSteeringDecisionsByTenant"),
2053
2126
  ])
2054
2127
  .authorization((allow) => [
2055
2128
  allow.groups(categoryWriteGroups).to(categoryAppendOnlyOperations),
@@ -2204,6 +2277,7 @@ const schema = a.schema({
2204
2277
  index("referenceLineageId").sortKeys(["sortKey"]).queryField("listReferenceAttachmentsByReferenceLineageAndSortKey"),
2205
2278
  index("storagePath").queryField("referenceAttachmentByStoragePath"),
2206
2279
  index("importRunId").sortKeys(["sortKey"]).queryField("listReferenceAttachmentsByImportRunAndSortKey"),
2280
+ index("tenantId").sortKeys(["id"]).queryField("listReferenceAttachmentsByTenant"),
2207
2281
  ])
2208
2282
  .authorization((allow) => [
2209
2283
  allow.groups(categoryWriteGroups).to(["read"]),
@@ -2250,6 +2324,7 @@ const schema = a.schema({
2250
2324
  index("corpusId").sortKeys(["nodeKey"]).queryField("listSemanticNodesByCorpusAndNodeKey"),
2251
2325
  index("importRunId").sortKeys(["nodeKey"]).queryField("listSemanticNodesByImportRunAndNodeKey"),
2252
2326
  index("versionState").sortKeys(["updatedAt"]).queryField("listSemanticNodesByVersionStateAndUpdatedAt"),
2327
+ index("tenantId").sortKeys(["id"]).queryField("listSemanticNodesByTenant"),
2253
2328
  ])
2254
2329
  .authorization((allow) => [
2255
2330
  allow.groups(categoryWriteGroups).to(["read"]),
@@ -2464,6 +2539,7 @@ const schema = a.schema({
2464
2539
  index("importRunId").sortKeys(["importedAt"]).queryField("listSemanticRelationsByImportRunAndImportedAt"),
2465
2540
  index("relationTypeKey").sortKeys(["importedAt"]).queryField("listSemanticRelationsByTypeAndImportedAt"),
2466
2541
  index("relationDomain").sortKeys(["importedAt"]).queryField("listSemanticRelationsByDomainAndImportedAt"),
2542
+ index("tenantId").sortKeys(["id"]).queryField("listSemanticRelationsByTenant"),
2467
2543
  ])
2468
2544
  .authorization((allow) => [
2469
2545
  allow.groups(categoryWriteGroups).to(categoryAppendOnlyOperations),
@@ -2594,6 +2670,7 @@ const schema = a.schema({
2594
2670
  .secondaryIndexes((index) => [
2595
2671
  index("slug").queryField("tagBySlug"),
2596
2672
  index("type").sortKeys(["label"]).queryField("listTagsByTypeAndLabel"),
2673
+ index("tenantId").sortKeys(["id"]).queryField("listTagsByTenant"),
2597
2674
  ])
2598
2675
  .authorization((allow) => [
2599
2676
  allow.groups(contentWriteGroups),
@@ -2615,6 +2692,7 @@ const schema = a.schema({
2615
2692
  .secondaryIndexes((index) => [
2616
2693
  index("itemId").sortKeys(["tagSlug"]).queryField("listItemTagsByItemAndTag"),
2617
2694
  index("tagId").sortKeys(["publishedAt"]).queryField("listItemTagsByTagAndPublishedAt"),
2695
+ index("tenantId").sortKeys(["id"]).queryField("listItemTagsByTenant"),
2618
2696
  ])
2619
2697
  .authorization((allow) => [
2620
2698
  allow.groups(contentWriteGroups),
@@ -2733,6 +2811,7 @@ const schema = a.schema({
2733
2811
  .secondaryIndexes((index) => [
2734
2812
  index("editionId").sortKeys(["sortKey"]).queryField("listEditionItemsByEditionAndSortKey"),
2735
2813
  index("itemId").sortKeys(["editionId"]).queryField("listEditionItemsByItemAndEdition"),
2814
+ index("tenantId").sortKeys(["id"]).queryField("listEditionItemsByTenant"),
2736
2815
  ])
2737
2816
  .authorization((allow) => [
2738
2817
  allow.groups(contentWriteGroups),
@@ -2783,6 +2862,7 @@ const schema = a.schema({
2783
2862
  index("typeStatus").sortKeys(["publishedAt"]).queryField("listPublishedItemsByTypeStatusAndPublishedAt"),
2784
2863
  index("sectionStatus").sortKeys(["publishedAt"]).queryField("listPublishedItemsBySectionStatusAndPublishedAt"),
2785
2864
  index("itemLineageId").sortKeys(["versionNumber"]).queryField("listPublishedItemsByLineageAndVersion"),
2865
+ index("tenantId").sortKeys(["id"]).queryField("listPublishedItemsByTenant"),
2786
2866
  ])
2787
2867
  .authorization((allow) => [
2788
2868
  allow.guest().to(["read"]),
@@ -2873,6 +2953,7 @@ const schema = a.schema({
2873
2953
  .secondaryIndexes((index) => [
2874
2954
  index("publishedEditionId").sortKeys(["sortKey"]).queryField("listPublishedEditionItemsByEditionAndSortKey"),
2875
2955
  index("publishedItemId").sortKeys(["publishedEditionId"]).queryField("listPublishedEditionItemsByItemAndEdition"),
2956
+ index("tenantId").sortKeys(["id"]).queryField("listPublishedEditionItemsByTenant"),
2876
2957
  ])
2877
2958
  .authorization((allow) => [
2878
2959
  allow.guest().to(["read"]),
@@ -2937,6 +3018,7 @@ const schema = a.schema({
2937
3018
  index("parentCategoryId").sortKeys(["rank"]).queryField("listPublishedCategoriesByParentAndRank"),
2938
3019
  index("parentCategoryKey").sortKeys(["rank"]).queryField("listPublishedCategoriesByParentKeyAndRank"),
2939
3020
  index("categoryKey").sortKeys(["publishedCategorySetId"]).queryField("listPublishedCategoriesByKeyAndSet"),
3021
+ index("tenantId").sortKeys(["id"]).queryField("listPublishedCategoriesByTenant"),
2940
3022
  ])
2941
3023
  .authorization((allow) => [
2942
3024
  allow.guest().to(["read"]),