@anthusai/papyrus 1.19.1 → 2.0.0

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.
@@ -22,9 +22,6 @@ export const NEWSROOM_INBOX_ROW_ACTIVE =
22
22
  export const NEWSROOM_SIDEBAR_NAV_ACTIVE =
23
23
  "bg-primary/10 text-foreground shadow-none hover:bg-primary/15";
24
24
 
25
- export const NEWSROOM_SIDEBAR_NAV_INACTIVE =
26
- "text-muted-foreground hover:bg-muted/50 hover:text-foreground";
27
-
28
25
  export function newsroomListRowClassName(active: boolean, className?: string): string {
29
26
  return cn(
30
27
  NEWSROOM_LIST_ROW_BASE,
@@ -18,23 +18,20 @@ export type NewsroomNavItem = {
18
18
  label: string;
19
19
  detail: string;
20
20
  href: string;
21
- mobilePrimary?: boolean;
22
21
  };
23
22
 
24
23
  export const NEWSROOM_OPS_NAV: NewsroomNavItem[] = [
25
- { id: "overview", label: "Overview", detail: "Desk home", href: newsroomHref(), mobilePrimary: true },
26
- { id: "articles", label: getContentItemName().plural, detail: "Drafts & published", href: newsroomHref("articles"), mobilePrimary: true },
27
- { id: "assignments", label: "Assignments", detail: "Work queue", href: newsroomHref("assignments"), mobilePrimary: true },
28
- { id: "references", label: "References", detail: "Knowledge base", href: newsroomHref("references"), mobilePrimary: true },
24
+ { id: "overview", label: "Overview", detail: "Desk home", href: newsroomHref() },
25
+ { id: "articles", label: getContentItemName().plural, detail: "Drafts & published", href: newsroomHref("articles") },
26
+ { id: "assignments", label: "Assignments", detail: "Work queue", href: newsroomHref("assignments") },
27
+ { id: "references", label: "References", detail: "Knowledge base", href: newsroomHref("references") },
29
28
  { id: "messages", label: "Messages", detail: "Forum", href: newsroomHref("messages") },
30
- { id: "topics", label: "Topics", detail: "Taxonomy", href: newsroomHref("topics"), mobilePrimary: true },
29
+ { id: "topics", label: "Topics", detail: "Taxonomy", href: newsroomHref("topics") },
31
30
  { id: "concepts", label: "Concept wiki", detail: "Knowledge graph", href: newsroomHref("concepts") },
32
31
  { id: "search", label: "Search", detail: "Knowledge base", href: newsroomHref("search") },
33
32
  { id: "administration", label: "Administration", detail: "Users & policies", href: newsroomHref("administration") },
34
33
  ];
35
34
 
36
- export const NEWSROOM_MOBILE_PRIMARY_NAV = NEWSROOM_OPS_NAV.filter((item) => item.mobilePrimary);
37
-
38
35
  export function getNewsroomNavHref(href: string, demo?: boolean): string {
39
36
  const path = toPublicNewsroomPath(href);
40
37
  if (!demo) return path;
@@ -1,16 +1,14 @@
1
1
  import type { NewsDeskTab } from "../components/topic-steering-workspace";
2
2
 
3
- /** The organizer restores the existing taxonomy editor; legacy sites retain their aliases. */
3
+ /** Resolves the requested newsroom section, mapping retired aliases onto their current destinations. */
4
4
  export function resolveNewsDeskTab(
5
5
  sectionValue: string | string[] | null | undefined,
6
6
  legacyTabValue: string | string[] | null | undefined,
7
- organizer = false,
8
7
  ): NewsDeskTab {
9
8
  const section = Array.isArray(sectionValue) ? sectionValue[0] : sectionValue;
10
9
  const legacyTab = Array.isArray(legacyTabValue) ? legacyTabValue[0] : legacyTabValue;
11
10
  const raw = section ?? (legacyTab === "categories" ? "topics" : legacyTab);
12
- const value = raw === "users" || raw === "doctrine" ? "administration"
13
- : raw === "desks" && !organizer ? "topics" : raw;
11
+ const value = raw === "users" || raw === "doctrine" ? "administration" : raw;
14
12
  switch (value) {
15
13
  case "desks": case "administration": case "topics": case "concepts":
16
14
  case "references": case "messages": case "assignments": case "search":
package/lib/site-brand.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { isLocalPreviewEnabled } from "./local-preview";
2
1
  import { areEditionsEnabled } from "./site-env";
3
2
  import type { ComponentType } from "react";
4
3
  import type { EditionPresentationFormat } from "./content-types";
@@ -134,8 +133,6 @@ export type SiteBrand = {
134
133
  /** Public URL prefix for the Pretext reader (home, editions, articles, archive, settings). Default `""`; e.g. `/information`. */
135
134
  readerBasePath?: string;
136
135
  opsChrome: OpsChrome;
137
- /** Opt-in CMS viewport layout; independent of the public reader renderer/theme. */
138
- newsroomLayout?: "organizer";
139
136
  corpusKey: string;
140
137
  steeringConfigPath: string;
141
138
  newsroomSectionsConfigPath: string;
@@ -205,11 +202,7 @@ const REGISTERED_SITE_BRANDS: Record<SiteBrandId, SiteBrand> = {
205
202
  ...Object.fromEntries((papyrusSite.brands ?? []).map((brand) => [brand.id, brand])),
206
203
  };
207
204
 
208
- const SITE_BRANDS: Record<SiteBrandId, SiteBrand> = isLocalPreviewEnabled()
209
- ? Object.fromEntries(
210
- Object.entries(REGISTERED_SITE_BRANDS).map(([id, brand]) => [id, { ...brand, newsroomLayout: "organizer" as const }]),
211
- )
212
- : REGISTERED_SITE_BRANDS;
205
+ const SITE_BRANDS: Record<SiteBrandId, SiteBrand> = REGISTERED_SITE_BRANDS;
213
206
 
214
207
  export function normalizeSiteBrandId(value: string | undefined | null): SiteBrandId | null {
215
208
  if (!value) return null;
package/package.json CHANGED
@@ -94,7 +94,6 @@
94
94
  "./components/newsroom-curation-provider": "./components/newsroom-curation-provider.tsx",
95
95
  "./components/newsroom-ops-overview": "./components/newsroom-ops-overview.tsx",
96
96
  "./components/newsroom-ops-shell": "./components/newsroom-ops-shell.tsx",
97
- "./components/newsroom-organizer-shell": "./components/newsroom-organizer-shell.tsx",
98
97
  "./components/newsroom-references-view": "./components/newsroom-references-view.tsx",
99
98
  "./components/newsroom-topics-view": "./components/newsroom-topics-view.tsx",
100
99
  "./components/papyrus-console-shell": "./components/papyrus-console-shell.tsx",
@@ -379,7 +378,7 @@
379
378
  "optional": true
380
379
  }
381
380
  },
382
- "version": "1.19.1",
381
+ "version": "2.0.0",
383
382
  "dependencies": {
384
383
  "@aws-amplify/adapter-nextjs": "^1.7.3",
385
384
  "@aws-crypto/sha256-js": "5.2.0",
@@ -392,7 +391,7 @@
392
391
  "@aws-sdk/s3-request-presigner": "^3.1045.0",
393
392
  "@base-ui/react": "^1.5.0",
394
393
  "@chenglou/pretext": "^0.0.7",
395
- "@kanbus/ui": "https://github.com/AnthusAI/Kanbus/releases/download/ui-v0.3.0/kanbus-ui-0.3.0.tgz",
394
+ "@kanbus/ui": "https://github.com/AnthusAI/Kanbus/releases/download/ui-v0.3.1/kanbus-ui-0.3.1.tgz",
396
395
  "@radix-ui/colors": "3.0.0",
397
396
  "@smithy/protocol-http": "5.4.1",
398
397
  "@smithy/signature-v4": "5.7.4",
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.19.1",
2
+ "version": "2.0.0",
3
3
  "routes": [
4
4
  {
5
5
  "file": "app/%5F_preview/[[...path]]/route.ts",
@@ -0,0 +1,44 @@
1
+ import { spawnSync } from "node:child_process";
2
+
3
+ const DEFAULT_REGION = "us-east-1";
4
+
5
+ export function resolveCdkRegion({ explicitRegion, environment = process.env }) {
6
+ return (
7
+ explicitRegion ||
8
+ environment.AWS_REGION ||
9
+ environment.AWS_DEFAULT_REGION ||
10
+ environment.CDK_DEFAULT_REGION ||
11
+ DEFAULT_REGION
12
+ );
13
+ }
14
+
15
+ function callerAccountFromAwsCli() {
16
+ const completed = spawnSync("aws", ["sts", "get-caller-identity", "--output", "json"], { encoding: "utf8" });
17
+ if (completed.error) throw new Error(`could not run the aws CLI: ${completed.error.message}`);
18
+ if (completed.status !== 0) throw new Error(String(completed.stderr || completed.stdout).trim() || `aws exited with status ${completed.status}`);
19
+ return JSON.parse(completed.stdout).Account;
20
+ }
21
+
22
+ export function resolveCdkAccount({ explicitAccount, environment = process.env, lookupCallerAccount = callerAccountFromAwsCli }) {
23
+ if (explicitAccount) return explicitAccount;
24
+ if (environment.CDK_DEFAULT_ACCOUNT) return environment.CDK_DEFAULT_ACCOUNT;
25
+ let account;
26
+ try {
27
+ account = lookupCallerAccount();
28
+ } catch (error) {
29
+ throw new Error(
30
+ `cannot determine the AWS account: pass --account, set CDK_DEFAULT_ACCOUNT, or provide credentials for "aws sts get-caller-identity" (${error instanceof Error ? error.message : error})`,
31
+ );
32
+ }
33
+ if (!/^\d{12}$/.test(String(account))) {
34
+ throw new Error(`cannot determine the AWS account: "aws sts get-caller-identity" returned ${JSON.stringify(account)}; pass --account or set CDK_DEFAULT_ACCOUNT`);
35
+ }
36
+ return String(account);
37
+ }
38
+
39
+ export function resolveCdkEnvironment({ explicitAccount, explicitRegion, environment = process.env, lookupCallerAccount }) {
40
+ return {
41
+ account: resolveCdkAccount({ explicitAccount, environment, lookupCallerAccount }),
42
+ region: resolveCdkRegion({ explicitRegion, environment }),
43
+ };
44
+ }
@@ -1,153 +0,0 @@
1
- "use client";
2
-
3
- import { useEffect, useId, useState } from "react";
4
- import Link from "next/link";
5
- import { usePathname, useRouter, useSearchParams } from "next/navigation";
6
- import { BookOpen, ClipboardList, Menu, Search, MessagesSquare, PanelLeftClose, PanelLeftOpen, Settings, UserRound, LogIn, LogOut } from "lucide-react";
7
- import { ORGANIZER_NAV_GROUPS, ORGANIZER_PRIMARY_NAV, ORGANIZER_SETTINGS_DESTINATION } from "../lib/newsroom-organizer-nav";
8
- import { browserPathToInternalNewsroomPath } from "../lib/newsroom-base-path";
9
- import { getNewsroomNavHref } from "../lib/newsroom-nav";
10
- import { SITE_BRAND } from "../lib/site-brand";
11
- import { useOptionalNewsDeskClient } from "./news-desk-client-provider";
12
- import { ReaderAuthControl } from "./reader-auth-control";
13
- import { ProspectusAccountChooser, useProspectusAccountSummary } from "./prospectus-account-chooser";
14
- import { Sheet, SheetContent, SheetHeader, SheetTitle, SheetDescription, SheetTrigger } from "./ui/sheet";
15
- import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuGroup, DropdownMenuLabel, DropdownMenuItem, DropdownMenuSeparator } from "./ui/dropdown-menu";
16
- import type { NewsroomOpsShellProps } from "./newsroom-ops-shell";
17
- import "./newsroom-organizer.css";
18
-
19
- /** The standard place to search the knowledge base; the Search page is the results page. */
20
- function OrganizerSearch({ demo }: { demo: boolean }) {
21
- const router = useRouter();
22
- const searchParams = useSearchParams();
23
- const [text, setText] = useState(searchParams.get("q") ?? "");
24
- return <form className="organizer-search" role="search" onSubmit={event => {
25
- event.preventDefault();
26
- const query = text.trim();
27
- if (query) router.push(getNewsroomNavHref(`/newsroom/search?q=${encodeURIComponent(query)}`, demo));
28
- }}>
29
- <Search size={14} aria-hidden="true" />
30
- <input aria-label="Search the knowledge base" data-newsroom-search type="search" onChange={event => setText(event.target.value)} placeholder="Search" value={text} />
31
- </form>;
32
- }
33
-
34
- const ICONS = { articles: ClipboardList, references: BookOpen, messages: MessagesSquare };
35
-
36
- /** Navigation is a presentation layer; existing route and server authorization still own access. */
37
- function Navigation({ activePath, demo, admin, surface, onNavigate }: { activePath: string; demo: boolean; admin: boolean; surface: string; onNavigate?: () => void }) {
38
- const id = useId();
39
- const all = ORGANIZER_NAV_GROUPS.flatMap(group => group.items);
40
- const active = all.filter(item => [item.path, ...(item.alsoActiveOnPaths ?? [])].some(candidate => activePath === candidate || (candidate !== "/newsroom" && activePath.startsWith(candidate + "/")))).sort((a, b) => b.path.length - a.path.length)[0]?.key;
41
- return <nav className="organizer-destinations" aria-label={surface === "sidebar" ? "Newsroom" : "All workspaces"}>
42
- {ORGANIZER_NAV_GROUPS.map((group, index) => <section key={group.title} aria-labelledby={`${id}-${index}`}>
43
- <h3 id={`${id}-${index}`}>{group.title}</h3>
44
- {group.items.filter(item => item.access !== "admin" || admin).map(item => <Link key={item.key}
45
- href={getNewsroomNavHref(item.path, demo)} onClick={onNavigate} aria-label={item.label}
46
- aria-current={active === item.key ? "page" : undefined} aria-describedby={`${id}-${item.key}`}
47
- data-news-desk-tab={item.key}>
48
- <strong>{item.label}</strong><small id={`${id}-${item.key}`}>{item.description}</small>
49
- </Link>)}
50
- </section>)}
51
- </nav>;
52
- }
53
-
54
- function Account({ placement }: { placement: "sidebar" | "header" }) {
55
- const session = useOptionalNewsDeskClient();
56
- const auth = session?.shell.auth ?? { status: "loading" as const, label: "Checking sign-in" };
57
- const [open, setOpen] = useState(false);
58
- const accountSummary = useProspectusAccountSummary();
59
- useEffect(() => {
60
- const media = matchMedia("(max-width: 900px)");
61
- const close = () => setOpen(false);
62
- media.addEventListener("change", close);
63
- return () => media.removeEventListener("change", close);
64
- }, []);
65
- return <DropdownMenu open={open} onOpenChange={setOpen}>
66
- <DropdownMenuTrigger id={`organizer-account-trigger-${placement}`} className={`organizer-account organizer-account-${placement}`} aria-label="Account menu" title="Account menu">
67
- <UserRound size={18} aria-hidden="true" /><span><strong>{auth.label}</strong><small>{accountSummary ?? (auth.status === "signedIn" ? "Account & preferences" : auth.status === "signedOut" ? "Not signed in" : "Checking session")}</small></span>
68
- </DropdownMenuTrigger>
69
- <DropdownMenuContent className="organizer-account-popup" side={placement === "sidebar" ? "top" : "bottom"} align="end">
70
- <DropdownMenuGroup>
71
- <DropdownMenuLabel>{auth.label}</DropdownMenuLabel><DropdownMenuSeparator />
72
- <ProspectusAccountChooser />
73
- <DropdownMenuItem render={<Link href={getNewsroomNavHref(ORGANIZER_SETTINGS_DESTINATION.path)} />}><Settings aria-hidden="true" />{ORGANIZER_SETTINGS_DESTINATION.label}</DropdownMenuItem>
74
- <ReaderAuthControl authState={auth} renderAction={({ disabled, onClick, signedIn }) => <DropdownMenuItem disabled={disabled} closeOnClick={false} onClick={onClick}>
75
- {signedIn ? <LogOut aria-hidden="true" /> : <LogIn aria-hidden="true" />}{signedIn ? "Sign out" : "Sign in"}
76
- </DropdownMenuItem>} />
77
- </DropdownMenuGroup>
78
- </DropdownMenuContent>
79
- </DropdownMenu>;
80
- }
81
-
82
- export function NewsroomOrganizerShell({ activeTab, appTitle, backHref = "/", backLabel, children, demo = false, headerActions, pageTitle, showNavigation = true }: NewsroomOpsShellProps) {
83
- const pathname = usePathname();
84
- const session = useOptionalNewsDeskClient();
85
- const admin = demo || session?.shell.dashboard?.canManageUsers === true;
86
- const [menuOpen, setMenuOpen] = useState(false);
87
- const [collapsed, setCollapsed] = useState(false);
88
- const [loadedPreference, setLoadedPreference] = useState(false);
89
- const preferenceKey = `papyrus.cms.sidebar.v1.${SITE_BRAND.id}`;
90
- useEffect(() => {
91
- try { setCollapsed(localStorage.getItem(preferenceKey) === "true"); } catch { /* Optional browser preference. */ }
92
- setLoadedPreference(true);
93
- }, [preferenceKey]);
94
- useEffect(() => { if (loadedPreference) try { localStorage.setItem(preferenceKey, String(collapsed)); } catch { /* Controls still work without storage. */ } }, [collapsed, loadedPreference, preferenceKey]);
95
- useEffect(() => { setMenuOpen(false); }, [pathname]);
96
- useEffect(() => {
97
- const media = matchMedia("(max-width: 900px)");
98
- let previousFocus: Element | null = null;
99
- let frame = 0;
100
- const remember = () => { if (document.activeElement !== document.body) previousFocus = document.activeElement; };
101
- const change = () => {
102
- const active = document.activeElement === document.body ? previousFocus : document.activeElement;
103
- if (!(active instanceof HTMLElement)) return;
104
- if (!media.matches) setMenuOpen(false);
105
- const selector = active.closest(".organizer-account, .organizer-account-popup") ? ".organizer-account"
106
- : media.matches && active.closest(".organizer-sidebar, .organizer-toggle") ? ".organizer-more"
107
- : !media.matches && active.closest(".organizer-bottom-nav, .organizer-menu") ? ".organizer-toggle" : null;
108
- if (!selector) return;
109
- cancelAnimationFrame(frame);
110
- frame = requestAnimationFrame(() => {
111
- if (document.activeElement === active || document.activeElement === document.body || !(document.activeElement as HTMLElement)?.getClientRects().length)
112
- Array.from(document.querySelectorAll<HTMLElement>(selector)).find(element => element.getClientRects().length)?.focus();
113
- });
114
- };
115
- document.addEventListener("focusin", remember);
116
- media.addEventListener("change", change);
117
- return () => { document.removeEventListener("focusin", remember); media.removeEventListener("change", change); cancelAnimationFrame(frame); };
118
- }, []);
119
- const activePath = browserPathToInternalNewsroomPath(pathname ?? "/newsroom");
120
- const sidebarToggleLabel = collapsed ? "Expand sidebar" : "Collapse sidebar";
121
- const sidebarToggle = <button type="button" className="organizer-toggle" title={sidebarToggleLabel}
122
- aria-label={sidebarToggleLabel} aria-expanded={!collapsed} aria-controls="organizer-sidebar" onClick={() => setCollapsed(value => !value)}>
123
- {collapsed ? <PanelLeftOpen size={16} aria-hidden="true" /> : <PanelLeftClose size={16} aria-hidden="true" />}
124
- </button>;
125
- return <div className="newsroom-organizer" data-news-desk data-newsroom-ops-shell="true" data-newsroom-chrome="organizer" data-sidebar-collapsed={collapsed || !showNavigation ? "true" : "false"}>
126
- {showNavigation && <aside className="organizer-sidebar" hidden={collapsed} id="organizer-sidebar">
127
- <div className="organizer-sidebar-head">
128
- <Link className="organizer-brand" href={getNewsroomNavHref("/newsroom", demo)}>{SITE_BRAND.components?.NewsroomLogo ? <SITE_BRAND.components.NewsroomLogo className="organizer-brand-logo" /> : appTitle}<small>The newsroom</small></Link>
129
- {sidebarToggle}
130
- </div>
131
- <Navigation activePath={activePath} demo={demo} admin={admin} surface="sidebar" />
132
- <Account placement="sidebar" />
133
- </aside>}
134
- <div className="organizer-workspace">
135
- <header className="organizer-topbar" data-newsroom-ops-topbar>
136
- {showNavigation && collapsed && sidebarToggle}
137
- <Link className="organizer-masthead" href={backHref} title={backLabel}>{appTitle}</Link>
138
- <h1 data-newsroom-ops-title>{pageTitle}</h1><OrganizerSearch demo={demo} /><div className="organizer-header-actions">{headerActions}</div><Account placement="header" />
139
- </header>
140
- <main className="organizer-main">{demo && <p className="organizer-demo-notice">Demo workspace · synthetic examples</p>}{children}</main>
141
- </div>
142
- {showNavigation && <nav className="organizer-bottom-nav" aria-label="Primary newsroom navigation"><ul>
143
- {ORGANIZER_PRIMARY_NAV.map(item => { const Icon = ICONS[item.key as keyof typeof ICONS]; return <li key={item.key}><Link
144
- href={getNewsroomNavHref(item.path, demo)} title={item.description} aria-label={item.label} aria-current={activeTab === item.key ? "page" : undefined}>
145
- <Icon size={18} aria-hidden="true" /><span>{item.label}</span></Link></li>; })}
146
- <li><Sheet open={menuOpen} onOpenChange={setMenuOpen}><SheetTrigger className="organizer-more" aria-label="More"><Menu size={18} aria-hidden="true" /><span>More</span></SheetTrigger>
147
- <SheetContent side="bottom" className="organizer-menu"><SheetHeader><SheetTitle>Newsroom</SheetTitle><SheetDescription>Workspaces and administration</SheetDescription></SheetHeader>
148
- <Navigation activePath={activePath} demo={demo} admin={admin} surface="menu" onNavigate={() => setMenuOpen(false)} />
149
- </SheetContent>
150
- </Sheet></li>
151
- </ul></nav>}
152
- </div>;
153
- }