@anthusai/papyrus 2.0.0-next.7 → 2.0.0-next.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/amplify/data/resource.js +23 -3
- package/amplify/data/resource.ts +25 -3
- package/amplify/data/schema.js +2028 -1979
- package/amplify/data/schema.ts +72 -14
- package/amplify/functions/assignment-action/data-access.js +90 -0
- package/amplify/functions/assignment-action/data-access.ts +89 -0
- package/amplify/functions/assignment-action/handler.ts +1 -1
- package/amplify/functions/content-actions/handler.py +61 -2
- package/amplify/functions/content-actions/requirements.txt +1 -0
- package/amplify/functions/content-actions/resource.js +1 -1
- package/amplify/functions/content-actions/resource.ts +1 -1
- package/amplify/{plugins/editorial-checks/function → functions/editorial-checks}/handler.py +3 -3
- package/amplify/functions/editorial-checks/requirements.txt +1 -0
- package/amplify/{plugins/editorial-checks/function → functions/editorial-checks}/resource.js +7 -7
- package/amplify/{plugins/editorial-checks/function → functions/editorial-checks}/resource.ts +7 -7
- package/amplify/functions/editorial-checks/schema.js +121 -0
- package/amplify/{plugins → functions}/editorial-checks/schema.ts +33 -6
- package/amplify/functions/editorial-checks/wire.js +53 -0
- package/amplify/functions/editorial-checks/wire.ts +61 -0
- package/amplify/functions/monitoring-view/handler.py +11 -0
- package/amplify/functions/monitoring-view/resource.js +24 -0
- package/amplify/functions/monitoring-view/resource.ts +34 -0
- package/amplify/functions/monitoring-view/schema.js +16 -0
- package/amplify/functions/monitoring-view/schema.ts +18 -0
- package/amplify/functions/monitoring-view/wire.js +37 -0
- package/amplify/functions/monitoring-view/wire.ts +47 -0
- package/amplify/functions/public-forms/core.js +247 -0
- package/amplify/functions/public-forms/core.ts +310 -0
- package/amplify/functions/public-forms/handler.ts +41 -0
- package/amplify/functions/public-forms/origins.js +35 -0
- package/amplify/functions/public-forms/origins.ts +43 -0
- package/amplify/functions/public-forms/resource.js +9 -0
- package/amplify/functions/public-forms/resource.ts +10 -0
- package/amplify/functions/public-forms/wire.js +25 -0
- package/amplify/functions/public-forms/wire.ts +32 -0
- package/amplify/functions/shared/editorial-context.ts +63 -4
- package/amplify/functions/shared/python-bundle.js +20 -14
- package/amplify/functions/shared/python-bundle.ts +25 -18
- package/amplify/plugins/newsletter/config.js +245 -0
- package/amplify/plugins/newsletter/config.ts +305 -0
- package/amplify/plugins/newsletter/function/handler.py +6 -0
- package/amplify/plugins/newsletter/function/requirements.txt +5 -0
- package/amplify/plugins/newsletter/ops/handler.py +12 -0
- package/amplify/plugins/newsletter/ops/resource.js +27 -0
- package/amplify/plugins/newsletter/ops/resource.ts +37 -0
- package/amplify/plugins/newsletter/papyrus.plugin.js +263 -0
- package/amplify/plugins/newsletter/papyrus.plugin.ts +311 -0
- package/amplify/plugins/newsletter/schema.js +56 -0
- package/amplify/plugins/newsletter/schema.ts +61 -0
- package/amplify/plugins/newsletter/secure-string-parameter.js +107 -0
- package/amplify/plugins/newsletter/secure-string-parameter.ts +120 -0
- package/amplify/plugins/newsletter/sending.js +140 -0
- package/amplify/plugins/newsletter/sending.ts +186 -0
- package/amplify/plugins/reader-steering/config.js +180 -0
- package/amplify/plugins/reader-steering/config.ts +280 -0
- package/amplify/plugins/reader-steering/function/ai_moderation.py +246 -0
- package/amplify/plugins/reader-steering/function/handler.py +1554 -0
- package/amplify/plugins/reader-steering/function/moderation-prompt.md +27 -0
- package/amplify/plugins/reader-steering/function/moderation.py +316 -0
- package/amplify/plugins/reader-steering/function/proposals.py +255 -0
- package/amplify/plugins/reader-steering/function/resource.js +27 -0
- package/amplify/plugins/reader-steering/function/resource.ts +35 -0
- package/amplify/plugins/reader-steering/papyrus.plugin.js +184 -0
- package/amplify/plugins/reader-steering/papyrus.plugin.ts +210 -0
- package/amplify/plugins/reader-steering/schema.js +204 -0
- package/amplify/plugins/reader-steering/schema.ts +206 -0
- package/amplify/plugins/registry.js +4 -2
- package/amplify/plugins/registry.ts +4 -2
- package/amplify/plugins/types.ts +5 -0
- package/amplify/plugins/wire.js +1 -0
- package/amplify/plugins/wire.ts +1 -0
- package/amplify/publication/projection-lease.js +30 -0
- package/amplify/publication/projection-lease.ts +39 -0
- package/amplify/publication/redirect-and-index.js +105 -0
- package/amplify/publication/redirect-rules.js +73 -0
- package/amplify/publication/redirect-rules.ts +93 -0
- package/amplify/publication/s3-projection.js +7 -1
- package/amplify/publication/s3-projection.ts +9 -1
- package/amplify/site-backend-config.ts +17 -0
- package/amplify/site-backend.js +38 -1
- package/amplify/site-backend.ts +46 -1
- package/app/api/auth/prospectus/sign-in/route.ts +4 -0
- package/app/api/newsletter/confirm/route.ts +13 -0
- package/app/api/newsletter/preferences/route.ts +13 -0
- package/app/api/newsletter/state/route.ts +9 -0
- package/app/api/newsletter/subscribe/route.ts +9 -0
- package/app/api/newsletter/unsubscribe/route.ts +13 -0
- package/app/api/newsroom/curation/context/route.ts +9 -0
- package/app/api/newsroom/curation/priming/route.ts +9 -0
- package/app/api/newsroom/curation/publication/route.ts +9 -0
- package/app/api/reader/comment/delete/route.ts +9 -0
- package/app/api/reader/comment/edit/route.ts +9 -0
- package/app/api/reader/comment/route.ts +9 -0
- package/app/api/reader/flag/route.ts +9 -0
- package/app/api/reader/handle/route.ts +9 -0
- package/app/api/reader/me/route.ts +9 -0
- package/app/api/reader/rating/route.ts +9 -0
- package/app/api/reader/report/route.ts +9 -0
- package/app/api/reader/retired/route.ts +9 -0
- package/app/api/reader/submit/route.ts +9 -0
- package/app/api/reader/vote/route.ts +9 -0
- package/bin/papyrus-infra.mjs +20 -1
- package/components/editorial-checks-admin-panel.tsx +36 -11
- package/components/moderation-panel.tsx +248 -0
- package/components/monitoring-overview-view.tsx +241 -0
- package/components/monitoring-panel.tsx +40 -0
- package/components/newsletter-panel.tsx +474 -0
- package/components/newsletter-sections.tsx +163 -0
- package/components/newsroom-article-editor.tsx +2 -4
- package/components/newsroom-curation-bootstrap.tsx +45 -0
- package/components/newsroom-organizer.css +31 -0
- package/components/newsroom-references-view.tsx +14 -14
- package/components/publication-cyclotron-panel.tsx +15 -10
- package/components/reference-add-entry.tsx +75 -0
- package/components/reference-curation-controls.tsx +31 -22
- package/components/reference-cyclotron-priming.tsx +58 -19
- package/components/reference-cyclotron-suggestion.tsx +1 -1
- package/components/reference-priming.tsx +14 -10
- package/components/reference-section-suggestion.tsx +1 -1
- package/components/topic-steering-workspace.tsx +64 -20
- package/components/use-editorial-checks.ts +12 -10
- package/infra/amplify-app-shell.js +90 -16
- package/infra/amplify-app-shell.ts +102 -18
- package/infra/index.js +1 -0
- package/infra/secure-string-parameter-handler.js +41 -0
- package/infra/secure-string-parameter-handler.ts +41 -0
- package/infra/secure-string-parameter.js +79 -0
- package/infra/secure-string-parameter.ts +91 -0
- package/infra/site-config.js +86 -6
- package/infra/site-config.ts +129 -6
- package/lib/category-repository.ts +11 -9
- package/lib/curation-routes.ts +345 -0
- package/lib/editorial-checks-backend.ts +1 -1
- package/lib/editorial-checks-client.ts +19 -1
- package/lib/editorial-checks-demo.ts +2 -2
- package/lib/editorial-checks-settings.ts +3 -0
- package/lib/editorial-checks.ts +8 -11
- package/lib/editorial-preview.ts +5 -5
- package/lib/monitoring-client.ts +29 -0
- package/lib/monitoring-overview-fixture.ts +51 -0
- package/lib/monitoring-overview.ts +145 -0
- package/lib/newsletter-api.ts +418 -0
- package/lib/newsletter-client.ts +46 -0
- package/lib/newsletter-fixture.ts +184 -0
- package/lib/newsletter-model.ts +202 -0
- package/lib/prospectus-session.ts +15 -14
- package/lib/prospectus-sign-in-routes.ts +84 -19
- package/lib/prospectus-site-identity.ts +24 -1
- package/lib/reader-api.ts +145 -0
- package/lib/reader-moderation.ts +220 -0
- package/lib/reader-retirement-route.ts +89 -0
- package/lib/reader-subject.md +29 -0
- package/lib/reader-subject.ts +53 -0
- package/lib/relevance-status.ts +2 -2
- package/lib/semantic-graph.ts +2 -0
- package/lib/site-brand-tenant.ts +11 -6
- package/lib/site-brand.ts +6 -3
- package/lib/site-origin.ts +67 -0
- package/middleware.ts +14 -3
- package/package.json +42 -3
- package/routes.manifest.json +215 -2
- package/amplify/plugins/editorial-checks/function/requirements.txt +0 -1
- package/amplify/plugins/editorial-checks/papyrus.plugin.js +0 -69
- package/amplify/plugins/editorial-checks/papyrus.plugin.ts +0 -85
- package/amplify/plugins/editorial-checks/schema.js +0 -94
package/routes.manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.0.0-next.
|
|
2
|
+
"version": "2.0.0-next.71",
|
|
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,218 @@
|
|
|
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/flag/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/handle/route.ts",
|
|
311
|
+
"hasDefault": false,
|
|
312
|
+
"exports": [
|
|
313
|
+
"POST"
|
|
314
|
+
],
|
|
315
|
+
"config": {
|
|
316
|
+
"dynamic": "\"force-dynamic\"",
|
|
317
|
+
"runtime": "\"nodejs\""
|
|
318
|
+
}
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
"file": "app/api/reader/me/route.ts",
|
|
322
|
+
"hasDefault": false,
|
|
323
|
+
"exports": [
|
|
324
|
+
"GET"
|
|
325
|
+
],
|
|
326
|
+
"config": {
|
|
327
|
+
"dynamic": "\"force-dynamic\"",
|
|
328
|
+
"runtime": "\"nodejs\""
|
|
329
|
+
}
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
"file": "app/api/reader/rating/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/report/route.ts",
|
|
344
|
+
"hasDefault": false,
|
|
345
|
+
"exports": [
|
|
346
|
+
"POST"
|
|
347
|
+
],
|
|
348
|
+
"config": {
|
|
349
|
+
"dynamic": "\"force-dynamic\"",
|
|
350
|
+
"runtime": "\"nodejs\""
|
|
351
|
+
}
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
"file": "app/api/reader/retired/route.ts",
|
|
355
|
+
"hasDefault": false,
|
|
356
|
+
"exports": [
|
|
357
|
+
"GET"
|
|
358
|
+
],
|
|
359
|
+
"config": {
|
|
360
|
+
"dynamic": "\"force-dynamic\"",
|
|
361
|
+
"runtime": "\"nodejs\""
|
|
362
|
+
}
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
"file": "app/api/reader/submit/route.ts",
|
|
366
|
+
"hasDefault": false,
|
|
367
|
+
"exports": [
|
|
368
|
+
"POST"
|
|
369
|
+
],
|
|
370
|
+
"config": {
|
|
371
|
+
"dynamic": "\"force-dynamic\"",
|
|
372
|
+
"runtime": "\"nodejs\""
|
|
373
|
+
}
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
"file": "app/api/reader/vote/route.ts",
|
|
377
|
+
"hasDefault": false,
|
|
378
|
+
"exports": [
|
|
379
|
+
"POST"
|
|
380
|
+
],
|
|
381
|
+
"config": {
|
|
382
|
+
"dynamic": "\"force-dynamic\"",
|
|
383
|
+
"runtime": "\"nodejs\""
|
|
384
|
+
}
|
|
385
|
+
},
|
|
173
386
|
{
|
|
174
387
|
"file": "app/api/revalidate/route.ts",
|
|
175
388
|
"hasDefault": false,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
limatus[jev]>=0.31,<0.32
|
|
@@ -1,69 +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 EDITORIAL_CHECKS_SECRETS = ["TYPESAFE_API_KEY", "OPENAI_API_KEY"];
|
|
17
|
-
/**
|
|
18
|
-
* SSM parameters holding the provider keys. A Python function reads its secret()
|
|
19
|
-
* values itself (Amplify only resolves them for Node functions), so it needs read
|
|
20
|
-
* access to the app's branch and shared secret paths, and to the sandbox paths.
|
|
21
|
-
*/
|
|
22
|
-
export function editorialChecksSecretParameters(region, account, appId) {
|
|
23
|
-
const arn = (path) => `arn:aws:ssm:${region}:${account}:parameter/amplify/${path}`;
|
|
24
|
-
return EDITORIAL_CHECKS_SECRETS.flatMap((name) => [
|
|
25
|
-
arn(`papyrus/*/${name}`),
|
|
26
|
-
arn(`shared/papyrus/${name}`),
|
|
27
|
-
...(appId ? [arn(`${appId}/*/${name}`), arn(`shared/${appId}/${name}`)] : []),
|
|
28
|
-
]);
|
|
29
|
-
}
|
|
30
|
-
export const editorialChecksManifest = {
|
|
31
|
-
name: "editorial-checks",
|
|
32
|
-
contract: 1,
|
|
33
|
-
models: ["EditorialPolicy", "EditorialCheckSettings", "EditorialFeedback"],
|
|
34
|
-
mutations: [...EDITORIAL_CHECKS_QUERIES, ...EDITORIAL_CHECKS_MUTATIONS],
|
|
35
|
-
guest: { mutations: [] },
|
|
36
|
-
newsroomPanels: [{ id: "editorial-checks", label: "Editorial checks" }],
|
|
37
|
-
staticAssets: [],
|
|
38
|
-
};
|
|
39
|
-
export function resolveEditorialChecksConfig(request) {
|
|
40
|
-
const raw = typeof request === "string" ? { name: request } : request;
|
|
41
|
-
const unknown = Object.keys(raw).filter((key) => key !== "name");
|
|
42
|
-
if (unknown.length > 0)
|
|
43
|
-
throw new Error(`Unknown editorial-checks plugin settings: ${unknown.join(", ")} (runtime settings are edited in the newsroom)`);
|
|
44
|
-
return {};
|
|
45
|
-
}
|
|
46
|
-
export const editorialChecksPlugin = {
|
|
47
|
-
manifest: editorialChecksManifest,
|
|
48
|
-
resolveConfig: resolveEditorialChecksConfig,
|
|
49
|
-
functions: () => ({ editorialChecks }),
|
|
50
|
-
schemaDefinitions: editorialChecksSchemaDefinitions,
|
|
51
|
-
publicSettings: () => ({ contract: editorialChecksManifest.contract }),
|
|
52
|
-
wire(backend, _config, context) {
|
|
53
|
-
const lambda = backend.editorialChecks.resources.lambda;
|
|
54
|
-
const stack = Stack.of(lambda);
|
|
55
|
-
lambda.addEnvironment("PAPYRUS_GRAPHQL_ENDPOINT", context.graphqlEndpoint);
|
|
56
|
-
for (const name of EDITORIAL_CHECKS_SECRETS)
|
|
57
|
-
backend.editorialChecks.addEnvironment(name, secret(name));
|
|
58
|
-
lambda.addToRolePolicy(new PolicyStatement({
|
|
59
|
-
effect: Effect.ALLOW,
|
|
60
|
-
actions: ["ssm:GetParameter", "ssm:GetParameters"],
|
|
61
|
-
resources: editorialChecksSecretParameters(stack.region, stack.account, (process.env.AWS_APP_ID ?? "").trim()),
|
|
62
|
-
}));
|
|
63
|
-
lambda.addToRolePolicy(new PolicyStatement({
|
|
64
|
-
effect: Effect.ALLOW,
|
|
65
|
-
actions: ["appsync:GraphQL"],
|
|
66
|
-
resources: EDITORIAL_CHECKS_FUNCTION_FIELDS.map((field) => `arn:aws:appsync:${stack.region}:${stack.account}:apis/${context.graphqlApiId}/types/${field}`),
|
|
67
|
-
}));
|
|
68
|
-
},
|
|
69
|
-
};
|
|
@@ -1,85 +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 EDITORIAL_CHECKS_SECRETS = ["TYPESAFE_API_KEY", "OPENAI_API_KEY"];
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* SSM parameters holding the provider keys. A Python function reads its secret()
|
|
28
|
-
* values itself (Amplify only resolves them for Node functions), so it needs read
|
|
29
|
-
* access to the app's branch and shared secret paths, and to the sandbox paths.
|
|
30
|
-
*/
|
|
31
|
-
export function editorialChecksSecretParameters(region: string, account: string, appId: string): string[] {
|
|
32
|
-
const arn = (path: string) => `arn:aws:ssm:${region}:${account}:parameter/amplify/${path}`;
|
|
33
|
-
return EDITORIAL_CHECKS_SECRETS.flatMap((name) => [
|
|
34
|
-
arn(`papyrus/*/${name}`),
|
|
35
|
-
arn(`shared/papyrus/${name}`),
|
|
36
|
-
...(appId ? [arn(`${appId}/*/${name}`), arn(`shared/${appId}/${name}`)] : []),
|
|
37
|
-
]);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export const editorialChecksManifest: PluginManifest = {
|
|
41
|
-
name: "editorial-checks",
|
|
42
|
-
contract: 1,
|
|
43
|
-
models: ["EditorialPolicy", "EditorialCheckSettings", "EditorialFeedback"],
|
|
44
|
-
mutations: [...EDITORIAL_CHECKS_QUERIES, ...EDITORIAL_CHECKS_MUTATIONS],
|
|
45
|
-
guest: { mutations: [] },
|
|
46
|
-
newsroomPanels: [{ id: "editorial-checks", label: "Editorial checks" }],
|
|
47
|
-
staticAssets: [],
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export function resolveEditorialChecksConfig(request: PluginRequest): EditorialChecksPluginConfig {
|
|
51
|
-
const raw = typeof request === "string" ? { name: request } : request;
|
|
52
|
-
const unknown = Object.keys(raw).filter((key) => key !== "name");
|
|
53
|
-
if (unknown.length > 0) throw new Error(`Unknown editorial-checks plugin settings: ${unknown.join(", ")} (runtime settings are edited in the newsroom)`);
|
|
54
|
-
return {};
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export const editorialChecksPlugin: PapyrusPlugin<EditorialChecksPluginConfig, { editorialChecks: typeof editorialChecks }> = {
|
|
58
|
-
manifest: editorialChecksManifest,
|
|
59
|
-
resolveConfig: resolveEditorialChecksConfig,
|
|
60
|
-
functions: () => ({ editorialChecks }),
|
|
61
|
-
schemaDefinitions: editorialChecksSchemaDefinitions,
|
|
62
|
-
publicSettings: () => ({ contract: editorialChecksManifest.contract }),
|
|
63
|
-
wire(backend, _config, context: PluginWiringContext) {
|
|
64
|
-
const lambda = backend.editorialChecks.resources.lambda as LambdaFunction;
|
|
65
|
-
const stack = Stack.of(lambda);
|
|
66
|
-
lambda.addEnvironment("PAPYRUS_GRAPHQL_ENDPOINT", context.graphqlEndpoint);
|
|
67
|
-
for (const name of EDITORIAL_CHECKS_SECRETS) backend.editorialChecks.addEnvironment(name, secret(name));
|
|
68
|
-
lambda.addToRolePolicy(
|
|
69
|
-
new PolicyStatement({
|
|
70
|
-
effect: Effect.ALLOW,
|
|
71
|
-
actions: ["ssm:GetParameter", "ssm:GetParameters"],
|
|
72
|
-
resources: editorialChecksSecretParameters(stack.region, stack.account, (process.env.AWS_APP_ID ?? "").trim()),
|
|
73
|
-
}),
|
|
74
|
-
);
|
|
75
|
-
lambda.addToRolePolicy(
|
|
76
|
-
new PolicyStatement({
|
|
77
|
-
effect: Effect.ALLOW,
|
|
78
|
-
actions: ["appsync:GraphQL"],
|
|
79
|
-
resources: EDITORIAL_CHECKS_FUNCTION_FIELDS.map(
|
|
80
|
-
(field) => `arn:aws:appsync:${stack.region}:${stack.account}:apis/${context.graphqlApiId}/types/${field}`,
|
|
81
|
-
),
|
|
82
|
-
}),
|
|
83
|
-
);
|
|
84
|
-
},
|
|
85
|
-
};
|
|
@@ -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
|
-
}
|