@anthusai/papyrus 1.2.0-next.1 → 1.2.0-next.2

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.
@@ -39,7 +39,8 @@ import type {
39
39
  UserDirectoryEntry,
40
40
  } from "../lib/category-repository";
41
41
  import { relationTypeKey } from "../lib/semantic-graph";
42
- import { CONTENT_ITEM_STAGES, type ContentItemVersionRecord } from "../lib/content-item-lifecycle";
42
+ import { contentItemStageKeys, type ContentItemVersionRecord } from "../lib/content-item-lifecycle";
43
+ import { getContentItemStageDefinitions } from "../lib/site-brand";
43
44
  import { DOCTRINE_DEFINITIONS, getCategoryDoctrineDefinitions, type DoctrineCategory } from "../lib/doctrine";
44
45
  import { configureAmplifyClient } from "./amplify-client-provider";
45
46
  import { isUnauthenticatedError, loadReaderSessionSnapshot, type ReaderAuthSnapshot } from "./reader-auth-state";
@@ -2173,7 +2174,7 @@ export async function loadNewsroomContentItemVersions(): Promise<ContentItemVers
2173
2174
  graphql: (options: Record<string, unknown>) => Promise<GraphQLConnectionResponse<ContentItemVersionRecord>>;
2174
2175
  };
2175
2176
  const field = "listItemsByStageAndUpdatedAt";
