@anthusai/papyrus 2.0.0-next.9 → 2.0.0-next.90

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 (217) hide show
  1. package/amplify/auth/resource.js +16 -1
  2. package/amplify/auth/resource.ts +19 -1
  3. package/amplify/data/function-handler.js +20 -0
  4. package/amplify/data/function-handler.ts +40 -0
  5. package/amplify/data/resource.js +151 -61
  6. package/amplify/data/resource.ts +157 -61
  7. package/amplify/data/schema.js +2096 -1980
  8. package/amplify/data/schema.ts +198 -69
  9. package/amplify/functions/assignment-action/data-access.js +2 -0
  10. package/amplify/functions/assignment-action/data-access.ts +2 -0
  11. package/amplify/functions/assignment-action/handler.ts +1 -1
  12. package/amplify/functions/automation-view/handler.py +17 -0
  13. package/amplify/functions/automation-view/resource.js +24 -0
  14. package/amplify/functions/automation-view/resource.ts +34 -0
  15. package/amplify/functions/automation-view/schema.js +26 -0
  16. package/amplify/functions/automation-view/schema.ts +28 -0
  17. package/amplify/functions/automation-view/wire.js +56 -0
  18. package/amplify/functions/automation-view/wire.ts +76 -0
  19. package/amplify/functions/content-actions/handler.py +61 -2
  20. package/amplify/functions/content-actions/requirements.txt +1 -0
  21. package/amplify/functions/content-actions/resource.js +1 -1
  22. package/amplify/functions/content-actions/resource.ts +1 -1
  23. package/amplify/{plugins/editorial-checks/function → functions/editorial-checks}/handler.py +3 -3
  24. package/amplify/functions/editorial-checks/requirements.txt +1 -0
  25. package/amplify/{plugins/editorial-checks/function → functions/editorial-checks}/resource.js +7 -7
  26. package/amplify/{plugins/editorial-checks/function → functions/editorial-checks}/resource.ts +7 -7
  27. package/amplify/functions/editorial-checks/schema.js +122 -0
  28. package/amplify/{plugins → functions}/editorial-checks/schema.ts +40 -12
  29. package/amplify/functions/editorial-checks/wire.js +53 -0
  30. package/amplify/functions/editorial-checks/wire.ts +61 -0
  31. package/amplify/functions/monitoring-view/handler.py +11 -0
  32. package/amplify/functions/monitoring-view/resource.js +24 -0
  33. package/amplify/functions/monitoring-view/resource.ts +34 -0
  34. package/amplify/functions/monitoring-view/schema.js +17 -0
  35. package/amplify/functions/monitoring-view/schema.ts +19 -0
  36. package/amplify/functions/monitoring-view/wire.js +37 -0
  37. package/amplify/functions/monitoring-view/wire.ts +47 -0
  38. package/amplify/functions/public-forms/core.js +247 -0
  39. package/amplify/functions/public-forms/core.ts +310 -0
  40. package/amplify/functions/public-forms/handler.ts +41 -0
  41. package/amplify/functions/public-forms/origins.js +35 -0
  42. package/amplify/functions/public-forms/origins.ts +43 -0
  43. package/amplify/functions/public-forms/resource.js +9 -0
  44. package/amplify/functions/public-forms/resource.ts +10 -0
  45. package/amplify/functions/public-forms/wire.js +25 -0
  46. package/amplify/functions/public-forms/wire.ts +32 -0
  47. package/amplify/functions/shared/editorial-context.ts +63 -4
  48. package/amplify/functions/shared/python-bundle.js +20 -14
  49. package/amplify/functions/shared/python-bundle.ts +25 -18
  50. package/amplify/plugins/newsletter/config.js +245 -0
  51. package/amplify/plugins/newsletter/config.ts +305 -0
  52. package/amplify/plugins/newsletter/function/handler.py +6 -0
  53. package/amplify/plugins/newsletter/function/requirements.txt +5 -0
  54. package/amplify/plugins/newsletter/ops/handler.py +12 -0
  55. package/amplify/plugins/newsletter/ops/resource.js +27 -0
  56. package/amplify/plugins/newsletter/ops/resource.ts +37 -0
  57. package/amplify/plugins/newsletter/papyrus.plugin.js +263 -0
  58. package/amplify/plugins/newsletter/papyrus.plugin.ts +311 -0
  59. package/amplify/plugins/newsletter/schema.js +57 -0
  60. package/amplify/plugins/newsletter/schema.ts +62 -0
  61. package/amplify/plugins/newsletter/secure-string-parameter.js +107 -0
  62. package/amplify/plugins/newsletter/secure-string-parameter.ts +120 -0
  63. package/amplify/plugins/newsletter/sending.js +140 -0
  64. package/amplify/plugins/newsletter/sending.ts +186 -0
  65. package/amplify/plugins/reader-steering/config.js +182 -0
  66. package/amplify/plugins/reader-steering/config.ts +290 -0
  67. package/amplify/plugins/reader-steering/function/ai_moderation.py +246 -0
  68. package/amplify/plugins/reader-steering/function/handler.py +1567 -0
  69. package/amplify/plugins/reader-steering/function/moderation-prompt.md +27 -0
  70. package/amplify/plugins/reader-steering/function/moderation.py +316 -0
  71. package/amplify/plugins/reader-steering/function/proposals.py +458 -0
  72. package/amplify/plugins/reader-steering/function/resource.js +27 -0
  73. package/amplify/plugins/reader-steering/function/resource.ts +35 -0
  74. package/amplify/plugins/reader-steering/papyrus.plugin.js +186 -0
  75. package/amplify/plugins/reader-steering/papyrus.plugin.ts +212 -0
  76. package/amplify/plugins/reader-steering/schema.js +229 -0
  77. package/amplify/plugins/reader-steering/schema.ts +231 -0
  78. package/amplify/plugins/registry.js +4 -2
  79. package/amplify/plugins/registry.ts +4 -2
  80. package/amplify/plugins/signup/schema.js +2 -1
  81. package/amplify/plugins/signup/schema.ts +2 -1
  82. package/amplify/plugins/types.ts +5 -0
  83. package/amplify/plugins/wire.js +1 -0
  84. package/amplify/plugins/wire.ts +1 -0
  85. package/amplify/publication/projection-lease.js +30 -0
  86. package/amplify/publication/projection-lease.ts +39 -0
  87. package/amplify/publication/redirect-and-index.js +105 -0
  88. package/amplify/publication/redirect-rules.js +73 -0
  89. package/amplify/publication/redirect-rules.ts +93 -0
  90. package/amplify/publication/s3-projection.js +7 -1
  91. package/amplify/publication/s3-projection.ts +9 -1
  92. package/amplify/site-backend-config.ts +18 -1
  93. package/amplify/site-backend-names.js +4 -2
  94. package/amplify/site-backend-names.ts +4 -2
  95. package/amplify/site-backend.js +45 -3
  96. package/amplify/site-backend.ts +51 -3
  97. package/app/api/auth/prospectus/sign-in/route.ts +4 -0
  98. package/app/api/newsletter/confirm/route.ts +13 -0
  99. package/app/api/newsletter/preferences/route.ts +13 -0
  100. package/app/api/newsletter/state/route.ts +9 -0
  101. package/app/api/newsletter/subscribe/route.ts +9 -0
  102. package/app/api/newsletter/unsubscribe/route.ts +13 -0
  103. package/app/api/newsroom/curation/context/route.ts +9 -0
  104. package/app/api/newsroom/curation/priming/route.ts +9 -0
  105. package/app/api/newsroom/curation/publication/route.ts +9 -0
  106. package/app/api/reader/comment/delete/route.ts +9 -0
  107. package/app/api/reader/comment/edit/route.ts +9 -0
  108. package/app/api/reader/comment/route.ts +9 -0
  109. package/app/api/reader/flag/route.ts +9 -0
  110. package/app/api/reader/handle/route.ts +9 -0
  111. package/app/api/reader/me/route.ts +9 -0
  112. package/app/api/reader/rating/route.ts +9 -0
  113. package/app/api/reader/report/route.ts +9 -0
  114. package/app/api/reader/retired/route.ts +9 -0
  115. package/app/api/reader/submit/route.ts +9 -0
  116. package/app/api/reader/vote/route.ts +9 -0
  117. package/bin/papyrus-infra.mjs +20 -1
  118. package/components/automation-panel.tsx +49 -0
  119. package/components/automation-run-now.tsx +97 -0
  120. package/components/automation-view.tsx +195 -0
  121. package/components/editorial-checks-admin-panel.tsx +38 -13
  122. package/components/moderation-panel.tsx +248 -0
  123. package/components/monitoring-overview-view.tsx +241 -0
  124. package/components/monitoring-panel.tsx +40 -0
  125. package/components/news-desk-client-provider.tsx +18 -18
  126. package/components/news-desk-taxonomy-client.ts +28 -8
  127. package/components/newsletter-panel.tsx +474 -0
  128. package/components/newsletter-sections.tsx +163 -0
  129. package/components/newsroom-access-gate.tsx +16 -2
  130. package/components/newsroom-article-editor.tsx +11 -11
  131. package/components/newsroom-articles-view.tsx +6 -6
  132. package/components/newsroom-assignment-detail.tsx +6 -6
  133. package/components/newsroom-board-view.tsx +8 -3
  134. package/components/newsroom-curation-bootstrap.tsx +45 -0
  135. package/components/newsroom-ops-overview.tsx +26 -96
  136. package/components/newsroom-ops-shell.tsx +2 -2
  137. package/components/newsroom-organizer.css +33 -0
  138. package/components/newsroom-overview-skeleton.tsx +25 -0
  139. package/components/newsroom-references-view.tsx +192 -49
  140. package/components/notification-center.tsx +277 -0
  141. package/components/publication-cyclotron-panel.tsx +15 -10
  142. package/components/reader-auth-state.ts +1 -1
  143. package/components/reference-add-entry.tsx +75 -0
  144. package/components/reference-curation-controls.tsx +31 -22
  145. package/components/reference-cyclotron-priming.tsx +58 -19
  146. package/components/reference-cyclotron-suggestion.tsx +10 -6
  147. package/components/reference-priming.tsx +14 -10
  148. package/components/reference-relevance-review.tsx +3 -3
  149. package/components/reference-section-suggestion.tsx +1 -1
  150. package/components/topic-steering-workspace.tsx +237 -158
  151. package/components/use-editorial-checks.ts +12 -10
  152. package/infra/amplify-app-shell.js +94 -16
  153. package/infra/amplify-app-shell.ts +106 -18
  154. package/infra/cloud-email-config.js +32 -0
  155. package/infra/cloud-email-config.ts +39 -0
  156. package/infra/cloud-email.js +57 -0
  157. package/infra/cloud-email.test.js +69 -0
  158. package/infra/cloud-email.test.ts +66 -0
  159. package/infra/cloud-email.ts +60 -0
  160. package/infra/index.js +1 -0
  161. package/infra/secure-string-parameter-handler.js +41 -0
  162. package/infra/secure-string-parameter-handler.ts +41 -0
  163. package/infra/secure-string-parameter.js +79 -0
  164. package/infra/secure-string-parameter.ts +91 -0
  165. package/infra/site-config.js +88 -6
  166. package/infra/site-config.ts +134 -6
  167. package/lib/automation-client.ts +54 -0
  168. package/lib/automation-fixture.ts +93 -0
  169. package/lib/automation-overview.ts +252 -0
  170. package/lib/category-repository.ts +14 -12
  171. package/lib/console-web-context.ts +1 -1
  172. package/lib/curation-routes.ts +345 -0
  173. package/lib/cyclotron-suggestions.ts +4 -4
  174. package/lib/editorial-checks-backend.ts +1 -1
  175. package/lib/editorial-checks-client.ts +19 -1
  176. package/lib/editorial-checks-demo.ts +2 -2
  177. package/lib/editorial-checks-settings.ts +3 -0
  178. package/lib/editorial-checks.ts +8 -11
  179. package/lib/editorial-preview.ts +5 -5
  180. package/lib/monitoring-client.ts +29 -0
  181. package/lib/monitoring-overview-fixture.ts +51 -0
  182. package/lib/monitoring-overview.ts +145 -0
  183. package/lib/news-desk-session.ts +12 -21
  184. package/lib/newsletter-api.ts +418 -0
  185. package/lib/newsletter-client.ts +46 -0
  186. package/lib/newsletter-fixture.ts +184 -0
  187. package/lib/newsletter-model.ts +202 -0
  188. package/lib/newsroom-demo-dashboard.ts +1 -1
  189. package/lib/newsroom-nav.ts +1 -1
  190. package/lib/newsroom-organizer-nav.ts +2 -1
  191. package/lib/prospectus-session.ts +15 -14
  192. package/lib/prospectus-sign-in-routes.ts +105 -20
  193. package/lib/prospectus-site-identity.ts +46 -6
  194. package/lib/reader-api.ts +145 -0
  195. package/lib/reader-moderation.ts +220 -0
  196. package/lib/reader-retirement-route.ts +89 -0
  197. package/lib/reader-subject.md +29 -0
  198. package/lib/reader-subject.ts +53 -0
  199. package/lib/reference-review-details.ts +71 -0
  200. package/lib/reference-review-request.ts +14 -0
  201. package/lib/relevance-decisions.ts +42 -10
  202. package/lib/relevance-status.ts +2 -2
  203. package/lib/review-client.ts +117 -0
  204. package/lib/review-fixture.ts +45 -0
  205. package/lib/review-requests.ts +244 -0
  206. package/lib/semantic-graph.ts +2 -0
  207. package/lib/site-brand-tenant.ts +11 -6
  208. package/lib/site-brand.ts +6 -3
  209. package/lib/site-origin.ts +67 -0
  210. package/lib/use-reference-review-data.ts +44 -0
  211. package/middleware.ts +14 -3
  212. package/package.json +56 -3
  213. package/routes.manifest.json +215 -2
  214. package/amplify/plugins/editorial-checks/function/requirements.txt +0 -1
  215. package/amplify/plugins/editorial-checks/papyrus.plugin.js +0 -71
  216. package/amplify/plugins/editorial-checks/papyrus.plugin.ts +0 -87
  217. package/amplify/plugins/editorial-checks/schema.js +0 -94
