@anthusai/papyrus 5.110.0 → 5.112.0-next.1
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.
- package/amplify/auth/resource.js +3 -0
- package/amplify/auth/resource.ts +3 -0
- package/amplify/auth/tenant-session-claims.js +27 -0
- package/amplify/auth/tenant-session-claims.ts +31 -0
- package/amplify/cost-attribution.js +12 -0
- package/amplify/cost-attribution.ts +12 -0
- package/amplify/data/resource.js +79 -0
- package/amplify/data/resource.ts +82 -0
- package/amplify/data/schema.js +82 -1
- package/amplify/data/schema.ts +85 -1
- package/amplify/functions/assignment-action/handler.ts +14 -9
- package/amplify/functions/automation-view/wire.js +2 -1
- package/amplify/functions/automation-view/wire.ts +2 -1
- package/amplify/functions/category-action/handler.ts +24 -18
- package/amplify/functions/category-action/message-hashtags.js +2 -1
- package/amplify/functions/category-action/message-hashtags.ts +2 -1
- package/amplify/functions/category-action/reference-links.js +3 -2
- package/amplify/functions/category-action/reference-links.ts +3 -2
- package/amplify/functions/console-chat-responder/resource.js +2 -1
- package/amplify/functions/console-chat-responder/resource.ts +2 -1
- package/amplify/functions/content-actions/handler.py +54 -22
- package/amplify/functions/content-actions/resource.js +4 -0
- package/amplify/functions/content-actions/resource.ts +5 -0
- package/amplify/functions/editorial-checks/handler.py +5 -1
- package/amplify/functions/editorial-checks/schema.js +10 -2
- package/amplify/functions/editorial-checks/schema.ts +10 -2
- package/amplify/functions/editorial-checks/wire.js +2 -1
- package/amplify/functions/editorial-checks/wire.ts +2 -1
- package/amplify/functions/image-service/wire.js +2 -1
- package/amplify/functions/image-service/wire.ts +2 -1
- package/amplify/functions/monitoring-view/wire.js +2 -1
- package/amplify/functions/monitoring-view/wire.ts +2 -1
- package/amplify/functions/newsroom-summary/handler.ts +16 -12
- package/amplify/functions/shared/tenant-context.js +98 -0
- package/amplify/functions/shared/tenant-context.ts +33 -0
- package/amplify/functions/shared/tenant-scoped-client.ts +80 -0
- package/amplify/functions/tenant-claims/claims.ts +90 -0
- package/amplify/functions/tenant-claims/environment.js +7 -0
- package/amplify/functions/tenant-claims/environment.ts +7 -0
- package/amplify/functions/tenant-claims/handler.ts +56 -0
- package/amplify/functions/tenant-claims/resource.js +12 -0
- package/amplify/functions/tenant-claims/resource.ts +13 -0
- package/amplify/plugins/newsletter/sending.js +2 -1
- package/amplify/plugins/newsletter/sending.ts +2 -1
- package/amplify/plugins/notifications/papyrus.plugin.js +2 -1
- package/amplify/plugins/notifications/papyrus.plugin.ts +2 -1
- package/amplify/plugins/reader-steering/schema.js +15 -3
- package/amplify/plugins/reader-steering/schema.ts +15 -3
- package/amplify/plugins/signup/papyrus.plugin.js +2 -1
- package/amplify/plugins/signup/papyrus.plugin.ts +2 -1
- package/amplify/plugins/signup/schema.js +1 -0
- package/amplify/plugins/signup/schema.ts +1 -0
- package/amplify/shared-stack/alarms.js +53 -0
- package/amplify/shared-stack/alarms.ts +109 -0
- package/amplify/shared-stack/define.js +15 -0
- package/amplify/shared-stack/define.ts +17 -0
- package/amplify/shared-stack/deny.js +27 -0
- package/amplify/shared-stack/deny.ts +28 -0
- package/amplify/shared-stack/inline-policy.js +53 -0
- package/amplify/shared-stack/inline-policy.ts +65 -0
- package/amplify/shared-stack/isolation.js +161 -0
- package/amplify/shared-stack/isolation.ts +204 -0
- package/amplify/shared-stack/names.js +95 -0
- package/amplify/shared-stack/names.ts +133 -0
- package/amplify/shared-stack/settings.js +70 -0
- package/amplify/shared-stack/settings.ts +95 -0
- package/amplify/site-api-access.js +13 -0
- package/amplify/site-api-access.ts +14 -0
- package/amplify/site-backend-config.js +7 -1
- package/amplify/site-backend-config.ts +8 -2
- package/amplify/site-backend.js +65 -13
- package/amplify/site-backend.ts +75 -19
- package/components/news-desk-taxonomy-client.ts +5 -0
- package/components/newsroom-article-editor.tsx +7 -3
- package/components/newsroom-board-view.tsx +4 -2
- package/components/newsroom-organizer.css +2 -2
- package/components/use-newsroom-desk-sections.ts +31 -0
- package/infra/amplify-app-shell.js +4 -1
- package/infra/amplify-app-shell.ts +4 -1
- package/infra/build-specs.js +4 -1
- package/infra/build-specs.ts +5 -1
- package/infra/cost-tags.test.js +1 -1
- package/infra/cost-tags.test.ts +1 -1
- package/infra/shared-stack-deny.js +80 -0
- package/infra/shared-stack-deny.test.js +56 -0
- package/infra/shared-stack-deny.test.ts +66 -0
- package/infra/shared-stack-deny.ts +86 -0
- package/lib/newsroom-sections.ts +14 -0
- package/lib/tenant-keys.js +16 -0
- package/lib/tenant-keys.ts +19 -0
- package/package.json +2 -1
- package/routes.manifest.json +1 -1
|
@@ -5,6 +5,8 @@ import { Amplify } from "aws-amplify";
|
|
|
5
5
|
import { generateClient } from "aws-amplify/data";
|
|
6
6
|
import type { Schema } from "../../data/resource";
|
|
7
7
|
import { putJsonModelPayload, putTextModelPayload, readJsonModelPayload } from "../shared/model-payloads";
|
|
8
|
+
import { actingFor, buildEventTenantContext, currentTenantContext } from "../shared/tenant-context";
|
|
9
|
+
import { newsroomSummaryPayloadId, tenantScopedClient } from "../shared/tenant-scoped-client";
|
|
8
10
|
import { curationActorKind, referenceStarFields, referenceVoteFields, validatedCurationSectionId } from "../shared/reference-curation-metadata";
|
|
9
11
|
import {
|
|
10
12
|
delegationExpiry,
|
|
@@ -131,7 +133,6 @@ const CATEGORY_PROPOSAL_KINDS = new Set([
|
|
|
131
133
|
"move-category",
|
|
132
134
|
"archive-category",
|
|
133
135
|
]);
|
|
134
|
-
const NEWSROOM_SUMMARY_PAYLOAD_ID = "knowledge-raw-payload-newsroom-summary-current";
|
|
135
136
|
const NEWSROOM_SUMMARY_PAYLOAD_OWNER_KIND = "knowledgeRawPayload";
|
|
136
137
|
const SUMMARY_STALE_AFTER_MS = 15 * 60 * 1000;
|
|
137
138
|
const REFERENCE_CURATION_ASSIGNMENT_TYPE = "curation.reference-refresh";
|
|
@@ -156,6 +157,11 @@ const DEFAULT_REFERENCE_CURATION_POLICY = {
|
|
|
156
157
|
let clientPromise: Promise<DataClient> | null = null;
|
|
157
158
|
|
|
158
159
|
export const handler = async (event: CategoryActionEvent) => {
|
|
160
|
+
const context = buildEventTenantContext(event); // one context per call; a shared stack refuses before any read
|
|
161
|
+
return actingFor(context, () => handleField(event));
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
async function handleField(event: CategoryActionEvent) {
|
|
159
165
|
const fieldName = normalizeOptionalString(event.info?.fieldName) ?? normalizeOptionalString((event as { fieldName?: string | null }).fieldName);
|
|
160
166
|
if (!fieldName) {
|
|
161
167
|
throw new Error("Unsupported steering action: missing GraphQL field name.");
|
|
@@ -195,7 +201,7 @@ export const handler = async (event: CategoryActionEvent) => {
|
|
|
195
201
|
if (fieldName === "archiveDraftCategory") return archiveDraftCategory(event as Parameters<ArchiveDraftCategoryHandler>[0]);
|
|
196
202
|
if (fieldName === "reviewReferenceTopicLabel") return reviewReferenceTopicLabel(event as Parameters<ReviewReferenceTopicLabelHandler>[0]);
|
|
197
203
|
throw new Error(`Unsupported steering action ${fieldName}.`);
|
|
198
|
-
}
|
|
204
|
+
}
|
|
199
205
|
|
|
200
206
|
async function reviewSteeringProposal(event: Parameters<ReviewHandler>[0]) {
|
|
201
207
|
const client = await getDataClient();
|
|
@@ -310,7 +316,7 @@ async function reviewReferenceCuration(
|
|
|
310
316
|
delegation,
|
|
311
317
|
decisionRelationId,
|
|
312
318
|
}),
|
|
313
|
-
newsroomFeedKey: reference.newsroomFeedKey ?? globalKey(REFERENCE_FEED_KEY),
|
|
319
|
+
newsroomFeedKey: reference.newsroomFeedKey ?? globalKey(REFERENCE_FEED_KEY, currentTenantContext().tenantId),
|
|
314
320
|
reviewedFeedKey: reviewedFeedKeyForStatus(nextStatus),
|
|
315
321
|
// A vote moves the Reference between the unrated and rated feeds; its original prediction and arrival stay as they were.
|
|
316
322
|
feedStateKey: referenceFeedStateKey({ ...reference, curationStatus: nextStatus }),
|
|
@@ -810,7 +816,7 @@ async function requestStoryStarsProjection(itemId: string) {
|
|
|
810
816
|
new InvokeCommand({
|
|
811
817
|
FunctionName: functionName,
|
|
812
818
|
InvocationType: "Event",
|
|
813
|
-
Payload: new TextEncoder().encode(JSON.stringify({ projectionTask: { task: STORY_STARS_PROJECTION_TASK, itemId } })),
|
|
819
|
+
Payload: new TextEncoder().encode(JSON.stringify({ projectionTask: { task: STORY_STARS_PROJECTION_TASK, itemId, ...(currentTenantContext().tenantId ? { tenantId: currentTenantContext().tenantId } : {}) } })),
|
|
814
820
|
}),
|
|
815
821
|
);
|
|
816
822
|
} catch (error) {
|
|
@@ -903,7 +909,7 @@ async function setReferenceQualityRating(event: Parameters<ReferenceQualityHandl
|
|
|
903
909
|
curationStatusUpdatedAt: now,
|
|
904
910
|
curationStatusUpdatedBy: actor,
|
|
905
911
|
curationStatusReason: note,
|
|
906
|
-
newsroomFeedKey: reference.newsroomFeedKey ?? globalKey(REFERENCE_FEED_KEY),
|
|
912
|
+
newsroomFeedKey: reference.newsroomFeedKey ?? globalKey(REFERENCE_FEED_KEY, currentTenantContext().tenantId),
|
|
907
913
|
reviewedFeedKey: reviewedFeedKeyForStatus(nextStatus),
|
|
908
914
|
// A vote moves the Reference between the unrated and rated feeds; its original prediction and arrival stay as they were.
|
|
909
915
|
feedStateKey: referenceFeedStateKey({ ...reference, curationStatus: nextStatus }),
|
|
@@ -1234,7 +1240,7 @@ async function createReferenceNote(event: Parameters<ReferenceNoteHandler>[0]) {
|
|
|
1234
1240
|
importedAt: now,
|
|
1235
1241
|
createdAt: now,
|
|
1236
1242
|
updatedAt: now,
|
|
1237
|
-
newsroomFeedKey: globalKey(SEMANTIC_RELATION_FEED_KEY),
|
|
1243
|
+
newsroomFeedKey: globalKey(SEMANTIC_RELATION_FEED_KEY, currentTenantContext().tenantId),
|
|
1238
1244
|
metadata: JSON.stringify({
|
|
1239
1245
|
kind: "reference.note",
|
|
1240
1246
|
summary,
|
|
@@ -1378,7 +1384,7 @@ async function moveReferenceCorpus(event: Parameters<MoveReferenceCorpusHandler>
|
|
|
1378
1384
|
curationShareable: typeof current.curationShareable === "boolean" ? current.curationShareable : null,
|
|
1379
1385
|
curationDelegation: current.curationDelegation ?? null,
|
|
1380
1386
|
curationDecisionRelationId: normalizeOptionalString(current.curationDecisionRelationId),
|
|
1381
|
-
newsroomFeedKey: normalizeOptionalString(current.newsroomFeedKey) ?? globalKey(REFERENCE_FEED_KEY),
|
|
1387
|
+
newsroomFeedKey: normalizeOptionalString(current.newsroomFeedKey) ?? globalKey(REFERENCE_FEED_KEY, currentTenantContext().tenantId),
|
|
1382
1388
|
reviewedFeedKey: normalizeOptionalString(current.reviewedFeedKey) ?? reviewedFeedKeyForStatus(curationStatus),
|
|
1383
1389
|
predictedAcceptProbability: typeof current.predictedAcceptProbability === "number" ? current.predictedAcceptProbability : null,
|
|
1384
1390
|
predictionDecidedAt: normalizeOptionalString(current.predictionDecidedAt),
|
|
@@ -1529,7 +1535,7 @@ async function startReferenceCuration(event: Parameters<StartReferenceCurationHa
|
|
|
1529
1535
|
importedAt: now,
|
|
1530
1536
|
createdAt: now,
|
|
1531
1537
|
updatedAt: now,
|
|
1532
|
-
newsroomFeedKey: globalKey(SEMANTIC_RELATION_FEED_KEY),
|
|
1538
|
+
newsroomFeedKey: globalKey(SEMANTIC_RELATION_FEED_KEY, currentTenantContext().tenantId),
|
|
1533
1539
|
metadata: JSON.stringify({
|
|
1534
1540
|
kind: "reference.curation.assignment",
|
|
1535
1541
|
runId,
|
|
@@ -2474,7 +2480,7 @@ function buildAuthoritativeLabelRelation({
|
|
|
2474
2480
|
importedAt: now,
|
|
2475
2481
|
createdAt: now,
|
|
2476
2482
|
updatedAt: now,
|
|
2477
|
-
newsroomFeedKey: globalKey(SEMANTIC_RELATION_FEED_KEY),
|
|
2483
|
+
newsroomFeedKey: globalKey(SEMANTIC_RELATION_FEED_KEY, currentTenantContext().tenantId),
|
|
2478
2484
|
metadata: JSON.stringify({
|
|
2479
2485
|
kind: sourceMode === "accepted_prediction"
|
|
2480
2486
|
? "classification.authoritative_label.accepted_from_prediction"
|
|
@@ -2540,7 +2546,7 @@ function buildReferenceQualityRelation({
|
|
|
2540
2546
|
importedAt: now,
|
|
2541
2547
|
createdAt: now,
|
|
2542
2548
|
updatedAt: now,
|
|
2543
|
-
newsroomFeedKey: globalKey(SEMANTIC_RELATION_FEED_KEY),
|
|
2549
|
+
newsroomFeedKey: globalKey(SEMANTIC_RELATION_FEED_KEY, currentTenantContext().tenantId),
|
|
2544
2550
|
metadata: JSON.stringify({
|
|
2545
2551
|
kind: "reference.quality-rating.manual",
|
|
2546
2552
|
actor,
|
|
@@ -2557,7 +2563,7 @@ async function updateNewsroomSummaryForSemanticRelationDelta(
|
|
|
2557
2563
|
amount: number,
|
|
2558
2564
|
now: string,
|
|
2559
2565
|
): Promise<void> {
|
|
2560
|
-
const response = await client.models.KnowledgeRawPayload.get({ id:
|
|
2566
|
+
const response = await client.models.KnowledgeRawPayload.get({ id: newsroomSummaryPayloadId(currentTenantContext()) });
|
|
2561
2567
|
assertNoDataErrors(response.errors, "get Newsroom summary snapshot");
|
|
2562
2568
|
const payload = normalizeSummaryPayload(await readNewsroomSummaryPayload(client), now);
|
|
2563
2569
|
payload.generatedAt = now;
|
|
@@ -2579,7 +2585,7 @@ async function getDataClient(): Promise<DataClient> {
|
|
|
2579
2585
|
return generateClient<Schema>();
|
|
2580
2586
|
})();
|
|
2581
2587
|
}
|
|
2582
|
-
return clientPromise;
|
|
2588
|
+
return tenantScopedClient(await clientPromise, currentTenantContext());
|
|
2583
2589
|
}
|
|
2584
2590
|
|
|
2585
2591
|
async function getRequiredRecord(
|
|
@@ -2623,7 +2629,7 @@ function normalizeReferenceCurationAction(value: unknown): "accept" | "reject" |
|
|
|
2623
2629
|
}
|
|
2624
2630
|
|
|
2625
2631
|
function reviewedFeedKeyForStatus(status: string): string | null {
|
|
2626
|
-
return status === "pending" ? null : globalKey(REFERENCE_REVIEWED_FEED_KEY);
|
|
2632
|
+
return status === "pending" ? null : globalKey(REFERENCE_REVIEWED_FEED_KEY, currentTenantContext().tenantId);
|
|
2627
2633
|
}
|
|
2628
2634
|
|
|
2629
2635
|
function referenceCurationStatusForAction(action: "accept" | "reject" | "reopen" | "archive"): "accepted" | "rejected" | "pending" | "archived" {
|
|
@@ -2702,7 +2708,7 @@ async function updateNewsroomSummaryForReferenceCuration(
|
|
|
2702
2708
|
client: DataClient,
|
|
2703
2709
|
input: { corpusId: string | null; previousStatus: string; nextStatus: string; now: string },
|
|
2704
2710
|
): Promise<void> {
|
|
2705
|
-
const response = await client.models.KnowledgeRawPayload.get({ id:
|
|
2711
|
+
const response = await client.models.KnowledgeRawPayload.get({ id: newsroomSummaryPayloadId(currentTenantContext()) });
|
|
2706
2712
|
assertNoDataErrors(response.errors, "get Newsroom summary snapshot");
|
|
2707
2713
|
const payload = normalizeSummaryPayload(await readNewsroomSummaryPayload(client), input.now);
|
|
2708
2714
|
payload.generatedAt = input.now;
|
|
@@ -2726,7 +2732,7 @@ async function updateNewsroomSummaryForReferenceStatus(
|
|
|
2726
2732
|
client: DataClient,
|
|
2727
2733
|
input: { corpusId: string | null; previousStatus: string; nextStatus: string; now: string },
|
|
2728
2734
|
): Promise<void> {
|
|
2729
|
-
const response = await client.models.KnowledgeRawPayload.get({ id:
|
|
2735
|
+
const response = await client.models.KnowledgeRawPayload.get({ id: newsroomSummaryPayloadId(currentTenantContext()) });
|
|
2730
2736
|
assertNoDataErrors(response.errors, "get Newsroom summary snapshot");
|
|
2731
2737
|
const payload = normalizeSummaryPayload(await readNewsroomSummaryPayload(client), input.now);
|
|
2732
2738
|
payload.generatedAt = input.now;
|
|
@@ -2854,7 +2860,7 @@ async function upsertNewsroomSummaryPayload(
|
|
|
2854
2860
|
now: string,
|
|
2855
2861
|
): Promise<void> {
|
|
2856
2862
|
const input = {
|
|
2857
|
-
id:
|
|
2863
|
+
id: newsroomSummaryPayloadId(currentTenantContext()),
|
|
2858
2864
|
ownerType: "newsroom",
|
|
2859
2865
|
ownerId: "newsroom",
|
|
2860
2866
|
payloadKind: "summary-snapshot",
|
|
@@ -2869,7 +2875,7 @@ async function upsertNewsroomSummaryPayload(
|
|
|
2869
2875
|
}
|
|
2870
2876
|
await putJsonModelPayload(
|
|
2871
2877
|
client as any,
|
|
2872
|
-
{ ownerKind: NEWSROOM_SUMMARY_PAYLOAD_OWNER_KIND, ownerId:
|
|
2878
|
+
{ ownerKind: NEWSROOM_SUMMARY_PAYLOAD_OWNER_KIND, ownerId: newsroomSummaryPayloadId(currentTenantContext()), importRunId: input.importRunId },
|
|
2873
2879
|
"raw_payload",
|
|
2874
2880
|
"summary-snapshot",
|
|
2875
2881
|
payload,
|
|
@@ -2881,7 +2887,7 @@ async function readNewsroomSummaryPayload(client: DataClient): Promise<Record<st
|
|
|
2881
2887
|
return readJsonModelPayload(
|
|
2882
2888
|
client as any,
|
|
2883
2889
|
NEWSROOM_SUMMARY_PAYLOAD_OWNER_KIND,
|
|
2884
|
-
|
|
2890
|
+
newsroomSummaryPayloadId(currentTenantContext()),
|
|
2885
2891
|
"raw_payload",
|
|
2886
2892
|
"summary-snapshot",
|
|
2887
2893
|
);
|
|
@@ -2,6 +2,7 @@ import { createHash } from "node:crypto";
|
|
|
2
2
|
import { hashtagsInMessageText } from "../../../lib/message-hashtags.js";
|
|
3
3
|
import { conceptKeysForHashtag } from "../../../lib/wiki.js";
|
|
4
4
|
import { REFERENCE_LINK_FEED_KEY, globalKey } from "../../../lib/tenant-knowledge-keys.js";
|
|
5
|
+
import { currentTenantContext } from "../shared/tenant-context.js";
|
|
5
6
|
export const MESSAGE_CONCEPT_EDGE_KIND = "message.concept";
|
|
6
7
|
export const MESSAGE_CONCEPT_FEED_KEY = REFERENCE_LINK_FEED_KEY;
|
|
7
8
|
function parseMetadata(value) {
|
|
@@ -78,7 +79,7 @@ export async function linkMessageHashtags(store, input) {
|
|
|
78
79
|
reviewRecommended: false,
|
|
79
80
|
importedAt: input.now,
|
|
80
81
|
updatedAt: input.now,
|
|
81
|
-
newsroomFeedKey: globalKey(MESSAGE_CONCEPT_FEED_KEY),
|
|
82
|
+
newsroomFeedKey: globalKey(MESSAGE_CONCEPT_FEED_KEY, currentTenantContext().tenantId),
|
|
82
83
|
metadata: JSON.stringify(metadata),
|
|
83
84
|
}, existing !== null);
|
|
84
85
|
linkedNodeKeys.push(node.nodeKey);
|
|
@@ -2,6 +2,7 @@ import { createHash } from "node:crypto";
|
|
|
2
2
|
import { hashtagsInMessageText } from "../../../lib/message-hashtags";
|
|
3
3
|
import { conceptKeysForHashtag } from "../../../lib/wiki";
|
|
4
4
|
import { REFERENCE_LINK_FEED_KEY, globalKey } from "../../../lib/tenant-knowledge-keys";
|
|
5
|
+
import { currentTenantContext } from "../shared/tenant-context";
|
|
5
6
|
|
|
6
7
|
export const MESSAGE_CONCEPT_EDGE_KIND = "message.concept";
|
|
7
8
|
export const MESSAGE_CONCEPT_FEED_KEY = REFERENCE_LINK_FEED_KEY;
|
|
@@ -96,7 +97,7 @@ export async function linkMessageHashtags(
|
|
|
96
97
|
reviewRecommended: false,
|
|
97
98
|
importedAt: input.now,
|
|
98
99
|
updatedAt: input.now,
|
|
99
|
-
newsroomFeedKey: globalKey(MESSAGE_CONCEPT_FEED_KEY),
|
|
100
|
+
newsroomFeedKey: globalKey(MESSAGE_CONCEPT_FEED_KEY, currentTenantContext().tenantId),
|
|
100
101
|
metadata: JSON.stringify(metadata),
|
|
101
102
|
},
|
|
102
103
|
existing !== null,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { changeReasonAfterNewDescription } from "./knowledge-review.js";
|
|
3
3
|
import { REFERENCE_LINK_FEED_KEY, SEMANTIC_NODE_FEED_KEY, globalKey } from "../../../lib/tenant-knowledge-keys.js";
|
|
4
|
+
import { currentTenantContext } from "../shared/tenant-context.js";
|
|
4
5
|
export const REFERENCE_LINK_KIND = "reference.link";
|
|
5
6
|
export const REFERENCE_CONCEPT_KIND = "reference.concept";
|
|
6
7
|
export const ITEM_CONCEPT_KIND = "item.concept";
|
|
@@ -144,7 +145,7 @@ export function buildHumanEdgeRow(input) {
|
|
|
144
145
|
reviewRecommended: false,
|
|
145
146
|
importedAt: input.now,
|
|
146
147
|
updatedAt: input.now,
|
|
147
|
-
newsroomFeedKey: globalKey(REFERENCE_LINK_FEED_KEY),
|
|
148
|
+
newsroomFeedKey: globalKey(REFERENCE_LINK_FEED_KEY, currentTenantContext().tenantId),
|
|
148
149
|
metadata: JSON.stringify(metadata),
|
|
149
150
|
};
|
|
150
151
|
}
|
|
@@ -261,7 +262,7 @@ export async function ensureEditorConcept(store, name, callerSub, now, options =
|
|
|
261
262
|
const node = {
|
|
262
263
|
id: `${lineageId}-v1`, lineageId, versionNumber: 1, versionState: "current", versionCreatedAt: now, versionCreatedBy: callerSub, changeReason: options.origin && options.origin !== "newsroom" ? `Invented by an editor with a hashtag (via ${options.origin})` : "Invented by an editor with a hashtag",
|
|
263
264
|
nodeKey: editorConceptKey(slug), nodeKind: EDITOR_CONCEPT_KIND, displayName, status: "accepted", aliases: [], createdAt: now, updatedAt: now,
|
|
264
|
-
newsroomFeedKey: globalKey(SEMANTIC_NODE_FEED_KEY),
|
|
265
|
+
newsroomFeedKey: globalKey(SEMANTIC_NODE_FEED_KEY, currentTenantContext().tenantId),
|
|
265
266
|
};
|
|
266
267
|
await store.createSemanticNode(node); // false: it exists now (a second tap); read it back either way
|
|
267
268
|
const made = await store.getSemanticNode(lineageId);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { changeReasonAfterNewDescription } from "./knowledge-review";
|
|
3
3
|
import { REFERENCE_LINK_FEED_KEY, SEMANTIC_NODE_FEED_KEY, globalKey } from "../../../lib/tenant-knowledge-keys";
|
|
4
|
+
import { currentTenantContext } from "../shared/tenant-context";
|
|
4
5
|
|
|
5
6
|
export const REFERENCE_LINK_KIND = "reference.link";
|
|
6
7
|
export const REFERENCE_CONCEPT_KIND = "reference.concept";
|
|
@@ -181,7 +182,7 @@ export function buildHumanEdgeRow(input: { relationId: string; kind: string; pre
|
|
|
181
182
|
reviewRecommended: false,
|
|
182
183
|
importedAt: input.now,
|
|
183
184
|
updatedAt: input.now,
|
|
184
|
-
newsroomFeedKey: globalKey(REFERENCE_LINK_FEED_KEY),
|
|
185
|
+
newsroomFeedKey: globalKey(REFERENCE_LINK_FEED_KEY, currentTenantContext().tenantId),
|
|
185
186
|
metadata: JSON.stringify(metadata),
|
|
186
187
|
};
|
|
187
188
|
}
|
|
@@ -289,7 +290,7 @@ export async function ensureEditorConcept(store: ReferenceLinkStore, name: strin
|
|
|
289
290
|
const node = {
|
|
290
291
|
id: `${lineageId}-v1`, lineageId, versionNumber: 1, versionState: "current", versionCreatedAt: now, versionCreatedBy: callerSub, changeReason: options.origin && options.origin !== "newsroom" ? `Invented by an editor with a hashtag (via ${options.origin})` : "Invented by an editor with a hashtag",
|
|
291
292
|
nodeKey: editorConceptKey(slug), nodeKind: EDITOR_CONCEPT_KIND, displayName, status: "accepted", aliases: [], createdAt: now, updatedAt: now,
|
|
292
|
-
newsroomFeedKey: globalKey(SEMANTIC_NODE_FEED_KEY),
|
|
293
|
+
newsroomFeedKey: globalKey(SEMANTIC_NODE_FEED_KEY, currentTenantContext().tenantId),
|
|
293
294
|
};
|
|
294
295
|
await store.createSemanticNode(node); // false: it exists now (a second tap); read it back either way
|
|
295
296
|
const made = await store.getSemanticNode(lineageId);
|
|
@@ -3,6 +3,7 @@ import { Platform } from "aws-cdk-lib/aws-ecr-assets";
|
|
|
3
3
|
import { Repository } from "aws-cdk-lib/aws-ecr";
|
|
4
4
|
import { Effect, PolicyStatement } from "aws-cdk-lib/aws-iam";
|
|
5
5
|
import { Architecture, CfnEventSourceMapping, DockerImageCode, DockerImageFunction } from "aws-cdk-lib/aws-lambda";
|
|
6
|
+
import { siteApiEnvironment } from "../../site-api-access.js";
|
|
6
7
|
export class ConsoleChatResponderStack extends NestedStack {
|
|
7
8
|
responderFunction;
|
|
8
9
|
constructor(scope, id, props) {
|
|
@@ -12,7 +13,7 @@ export class ConsoleChatResponderStack extends NestedStack {
|
|
|
12
13
|
PAPYRUS_MESSAGE_TABLE_NAME: props.messageTable.tableName,
|
|
13
14
|
PAPYRUS_MESSAGE_THREAD_TABLE_NAME: props.threadTable.tableName,
|
|
14
15
|
PAPYRUS_MESSAGE_THREAD_SEQUENCE_INDEX_NAME: "messagesByThreadSequence",
|
|
15
|
-
|
|
16
|
+
...siteApiEnvironment(props.graphqlEndpoint),
|
|
16
17
|
PAPYRUS_CONSOLE_RESPONSE_TARGET: responseTarget,
|
|
17
18
|
PAPYRUS_CONSOLE_MODEL: props.model?.trim() || process.env.PAPYRUS_CONSOLE_MODEL || "gpt-6-luna",
|
|
18
19
|
PAPYRUS_CONSOLE_CONTEXT_CACHE_ROOT: "/tmp/papyrus-console/thread-context",
|
|
@@ -5,6 +5,7 @@ import { Effect, PolicyStatement } from "aws-cdk-lib/aws-iam";
|
|
|
5
5
|
import { Architecture, CfnEventSourceMapping, DockerImageCode, DockerImageFunction } from "aws-cdk-lib/aws-lambda";
|
|
6
6
|
import type { ITable } from "aws-cdk-lib/aws-dynamodb";
|
|
7
7
|
import { Construct } from "constructs";
|
|
8
|
+
import { siteApiEnvironment } from "../../site-api-access";
|
|
8
9
|
|
|
9
10
|
export type ConsoleChatResponderStackProps = NestedStackProps & {
|
|
10
11
|
messageTable: ITable;
|
|
@@ -28,7 +29,7 @@ export class ConsoleChatResponderStack extends NestedStack {
|
|
|
28
29
|
PAPYRUS_MESSAGE_TABLE_NAME: props.messageTable.tableName,
|
|
29
30
|
PAPYRUS_MESSAGE_THREAD_TABLE_NAME: props.threadTable.tableName,
|
|
30
31
|
PAPYRUS_MESSAGE_THREAD_SEQUENCE_INDEX_NAME: "messagesByThreadSequence",
|
|
31
|
-
|
|
32
|
+
...siteApiEnvironment(props.graphqlEndpoint),
|
|
32
33
|
PAPYRUS_CONSOLE_RESPONSE_TARGET: responseTarget,
|
|
33
34
|
PAPYRUS_CONSOLE_MODEL: props.model?.trim() || process.env.PAPYRUS_CONSOLE_MODEL || "gpt-6-luna",
|
|
34
35
|
PAPYRUS_CONSOLE_CONTEXT_CACHE_ROOT: "/tmp/papyrus-console/thread-context",
|
|
@@ -7,6 +7,7 @@ from typing import Any
|
|
|
7
7
|
from papyrus_content import request_meter
|
|
8
8
|
from papyrus_content.edge_invalidation import distribution_ids_from_environment, invalidate_revalidated_paths
|
|
9
9
|
from papyrus_content.graphql_authoring import create_authoring_client
|
|
10
|
+
from papyrus_content.tenant_context import acting_for, build_event_tenant_context, build_invocation_tenant_context, current_tenant_context
|
|
10
11
|
from papyrus_content.markus_renderer.body_features import install_body_features
|
|
11
12
|
from papyrus_content.markus_renderer.derive import derive_body
|
|
12
13
|
from papyrus_content.projection.deploy_render import deploy_render, drift_metric_line
|
|
@@ -43,6 +44,7 @@ from papyrus_content.story_schedule import TASK_NAME as PUBLISH_SCHEDULED_TASK,
|
|
|
43
44
|
from papyrus_content.live_schema import wait_for_live_schema
|
|
44
45
|
from papyrus_content.publication import ensure_publication_from_environment
|
|
45
46
|
from papyrus_content.editorial_checks import GraphQLEditorialStore, ensure_default_policies
|
|
47
|
+
from papyrus_content.item_language_backfill import ensure_item_languages
|
|
46
48
|
from papyrus_content.reference_intake import IntakeError, intake_email_submission_references, intake_references
|
|
47
49
|
from papyrus_content.publish_alerts import PUBLISHED_TASK_KEY, announce_published
|
|
48
50
|
from papyrus_content.publishing import (
|
|
@@ -52,6 +54,7 @@ from papyrus_content.publishing import (
|
|
|
52
54
|
published_item_id_for,
|
|
53
55
|
save_item,
|
|
54
56
|
unpublish_item,
|
|
57
|
+
utc_now_iso,
|
|
55
58
|
)
|
|
56
59
|
|
|
57
60
|
|
|
@@ -66,6 +69,12 @@ def parse_input(raw: Any) -> dict:
|
|
|
66
69
|
return parsed
|
|
67
70
|
|
|
68
71
|
|
|
72
|
+
def authoring_client():
|
|
73
|
+
"""The authoring client of the call being served. Its tenant is the one in the context the handler built from the event, never the environment's."""
|
|
74
|
+
client, _claims = create_authoring_client(current_tenant_context().tenant_id)
|
|
75
|
+
return client
|
|
76
|
+
|
|
77
|
+
|
|
69
78
|
def actor_from_event(event: dict) -> str:
|
|
70
79
|
identity = event.get("identity") or {}
|
|
71
80
|
return identity.get("username") or identity.get("sub") or "unknown"
|
|
@@ -143,12 +152,19 @@ def send_to_projection_dead_letter_queue(task: dict, error: str) -> None:
|
|
|
143
152
|
pass
|
|
144
153
|
|
|
145
154
|
|
|
155
|
+
def stamped_with_tenant(task: dict) -> dict:
|
|
156
|
+
"""A task carries the tenant of the call that scheduled it, so a shared stack's later invocation names it (a dedicated stack with no tenant adds nothing)."""
|
|
157
|
+
tenant_id = current_tenant_context().tenant_id
|
|
158
|
+
return {**task, "tenantId": tenant_id} if tenant_id else task
|
|
159
|
+
|
|
160
|
+
|
|
146
161
|
def schedule_projection_task(task: dict, error: str) -> bool:
|
|
147
162
|
"""Run a projection task later, in this same function, as an asynchronous invocation.
|
|
148
163
|
|
|
149
164
|
The function has an on-failure destination (the dead letter queue), so a task
|
|
150
165
|
that keeps failing ends up there for ``papyrus ops content project --reconcile``.
|
|
151
166
|
"""
|
|
167
|
+
task = stamped_with_tenant(task)
|
|
152
168
|
function_name = (os.environ.get("AWS_LAMBDA_FUNCTION_NAME") or "").strip()
|
|
153
169
|
if not function_name:
|
|
154
170
|
send_to_projection_dead_letter_queue(task, error)
|
|
@@ -318,7 +334,7 @@ def refresh_site_pages_action(arguments: dict, who: str = "content-actions") ->
|
|
|
318
334
|
return {"ok": False, "operation": name, "error": {"code": "not_projected", "message": "This site does not project its pages to S3, so there is no edge cache to refresh from here."}}
|
|
319
335
|
operation = PAGE_REFRESH_OPERATIONS.get(name)
|
|
320
336
|
if operation is None:
|
|
321
|
-
return run_page_refresh(name, inputs, refresh_service(
|
|
337
|
+
return run_page_refresh(name, inputs, refresh_service(authoring_client(), who))
|
|
322
338
|
if inputs.pop("jobStatus", False) is True:
|
|
323
339
|
return rerender_status_action(inputs)
|
|
324
340
|
background = inputs.pop("async", False) is True
|
|
@@ -326,7 +342,7 @@ def refresh_site_pages_action(arguments: dict, who: str = "content-actions") ->
|
|
|
326
342
|
validate_page_refresh(operation, inputs)
|
|
327
343
|
except RefreshError as error:
|
|
328
344
|
return {"ok": False, "operation": name, "error": {"code": error.code, "message": error.message}}
|
|
329
|
-
client
|
|
345
|
+
client = authoring_client()
|
|
330
346
|
service = refresh_service(client, who)
|
|
331
347
|
if name == "site_rerender_pages" and (inputs["scope"] != "story" or background) and not inputs.get("dryRun"):
|
|
332
348
|
checked = run_page_refresh(name, {**inputs, "dryRun": True}, service) # the guard first: nothing is scheduled that would be refused or is only a preview
|
|
@@ -373,8 +389,10 @@ def ensure_default_editorial_policies(client) -> None:
|
|
|
373
389
|
def run_deploy_render_task(client) -> dict:
|
|
374
390
|
"""Render every published page after a backend deploy, then report drift (a dry run: nothing is deleted)."""
|
|
375
391
|
ensure_publication_from_environment(client)
|
|
376
|
-
ensure_default_editorial_policies(client)
|
|
377
392
|
context = projection_context(client)
|
|
393
|
+
# Before anything reads a language (the render, the editorial policies' checks): rows written before the fields get them, once per site.
|
|
394
|
+
print(json.dumps(ensure_item_languages(client, context.writer, now=utc_now_iso, echo=lambda line: None)))
|
|
395
|
+
ensure_default_editorial_policies(client)
|
|
378
396
|
if targeted_invalidation(os.environ):
|
|
379
397
|
context.invalidate = None # the default, "targeted": a deploy never purges; pages age out with the HTML lifetime (PPY-2745c1)
|
|
380
398
|
report = deploy_render(context)
|
|
@@ -394,12 +412,13 @@ def run_home_page_snapshot_task(client, task: dict | None = None) -> dict:
|
|
|
394
412
|
grow with the corpus (``papyrus_content/home_page/incremental.py``). Any other run reads the whole corpus and leaves the private state for the next one.
|
|
395
413
|
"""
|
|
396
414
|
context = projection_context(client)
|
|
415
|
+
tenant_id = client.tenant_id
|
|
397
416
|
state_store, dirty_store, batch = home_page_stores_for(task or {})
|
|
398
417
|
report = run_home_page_snapshot(
|
|
399
418
|
context,
|
|
400
419
|
client,
|
|
401
420
|
home_page_settings_of(context.projector),
|
|
402
|
-
client_factory=lambda: create_authoring_client()[0],
|
|
421
|
+
client_factory=lambda: create_authoring_client(tenant_id)[0], # worker threads do not inherit the call's context: the tenant is passed in
|
|
403
422
|
workers=HOME_PAGE_SNAPSHOT_WORKERS,
|
|
404
423
|
state_store=state_store,
|
|
405
424
|
dirty=batch,
|
|
@@ -600,7 +619,7 @@ def run_page_refresh_rerender_task(client, task: dict) -> dict:
|
|
|
600
619
|
|
|
601
620
|
|
|
602
621
|
def _run_projection_task(task: dict, lambda_context=None) -> dict:
|
|
603
|
-
client
|
|
622
|
+
client = authoring_client()
|
|
604
623
|
if task.get("task") in ("item", "item-pages", "drain"):
|
|
605
624
|
return run_queued_build(client, task, lambda_context)
|
|
606
625
|
if task.get("task") == "all":
|
|
@@ -655,7 +674,7 @@ def set_story_step_action(arguments: dict, event: dict) -> dict:
|
|
|
655
674
|
return {"ok": False, "errors": [{"code": "not-signed-in", "message": "Sign in as an editor to change a checklist step.", "line": None}]}
|
|
656
675
|
agent = (arguments.get("agent") or "").strip()
|
|
657
676
|
label = agent or (arguments.get("actorLabel") or "").strip() or (event.get("identity") or {}).get("username") or "editor"
|
|
658
|
-
client
|
|
677
|
+
client = authoring_client()
|
|
659
678
|
actor = {"kind": ACTOR_AGENT if agent else ACTOR_PERSON, "label": label, "sub": person}
|
|
660
679
|
try:
|
|
661
680
|
if not arguments.get("state"): # no state: a note on the step, whatever its state, changing nothing else
|
|
@@ -671,7 +690,11 @@ def set_story_step_action(arguments: dict, event: dict) -> dict:
|
|
|
671
690
|
|
|
672
691
|
|
|
673
692
|
def save_item_draft_action(arguments: dict, actor: str, approved_by: str | None = None) -> dict:
|
|
674
|
-
client
|
|
693
|
+
client = authoring_client()
|
|
694
|
+
if arguments.get("id") and current_tenant_context().mode == "shared" and client.get_record("Item", arguments["id"]) is None:
|
|
695
|
+
# A shared stack's editor names a story it can see: an id that is not the tenant's answers "not found" and writes nothing
|
|
696
|
+
# (a missing row and another tenant's row are indistinguishable to a tenant client, and neither is created here).
|
|
697
|
+
raise PublishError("not-found", "That story was not found.")
|
|
675
698
|
if arguments.get("newVersion") and arguments.get("id"):
|
|
676
699
|
existing = client.get_record("Item", arguments["id"])
|
|
677
700
|
if existing is None:
|
|
@@ -776,7 +799,7 @@ def projection_status_action(arguments: dict) -> dict:
|
|
|
776
799
|
jobs = publish_jobs_from_environment()
|
|
777
800
|
if jobs is None:
|
|
778
801
|
return {"ok": True, "projection": {"state": "unknown", "reason": "this site keeps no build records (no projection lock table)"}}
|
|
779
|
-
client
|
|
802
|
+
client = authoring_client()
|
|
780
803
|
candidate = client.get_record("Item", arguments["id"]) or {}
|
|
781
804
|
job = jobs.status(arguments["id"])
|
|
782
805
|
answer = job_answer(job)
|
|
@@ -818,7 +841,7 @@ def start_projection_job(client, item_id: str, *, version: int | None, published
|
|
|
818
841
|
def publish_item_action(arguments: dict, actor: str, approved_by: str | None = None) -> dict:
|
|
819
842
|
if arguments.get("jobStatus"):
|
|
820
843
|
return projection_status_action(arguments)
|
|
821
|
-
client
|
|
844
|
+
client = authoring_client()
|
|
822
845
|
candidate = client.get_record("Item", arguments["id"]) or {}
|
|
823
846
|
live = client.get_record("PublishedItem", published_item_id_for(candidate.get("lineageId") or arguments["id"]))
|
|
824
847
|
render_preflight(client, arguments["id"]) # a page the site cannot render is refused before any published data is written
|
|
@@ -859,7 +882,7 @@ def remove_schedules(client, item: dict, version_number: int | None) -> dict:
|
|
|
859
882
|
|
|
860
883
|
|
|
861
884
|
def unpublish_item_action(arguments: dict, actor: str) -> dict:
|
|
862
|
-
client
|
|
885
|
+
client = authoring_client()
|
|
863
886
|
candidate = client.get_record("Item", arguments["id"]) or {}
|
|
864
887
|
result = unpublish_item(client, arguments["id"], actor=actor)
|
|
865
888
|
response = {"ok": True, "changed": result.changed}
|
|
@@ -884,7 +907,7 @@ def caller_from_event(event: dict) -> Caller:
|
|
|
884
907
|
|
|
885
908
|
def schedule_item_action(arguments: dict, event: dict) -> dict:
|
|
886
909
|
"""``scheduleItem`` ``{"operation": "schedule" | "schedule_list", "arguments": {...}}``: the one operation table of scheduled publishing (story_schedule.OPERATIONS)."""
|
|
887
|
-
client
|
|
910
|
+
client = authoring_client()
|
|
888
911
|
try:
|
|
889
912
|
service = schedule_service(client)
|
|
890
913
|
except ScheduleError as error:
|
|
@@ -911,7 +934,7 @@ def publish_scheduled_action(client, task: dict) -> dict:
|
|
|
911
934
|
def move_story_stage_action(arguments: dict, actor: str) -> dict:
|
|
912
935
|
from papyrus_content.story_reporting import move_story_stage
|
|
913
936
|
|
|
914
|
-
client
|
|
937
|
+
client = authoring_client()
|
|
915
938
|
try:
|
|
916
939
|
result = move_story_stage(client, arguments["lineageId"], arguments["stage"], actor=actor, reason=arguments.get("reason"))
|
|
917
940
|
except ValueError as error:
|
|
@@ -932,7 +955,7 @@ def suggest_reference_links_action(arguments: dict) -> dict:
|
|
|
932
955
|
index_arn = (os.environ.get("PAPYRUS_S3_VECTOR_INDEX_ARN") or "").strip()
|
|
933
956
|
if not index_arn:
|
|
934
957
|
return {"ok": False, "errors": [{"code": "knowledge-index-not-configured", "message": "Suggestions need the knowledge index.", "line": None}]}
|
|
935
|
-
client
|
|
958
|
+
client = authoring_client()
|
|
936
959
|
provider = S3VectorsProvider(vector_index_arn=index_arn, region_name=os.environ.get("AWS_REGION") or os.environ.get("AWS_DEFAULT_REGION"))
|
|
937
960
|
try:
|
|
938
961
|
return {"ok": True, **suggest_for(client, provider, reference_id)}
|
|
@@ -956,7 +979,7 @@ def add_story_agent_note_action(arguments: dict, person: str | None) -> dict:
|
|
|
956
979
|
|
|
957
980
|
if not person:
|
|
958
981
|
return {"ok": False, "errors": [{"code": "not-signed-in", "message": "Sign in as an editor to add an agent note.", "line": None}]}
|
|
959
|
-
client
|
|
982
|
+
client = authoring_client()
|
|
960
983
|
try:
|
|
961
984
|
version = arguments.get("versionNumber")
|
|
962
985
|
result = save_agent_note(
|
|
@@ -974,7 +997,7 @@ def create_story_from_reference_action(arguments: dict, actor: str) -> dict:
|
|
|
974
997
|
from papyrus_content.ideas.signal_queue import ReferenceSummaries
|
|
975
998
|
from papyrus_content.story_from_reference import create_story_from_reference
|
|
976
999
|
|
|
977
|
-
client
|
|
1000
|
+
client = authoring_client()
|
|
978
1001
|
summaries = ReferenceSummaries(client)
|
|
979
1002
|
try:
|
|
980
1003
|
result = create_story_from_reference(
|
|
@@ -1008,16 +1031,25 @@ def handler(event, context=None):
|
|
|
1008
1031
|
|
|
1009
1032
|
|
|
1010
1033
|
def _handle(event, context=None):
|
|
1011
|
-
if PROJECTION_TASK_KEY in event:
|
|
1012
|
-
|
|
1034
|
+
if PROJECTION_TASK_KEY in event: # a task the platform invoked: on a shared stack it names its tenant, like any IAM-signed call
|
|
1035
|
+
task = event[PROJECTION_TASK_KEY]
|
|
1036
|
+
with acting_for(build_invocation_tenant_context(task.get("tenantId"))):
|
|
1037
|
+
return run_projection_task(task, context)
|
|
1013
1038
|
if "refreshSitePages" in event: # a direct invocation by an operator's profile: the operator lane needs no CloudFront rights of its own
|
|
1014
|
-
|
|
1039
|
+
request = event["refreshSitePages"]
|
|
1040
|
+
with acting_for(build_invocation_tenant_context(request.get("tenantId"))):
|
|
1041
|
+
return refresh_site_pages_action({key: value for key, value in request.items() if key != "tenantId"}, str(event.get("who") or "operator"))
|
|
1042
|
+
with acting_for(build_event_tenant_context(event)): # one context per call, from the event's identity; a shared stack refuses before any read
|
|
1043
|
+
return _handle_field(event)
|
|
1044
|
+
|
|
1045
|
+
|
|
1046
|
+
def _handle_field(event):
|
|
1015
1047
|
field = event["fieldName"]
|
|
1016
|
-
arguments = parse_input(event["arguments"]["input"])
|
|
1048
|
+
arguments = {key: value for key, value in parse_input(event["arguments"]["input"]).items() if key != "tenantId"} # the tenant is never taken from the body (an IAM caller's is in the context)
|
|
1017
1049
|
actor = actor_from_event(event)
|
|
1018
1050
|
try:
|
|
1019
1051
|
if field == "intakePendingReferences":
|
|
1020
|
-
client
|
|
1052
|
+
client = authoring_client()
|
|
1021
1053
|
try:
|
|
1022
1054
|
created = intake_references(client, arguments, event.get("identity") or {})
|
|
1023
1055
|
from papyrus_content.reference_prediction_queue import queue_after_intake
|
|
@@ -1025,7 +1057,7 @@ def _handle(event, context=None):
|
|
|
1025
1057
|
except IntakeError as error:
|
|
1026
1058
|
return {"ok": False, "errors": [{"code": "intake-rejected", "message": str(error)}]}
|
|
1027
1059
|
if field == "intakeEmailSubmissionReferences":
|
|
1028
|
-
client
|
|
1060
|
+
client = authoring_client()
|
|
1029
1061
|
try:
|
|
1030
1062
|
from papyrus_content.monitoring_view import default_email_store_factory
|
|
1031
1063
|
receipt_store = default_email_store_factory(os.environ)()
|
|
@@ -1036,7 +1068,7 @@ def _handle(event, context=None):
|
|
|
1036
1068
|
if field == "correctReferenceCapture":
|
|
1037
1069
|
from papyrus_content.reference_curation_store import CurationError, correct_reference_capture
|
|
1038
1070
|
|
|
1039
|
-
client
|
|
1071
|
+
client = authoring_client()
|
|
1040
1072
|
try:
|
|
1041
1073
|
return correct_reference_capture(client, arguments, event.get("identity") or {})
|
|
1042
1074
|
except CurationError as error:
|
|
@@ -16,6 +16,10 @@ let siteFilesForNextContentActionsBundle;
|
|
|
16
16
|
export function setSiteFilesForContentActionsBundle(siteFiles) {
|
|
17
17
|
siteFilesForNextContentActionsBundle = siteFiles;
|
|
18
18
|
}
|
|
19
|
+
/** The site files the next content-actions bundle will hold (undefined: the bundle takes none). Read by the synth harness. */
|
|
20
|
+
export function siteFilesForContentActionsBundle() {
|
|
21
|
+
return siteFilesForNextContentActionsBundle;
|
|
22
|
+
}
|
|
19
23
|
export const contentActions = defineFunction((scope) => {
|
|
20
24
|
return new Function(scope, "papyrus-content-actions", {
|
|
21
25
|
runtime: Runtime.PYTHON_3_12,
|
|
@@ -26,6 +26,11 @@ export function setSiteFilesForContentActionsBundle(siteFiles: SiteBundleFile[]
|
|
|
26
26
|
siteFilesForNextContentActionsBundle = siteFiles;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
/** The site files the next content-actions bundle will hold (undefined: the bundle takes none). Read by the synth harness. */
|
|
30
|
+
export function siteFilesForContentActionsBundle(): SiteBundleFile[] | undefined {
|
|
31
|
+
return siteFilesForNextContentActionsBundle;
|
|
32
|
+
}
|
|
33
|
+
|
|
29
34
|
export const contentActions = defineFunction(
|
|
30
35
|
(scope: Construct) => {
|
|
31
36
|
return new Function(scope, "papyrus-content-actions", {
|
|
@@ -5,6 +5,7 @@ from __future__ import annotations
|
|
|
5
5
|
from typing import Any
|
|
6
6
|
|
|
7
7
|
from papyrus_content.editorial_checks import GraphQLEditorialStore, Services, event_field_name, handle, load_provider_keys
|
|
8
|
+
from papyrus_content.tenant_context import acting_for, build_event_tenant_context
|
|
8
9
|
from papyrus_cost_usage import SiteUsage
|
|
9
10
|
|
|
10
11
|
# Amplify passes secrets to Python functions as placeholders; resolve them once per cold start.
|
|
@@ -15,7 +16,10 @@ USAGE = SiteUsage.from_environment()
|
|
|
15
16
|
|
|
16
17
|
def handler(event: dict[str, Any], _context: Any = None) -> dict[str, Any]:
|
|
17
18
|
try:
|
|
18
|
-
|
|
19
|
+
context = build_event_tenant_context(event) # one context per call; a shared stack refuses before any read
|
|
20
|
+
with acting_for(context):
|
|
21
|
+
store = GraphQLEditorialStore(tenant_id=context.tenant_id)
|
|
22
|
+
return handle(event_field_name(event), event.get("arguments") or {}, Services(store=store, usage=USAGE))
|
|
19
23
|
finally:
|
|
20
24
|
# A frozen Lambda loses what is only in memory: send before the invocation returns. Never raises.
|
|
21
25
|
USAGE.flush()
|
|
@@ -28,6 +28,7 @@ export const editorialChecksSchemaDefinitions = {
|
|
|
28
28
|
source: a.string().required(),
|
|
29
29
|
})
|
|
30
30
|
.disableOperations(["subscriptions"])
|
|
31
|
+
.secondaryIndexes((index) => [index("tenantId").sortKeys(["id"]).queryField("listEditorialPoliciesByTenant")])
|
|
31
32
|
.authorization((allow) => [allow.group("editor").to(["read"]), allow.group("admin")]),
|
|
32
33
|
EditorialCheckSettings: a
|
|
33
34
|
.model({
|
|
@@ -36,6 +37,7 @@ export const editorialChecksSchemaDefinitions = {
|
|
|
36
37
|
settings: a.json().required(),
|
|
37
38
|
})
|
|
38
39
|
.disableOperations(["subscriptions"])
|
|
40
|
+
.secondaryIndexes((index) => [index("tenantId").sortKeys(["id"]).queryField("listEditorialCheckSettingsByTenant")])
|
|
39
41
|
.authorization((allow) => [allow.group("editor").to(["read"]), allow.group("admin")]),
|
|
40
42
|
EditorialFeedback: a
|
|
41
43
|
.model({
|
|
@@ -52,7 +54,10 @@ export const editorialChecksSchemaDefinitions = {
|
|
|
52
54
|
text: a.string(),
|
|
53
55
|
})
|
|
54
56
|
.disableOperations(["subscriptions"])
|
|
55
|
-
.secondaryIndexes((index) => [
|
|
57
|
+
.secondaryIndexes((index) => [
|
|
58
|
+
index("itemId").queryField("listEditorialFeedbackByItem"),
|
|
59
|
+
index("tenantId").sortKeys(["id"]).queryField("listEditorialFeedbackByTenant"),
|
|
60
|
+
])
|
|
56
61
|
.authorization((allow) => [allow.group("editor").to(["create", "read"]), allow.group("admin")]),
|
|
57
62
|
EditorialCheckRun: a
|
|
58
63
|
.model({
|
|
@@ -71,7 +76,10 @@ export const editorialChecksSchemaDefinitions = {
|
|
|
71
76
|
checkedAt: a.datetime().required(),
|
|
72
77
|
})
|
|
73
78
|
.disableOperations(["subscriptions"])
|
|
74
|
-
.secondaryIndexes((index) => [
|
|
79
|
+
.secondaryIndexes((index) => [
|
|
80
|
+
index("lineageId").sortKeys(["versionNumber"]).queryField("listEditorialCheckRunsByLineage"),
|
|
81
|
+
index("tenantId").sortKeys(["id"]).queryField("listEditorialCheckRunsByTenant"),
|
|
82
|
+
])
|
|
75
83
|
.authorization((allow) => [allow.group("editor").to(["read"]), allow.group("admin")]),
|
|
76
84
|
listEditorialStarterPacks: a
|
|
77
85
|
.query()
|