@anthusai/papyrus 2.0.0-next.5 → 2.0.0-next.7
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/plugins/editorial-checks/function/handler.py +4 -1
- package/amplify/plugins/editorial-checks/papyrus.plugin.js +21 -2
- package/amplify/plugins/editorial-checks/papyrus.plugin.ts +24 -2
- package/components/newsroom-board-view.tsx +4 -1
- package/lib/newsroom-board.ts +27 -2
- package/package.json +2 -2
- package/routes.manifest.json +1 -1
|
@@ -4,7 +4,10 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
from typing import Any
|
|
6
6
|
|
|
7
|
-
from papyrus_content.editorial_checks import GraphQLEditorialStore, Services, handle
|
|
7
|
+
from papyrus_content.editorial_checks import GraphQLEditorialStore, Services, handle, load_provider_keys
|
|
8
|
+
|
|
9
|
+
# Amplify passes secrets to Python functions as placeholders; resolve them once per cold start.
|
|
10
|
+
load_provider_keys()
|
|
8
11
|
|
|
9
12
|
|
|
10
13
|
def handler(event: dict[str, Any], _context: Any = None) -> dict[str, Any]:
|
|
@@ -13,6 +13,20 @@ export const EDITORIAL_CHECKS_FUNCTION_FIELDS = [
|
|
|
13
13
|
"Mutation/fields/createEditorialPolicy",
|
|
14
14
|
"Mutation/fields/updateEditorialPolicy",
|
|
15
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
|
+
}
|
|
16
30
|
export const editorialChecksManifest = {
|
|
17
31
|
name: "editorial-checks",
|
|
18
32
|
contract: 1,
|
|
@@ -39,8 +53,13 @@ export const editorialChecksPlugin = {
|
|
|
39
53
|
const lambda = backend.editorialChecks.resources.lambda;
|
|
40
54
|
const stack = Stack.of(lambda);
|
|
41
55
|
lambda.addEnvironment("PAPYRUS_GRAPHQL_ENDPOINT", context.graphqlEndpoint);
|
|
42
|
-
|
|
43
|
-
|
|
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
|
+
}));
|
|
44
63
|
lambda.addToRolePolicy(new PolicyStatement({
|
|
45
64
|
effect: Effect.ALLOW,
|
|
46
65
|
actions: ["appsync:GraphQL"],
|
|
@@ -21,6 +21,22 @@ export const EDITORIAL_CHECKS_FUNCTION_FIELDS = [
|
|
|
21
21
|
"Mutation/fields/updateEditorialPolicy",
|
|
22
22
|
];
|
|
23
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
|
+
|
|
24
40
|
export const editorialChecksManifest: PluginManifest = {
|
|
25
41
|
name: "editorial-checks",
|
|
26
42
|
contract: 1,
|
|
@@ -48,8 +64,14 @@ export const editorialChecksPlugin: PapyrusPlugin<EditorialChecksPluginConfig, {
|
|
|
48
64
|
const lambda = backend.editorialChecks.resources.lambda as LambdaFunction;
|
|
49
65
|
const stack = Stack.of(lambda);
|
|
50
66
|
lambda.addEnvironment("PAPYRUS_GRAPHQL_ENDPOINT", context.graphqlEndpoint);
|
|
51
|
-
backend.editorialChecks.addEnvironment(
|
|
52
|
-
|
|
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
|
+
);
|
|
53
75
|
lambda.addToRolePolicy(
|
|
54
76
|
new PolicyStatement({
|
|
55
77
|
effect: Effect.ALLOW,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
4
4
|
import Link from "next/link";
|
|
5
5
|
import { usePathname, useRouter, useSearchParams } from "next/navigation";
|
|
6
|
-
import { IssueCollection, IssueDetailPanel, IssueTypeFilter, issueTypeFromFilter, useBoardColumnState } from "@kanbus/ui";
|
|
6
|
+
import { IssueCollection, IssueDetailPanel, IssueIdFormatProvider, IssueTypeFilter, issueTypeFromFilter, useBoardColumnState } from "@kanbus/ui";
|
|
7
7
|
import "./newsroom-theme";
|
|
8
8
|
import { PlusIcon } from "lucide-react";
|
|
9
9
|
import { newsroomHref } from "../lib/newsroom-base-path";
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
deskBoardConfig,
|
|
17
17
|
deskContainsAssignment,
|
|
18
18
|
deskContainsContentItem,
|
|
19
|
+
formatNativeIssueId,
|
|
19
20
|
projectAssignmentBoard,
|
|
20
21
|
projectContentItemBoard,
|
|
21
22
|
type NativeBoardIssue,
|
|
@@ -168,6 +169,7 @@ export function NewsroomBoardView({ subject, deskId }: { subject: NewsroomBoardS
|
|
|
168
169
|
</Link>
|
|
169
170
|
)}
|
|
170
171
|
</>}>
|
|
172
|
+
<IssueIdFormatProvider formatIssueId={formatNativeIssueId}>
|
|
171
173
|
<div className="organizer-native-board">
|
|
172
174
|
{error && <NewsroomOpsStatusBanner tone="error">{error}</NewsroomOpsStatusBanner>}
|
|
173
175
|
{subject === "desk" && <IssueTypeFilter config={config} value={typeFilter} onChange={setTypeFilter} name="Record type" className="organizer-board-type-filter" />}
|
|
@@ -192,5 +194,6 @@ export function NewsroomBoardView({ subject, deskId }: { subject: NewsroomBoardS
|
|
|
192
194
|
</IssueDetailPanel>}
|
|
193
195
|
</div>
|
|
194
196
|
</div>
|
|
197
|
+
</IssueIdFormatProvider>
|
|
195
198
|
</NewsroomOpsShell>;
|
|
196
199
|
}
|
package/lib/newsroom-board.ts
CHANGED
|
@@ -21,6 +21,31 @@ export interface NativeBoardIssue extends KanbanIssue {
|
|
|
21
21
|
href: string;
|
|
22
22
|
/** A few lines to show under the headline: the blurb, else the subtitle. */
|
|
23
23
|
excerpt?: string;
|
|
24
|
+
/** The quiet path shown where a board would print the ID, e.g. `articles/my-slug` or `assignments/write-it`. */
|
|
25
|
+
displayId: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function slugify(text: string): string {
|
|
29
|
+
return text.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Section and slug for a content item, falling back to the publication's board path segment. */
|
|
33
|
+
export function contentItemDisplayId(version: { section?: string | null; slug?: string | null; lineageId: string }): string {
|
|
34
|
+
const section = slugify(version.section ?? "") || contentItemBoardPathSegment();
|
|
35
|
+
return `${section}/${slugify(version.slug ?? "") || version.lineageId.slice(0, 8)}`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Assignments have no slug: use the title as one, else a short id. */
|
|
39
|
+
export function assignmentDisplayId(assignment: { id: string; title?: string | null }): string {
|
|
40
|
+
const titleSlug = slugify(assignment.title ?? "").slice(0, 48).replace(/-+$/g, "");
|
|
41
|
+
return `assignments/${titleSlug || assignment.id.slice(0, 8)}`;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** `formatIssueId` for the Kanbus UI: the host-provided path, never the raw `kind:id` prefix. */
|
|
45
|
+
export function formatNativeIssueId(issue: KanbanIssue): string {
|
|
46
|
+
const displayId = (issue as Partial<NativeBoardIssue>).displayId;
|
|
47
|
+
if (displayId) return displayId;
|
|
48
|
+
return issue.id.replace(/^[A-Za-z]+:/, "").slice(0, 12);
|
|
24
49
|
}
|
|
25
50
|
|
|
26
51
|
export function contentItemBoardPathSegment(): string {
|
|
@@ -60,7 +85,7 @@ export function projectContentItemBoard(records: {
|
|
|
60
85
|
title: version.headline || version.title || version.slug, nativeStatus: stage, status: `${contentItemType}/${stage}`,
|
|
61
86
|
priority: 2, description: workCount ? `${workCount} assignment${workCount === 1 ? "" : "s"} on this ${contentItemType}.` : undefined,
|
|
62
87
|
updated_at: version.updatedAt ?? undefined, href: `/newsroom/articles/${encodeURIComponent(version.id)}`,
|
|
63
|
-
excerpt: contentItemExcerpt(version),
|
|
88
|
+
excerpt: contentItemExcerpt(version), displayId: contentItemDisplayId(version),
|
|
64
89
|
};
|
|
65
90
|
});
|
|
66
91
|
}
|
|
@@ -73,7 +98,7 @@ export function projectAssignmentBoard(assignments: readonly AssignmentRecord[])
|
|
|
73
98
|
priority: row.priority ?? 2, assignee: row.assigneeId || undefined,
|
|
74
99
|
description: row.summary || row.brief || undefined,
|
|
75
100
|
created_at: row.createdAt, updated_at: row.updatedAt,
|
|
76
|
-
href: `/newsroom/assignments/${encodeURIComponent(row.id)}`,
|
|
101
|
+
href: `/newsroom/assignments/${encodeURIComponent(row.id)}`, displayId: assignmentDisplayId(row),
|
|
77
102
|
}));
|
|
78
103
|
}
|
|
79
104
|
|
package/package.json
CHANGED
|
@@ -395,7 +395,7 @@
|
|
|
395
395
|
"optional": true
|
|
396
396
|
}
|
|
397
397
|
},
|
|
398
|
-
"version": "2.0.0-next.
|
|
398
|
+
"version": "2.0.0-next.7",
|
|
399
399
|
"dependencies": {
|
|
400
400
|
"@aws-amplify/adapter-nextjs": "^1.7.3",
|
|
401
401
|
"@aws-crypto/sha256-js": "5.2.0",
|
|
@@ -422,7 +422,7 @@
|
|
|
422
422
|
"@fontsource-variable/source-serif-4": "5.3.1",
|
|
423
423
|
"@fontsource/ibm-plex-mono": "5.3.0",
|
|
424
424
|
"@fontsource/ibm-plex-sans": "5.3.0",
|
|
425
|
-
"@kanbus/ui": "https://github.com/AnthusAI/Kanbus/releases/download/ui-v0.4.
|
|
425
|
+
"@kanbus/ui": "https://github.com/AnthusAI/Kanbus/releases/download/ui-v0.4.1/kanbus-ui-0.4.1.tgz",
|
|
426
426
|
"@lezer/highlight": "^1.2.5",
|
|
427
427
|
"@radix-ui/colors": "3.0.0",
|
|
428
428
|
"@smithy/protocol-http": "5.4.1",
|
package/routes.manifest.json
CHANGED