@@ -1,6 +1,6 @@
1
1
  import { defineAuth, secret } from "@aws-amplify/backend";
2
2
  import { manageUserRole } from "../functions/manage-user-role/resource.js";
3
- import { CfnUserPoolDomain } from "aws-cdk-lib/aws-cognito";
3
+ import { CfnUserPoolDomain, CfnUserPoolIdentityProvider } from "aws-cdk-lib/aws-cognito";
4
4
  import { expandNewsroomRedirectUrls } from "./redirect-urls.js";
5
5
  // Default OAuth redirect URLs for the p.apyr.us app. Other publications pass
6
6
  // `auth.redirectUrls` to `defineSiteBackend` (or, for Papyrus's own backend,
@@ -35,6 +35,21 @@ export function authConfigFromEnv() {
35
35
  export function siteAuthRedirectUrls(config) {
36
36
  return config.redirectUrls ?? DEFAULT_AUTH_REDIRECT_URLS;
37
37
  }
38
+ /** Keep Cognito's federated email verification state in sync with Google's verified claim. */
39
+ export function applyGoogleEmailVerifiedMapping(authStack) {
40
+ const googleProviders = authStack.node
41
+ .findAll()
42
+ .filter((construct) => construct instanceof CfnUserPoolIdentityProvider && construct.providerName === "Google");
43
+ if (googleProviders.length !== 1) {
44
+ throw new Error(`Expected exactly one Google identity provider to map email_verified, found ${googleProviders.length}`);
45
+ }
46
+ const [provider] = googleProviders;
47
+ const mapping = provider.attributeMapping;
48
+ if (mapping !== undefined && (typeof mapping !== "object" || Array.isArray(mapping))) {
49
+ throw new Error("Expected Google identity provider attribute mappings to be a plain object");
50
+ }
51
+ provider.attributeMapping = { ...(mapping ?? {}), email_verified: "email_verified" };
52
+ }
38
53
  export function defineSiteAuth(config) {
39
54
  const authRedirectUrls = expandNewsroomRedirectUrls(siteAuthRedirectUrls(config), config.newsroomBasePath);
40
55
  const disableGoogleOAuth = config.disableGoogleOAuth === true;
@@ -1,7 +1,7 @@
1
1
  import { defineAuth, secret } from "@aws-amplify/backend";
2
2
  import { manageUserRole } from "../functions/manage-user-role/resource";
3
3
  import { Stack } from "aws-cdk-lib";
4
- import { CfnUserPoolDomain } from "aws-cdk-lib/aws-cognito";
4
+ import { CfnUserPoolDomain, CfnUserPoolIdentityProvider } from "aws-cdk-lib/aws-cognito";
5
5
  import type { PapyrusAuthConfig } from "../site-backend-config";
6
6
  import { expandNewsroomRedirectUrls } from "./redirect-urls";
7
7
 
@@ -41,6 +41,24 @@ export function siteAuthRedirectUrls(config: PapyrusAuthConfig): string[] {
41
41
  return config.redirectUrls ?? DEFAULT_AUTH_REDIRECT_URLS;
42
42
  }
43
43
 
44
+ /** Keep Cognito's federated email verification state in sync with Google's verified claim. */
45
+ export function applyGoogleEmailVerifiedMapping(authStack: Stack): void {
46
+ const googleProviders = authStack.node
47
+ .findAll()
48
+ .filter((construct): construct is CfnUserPoolIdentityProvider =>
49
+ construct instanceof CfnUserPoolIdentityProvider && construct.providerName === "Google");
50
+ if (googleProviders.length !== 1) {
51
+ throw new Error(`Expected exactly one Google identity provider to map email_verified, found ${googleProviders.length}`);
52
+ }
53
+
54
+ const [provider] = googleProviders;
55
+ const mapping = provider.attributeMapping;
56
+ if (mapping !== undefined && (typeof mapping !== "object" || Array.isArray(mapping))) {
57
+ throw new Error("Expected Google identity provider attribute mappings to be a plain object");
58
+ }
59
+ provider.attributeMapping = { ...(mapping ?? {}), email_verified: "email_verified" };
60
+ }
61
+
44
62
  export function defineSiteAuth(config: PapyrusAuthConfig) {
45
63
  const authRedirectUrls = expandNewsroomRedirectUrls(
46
64
  siteAuthRedirectUrls(config),
@@ -0,0 +1,20 @@
1
+ import { a } from "@aws-amplify/backend";
2
+ const registered = new Map();
3
+ /** The shared name for a Lambda: stable, alphanumeric, unique per function. */
4
+ export function sharedFunctionName(name) {
5
+ return `Fn${name.charAt(0).toUpperCase()}${name.slice(1)}`;
6
+ }
7
+ /** A schema handler for `fn` that shares one data source with every other field handled by `fn`. */
8
+ export function functionHandler(name, fn) {
9
+ const shared = sharedFunctionName(name);
10
+ const existing = registered.get(shared);
11
+ if (existing !== undefined && existing !== fn) {
12
+ throw new Error(`Two different functions are registered as "${shared}"`);
13
+ }
14
+ registered.set(shared, fn);
15
+ return a.handler.function(shared);
16
+ }
17
+ /** Every function that a schema handler refers to by shared name, for `defineData({ functions })`. */
18
+ export function sharedFunctions() {
19
+ return Object.fromEntries(registered);
20
+ }
@@ -0,0 +1,40 @@
1
+ import { a } from "@aws-amplify/backend";
2
+
3
+ /**
4
+ * One AppSync Lambda data source per Lambda, not one per field.
5
+ *
6
+ * `a.handler.function(fn)` names every field's function `Fn<FieldName>`, and the @function transformer creates a data
7
+ * source, an IAM role, an IAM policy and two function configurations for each distinct name, all in one nested stack
8
+ * (`FunctionDirectiveStack`). CloudFormation allows 500 resources in a stack, and that stack grows by six resources per
9
+ * Lambda-backed field. Giving every field that calls the same Lambda the same name makes them share one data source,
10
+ * role, policy and function configuration, so each extra field costs only its resolver. The Lambda receives the same
11
+ * event as before (`typeName`, `fieldName`, `arguments`, `identity`), so no handler changes.
12
+ *
13
+ * Every function used this way is registered here and handed to `defineData({ functions })`, which is how Amplify
14
+ * resolves a handler given by name.
15
+ */
16
+ /** What `a.handler.function` accepts, and what `defineData({ functions })` takes by name. */
17
+ type HandlerFunction = Exclude<Parameters<typeof a.handler.function>[0], string>;
18
+
19
+ const registered = new Map<string, HandlerFunction>();
20
+
21
+ /** The shared name for a Lambda: stable, alphanumeric, unique per function. */
22
+ export function sharedFunctionName(name: string): string {
23
+ return `Fn${name.charAt(0).toUpperCase()}${name.slice(1)}`;
24
+ }
25
+
26
+ /** A schema handler for `fn` that shares one data source with every other field handled by `fn`. */
27
+ export function functionHandler(name: string, fn: HandlerFunction) {
28
+ const shared = sharedFunctionName(name);
29
+ const existing = registered.get(shared);
30
+ if (existing !== undefined && existing !== fn) {
31
+ throw new Error(`Two different functions are registered as "${shared}"`);
32
+ }
33
+ registered.set(shared, fn);
34
+ return a.handler.function(shared);
35
+ }
36
+
37
+ /** Every function that a schema handler refers to by shared name, for `defineData({ functions })`. */
38
+ export function sharedFunctions(): Record<string, HandlerFunction> {
39
+ return Object.fromEntries(registered);
40
+ }