@anthusai/papyrus 2.0.0-next.6 → 2.0.0-next.61

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 (164) hide show
  1. package/amplify/data/resource.js +23 -3
  2. package/amplify/data/resource.ts +25 -3
  3. package/amplify/data/schema.js +2028 -1979
  4. package/amplify/data/schema.ts +72 -14
  5. package/amplify/functions/assignment-action/data-access.js +90 -0
  6. package/amplify/functions/assignment-action/data-access.ts +89 -0
  7. package/amplify/functions/assignment-action/handler.ts +1 -1
  8. package/amplify/functions/content-actions/handler.py +61 -2
  9. package/amplify/functions/content-actions/requirements.txt +1 -0
  10. package/amplify/functions/content-actions/resource.js +1 -1
  11. package/amplify/functions/content-actions/resource.ts +1 -1
  12. package/amplify/functions/editorial-checks/handler.py +14 -0
  13. package/amplify/functions/editorial-checks/requirements.txt +1 -0
  14. package/amplify/{plugins/editorial-checks/function → functions/editorial-checks}/resource.js +7 -7
  15. package/amplify/{plugins/editorial-checks/function → functions/editorial-checks}/resource.ts +7 -7
  16. package/amplify/functions/editorial-checks/schema.js +121 -0
  17. package/amplify/{plugins → functions}/editorial-checks/schema.ts +33 -6
  18. package/amplify/functions/editorial-checks/wire.js +53 -0
  19. package/amplify/functions/editorial-checks/wire.ts +61 -0
  20. package/amplify/functions/monitoring-view/handler.py +11 -0
  21. package/amplify/functions/monitoring-view/resource.js +24 -0
  22. package/amplify/functions/monitoring-view/resource.ts +34 -0
  23. package/amplify/functions/monitoring-view/schema.js +16 -0
  24. package/amplify/functions/monitoring-view/schema.ts +18 -0
  25. package/amplify/functions/monitoring-view/wire.js +37 -0
  26. package/amplify/functions/monitoring-view/wire.ts +47 -0
  27. package/amplify/functions/public-forms/core.js +247 -0
  28. package/amplify/functions/public-forms/core.ts +310 -0
  29. package/amplify/functions/public-forms/handler.ts +41 -0
  30. package/amplify/functions/public-forms/origins.js +35 -0
  31. package/amplify/functions/public-forms/origins.ts +43 -0
  32. package/amplify/functions/public-forms/resource.js +9 -0
  33. package/amplify/functions/public-forms/resource.ts +10 -0
  34. package/amplify/functions/public-forms/wire.js +25 -0
  35. package/amplify/functions/public-forms/wire.ts +32 -0
  36. package/amplify/functions/shared/editorial-context.ts +63 -4
  37. package/amplify/functions/shared/python-bundle.js +20 -14
  38. package/amplify/functions/shared/python-bundle.ts +25 -18
  39. package/amplify/plugins/newsletter/config.js +245 -0
  40. package/amplify/plugins/newsletter/config.ts +305 -0
  41. package/amplify/plugins/newsletter/function/handler.py +6 -0
  42. package/amplify/plugins/newsletter/function/requirements.txt +5 -0
  43. package/amplify/plugins/newsletter/ops/handler.py +12 -0
  44. package/amplify/plugins/newsletter/ops/resource.js +27 -0
  45. package/amplify/plugins/newsletter/ops/resource.ts +37 -0
  46. package/amplify/plugins/newsletter/papyrus.plugin.js +263 -0
  47. package/amplify/plugins/newsletter/papyrus.plugin.ts +311 -0
  48. package/amplify/plugins/newsletter/schema.js +56 -0
  49. package/amplify/plugins/newsletter/schema.ts +61 -0
  50. package/amplify/plugins/newsletter/secure-string-parameter.js +107 -0
  51. package/amplify/plugins/newsletter/secure-string-parameter.ts +120 -0
  52. package/amplify/plugins/newsletter/sending.js +140 -0
  53. package/amplify/plugins/newsletter/sending.ts +186 -0
  54. package/amplify/plugins/reader-steering/config.js +173 -0
  55. package/amplify/plugins/reader-steering/config.ts +268 -0
  56. package/amplify/plugins/reader-steering/function/ai_moderation.py +246 -0
  57. package/amplify/plugins/reader-steering/function/handler.py +1363 -0
  58. package/amplify/plugins/reader-steering/function/moderation-prompt.md +27 -0
  59. package/amplify/plugins/reader-steering/function/moderation.py +316 -0
  60. package/amplify/plugins/reader-steering/function/resource.js +27 -0
  61. package/amplify/plugins/reader-steering/function/resource.ts +35 -0
  62. package/amplify/plugins/reader-steering/papyrus.plugin.js +176 -0
  63. package/amplify/plugins/reader-steering/papyrus.plugin.ts +202 -0
  64. package/amplify/plugins/reader-steering/schema.js +140 -0
  65. package/amplify/plugins/reader-steering/schema.ts +142 -0
  66. package/amplify/plugins/registry.js +4 -2
  67. package/amplify/plugins/registry.ts +4 -2
  68. package/amplify/plugins/types.ts +5 -0
  69. package/amplify/plugins/wire.js +1 -0
  70. package/amplify/plugins/wire.ts +1 -0
  71. package/amplify/publication/projection-lease.js +30 -0
  72. package/amplify/publication/projection-lease.ts +39 -0
  73. package/amplify/publication/redirect-and-index.js +105 -0
  74. package/amplify/publication/redirect-rules.js +73 -0
  75. package/amplify/publication/redirect-rules.ts +93 -0
  76. package/amplify/publication/s3-projection.js +7 -1
  77. package/amplify/publication/s3-projection.ts +9 -1
  78. package/amplify/site-backend-config.ts +17 -0
  79. package/amplify/site-backend.js +38 -1
  80. package/amplify/site-backend.ts +46 -1
  81. package/app/api/auth/prospectus/sign-in/route.ts +4 -0
  82. package/app/api/newsletter/confirm/route.ts +13 -0
  83. package/app/api/newsletter/preferences/route.ts +13 -0
  84. package/app/api/newsletter/state/route.ts +9 -0
  85. package/app/api/newsletter/subscribe/route.ts +9 -0
  86. package/app/api/newsletter/unsubscribe/route.ts +13 -0
  87. package/app/api/newsroom/curation/context/route.ts +9 -0
  88. package/app/api/newsroom/curation/priming/route.ts +9 -0
  89. package/app/api/newsroom/curation/publication/route.ts +9 -0
  90. package/app/api/reader/comment/delete/route.ts +9 -0
  91. package/app/api/reader/comment/edit/route.ts +9 -0
  92. package/app/api/reader/comment/route.ts +9 -0
  93. package/app/api/reader/handle/route.ts +9 -0
  94. package/app/api/reader/me/route.ts +9 -0
  95. package/app/api/reader/rating/route.ts +9 -0
  96. package/app/api/reader/report/route.ts +9 -0
  97. package/app/api/reader/retired/route.ts +9 -0
  98. package/app/api/reader/submit/route.ts +9 -0
  99. package/app/api/reader/vote/route.ts +9 -0
  100. package/bin/papyrus-infra.mjs +20 -1
  101. package/components/editorial-checks-admin-panel.tsx +36 -11
  102. package/components/moderation-panel.tsx +248 -0
  103. package/components/monitoring-overview-view.tsx +241 -0
  104. package/components/monitoring-panel.tsx +40 -0
  105. package/components/newsletter-panel.tsx +474 -0
  106. package/components/newsletter-sections.tsx +163 -0
  107. package/components/newsroom-article-editor.tsx +2 -4
  108. package/components/newsroom-curation-bootstrap.tsx +45 -0
  109. package/components/newsroom-organizer.css +31 -0
  110. package/components/newsroom-references-view.tsx +14 -14
  111. package/components/publication-cyclotron-panel.tsx +15 -10
  112. package/components/reference-add-entry.tsx +75 -0
  113. package/components/reference-curation-controls.tsx +31 -22
  114. package/components/reference-cyclotron-priming.tsx +58 -19
  115. package/components/reference-cyclotron-suggestion.tsx +1 -1
  116. package/components/reference-priming.tsx +14 -10
  117. package/components/reference-section-suggestion.tsx +1 -1
  118. package/components/topic-steering-workspace.tsx +64 -20
  119. package/components/use-editorial-checks.ts +12 -10
  120. package/infra/amplify-app-shell.js +90 -16
  121. package/infra/amplify-app-shell.ts +102 -18
  122. package/infra/index.js +1 -0
  123. package/infra/secure-string-parameter-handler.js +41 -0
  124. package/infra/secure-string-parameter-handler.ts +41 -0
  125. package/infra/secure-string-parameter.js +79 -0
  126. package/infra/secure-string-parameter.ts +91 -0
  127. package/infra/site-config.js +86 -6
  128. package/infra/site-config.ts +129 -6
  129. package/lib/category-repository.ts +11 -9
  130. package/lib/curation-routes.ts +345 -0
  131. package/lib/editorial-checks-backend.ts +1 -1
  132. package/lib/editorial-checks-client.ts +19 -1
  133. package/lib/editorial-checks-demo.ts +2 -2
  134. package/lib/editorial-checks-settings.ts +3 -0
  135. package/lib/editorial-checks.ts +8 -11
  136. package/lib/editorial-preview.ts +5 -5
  137. package/lib/monitoring-client.ts +29 -0
  138. package/lib/monitoring-overview-fixture.ts +51 -0
  139. package/lib/monitoring-overview.ts +145 -0
  140. package/lib/newsletter-api.ts +418 -0
  141. package/lib/newsletter-client.ts +46 -0
  142. package/lib/newsletter-fixture.ts +184 -0
  143. package/lib/newsletter-model.ts +202 -0
  144. package/lib/prospectus-session.ts +15 -14
  145. package/lib/prospectus-sign-in-routes.ts +84 -19
  146. package/lib/prospectus-site-identity.ts +24 -1
  147. package/lib/reader-api.ts +145 -0
  148. package/lib/reader-moderation.ts +220 -0
  149. package/lib/reader-retirement-route.ts +89 -0
  150. package/lib/reader-subject.md +29 -0
  151. package/lib/reader-subject.ts +53 -0
  152. package/lib/relevance-status.ts +2 -2
  153. package/lib/semantic-graph.ts +2 -0
  154. package/lib/site-brand-tenant.ts +11 -6
  155. package/lib/site-brand.ts +6 -3
  156. package/lib/site-origin.ts +67 -0
  157. package/middleware.ts +14 -3
  158. package/package.json +41 -3
  159. package/routes.manifest.json +204 -2
  160. package/amplify/plugins/editorial-checks/function/handler.py +0 -11
  161. package/amplify/plugins/editorial-checks/function/requirements.txt +0 -1
  162. package/amplify/plugins/editorial-checks/papyrus.plugin.js +0 -50
  163. package/amplify/plugins/editorial-checks/papyrus.plugin.ts +0 -63
  164. package/amplify/plugins/editorial-checks/schema.js +0 -94
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.0.0-next.6",
2
+ "version": "2.0.0-next.61",
3
3
  "routes": [
4
4
  {
5
5
  "file": "app/%5F_preview/[[...path]]/route.ts",
@@ -114,7 +114,8 @@
114
114
  "file": "app/api/auth/prospectus/sign-in/route.ts",
115
115
  "hasDefault": false,
116
116
  "exports": [
117
- "GET"
117
+ "GET",
118
+ "POST"
118
119
  ],
119
120
  "config": {
120
121
  "dynamic": "\"force-dynamic\"",
@@ -170,6 +171,207 @@
170
171
  "dynamic": "\"force-dynamic\""
171
172
  }
172
173
  },
174
+ {
175
+ "file": "app/api/newsletter/confirm/route.ts",
176
+ "hasDefault": false,
177
+ "exports": [
178
+ "GET",
179
+ "POST"
180
+ ],
181
+ "config": {
182
+ "dynamic": "\"force-dynamic\"",
183
+ "runtime": "\"nodejs\""
184
+ }
185
+ },
186
+ {
187
+ "file": "app/api/newsletter/preferences/route.ts",
188
+ "hasDefault": false,
189
+ "exports": [
190
+ "GET",
191
+ "POST"
192
+ ],
193
+ "config": {
194
+ "dynamic": "\"force-dynamic\"",
195
+ "runtime": "\"nodejs\""
196
+ }
197
+ },
198
+ {
199
+ "file": "app/api/newsletter/state/route.ts",
200
+ "hasDefault": false,
201
+ "exports": [
202
+ "GET"
203
+ ],
204
+ "config": {
205
+ "dynamic": "\"force-dynamic\"",
206
+ "runtime": "\"nodejs\""
207
+ }
208
+ },
209
+ {
210
+ "file": "app/api/newsletter/subscribe/route.ts",
211
+ "hasDefault": false,
212
+ "exports": [
213
+ "POST"
214
+ ],
215
+ "config": {
216
+ "dynamic": "\"force-dynamic\"",
217
+ "runtime": "\"nodejs\""
218
+ }
219
+ },
220
+ {
221
+ "file": "app/api/newsletter/unsubscribe/route.ts",
222
+ "hasDefault": false,
223
+ "exports": [
224
+ "GET",
225
+ "POST"
226
+ ],
227
+ "config": {
228
+ "dynamic": "\"force-dynamic\"",
229
+ "runtime": "\"nodejs\""
230
+ }
231
+ },
232
+ {
233
+ "file": "app/api/newsroom/curation/context/route.ts",
234
+ "hasDefault": false,
235
+ "exports": [
236
+ "GET"
237
+ ],
238
+ "config": {
239
+ "dynamic": "\"force-dynamic\"",
240
+ "runtime": "\"nodejs\""
241
+ }
242
+ },
243
+ {
244
+ "file": "app/api/newsroom/curation/priming/route.ts",
245
+ "hasDefault": false,
246
+ "exports": [
247
+ "POST"
248
+ ],
249
+ "config": {
250
+ "dynamic": "\"force-dynamic\"",
251
+ "runtime": "\"nodejs\""
252
+ }
253
+ },
254
+ {
255
+ "file": "app/api/newsroom/curation/publication/route.ts",
256
+ "hasDefault": false,
257
+ "exports": [
258
+ "POST"
259
+ ],
260
+ "config": {
261
+ "dynamic": "\"force-dynamic\"",
262
+ "runtime": "\"nodejs\""
263
+ }
264
+ },
265
+ {
266
+ "file": "app/api/reader/comment/delete/route.ts",
267
+ "hasDefault": false,
268
+ "exports": [
269
+ "POST"
270
+ ],
271
+ "config": {
272
+ "dynamic": "\"force-dynamic\"",
273
+ "runtime": "\"nodejs\""
274
+ }
275
+ },
276
+ {
277
+ "file": "app/api/reader/comment/edit/route.ts",
278
+ "hasDefault": false,
279
+ "exports": [
280
+ "POST"
281
+ ],
282
+ "config": {
283
+ "dynamic": "\"force-dynamic\"",
284
+ "runtime": "\"nodejs\""
285
+ }
286
+ },
287
+ {
288
+ "file": "app/api/reader/comment/route.ts",
289
+ "hasDefault": false,
290
+ "exports": [
291
+ "POST"
292
+ ],
293
+ "config": {
294
+ "dynamic": "\"force-dynamic\"",
295
+ "runtime": "\"nodejs\""
296
+ }
297
+ },
298
+ {
299
+ "file": "app/api/reader/handle/route.ts",
300
+ "hasDefault": false,
301
+ "exports": [
302
+ "POST"
303
+ ],
304
+ "config": {
305
+ "dynamic": "\"force-dynamic\"",
306
+ "runtime": "\"nodejs\""
307
+ }
308
+ },
309
+ {
310
+ "file": "app/api/reader/me/route.ts",
311
+ "hasDefault": false,
312
+ "exports": [
313
+ "GET"
314
+ ],
315
+ "config": {
316
+ "dynamic": "\"force-dynamic\"",
317
+ "runtime": "\"nodejs\""
318
+ }
319
+ },
320
+ {
321
+ "file": "app/api/reader/rating/route.ts",
322
+ "hasDefault": false,
323
+ "exports": [
324
+ "POST"
325
+ ],
326
+ "config": {
327
+ "dynamic": "\"force-dynamic\"",
328
+ "runtime": "\"nodejs\""
329
+ }
330
+ },
331
+ {
332
+ "file": "app/api/reader/report/route.ts",
333
+ "hasDefault": false,
334
+ "exports": [
335
+ "POST"
336
+ ],
337
+ "config": {
338
+ "dynamic": "\"force-dynamic\"",
339
+ "runtime": "\"nodejs\""
340
+ }
341
+ },
342
+ {
343
+ "file": "app/api/reader/retired/route.ts",
344
+ "hasDefault": false,
345
+ "exports": [
346
+ "GET"
347
+ ],
348
+ "config": {
349
+ "dynamic": "\"force-dynamic\"",
350
+ "runtime": "\"nodejs\""
351
+ }
352
+ },
353
+ {
354
+ "file": "app/api/reader/submit/route.ts",
355
+ "hasDefault": false,
356
+ "exports": [
357
+ "POST"
358
+ ],
359
+ "config": {
360
+ "dynamic": "\"force-dynamic\"",
361
+ "runtime": "\"nodejs\""
362
+ }
363
+ },
364
+ {
365
+ "file": "app/api/reader/vote/route.ts",
366
+ "hasDefault": false,
367
+ "exports": [
368
+ "POST"
369
+ ],
370
+ "config": {
371
+ "dynamic": "\"force-dynamic\"",
372
+ "runtime": "\"nodejs\""
373
+ }
374
+ },
173
375
  {
174
376
  "file": "app/api/revalidate/route.ts",
175
377
  "hasDefault": false,
@@ -1,11 +0,0 @@
1
- """The editorial-checks plugin's function: routes its GraphQL fields to papyrus_content.editorial_checks."""
2
-
3
- from __future__ import annotations
4
-
5
- from typing import Any
6
-
7
- from papyrus_content.editorial_checks import GraphQLEditorialStore, Services, handle
8
-
9
-
10
- def handler(event: dict[str, Any], _context: Any = None) -> dict[str, Any]:
11
- return handle(event["info"]["fieldName"], event.get("arguments") or {}, Services(store=GraphQLEditorialStore()))
@@ -1 +0,0 @@
1
- limatus[jev]>=0.31,<0.32
@@ -1,50 +0,0 @@
1
- import { secret } from "@aws-amplify/backend";
2
- import { Stack } from "aws-cdk-lib";
3
- import { Effect, PolicyStatement } from "aws-cdk-lib/aws-iam";
4
- import { editorialChecks } from "./function/resource.js";
5
- import { editorialChecksSchemaDefinitions } from "./schema.js";
6
- export const EDITORIAL_CHECKS_QUERIES = ["checkEditorial", "suggestEditorialRewrite", "draftEditorialQuestions", "tryEditorialPolicy"];
7
- export const EDITORIAL_CHECKS_MUTATIONS = ["importEditorialStarterPack", "recalibrateEditorialPolicies"];
8
- /** The model operations the function performs with its own role. */
9
- export const EDITORIAL_CHECKS_FUNCTION_FIELDS = [
10
- "Query/fields/listEditorialPolicies",
11
- "Query/fields/getEditorialCheckSettings",
12
- "Query/fields/listEditorialFeedbacks",
13
- "Mutation/fields/createEditorialPolicy",
14
- "Mutation/fields/updateEditorialPolicy",
15
- ];
16
- export const editorialChecksManifest = {
17
- name: "editorial-checks",
18
- contract: 1,
19
- models: ["EditorialPolicy", "EditorialCheckSettings", "EditorialFeedback"],
20
- mutations: [...EDITORIAL_CHECKS_QUERIES, ...EDITORIAL_CHECKS_MUTATIONS],
21
- guest: { mutations: [] },
22
- newsroomPanels: [{ id: "editorial-checks", label: "Editorial checks" }],
23
- staticAssets: [],
24
- };
25
- export function resolveEditorialChecksConfig(request) {
26
- const raw = typeof request === "string" ? { name: request } : request;
27
- const unknown = Object.keys(raw).filter((key) => key !== "name");
28
- if (unknown.length > 0)
29
- throw new Error(`Unknown editorial-checks plugin settings: ${unknown.join(", ")} (runtime settings are edited in the newsroom)`);
30
- return {};
31
- }
32
- export const editorialChecksPlugin = {
33
- manifest: editorialChecksManifest,
34
- resolveConfig: resolveEditorialChecksConfig,
35
- functions: () => ({ editorialChecks }),
36
- schemaDefinitions: editorialChecksSchemaDefinitions,
37
- publicSettings: () => ({ contract: editorialChecksManifest.contract }),
38
- wire(backend, _config, context) {
39
- const lambda = backend.editorialChecks.resources.lambda;
40
- const stack = Stack.of(lambda);
41
- lambda.addEnvironment("PAPYRUS_GRAPHQL_ENDPOINT", context.graphqlEndpoint);
42
- backend.editorialChecks.addEnvironment("TYPESAFE_API_KEY", secret("TYPESAFE_API_KEY"));
43
- backend.editorialChecks.addEnvironment("OPENAI_API_KEY", secret("OPENAI_API_KEY"));
44
- lambda.addToRolePolicy(new PolicyStatement({
45
- effect: Effect.ALLOW,
46
- actions: ["appsync:GraphQL"],
47
- resources: EDITORIAL_CHECKS_FUNCTION_FIELDS.map((field) => `arn:aws:appsync:${stack.region}:${stack.account}:apis/${context.graphqlApiId}/types/${field}`),
48
- }));
49
- },
50
- };
@@ -1,63 +0,0 @@
1
- import { secret } from "@aws-amplify/backend";
2
- import { Stack } from "aws-cdk-lib";
3
- import { Effect, PolicyStatement } from "aws-cdk-lib/aws-iam";
4
- import type { Function as LambdaFunction } from "aws-cdk-lib/aws-lambda";
5
- import type { PapyrusPlugin, PluginManifest, PluginRequest, PluginWiringContext } from "../types";
6
- import { editorialChecks } from "./function/resource";
7
- import { editorialChecksSchemaDefinitions } from "./schema";
8
-
9
- /** Runtime settings (lanes, models, deadline) live in EditorialCheckSettings, edited in the newsroom; enabling the plugin takes no options. */
10
- export type EditorialChecksPluginConfig = Record<string, never>;
11
-
12
- export const EDITORIAL_CHECKS_QUERIES = ["checkEditorial", "suggestEditorialRewrite", "draftEditorialQuestions", "tryEditorialPolicy"];
13
- export const EDITORIAL_CHECKS_MUTATIONS = ["importEditorialStarterPack", "recalibrateEditorialPolicies"];
14
-
15
- /** The model operations the function performs with its own role. */
16
- export const EDITORIAL_CHECKS_FUNCTION_FIELDS = [
17
- "Query/fields/listEditorialPolicies",
18
- "Query/fields/getEditorialCheckSettings",
19
- "Query/fields/listEditorialFeedbacks",
20
- "Mutation/fields/createEditorialPolicy",
21
- "Mutation/fields/updateEditorialPolicy",
22
- ];
23
-
24
- export const editorialChecksManifest: PluginManifest = {
25
- name: "editorial-checks",
26
- contract: 1,
27
- models: ["EditorialPolicy", "EditorialCheckSettings", "EditorialFeedback"],
28
- mutations: [...EDITORIAL_CHECKS_QUERIES, ...EDITORIAL_CHECKS_MUTATIONS],
29
- guest: { mutations: [] },
30
- newsroomPanels: [{ id: "editorial-checks", label: "Editorial checks" }],
31
- staticAssets: [],
32
- };
33
-
34
- export function resolveEditorialChecksConfig(request: PluginRequest): EditorialChecksPluginConfig {
35
- const raw = typeof request === "string" ? { name: request } : request;
36
- const unknown = Object.keys(raw).filter((key) => key !== "name");
37
- if (unknown.length > 0) throw new Error(`Unknown editorial-checks plugin settings: ${unknown.join(", ")} (runtime settings are edited in the newsroom)`);
38
- return {};
39
- }
40
-
41
- export const editorialChecksPlugin: PapyrusPlugin<EditorialChecksPluginConfig, { editorialChecks: typeof editorialChecks }> = {
42
- manifest: editorialChecksManifest,
43
- resolveConfig: resolveEditorialChecksConfig,
44
- functions: () => ({ editorialChecks }),
45
- schemaDefinitions: editorialChecksSchemaDefinitions,
46
- publicSettings: () => ({ contract: editorialChecksManifest.contract }),
47
- wire(backend, _config, context: PluginWiringContext) {
48
- const lambda = backend.editorialChecks.resources.lambda as LambdaFunction;
49
- const stack = Stack.of(lambda);
50
- lambda.addEnvironment("PAPYRUS_GRAPHQL_ENDPOINT", context.graphqlEndpoint);
51
- backend.editorialChecks.addEnvironment("TYPESAFE_API_KEY", secret("TYPESAFE_API_KEY"));
52
- backend.editorialChecks.addEnvironment("OPENAI_API_KEY", secret("OPENAI_API_KEY"));
53
- lambda.addToRolePolicy(
54
- new PolicyStatement({
55
- effect: Effect.ALLOW,
56
- actions: ["appsync:GraphQL"],
57
- resources: EDITORIAL_CHECKS_FUNCTION_FIELDS.map(
58
- (field) => `arn:aws:appsync:${stack.region}:${stack.account}:apis/${context.graphqlApiId}/types/${field}`,
59
- ),
60
- }),
61
- );
62
- },
63
- };
@@ -1,94 +0,0 @@
1
- import { a } from "@aws-amplify/backend";
2
- import { editorialChecks } from "./function/resource.js";
3
- const editors = ["editor", "admin"];
4
- /**
5
- * Policies, settings and editors' decisions live in Papyrus; Limatus checks
6
- * content against them. Editors read policies and record decisions; admins
7
- * manage policies and settings. Only the function (IAM) calls Limatus.
8
- */
9
- export function editorialChecksSchemaDefinitions() {
10
- return {
11
- EditorialPolicy: a
12
- .model({
13
- id: a.id().required(),
14
- policyKey: a.string().required(),
15
- scope: a.string().required(),
16
- version: a.integer().required(),
17
- title: a.string().required(),
18
- guidance: a.string().required(),
19
- severity: a.string().required(),
20
- enabled: a.boolean().required(),
21
- detectors: a.json().required(),
22
- examples: a.json(),
23
- rewriteGuidance: a.string(),
24
- source: a.string().required(),
25
- })
26
- .disableOperations(["subscriptions"])
27
- .authorization((allow) => [allow.group("editor").to(["read"]), allow.group("admin")]),
28
- EditorialCheckSettings: a
29
- .model({
30
- id: a.id().required(),
31
- settings: a.json().required(),
32
- })
33
- .disableOperations(["subscriptions"])
34
- .authorization((allow) => [allow.group("editor").to(["read"]), allow.group("admin")]),
35
- EditorialFeedback: a
36
- .model({
37
- id: a.id().required(),
38
- itemId: a.string().required(),
39
- findingId: a.string().required(),
40
- policyId: a.string().required(),
41
- detectorId: a.string().required(),
42
- lane: a.string().required(),
43
- probability: a.float(),
44
- decision: a.string().required(),
45
- reason: a.string(),
46
- text: a.string(),
47
- })
48
- .disableOperations(["subscriptions"])
49
- .secondaryIndexes((index) => [index("itemId").queryField("listEditorialFeedbackByItem")])
50
- .authorization((allow) => [allow.group("editor").to(["create", "read"]), allow.group("admin")]),
51
- checkEditorial: a
52
- .query()
53
- .arguments({ body: a.string().required(), format: a.string(), section: a.string() })
54
- .returns(a.json())
55
- .authorization((allow) => [allow.groups(editors)])
56
- .handler(a.handler.function(editorialChecks)),
57
- suggestEditorialRewrite: a
58
- .query()
59
- .arguments({
60
- body: a.string().required(),
61
- format: a.string(),
62
- section: a.string(),
63
- finding: a.json(),
64
- selection: a.json(),
65
- note: a.string(),
66
- })
67
- .returns(a.json())
68
- .authorization((allow) => [allow.groups(editors)])
69
- .handler(a.handler.function(editorialChecks)),
70
- draftEditorialQuestions: a
71
- .query()
72
- .arguments({ title: a.string().required(), guidance: a.string().required(), examples: a.json() })
73
- .returns(a.json())
74
- .authorization((allow) => [allow.group("admin")])
75
- .handler(a.handler.function(editorialChecks)),
76
- tryEditorialPolicy: a
77
- .query()
78
- .arguments({ policy: a.json().required(), text: a.string().required(), format: a.string() })
79
- .returns(a.json())
80
- .authorization((allow) => [allow.group("admin")])
81
- .handler(a.handler.function(editorialChecks)),
82
- importEditorialStarterPack: a
83
- .mutation()
84
- .arguments({ name: a.string().required() })
85
- .returns(a.json())
86
- .authorization((allow) => [allow.group("admin")])
87
- .handler(a.handler.function(editorialChecks)),
88
- recalibrateEditorialPolicies: a
89
- .mutation()
90
- .returns(a.json())
91
- .authorization((allow) => [allow.group("admin")])
92
- .handler(a.handler.function(editorialChecks)),
93
- };
94
- }