@anthusai/papyrus 1.4.0-next.2 → 1.5.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.
@@ -41,7 +41,7 @@ import type {
41
41
  UserDirectoryEntry,
42
42
  } from "../lib/category-repository";
43
43
  import { relationTypeKey } from "../lib/semantic-graph";
44
- import { legacyStageKeysToLoad, type ContentItemVersionRecord } from "../lib/content-item-lifecycle";
44
+ import { contentItemStageKeys, type ContentItemVersionRecord } from "../lib/content-item-lifecycle";
45
45
  import { getContentItemStageDefinitions } from "../lib/site-brand";
46
46
  import { DOCTRINE_DEFINITIONS, getCategoryDoctrineDefinitions, type DoctrineCategory } from "../lib/doctrine";
47
47
  import { configureAmplifyClient } from "./amplify-client-provider";
@@ -2172,23 +2172,14 @@ const CONTENT_ITEMS_BY_STAGE_QUERY = `
2172
2172
  }
2173
2173
  `;
2174
2174
 
2175
- export async function loadNewsroomContentItemVersions(options: { includeCollapsedUntilOpenedStages?: readonly string[] } = {}): Promise<ContentItemVersionRecord[]> {
2176
- const stageDefinitions = getContentItemStageDefinitions();
2177
- const stagesToLoad = [
2178
- ...stageDefinitions
2179
- .filter(definition => !definition.collapsedUntilOpened || options.includeCollapsedUntilOpenedStages?.includes(definition.key))
2180
- .map(definition => definition.key),
2181
- ...legacyStageKeysToLoad(stageDefinitions),
2182
- ];
2183
- if (isLocalPreviewEnabled()) {
2184
- return createLocalPreviewContentItemVersions().filter(version => stagesToLoad.includes(version.stage ?? ""));
2185
- }
2175
+ export async function loadNewsroomContentItemVersions(): Promise<ContentItemVersionRecord[]> {
2176
+ if (isLocalPreviewEnabled()) return createLocalPreviewContentItemVersions();
2186
2177
  configureAmplifyClient();
2187
2178
  const client = generateClient<Schema>() as unknown as {
2188
2179
  graphql: (options: Record<string, unknown>) => Promise<GraphQLConnectionResponse<ContentItemVersionRecord>>;
2189
2180
  };
2190
2181
  const field = "listItemsByStageAndUpdatedAt";
2191
- const versionsPerStage = await Promise.all(stagesToLoad.map(async (stage) => {
2182
+ const versionsPerStage = await Promise.all(contentItemStageKeys(getContentItemStageDefinitions()).map(async (stage) => {
2192
2183
  const versions: ContentItemVersionRecord[] = [];
2193
2184
  let nextToken: string | null = null;
2194
2185
  do {
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { useEffect, useMemo, useRef, useState } from "react";
4
4
  import Link from "next/link";
5
- import { IssueCollection, IssueDetailPanel, useBoardColumnState } from "@kanbus/ui";
5
+ import { IssueCollection, IssueDetailPanel } from "@kanbus/ui";
6
6
  import "@kanbus/ui/styles/kanban.css";
7
7
  import "./newsroom-newsprint-board.css";
8
8
  import { PlusIcon } from "lucide-react";
@@ -20,7 +20,7 @@ import {
20
20
  type NativeBoardIssue,
21
21
  } from "../lib/newsroom-board";
22
22
  import type { AssignmentRecord } from "../lib/category-repository";
23
- import { getContentItemName, getContentItemStageDefinitions, SITE_BRAND } from "../lib/site-brand";
23
+ import { getContentItemName, SITE_BRAND } from "../lib/site-brand";
24
24
  import { getNewsroomNavHref } from "../lib/newsroom-nav";
25
25
  import { loadNewsroomAssignmentPage, loadNewsroomContentItemVersions, loadNewsroomPublishedContentItemVersions } from "./news-desk-taxonomy-client";
26
26
  import { useOptionalNewsDeskClient } from "./news-desk-client-provider";
@@ -57,8 +57,6 @@ export function NewsroomBoardView({ subject }: { subject: NewsroomBoardSubject }
57
57
  const [loading, setLoading] = useState(false);
58
58
  const [error, setError] = useState<string | null>(null);
59
59
  const generation = useRef(0);
60
- const openedCollapsedUntilOpenedStagesRef = useRef<string[]>([]);
61
- const refreshIssuesRef = useRef<((initial: boolean) => void) | null>(null);
62
60
  useEffect(() => {
63
61
  setLowMotion(readLocalReaderSettings().motion === "low");
64
62
  return subscribeReaderSettingsChanges(settings => setLowMotion(settings.motion === "low"));
@@ -69,7 +67,7 @@ export function NewsroomBoardView({ subject }: { subject: NewsroomBoardSubject }
69
67
  if (!allowed) { setLoading(false); return; }
70
68
  const loadIssues = () => subject === "contentItem"
71
69
  ? Promise.all([
72
- Promise.all([loadNewsroomContentItemVersions({ includeCollapsedUntilOpenedStages: openedCollapsedUntilOpenedStagesRef.current }), loadNewsroomPublishedContentItemVersions()]).then(([workingVersions, publishedVersions]) => [...workingVersions, ...publishedVersions]),
70
+ Promise.all([loadNewsroomContentItemVersions(), loadNewsroomPublishedContentItemVersions()]).then(([workingVersions, publishedVersions]) => [...workingVersions, ...publishedVersions]),
73
71
  loadEveryNewsroomAssignment(),
74
72
  ]).then(([contentItemVersions, assignments]) => projectContentItemBoard({ contentItemVersions, assignments }))
75
73
  : loadEveryNewsroomAssignment().then(projectAssignmentBoard);
@@ -83,7 +81,6 @@ export function NewsroomBoardView({ subject }: { subject: NewsroomBoardSubject }
83
81
  if (generation.current === request && initial) setError(reason instanceof Error ? reason.message : "Could not load newsroom records.");
84
82
  }).finally(() => { if (generation.current === request && initial) setLoading(false); });
85
83
  };
86
- refreshIssuesRef.current = refresh;
87
84
  refresh(true);
88
85
  const refreshWhenVisible = () => { if (document.visibilityState === "visible") refresh(false); };
89
86
  const interval = window.setInterval(refreshWhenVisible, BOARD_REFRESH_INTERVAL_MILLISECONDS);
@@ -92,14 +89,6 @@ export function NewsroomBoardView({ subject }: { subject: NewsroomBoardSubject }
92
89
  }, [allowed, subject]);
93
90
  const config = useMemo(() => subject === "contentItem" ? contentItemBoardConfig(issues) : assignmentBoardConfig(issues), [issues, subject]);
94
91
  const boardType = subject === "contentItem" ? contentItemBoardType() : ASSIGNMENT_BOARD_TYPE;
95
- const columnState = useBoardColumnState({ config, storageKey: `papyrus.cms.columns.v1.${SITE_BRAND.id}.${subject}` });
96
- const openedCollapsedUntilOpenedStageKeys = useMemo(() => subject !== "contentItem" ? "" : getContentItemStageDefinitions()
97
- .filter(definition => definition.collapsedUntilOpened && !columnState.collapsedColumns.has(`${boardType}/${definition.key}`))
98
- .map(definition => definition.key).join(","), [boardType, columnState.collapsedColumns, subject]);
99
- useEffect(() => {
100
- openedCollapsedUntilOpenedStagesRef.current = openedCollapsedUntilOpenedStageKeys ? openedCollapsedUntilOpenedStageKeys.split(",") : [];
101
- if (openedCollapsedUntilOpenedStageKeys) refreshIssuesRef.current?.(false);
102
- }, [openedCollapsedUntilOpenedStageKeys]);
103
92
  const pageTitle = subject === "contentItem" ? getContentItemName().plural : "Assignments";
104
93
  const issue = issues.find(item => item.id === selected);
105
94
  if (!allowed) return <NewsDeskAccessGate shell={session?.shell ?? null} />;
@@ -119,7 +108,7 @@ export function NewsroomBoardView({ subject }: { subject: NewsroomBoardSubject }
119
108
  <div className="organizer-board-body" data-detail-open={Boolean(issue)}>
120
109
  <IssueCollection issues={issues} config={config} query={{ type: boardType }} view={view}
121
110
  motion={lowMotion ? STATIC_MOTION : undefined}
122
- collapsedColumns={columnState.collapsedColumns} onToggleCollapse={columnState.toggleColumn} initialScroll="start"
111
+ columnStateKey={`papyrus.cms.columns.v1.${SITE_BRAND.id}.${subject}`} initialScroll="start"
123
112
  selectedIssueId={selected} detailOpen={Boolean(issue)} onSelectIssue={item => setSelected(item.id)} ariaLabel={pageTitle}
124
113
  emptyMessage={loading ? "Loading records…" : error ? "Records could not be loaded." : "No records in this selection."} />
125
114
  {issue && <IssueDetailPanel issue={issue} onClose={() => setSelected(null)} fields={[{ label: "CMS record ID", value: issue.nativeId }, { label: "Status", value: issue.nativeStatus }]}>
@@ -7,51 +7,24 @@
7
7
  export type ContentItemStageDefinition = {
8
8
  key: string;
9
9
  label: string;
10
- /** Closed or rarely visited stage: its board column starts collapsed and its cards load only when it is opened. */
11
- collapsedUntilOpened?: boolean;
12
10
  };
13
11
 
14
- export const PUBLISHED_STAGE_KEY = "published";
15
-
16
- /** Stage keys written before the story stages were simplified, read as the stage that replaced them. */
17
- export const LEGACY_CONTENT_ITEM_STAGE_ALIASES: Readonly<Record<string, string>> = {
18
- research: "reporting",
19
- report: "reporting",
20
- editor_select: "reporting",
21
- };
22
-
23
- /** Stages for work that has not become a story yet; they appear on the assignments board only. */
24
- export const ASSIGNMENT_PHASE_STAGE_KEYS: readonly string[] = ["idea", "assignment"];
25
-
26
12
  export const DEFAULT_CONTENT_ITEM_STAGE_DEFINITIONS: readonly ContentItemStageDefinition[] = [
27
- { key: "reporting", label: "Reporting" },
13
+ { key: "idea", label: "Idea" },
14
+ { key: "assignment", label: "Assignment" },
15
+ { key: "research", label: "Research" },
16
+ { key: "report", label: "Report" },
17
+ { key: "editor_select", label: "Editor select" },
28
18
  { key: "copywriting", label: "Copywriting" },
29
19
  { key: "illustration", label: "Illustration" },
30
20
  { key: "typesetting", label: "Typesetting" },
31
21
  { key: "published", label: "Published" },
32
- { key: "held", label: "Held" },
33
- { key: "spiked", label: "Spiked", collapsedUntilOpened: true },
34
22
  ];
35
23
 
36
24
  export function contentItemStageKeys(stageDefinitions: readonly ContentItemStageDefinition[]): string[] {
37
25
  return stageDefinitions.map(definition => definition.key);
38
26
  }
39
27
 
40
- export function canonicalContentItemStage(
41
- stage: string,
42
- stageDefinitions: readonly ContentItemStageDefinition[] = DEFAULT_CONTENT_ITEM_STAGE_DEFINITIONS,
43
- ): string {
44
- const isDefined = stageDefinitions.some(definition => definition.key === stage);
45
- return isDefined ? stage : LEGACY_CONTENT_ITEM_STAGE_ALIASES[stage] ?? stage;
46
- }
47
-
48
- export function legacyStageKeysToLoad(stageDefinitions: readonly ContentItemStageDefinition[]): string[] {
49
- const definedKeys = contentItemStageKeys(stageDefinitions);
50
- return Object.entries(LEGACY_CONTENT_ITEM_STAGE_ALIASES)
51
- .filter(([legacyKey, replacementKey]) => !definedKeys.includes(legacyKey) && definedKeys.includes(replacementKey))
52
- .map(([legacyKey]) => legacyKey);
53
- }
54
-
55
28
  export function contentItemStageLabel(
56
29
  stage: string,
57
30
  stageDefinitions: readonly ContentItemStageDefinition[] = DEFAULT_CONTENT_ITEM_STAGE_DEFINITIONS,
@@ -6,13 +6,15 @@ const SEED_TIMESTAMP_BASE = Date.parse("2026-10-01T12:00:00.000Z");
6
6
  const ONE_HOUR_IN_MILLISECONDS = 60 * 60 * 1000;
7
7
 
8
8
  const SEED_CONTENT_ITEM_HEADLINES_BY_POSITION: readonly (readonly string[])[] = [
9
+ ["Readers ask what the newsroom should chase next", "A tip from the field: harbor dredging schedule"],
10
+ ["City council budget vote draws a crowd", "Interview request: regional transit director"],
11
+ ["Mapping every permit filed since January", "What the county audit left out"],
9
12
  ["Three sources confirm the zoning reversal", "Reporting packet: school board redistricting"],
13
+ ["Editor shortlist: the week's lead candidates", "Editor shortlist: the weekend long read"],
10
14
  ["Draft in progress: the last ferry crossing", "Draft in progress: neighborhood bakery profile"],
11
15
  ["Illustration brief: flooded streets, aerial view", "Illustration brief: the market at dawn"],
12
16
  ["Layout pass: front page lead and rail", "Layout pass: the Saturday supplement"],
13
17
  ["Published: harbor safety review", "Published: the lighthouse keepers' archive"],
14
- ["Held for the winter issue: the lighthouse keepers' archive", "Evergreen: how the harbor dredging works"],
15
- ["Spiked: the unconfirmed council rumor", "Spiked: the recycled press release"],
16
18
  ];
17
19
 
18
20
  function isoTimestampHoursBeforeBase(hours: number): string {
@@ -1,9 +1,6 @@
1
1
  import type { KanbanConfig, KanbanIssue } from "@kanbus/ui";
2
2
  import type { AssignmentRecord } from "./category-repository";
3
3
  import {
4
- ASSIGNMENT_PHASE_STAGE_KEYS,
5
- PUBLISHED_STAGE_KEY,
6
- canonicalContentItemStage,
7
4
  contentItemStageKeys,
8
5
  contentItemStageLabel,
9
6
  latestVersionPerContentItem,
@@ -45,12 +42,8 @@ export function projectContentItemBoard(records: {
45
42
  }
46
43
  }
47
44
  const contentItemType = contentItemBoardType();
48
- const stageDefinitions = getContentItemStageDefinitions();
49
- const stageKeys = contentItemStageKeys(stageDefinitions);
50
- const contentItemVersionsOnBoard = latestVersionPerContentItem(records.contentItemVersions)
51
- .map(version => ({ version, stage: canonicalContentItemStage(version.stage ?? "idea", stageDefinitions) }))
52
- .filter(({ stage }) => stageKeys.includes(stage) || !ASSIGNMENT_PHASE_STAGE_KEYS.includes(stage));
53
- return contentItemVersionsOnBoard.map(({ version, stage }) => {
45
+ return latestVersionPerContentItem(records.contentItemVersions).map(version => {
46
+ const stage = version.stage ?? "idea";
54
47
  const workCount = assignmentCountByContentItem.get(version.lineageId) ?? 0;
55
48
  return {
56
49
  id: `contentItem:${version.lineageId}`, nativeId: version.lineageId, kind: "contentItem" as const, type: contentItemType,
@@ -77,10 +70,9 @@ export function contentItemColumnOrder(
77
70
  stagesPresentOnBoard: readonly string[],
78
71
  stageKeys: readonly string[] = contentItemStageKeys(getContentItemStageDefinitions()),
79
72
  ): string[] {
73
+ const lastStage = stageKeys[stageKeys.length - 1];
80
74
  const unrecognizedStages = [...new Set(stagesPresentOnBoard)].filter(stage => !stageKeys.includes(stage));
81
- const stageBeforeWhichUnrecognizedStagesSit = stageKeys.includes(PUBLISHED_STAGE_KEY) ? PUBLISHED_STAGE_KEY : stageKeys[stageKeys.length - 1];
82
- const insertionIndex = stageKeys.indexOf(stageBeforeWhichUnrecognizedStagesSit);
83
- return [...stageKeys.slice(0, insertionIndex), ...unrecognizedStages, ...stageKeys.slice(insertionIndex)];
75
+ return [...stageKeys.filter(stage => stage !== lastStage), ...unrecognizedStages, lastStage];
84
76
  }
85
77
 
86
78
  export function assignmentColumnOrder(statusesPresentOnBoard: readonly string[]): string[] {
@@ -89,7 +81,7 @@ export function assignmentColumnOrder(statusesPresentOnBoard: readonly string[])
89
81
  return [...ASSIGNMENT_STATUSES_BEFORE_OTHERS, ...otherStatuses, ...ASSIGNMENT_STATUSES_AFTER_OTHERS];
90
82
  }
91
83
 
92
- function boardConfigForType(type: string, columns: readonly { key: string; name: string; collapsed?: boolean }[]): KanbanConfig {
84
+ function boardConfigForType(type: string, columns: readonly { key: string; name: string }[]): KanbanConfig {
93
85
  const statuses = columns.map(column => ({ ...column, category: "native" }));
94
86
  return {
95
87
  hierarchy: [], types: [type], statuses,
@@ -98,15 +90,11 @@ function boardConfigForType(type: string, columns: readonly { key: string; name:
98
90
  };
99
91
  }
100
92
 
101
- /** Content items read left to right through the lifecycle; stages marked collapsed-until-opened start collapsed. */
93
+ /** Content items read left to right through the lifecycle with the final stage last. */
102
94
  export function contentItemBoardConfig(issues: readonly NativeBoardIssue[]): KanbanConfig {
103
95
  const contentItemType = contentItemBoardType();
104
96
  return boardConfigForType(contentItemType, contentItemColumnOrder(issues.map(issue => issue.nativeStatus))
105
- .map(stage => ({
106
- key: `${contentItemType}/${stage}`,
107
- name: contentItemStageLabel(stage, getContentItemStageDefinitions()),
108
- collapsed: getContentItemStageDefinitions().some(definition => definition.key === stage && definition.collapsedUntilOpened),
109
- })));
97
+ .map(stage => ({ key: `${contentItemType}/${stage}`, name: contentItemStageLabel(stage, getContentItemStageDefinitions()) })));
110
98
  }
111
99
 
112
100
  export function assignmentBoardConfig(issues: readonly NativeBoardIssue[]): KanbanConfig {
package/package.json CHANGED
@@ -350,7 +350,7 @@
350
350
  "optional": true
351
351
  }
352
352
  },
353
- "version": "1.4.0-next.2",
353
+ "version": "1.5.0",
354
354
  "dependencies": {
355
355
  "@aws-amplify/adapter-nextjs": "^1.7.3",
356
356
  "@aws-crypto/sha256-js": "5.2.0",
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.4.0-next.2",
2
+ "version": "1.5.0",
3
3
  "routes": [
4
4
  {
5
5
  "file": "app/%5F_preview/[[...path]]/route.ts",