@anthusai/papyrus 2.0.0-next.10 → 2.0.0-next.101
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/auth/resource.js +16 -1
- package/amplify/auth/resource.ts +19 -1
- package/amplify/data/function-handler.js +20 -0
- package/amplify/data/function-handler.ts +40 -0
- package/amplify/data/resource.js +152 -62
- package/amplify/data/resource.ts +158 -62
- package/amplify/data/schema.js +2102 -1986
- package/amplify/data/schema.ts +199 -70
- package/amplify/functions/assignment-action/data-access.js +2 -0
- package/amplify/functions/assignment-action/data-access.ts +2 -0
- package/amplify/functions/assignment-action/handler.ts +1 -1
- package/amplify/functions/automation-view/handler.py +17 -0
- package/amplify/functions/automation-view/resource.js +24 -0
- package/amplify/functions/automation-view/resource.ts +34 -0
- package/amplify/functions/automation-view/schema.js +26 -0
- package/amplify/functions/automation-view/schema.ts +28 -0
- package/amplify/functions/automation-view/wire.js +56 -0
- package/amplify/functions/automation-view/wire.ts +76 -0
- package/amplify/functions/content-actions/handler.py +64 -3
- 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 +122 -0
- package/amplify/{plugins → functions}/editorial-checks/schema.ts +40 -12
- 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 +29 -0
- package/amplify/functions/monitoring-view/schema.ts +31 -0
- package/amplify/functions/monitoring-view/wire.js +64 -0
- package/amplify/functions/monitoring-view/wire.ts +81 -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 +57 -0
- package/amplify/plugins/newsletter/schema.ts +62 -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 +182 -0
- package/amplify/plugins/reader-steering/config.ts +290 -0
- package/amplify/plugins/reader-steering/function/ai_moderation.py +246 -0
- package/amplify/plugins/reader-steering/function/handler.py +1567 -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 +458 -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 +186 -0
- package/amplify/plugins/reader-steering/papyrus.plugin.ts +212 -0
- package/amplify/plugins/reader-steering/schema.js +229 -0
- package/amplify/plugins/reader-steering/schema.ts +231 -0
- package/amplify/plugins/registry.js +4 -2
- package/amplify/plugins/registry.ts +4 -2
- package/amplify/plugins/signup/schema.js +2 -1
- package/amplify/plugins/signup/schema.ts +2 -1
- 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.js +19 -0
- package/amplify/site-backend-config.ts +45 -1
- package/amplify/site-backend-names.js +4 -2
- package/amplify/site-backend-names.ts +4 -2
- package/amplify/site-backend.js +46 -4
- package/amplify/site-backend.ts +49 -4
- 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/chat/[...path]/route.ts +17 -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/app/layout.tsx +5 -1
- package/bin/papyrus-infra.mjs +20 -1
- package/components/automation-panel.tsx +49 -0
- package/components/automation-run-now.tsx +97 -0
- package/components/automation-view.tsx +195 -0
- package/components/editorial-checks-admin-panel.tsx +38 -13
- package/components/moderation-panel.tsx +248 -0
- package/components/monitoring-overview-view.tsx +414 -0
- package/components/monitoring-panel.tsx +60 -0
- package/components/news-desk-client-provider.tsx +18 -18
- package/components/news-desk-taxonomy-client.ts +28 -8
- package/components/newsletter-panel.tsx +474 -0
- package/components/newsletter-sections.tsx +163 -0
- package/components/newsroom-access-gate.tsx +16 -2
- package/components/newsroom-article-editor.tsx +11 -11
- package/components/newsroom-articles-view.tsx +6 -6
- package/components/newsroom-assignment-detail.tsx +6 -6
- package/components/newsroom-board-view.tsx +8 -3
- package/components/newsroom-curation-bootstrap.tsx +45 -0
- package/components/newsroom-ops-overview.tsx +26 -96
- package/components/newsroom-ops-shell.tsx +2 -2
- package/components/newsroom-organizer.css +33 -0
- package/components/newsroom-overview-skeleton.tsx +25 -0
- package/components/newsroom-references-view.tsx +192 -49
- package/components/notification-center.tsx +281 -0
- package/components/papyrus-console-conversation.css +14 -0
- package/components/papyrus-console-conversation.tsx +55 -0
- package/components/papyrus-console-shell.tsx +62 -420
- package/components/papyrus-private-chat-panel.tsx +134 -0
- package/components/publication-cyclotron-panel.tsx +15 -10
- package/components/reader-auth-state.ts +1 -1
- 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 +10 -6
- package/components/reference-priming.tsx +14 -10
- package/components/reference-relevance-review.tsx +3 -3
- package/components/reference-section-suggestion.tsx +1 -1
- package/components/topic-steering-workspace.tsx +237 -158
- package/components/use-editorial-checks.ts +12 -10
- package/infra/amplify-app-shell.js +96 -16
- package/infra/amplify-app-shell.ts +108 -18
- package/infra/cloud-email-config.js +32 -0
- package/infra/cloud-email-config.ts +39 -0
- package/infra/cloud-email.js +57 -0
- package/infra/cloud-email.test.js +69 -0
- package/infra/cloud-email.test.ts +66 -0
- package/infra/cloud-email.ts +60 -0
- 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 +92 -6
- package/infra/site-config.ts +138 -6
- package/lib/automation-client.ts +54 -0
- package/lib/automation-fixture.ts +93 -0
- package/lib/automation-overview.ts +252 -0
- package/lib/category-repository.ts +14 -12
- package/lib/console-web-context.ts +1 -1
- package/lib/curation-routes.ts +345 -0
- package/lib/cyclotron-suggestions.ts +4 -4
- 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 +83 -0
- package/lib/monitoring-overview-fixture.ts +51 -0
- package/lib/monitoring-overview.ts +188 -0
- package/lib/news-desk-session.ts +12 -21
- 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/newsroom-demo-dashboard.ts +1 -1
- package/lib/newsroom-nav.ts +1 -1
- package/lib/newsroom-organizer-nav.ts +2 -1
- package/lib/papyrus-chat-admission.ts +65 -0
- package/lib/papyrus-hosted-chat.ts +217 -0
- package/lib/papyrus-private-chat-client.ts +81 -0
- package/lib/prospectus-session.ts +30 -14
- package/lib/prospectus-sign-in-routes.ts +106 -31
- package/lib/prospectus-site-identity.ts +46 -6
- 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/reference-review-details.ts +71 -0
- package/lib/reference-review-request.ts +14 -0
- package/lib/relevance-decisions.ts +42 -10
- package/lib/relevance-status.ts +2 -2
- package/lib/review-client.ts +120 -0
- package/lib/review-fixture.ts +45 -0
- package/lib/review-requests.ts +246 -0
- package/lib/semantic-graph.ts +2 -0
- package/lib/shared-chat-admission.ts +182 -0
- package/lib/site-brand-tenant.ts +11 -6
- package/lib/site-brand.ts +6 -3
- package/lib/site-origin-value.ts +50 -0
- package/lib/site-origin.ts +8 -0
- package/lib/use-reference-review-data.ts +44 -0
- package/middleware.ts +14 -3
- package/package.json +65 -3
- package/routes.manifest.json +227 -2
- package/src/with-papyrus.mjs +1 -1
- package/amplify/plugins/editorial-checks/function/requirements.txt +0 -1
- package/amplify/plugins/editorial-checks/papyrus.plugin.js +0 -71
- package/amplify/plugins/editorial-checks/papyrus.plugin.ts +0 -87
- package/amplify/plugins/editorial-checks/schema.js +0 -94
|
@@ -1,71 +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/listKnowledgeCorporaByRoleAndName",
|
|
11
|
-
"Query/fields/getEditorialContext",
|
|
12
|
-
"Query/fields/listEditorialPolicies",
|
|
13
|
-
"Query/fields/getEditorialCheckSettings",
|
|
14
|
-
"Query/fields/listEditorialFeedbacks",
|
|
15
|
-
"Mutation/fields/createEditorialPolicy",
|
|
16
|
-
"Mutation/fields/updateEditorialPolicy",
|
|
17
|
-
];
|
|
18
|
-
export const EDITORIAL_CHECKS_SECRETS = ["TYPESAFE_API_KEY", "OPENAI_API_KEY"];
|
|
19
|
-
/**
|
|
20
|
-
* SSM parameters holding the provider keys. A Python function reads its secret()
|
|
21
|
-
* values itself (Amplify only resolves them for Node functions), so it needs read
|
|
22
|
-
* access to the app's branch and shared secret paths, and to the sandbox paths.
|
|
23
|
-
*/
|
|
24
|
-
export function editorialChecksSecretParameters(region, account, appId) {
|
|
25
|
-
const arn = (path) => `arn:aws:ssm:${region}:${account}:parameter/amplify/${path}`;
|
|
26
|
-
return EDITORIAL_CHECKS_SECRETS.flatMap((name) => [
|
|
27
|
-
arn(`papyrus/*/${name}`),
|
|
28
|
-
arn(`shared/papyrus/${name}`),
|
|
29
|
-
...(appId ? [arn(`${appId}/*/${name}`), arn(`shared/${appId}/${name}`)] : []),
|
|
30
|
-
]);
|
|
31
|
-
}
|
|
32
|
-
export const editorialChecksManifest = {
|
|
33
|
-
name: "editorial-checks",
|
|
34
|
-
contract: 1,
|
|
35
|
-
models: ["EditorialPolicy", "EditorialCheckSettings", "EditorialFeedback"],
|
|
36
|
-
mutations: [...EDITORIAL_CHECKS_QUERIES, ...EDITORIAL_CHECKS_MUTATIONS],
|
|
37
|
-
guest: { mutations: [] },
|
|
38
|
-
newsroomPanels: [{ id: "editorial-checks", label: "Editorial checks" }],
|
|
39
|
-
staticAssets: [],
|
|
40
|
-
};
|
|
41
|
-
export function resolveEditorialChecksConfig(request) {
|
|
42
|
-
const raw = typeof request === "string" ? { name: request } : request;
|
|
43
|
-
const unknown = Object.keys(raw).filter((key) => key !== "name");
|
|
44
|
-
if (unknown.length > 0)
|
|
45
|
-
throw new Error(`Unknown editorial-checks plugin settings: ${unknown.join(", ")} (runtime settings are edited in the newsroom)`);
|
|
46
|
-
return {};
|
|
47
|
-
}
|
|
48
|
-
export const editorialChecksPlugin = {
|
|
49
|
-
manifest: editorialChecksManifest,
|
|
50
|
-
resolveConfig: resolveEditorialChecksConfig,
|
|
51
|
-
functions: () => ({ editorialChecks }),
|
|
52
|
-
schemaDefinitions: editorialChecksSchemaDefinitions,
|
|
53
|
-
publicSettings: () => ({ contract: editorialChecksManifest.contract }),
|
|
54
|
-
wire(backend, _config, context) {
|
|
55
|
-
const lambda = backend.editorialChecks.resources.lambda;
|
|
56
|
-
const stack = Stack.of(lambda);
|
|
57
|
-
lambda.addEnvironment("PAPYRUS_GRAPHQL_ENDPOINT", context.graphqlEndpoint);
|
|
58
|
-
for (const name of EDITORIAL_CHECKS_SECRETS)
|
|
59
|
-
backend.editorialChecks.addEnvironment(name, secret(name));
|
|
60
|
-
lambda.addToRolePolicy(new PolicyStatement({
|
|
61
|
-
effect: Effect.ALLOW,
|
|
62
|
-
actions: ["ssm:GetParameter", "ssm:GetParameters"],
|
|
63
|
-
resources: editorialChecksSecretParameters(stack.region, stack.account, (process.env.AWS_APP_ID ?? "").trim()),
|
|
64
|
-
}));
|
|
65
|
-
lambda.addToRolePolicy(new PolicyStatement({
|
|
66
|
-
effect: Effect.ALLOW,
|
|
67
|
-
actions: ["appsync:GraphQL"],
|
|
68
|
-
resources: EDITORIAL_CHECKS_FUNCTION_FIELDS.map((field) => `arn:aws:appsync:${stack.region}:${stack.account}:apis/${context.graphqlApiId}/types/${field}`),
|
|
69
|
-
}));
|
|
70
|
-
},
|
|
71
|
-
};
|
|
@@ -1,87 +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/listKnowledgeCorporaByRoleAndName",
|
|
18
|
-
"Query/fields/getEditorialContext",
|
|
19
|
-
"Query/fields/listEditorialPolicies",
|
|
20
|
-
"Query/fields/getEditorialCheckSettings",
|
|
21
|
-
"Query/fields/listEditorialFeedbacks",
|
|
22
|
-
"Mutation/fields/createEditorialPolicy",
|
|
23
|
-
"Mutation/fields/updateEditorialPolicy",
|
|
24
|
-
];
|
|
25
|
-
|
|
26
|
-
export const EDITORIAL_CHECKS_SECRETS = ["TYPESAFE_API_KEY", "OPENAI_API_KEY"];
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* SSM parameters holding the provider keys. A Python function reads its secret()
|
|
30
|
-
* values itself (Amplify only resolves them for Node functions), so it needs read
|
|
31
|
-
* access to the app's branch and shared secret paths, and to the sandbox paths.
|
|
32
|
-
*/
|
|
33
|
-
export function editorialChecksSecretParameters(region: string, account: string, appId: string): string[] {
|
|
34
|
-
const arn = (path: string) => `arn:aws:ssm:${region}:${account}:parameter/amplify/${path}`;
|
|
35
|
-
return EDITORIAL_CHECKS_SECRETS.flatMap((name) => [
|
|
36
|
-
arn(`papyrus/*/${name}`),
|
|
37
|
-
arn(`shared/papyrus/${name}`),
|
|
38
|
-
...(appId ? [arn(`${appId}/*/${name}`), arn(`shared/${appId}/${name}`)] : []),
|
|
39
|
-
]);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export const editorialChecksManifest: PluginManifest = {
|
|
43
|
-
name: "editorial-checks",
|
|
44
|
-
contract: 1,
|
|
45
|
-
models: ["EditorialPolicy", "EditorialCheckSettings", "EditorialFeedback"],
|
|
46
|
-
mutations: [...EDITORIAL_CHECKS_QUERIES, ...EDITORIAL_CHECKS_MUTATIONS],
|
|
47
|
-
guest: { mutations: [] },
|
|
48
|
-
newsroomPanels: [{ id: "editorial-checks", label: "Editorial checks" }],
|
|
49
|
-
staticAssets: [],
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export function resolveEditorialChecksConfig(request: PluginRequest): EditorialChecksPluginConfig {
|
|
53
|
-
const raw = typeof request === "string" ? { name: request } : request;
|
|
54
|
-
const unknown = Object.keys(raw).filter((key) => key !== "name");
|
|
55
|
-
if (unknown.length > 0) throw new Error(`Unknown editorial-checks plugin settings: ${unknown.join(", ")} (runtime settings are edited in the newsroom)`);
|
|
56
|
-
return {};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export const editorialChecksPlugin: PapyrusPlugin<EditorialChecksPluginConfig, { editorialChecks: typeof editorialChecks }> = {
|
|
60
|
-
manifest: editorialChecksManifest,
|
|
61
|
-
resolveConfig: resolveEditorialChecksConfig,
|
|
62
|
-
functions: () => ({ editorialChecks }),
|
|
63
|
-
schemaDefinitions: editorialChecksSchemaDefinitions,
|
|
64
|
-
publicSettings: () => ({ contract: editorialChecksManifest.contract }),
|
|
65
|
-
wire(backend, _config, context: PluginWiringContext) {
|
|
66
|
-
const lambda = backend.editorialChecks.resources.lambda as LambdaFunction;
|
|
67
|
-
const stack = Stack.of(lambda);
|
|
68
|
-
lambda.addEnvironment("PAPYRUS_GRAPHQL_ENDPOINT", context.graphqlEndpoint);
|
|
69
|
-
for (const name of EDITORIAL_CHECKS_SECRETS) backend.editorialChecks.addEnvironment(name, secret(name));
|
|
70
|
-
lambda.addToRolePolicy(
|
|
71
|
-
new PolicyStatement({
|
|
72
|
-
effect: Effect.ALLOW,
|
|
73
|
-
actions: ["ssm:GetParameter", "ssm:GetParameters"],
|
|
74
|
-
resources: editorialChecksSecretParameters(stack.region, stack.account, (process.env.AWS_APP_ID ?? "").trim()),
|
|
75
|
-
}),
|
|
76
|
-
);
|
|
77
|
-
lambda.addToRolePolicy(
|
|
78
|
-
new PolicyStatement({
|
|
79
|
-
effect: Effect.ALLOW,
|
|
80
|
-
actions: ["appsync:GraphQL"],
|
|
81
|
-
resources: EDITORIAL_CHECKS_FUNCTION_FIELDS.map(
|
|
82
|
-
(field) => `arn:aws:appsync:${stack.region}:${stack.account}:apis/${context.graphqlApiId}/types/${field}`,
|
|
83
|
-
),
|
|
84
|
-
}),
|
|
85
|
-
);
|
|
86
|
-
},
|
|
87
|
-
};
|
|
@@ -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
|
-
}
|