@anthusai/papyrus 5.53.0 → 5.54.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.
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { loadReferenceReviewDetails } from "../lib/reference-review-details";
|
|
4
|
+
import { loadAllPages } from "../lib/newsroom-all-pages";
|
|
4
5
|
import { hasEditorRights } from "../lib/staff-groups";
|
|
5
6
|
|
|
6
7
|
import { isEditorialWorkAssignment } from "../lib/newsroom-assignments";
|
|
@@ -1651,22 +1652,26 @@ export async function loadEditorReferencesData(): Promise<{
|
|
|
1651
1652
|
referenceAttachments,
|
|
1652
1653
|
};
|
|
1653
1654
|
}
|
|
1654
|
-
const referencePage = await loadNewsroomReferencePage();
|
|
1655
1655
|
return {
|
|
1656
|
-
references:
|
|
1656
|
+
references: await loadAllNewsroomReferences(),
|
|
1657
1657
|
referenceAttachments,
|
|
1658
1658
|
};
|
|
1659
1659
|
}
|
|
1660
|
-
const [
|
|
1661
|
-
|
|
1660
|
+
const [references, referenceAttachments] = await Promise.all([
|
|
1661
|
+
loadAllNewsroomReferences(),
|
|
1662
1662
|
listUserPoolModel<ReferenceAttachmentRecord>("ReferenceAttachment"),
|
|
1663
1663
|
]);
|
|
1664
1664
|
return {
|
|
1665
|
-
references
|
|
1665
|
+
references,
|
|
1666
1666
|
referenceAttachments: referenceAttachments.sort((left, right) => left.sortKey.localeCompare(right.sortKey)),
|
|
1667
1667
|
};
|
|
1668
1668
|
}
|
|
1669
1669
|
|
|
1670
|
+
/** Every reference, page by page: the References feed ranks the whole set, so stopping at the first page hid most of it. */
|
|
1671
|
+
function loadAllNewsroomReferences(): Promise<ReferenceRecord[]> {
|
|
1672
|
+
return loadAllPages((nextToken) => loadNewsroomReferencePage({ nextToken }));
|
|
1673
|
+
}
|
|
1674
|
+
|
|
1670
1675
|
export function normalizeNewsroomReferencePageOrder(value?: string | null): NewsroomReferencePageOrder {
|
|
1671
1676
|
return value?.trim() === "imported" ? "imported" : "published";
|
|
1672
1677
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Every row a paged newsroom read returns, following `nextToken` to the end; rows repeated across pages are kept once. */
|
|
2
|
+
export async function loadAllPages<T extends { id?: string | null }>(
|
|
3
|
+
loadPage: (nextToken: string | null) => Promise<{ items: T[]; nextToken?: string | null; hasMore: boolean }>,
|
|
4
|
+
): Promise<T[]> {
|
|
5
|
+
const rows: T[] = [];
|
|
6
|
+
const seenIds = new Set<string>();
|
|
7
|
+
const seenTokens = new Set<string>();
|
|
8
|
+
let nextToken: string | null = null;
|
|
9
|
+
do {
|
|
10
|
+
const page = await loadPage(nextToken);
|
|
11
|
+
for (const row of page.items) {
|
|
12
|
+
if (!row?.id || seenIds.has(row.id)) continue;
|
|
13
|
+
seenIds.add(row.id);
|
|
14
|
+
rows.push(row);
|
|
15
|
+
}
|
|
16
|
+
nextToken = page.hasMore ? page.nextToken ?? null : null;
|
|
17
|
+
if (nextToken && seenTokens.has(nextToken)) throw new Error("The list repeated a page; reload to try again.");
|
|
18
|
+
if (nextToken) seenTokens.add(nextToken);
|
|
19
|
+
} while (nextToken);
|
|
20
|
+
return rows;
|
|
21
|
+
}
|
package/package.json
CHANGED
|
@@ -279,6 +279,7 @@
|
|
|
279
279
|
"./lib/newsletter-fixture": "./lib/newsletter-fixture.ts",
|
|
280
280
|
"./lib/newsletter-model": "./lib/newsletter-model.ts",
|
|
281
281
|
"./lib/newspaper-layout": "./lib/newspaper-layout.ts",
|
|
282
|
+
"./lib/newsroom-all-pages": "./lib/newsroom-all-pages.ts",
|
|
282
283
|
"./lib/newsroom-articles": "./lib/newsroom-articles.ts",
|
|
283
284
|
"./lib/newsroom-assignments": "./lib/newsroom-assignments.ts",
|
|
284
285
|
"./lib/newsroom-base-path": "./lib/newsroom-base-path.ts",
|
|
@@ -500,7 +501,7 @@
|
|
|
500
501
|
"optional": true
|
|
501
502
|
}
|
|
502
503
|
},
|
|
503
|
-
"version": "5.
|
|
504
|
+
"version": "5.54.0",
|
|
504
505
|
"dependencies": {
|
|
505
506
|
"@aws-amplify/adapter-nextjs": "^1.7.3",
|
|
506
507
|
"@aws-crypto/sha256-js": "5.2.0",
|
package/routes.manifest.json
CHANGED