@anthusai/papyrus 5.43.0-next.51 → 5.43.0-next.52

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.
@@ -21,6 +21,7 @@ import { ProposalsPanel } from "./proposals-panel";
21
21
  import { NewsletterPanel } from "./newsletter-panel";
22
22
  import { SignupEntriesPanel } from "./signup-entries-panel";
23
23
  import { pluginSettings, type PluginOutputs } from "../lib/plugin-settings";
24
+ import { assertReferenceReviewSaved, type ReferenceReviewResult } from "../lib/reference-review-response";
24
25
  import { generateClient } from "aws-amplify/data";
25
26
  import type { Schema } from "../amplify/data/resource";
26
27
  import {
@@ -429,15 +430,7 @@ type CategoryReviewResponse = {
429
430
  };
430
431
 
431
432
  type ReferenceReviewResponse = {
432
- data?: {
433
- ok?: boolean | null;
434
- action?: string | null;
435
- referenceId?: string | null;
436
- status?: string | null;
437
- reasonCode?: string | null;
438
- messageId?: string | null;
439
- relationId?: string | null;
440
- } | null;
433
+ data?: ReferenceReviewResult | null;
441
434
  errors?: Array<{ message?: string | null } | string | null> | null;
442
435
  };
443
436
 
@@ -14561,20 +14554,11 @@ function assertReviewMutationSucceeded(response: CategoryReviewResponse, proposa
14561
14554
  return response.data;
14562
14555
  }
14563
14556
 
14564
- function assertReferenceReviewMutationSucceeded(response: ReferenceReviewResponse, referenceId: string): NonNullable<ReferenceReviewResponse["data"]> {
14557
+ function assertReferenceReviewMutationSucceeded(response: ReferenceReviewResponse, referenceId: string): ReferenceReviewResult {
14565
14558
  if (response.errors?.length) {
14566
14559
  throw new Error(response.errors.map(formatGraphQLError).join("; "));
14567
14560
  }
14568
- if (!response.data?.ok) {
14569
- throw new Error(`Reference curation review was not saved for ${referenceId}.`);
14570
- }
14571
- if (response.data.referenceId && response.data.referenceId !== referenceId) {
14572
- throw new Error(`Reference review response did not match ${referenceId}.`);
14573
- }
14574
- if (!response.data.messageId || !response.data.relationId) {
14575
- throw new Error(`Reference review saved without commentary audit rows for ${referenceId}.`);
14576
- }
14577
- return response.data;
14561
+ return assertReferenceReviewSaved(response.data, referenceId);
14578
14562
  }
14579
14563
 
14580
14564
  function assertReferenceQualityMutationSucceeded(
@@ -0,0 +1,19 @@
1
+ // What the newsroom checks in a saved vote's response. A vote is recorded on the Reference itself and writes no Message
2
+ // or relation (Messages come only from people), so the response carries only the outcome.
3
+ export type ReferenceReviewResult = {
4
+ ok?: boolean | null;
5
+ action?: string | null;
6
+ referenceId?: string | null;
7
+ status?: string | null;
8
+ reasonCode?: string | null;
9
+ };
10
+
11
+ export function assertReferenceReviewSaved(data: ReferenceReviewResult | null | undefined, referenceId: string): ReferenceReviewResult {
12
+ if (!data?.ok) {
13
+ throw new Error(`Reference curation review was not saved for ${referenceId}.`);
14
+ }
15
+ if (data.referenceId && data.referenceId !== referenceId) {
16
+ throw new Error(`Reference review response did not match ${referenceId}.`);
17
+ }
18
+ return data;
19
+ }
package/package.json CHANGED
@@ -363,6 +363,7 @@
363
363
  "./lib/reference-preview": "./lib/reference-preview.ts",
364
364
  "./lib/reference-review-details": "./lib/reference-review-details.ts",
365
365
  "./lib/reference-review-request": "./lib/reference-review-request.ts",
366
+ "./lib/reference-review-response": "./lib/reference-review-response.ts",
366
367
  "./lib/reference-source-preview": "./lib/reference-source-preview.ts",
367
368
  "./lib/relevance-decisions": "./lib/relevance-decisions.ts",
368
369
  "./lib/relevance-status": "./lib/relevance-status.ts",
@@ -520,7 +521,7 @@
520
521
  "optional": true
521
522
  }
522
523
  },
523
- "version": "5.43.0-next.51",
524
+ "version": "5.43.0-next.52",
524
525
  "dependencies": {
525
526
  "@aws-amplify/adapter-nextjs": "^1.7.3",
526
527
  "@aws-crypto/sha256-js": "5.2.0",
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "5.43.0-next.51",
2
+ "version": "5.43.0-next.52",
3
3
  "routes": [
4
4
  {
5
5
  "file": "app/%5F_preview/[[...path]]/route.ts",