@anthusai/papyrus 5.59.0 → 5.60.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,3 +1,4 @@
1
+ import { fileURLToPath } from "node:url";
1
2
  import { a } from "@aws-amplify/backend";
2
3
  /**
3
4
  * Messages belong to their author, and the backend says so. The browser cannot create, edit or delete a Message through the
@@ -10,8 +11,11 @@ import { a } from "@aws-amplify/backend";
10
11
  */
11
12
  const people = (allow) => [allow.group("editor"), allow.group("admin")];
12
13
  const adminsOnly = (allow) => [allow.group("admin")];
13
- const onMessages = (entry) => a.handler.custom({ dataSource: a.ref("Message"), entry });
14
- const onThreads = (entry) => a.handler.custom({ dataSource: a.ref("MessageThread"), entry });
14
+ // Absolute paths: when a site loads this file from the package, its call site carries a loader query
15
+ // (`?tsx-namespace=...`) that Amplify cannot turn back into a directory, so a relative entry fails to deploy.
16
+ export const resolverEntry = (relative) => fileURLToPath(new URL(relative, import.meta.url));
17
+ const onMessages = (entry) => a.handler.custom({ dataSource: a.ref("Message"), entry: resolverEntry(entry) });
18
+ const onThreads = (entry) => a.handler.custom({ dataSource: a.ref("MessageThread"), entry: resolverEntry(entry) });
15
19
  export const messageActionsSchemaDefinitions = {
16
20
  postMessage: a
17
21
  .mutation()
@@ -1,3 +1,4 @@
1
+ import { fileURLToPath } from "node:url";
1
2
  import { a } from "@aws-amplify/backend";
2
3
 
3
4
  /**
@@ -11,8 +12,11 @@ import { a } from "@aws-amplify/backend";
11
12
  */
12
13
  const people = (allow: any) => [allow.group("editor"), allow.group("admin")];
13
14
  const adminsOnly = (allow: any) => [allow.group("admin")];
14
- const onMessages = (entry: string) => a.handler.custom({ dataSource: a.ref("Message"), entry });
15
- const onThreads = (entry: string) => a.handler.custom({ dataSource: a.ref("MessageThread"), entry });
15
+ // Absolute paths: when a site loads this file from the package, its call site carries a loader query
16
+ // (`?tsx-namespace=...`) that Amplify cannot turn back into a directory, so a relative entry fails to deploy.
17
+ export const resolverEntry = (relative: string) => fileURLToPath(new URL(relative, import.meta.url));
18
+ const onMessages = (entry: string) => a.handler.custom({ dataSource: a.ref("Message"), entry: resolverEntry(entry) });
19
+ const onThreads = (entry: string) => a.handler.custom({ dataSource: a.ref("MessageThread"), entry: resolverEntry(entry) });
16
20
 
17
21
  export const messageActionsSchemaDefinitions = {
18
22
  postMessage: a
@@ -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.59.0",
524
+ "version": "5.60.0",
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.59.0",
2
+ "version": "5.60.0",
3
3
  "routes": [
4
4
  {
5
5
  "file": "app/%5F_preview/[[...path]]/route.ts",