2176
- const versionsPerStage = await Promise.all(CONTENT_ITEM_STAGES.map(async (stage) => {
2177
+ const versionsPerStage = await Promise.all(contentItemStageKeys(getContentItemStageDefinitions()).map(async (stage) => {
2177
2178
  const versions: ContentItemVersionRecord[] = [];
2178
2179
  let nextToken: string | null = null;
2179
2180
  do {
@@ -1,36 +1,35 @@
1
1
  /**
2
2
  * One content item, one lifecycle: the stages an Item lineage moves through.
3
- * Mirrors CONTENT_ITEM_STAGES in src/papyrus_content/content_item_lifecycle.py.
3
+ * The default stages mirror CONTENT_ITEM_STAGES in src/papyrus_content/content_item_lifecycle.py;
4
+ * a publication overrides them with SiteBrand.contentItemStages.
4
5
  * See docs/content-item-lifecycle.md.
5
6
  */
6
- export const CONTENT_ITEM_STAGES = [
7
- "idea",
8
- "assignment",
9
- "research",
10
- "report",
11
- "editor_select",
12
- "copywriting",
13
- "illustration",
14
- "typesetting",
15
- "published",
16
- ] as const;
7
+ export type ContentItemStageDefinition = {
8
+ key: string;
9
+ label: string;
10
+ };
17
11
 
18
- export type ContentItemStage = (typeof CONTENT_ITEM_STAGES)[number];
12
+ export const DEFAULT_CONTENT_ITEM_STAGE_DEFINITIONS: readonly ContentItemStageDefinition[] = [
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" },
18
+ { key: "copywriting", label: "Copywriting" },
19
+ { key: "illustration", label: "Illustration" },
20
+ { key: "typesetting", label: "Typesetting" },
21
+ { key: "published", label: "Published" },
22
+ ];
19
23
 
20
- const CONTENT_ITEM_STAGE_LABELS: Record<ContentItemStage, string> = {
21
- idea: "Idea",
22
- assignment: "Assignment",
23
- research: "Research",
24
- report: "Report",
25
- editor_select: "Editor select",
26
- copywriting: "Copywriting",
27
- illustration: "Illustration",
28
- typesetting: "Typesetting",
29
- published: "Published",
30
- };
24
+ export function contentItemStageKeys(stageDefinitions: readonly ContentItemStageDefinition[]): string[] {
25
+ return stageDefinitions.map(definition => definition.key);
26
+ }
31
27
 
32
- export function contentItemStageLabel(stage: string): string {
33
- return (CONTENT_ITEM_STAGE_LABELS as Record<string, string>)[stage] ?? stage;
28
+ export function contentItemStageLabel(
29
+ stage: string,
30
+ stageDefinitions: readonly ContentItemStageDefinition[] = DEFAULT_CONTENT_ITEM_STAGE_DEFINITIONS,
31
+ ): string {
32
+ return stageDefinitions.find(definition => definition.key === stage)?.label ?? stage;
34
33
  }
35
34
 
36
35
  export type ContentItemVersionRecord = {
@@ -1,12 +1,12 @@
1
1
  import type { KanbanConfig, KanbanIssue } from "@kanbus/ui";
2
2
  import type { AssignmentRecord, ReferenceRecord } from "./category-repository";
3
3
  import {
4
- CONTENT_ITEM_STAGES,
4
+ contentItemStageKeys,
5
5
  contentItemStageLabel,
6
6
  latestVersionPerContentItem,
7
7
  type ContentItemVersionRecord,
8
8
  } from "./content-item-lifecycle";
9
- import { getContentItemName } from "./site-brand";
9
+ import { getContentItemName, getContentItemStageDefinitions } from "./site-brand";
10
10
 
11
11
  export type NativeBoardKind = "contentItem" | "reference" | "assignment";
12
12
  export interface NativeBoardIssue extends KanbanIssue {
@@ -71,10 +71,13 @@ export function projectNewsroomBoard(records: {
71
71
  ];
72
72
  }
73
73
 
74
- export function contentItemColumnOrder(stagesPresentOnBoard: readonly string[]): string[] {
75
- const lastStage = CONTENT_ITEM_STAGES[CONTENT_ITEM_STAGES.length - 1];
76
- const unrecognizedStages = [...new Set(stagesPresentOnBoard)].filter(stage => !(CONTENT_ITEM_STAGES as readonly string[]).includes(stage));
77
- return [...CONTENT_ITEM_STAGES.filter(stage => stage !== lastStage), ...unrecognizedStages, lastStage];
74
+ export function contentItemColumnOrder(
75
+ stagesPresentOnBoard: readonly string[],
76
+ stageKeys: readonly string[] = contentItemStageKeys(getContentItemStageDefinitions()),
77
+ ): string[] {
78
+ const lastStage = stageKeys[stageKeys.length - 1];
79
+ const unrecognizedStages = [...new Set(stagesPresentOnBoard)].filter(stage => !stageKeys.includes(stage));
80
+ return [...stageKeys.filter(stage => stage !== lastStage), ...unrecognizedStages, lastStage];
78
81
  }
79
82
 
80
83
  /** Content items read left to right through the lifecycle with the final stage last; other record kinds follow it. */
@@ -82,7 +85,7 @@ export function newsroomBoardConfig(issues: readonly NativeBoardIssue[]): Kanban
82
85
  const contentItemType = contentItemBoardType();
83
86
  const kinds: NativeBoardKind[] = ["contentItem", "reference", "assignment"];
84
87
  const contentItemStatuses = contentItemColumnOrder(issues.filter(issue => issue.kind === "contentItem").map(issue => issue.nativeStatus))
85
- .map(stage => ({ key: `${contentItemType}/${stage}`, name: contentItemStageLabel(stage), category: "native" }));
88
+ .map(stage => ({ key: `${contentItemType}/${stage}`, name: contentItemStageLabel(stage, getContentItemStageDefinitions()), category: "native" }));
86
89
  const otherStatuses = [...new Set(issues.filter(issue => issue.kind !== "contentItem").map(issue => issue.status))]
87
90
  .map(key => ({ key, name: key.replace("/", " · "), category: "native" }));
88
91
  const statuses = [...contentItemStatuses, ...otherStatuses];
package/lib/site-brand.ts CHANGED
@@ -5,6 +5,7 @@ import type { BlogPageBackgroundProps } from "../components/blog-page-background
5
5
  import type { SiteBrandFont } from "./brand-fonts";
6
6
  import type { PictogramFigureProps } from "../components/pictogram-figure";
7
7
  import papyrusSite from "papyrus-site";
8
+ import { DEFAULT_CONTENT_ITEM_STAGE_DEFINITIONS, type ContentItemStageDefinition } from "./content-item-lifecycle";
8
9
  import {
9
10
  DEFAULT_THEME_PACK_TOKENS,
10
11
  type HostingConfig,
@@ -92,6 +93,8 @@ export type SiteBrand = {
92
93
  articleTitleSuffix: string;
93
94
  /** Defaults to Story / Stories, the newsroom term. */
94
95
  contentItemName?: ContentItemName;
96
+ /** The lifecycle stages in board order, last one being publication. Defaults to the standard newsroom lifecycle. */
97
+ contentItemStages?: readonly ContentItemStageDefinition[];
95
98
  placeholderByline: string;
96
99
  defaultPresentation: EditionPresentationFormat;
97
100
  forcedPresentation?: EditionPresentationFormat;
@@ -223,6 +226,10 @@ export function getContentItemName(brand: SiteBrand = SITE_BRAND): ContentItemNa
223
226
  return brand.contentItemName ?? DEFAULT_CONTENT_ITEM_NAME;
224
227
  }
225
228
 
229
+ export function getContentItemStageDefinitions(brand: SiteBrand = SITE_BRAND): readonly ContentItemStageDefinition[] {
230
+ return brand.contentItemStages?.length ? brand.contentItemStages : DEFAULT_CONTENT_ITEM_STAGE_DEFINITIONS;
231
+ }
232
+
226
233
  /** Root-route config for a brand, defaulting to `{ kind: "reader" }`. */
227
234
  export function getRootRoute(brand: SiteBrand = SITE_BRAND): RootRouteConfig {
228
235
  return brand.rootRoute ?? { kind: "reader" };
package/package.json CHANGED
@@ -339,7 +339,7 @@
339
339
  "optional": true
340
340
  }
341
341
  },
342
- "version": "1.2.0-next.1",
342
+ "version": "1.2.0-next.2",
343
343
  "dependencies": {
344
344
  "@aws-amplify/adapter-nextjs": "^1.7.3",
345
345
  "@aws-crypto/sha256-js": "5.2.0",
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.2.0-next.1",
2
+ "version": "1.2.0-next.2",
3
3
  "routes": [
4
4
  {
5
5
  "file": "app/%5F_preview/[[...path]]/route.ts",