@anthusai/papyrus 1.13.0 → 1.15.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.
- package/amplify/data/resource.js +64 -0
- package/amplify/data/resource.ts +70 -0
- package/amplify/data/schema.js +64 -0
- package/amplify/data/schema.ts +70 -0
- package/amplify/functions/category-action/handler.ts +91 -9
- package/amplify/functions/shared/curation-delegation-flow.ts +147 -0
- package/amplify/functions/shared/curation-delegation.ts +50 -2
- package/amplify/functions/shared/reference-curation-metadata.ts +31 -0
- package/app/api/auth/prospectus/accounts/route.ts +9 -0
- package/components/administration-delegations-panel.tsx +52 -100
- package/components/curation-delegation-client.ts +46 -23
- package/components/news-desk-taxonomy-client.ts +12 -0
- package/components/newsroom-board-view.tsx +3 -5
- package/components/newsroom-newsprint-board.css +5 -54
- package/components/newsroom-organizer.css +21 -0
- package/components/newsroom-references-view.tsx +47 -5
- package/components/prospectus-account-chooser.tsx +34 -1
- package/components/reference-section-suggestion.tsx +104 -0
- package/components/topic-steering-workspace.tsx +39 -1
- package/lib/curation-delegation-helpers.ts +35 -25
- package/lib/local-preview-section-fixtures.ts +72 -0
- package/lib/prospectus-account-client.ts +26 -0
- package/lib/prospectus-sign-in-routes.ts +45 -0
- package/lib/prospectus-site-identity.ts +13 -1
- package/lib/site-section-suggestions.ts +120 -0
- package/package.json +6 -3
- package/routes.manifest.json +12 -1
- package/components/board-card-excerpts.tsx +0 -61
package/amplify/data/resource.js
CHANGED
|
@@ -219,6 +219,25 @@ const schema = a.schema({
|
|
|
219
219
|
grantorLabel: a.string(),
|
|
220
220
|
expiresAt: a.datetime().required(),
|
|
221
221
|
revokedAt: a.datetime(),
|
|
222
|
+
state: a.string(),
|
|
223
|
+
userCode: a.string(),
|
|
224
|
+
requestedHours: a.integer(),
|
|
225
|
+
pendingExpiresAt: a.datetime(),
|
|
226
|
+
approvedAt: a.datetime(),
|
|
227
|
+
deniedAt: a.datetime(),
|
|
228
|
+
}),
|
|
229
|
+
CurationDelegationRequestResult: a.customType({
|
|
230
|
+
ok: a.boolean().required(),
|
|
231
|
+
delegationId: a.id().required(),
|
|
232
|
+
userCode: a.string().required(),
|
|
233
|
+
pendingExpiresAt: a.datetime().required(),
|
|
234
|
+
requestedHours: a.integer().required(),
|
|
235
|
+
}),
|
|
236
|
+
CurationDelegationStatusResult: a.customType({
|
|
237
|
+
delegationId: a.id().required(),
|
|
238
|
+
state: a.string().required(),
|
|
239
|
+
expiresAt: a.datetime().required(),
|
|
240
|
+
grantorLabel: a.string(),
|
|
222
241
|
}),
|
|
223
242
|
ReferenceCurationActionResult: a.customType({
|
|
224
243
|
ok: a.boolean().required(),
|
|
@@ -298,6 +317,7 @@ const schema = a.schema({
|
|
|
298
317
|
reasonCode: a.string(),
|
|
299
318
|
decisionRelationId: a.id(),
|
|
300
319
|
shareable: a.boolean(),
|
|
320
|
+
sectionId: a.id(),
|
|
301
321
|
})
|
|
302
322
|
.returns(a.ref("ReferenceCurationActionResult"))
|
|
303
323
|
.authorization((allow) => [
|
|
@@ -332,6 +352,49 @@ const schema = a.schema({
|
|
|
332
352
|
allow.groups(categoryWriteGroups),
|
|
333
353
|
])
|
|
334
354
|
.handler(a.handler.function(categoryAction)),
|
|
355
|
+
requestCurationDelegation: a
|
|
356
|
+
.mutation()
|
|
357
|
+
.arguments({
|
|
358
|
+
delegationId: a.id().required(),
|
|
359
|
+
tokenHash: a.string().required(),
|
|
360
|
+
agentLabel: a.string().required(),
|
|
361
|
+
hours: a.integer(),
|
|
362
|
+
})
|
|
363
|
+
.returns(a.ref("CurationDelegationRequestResult"))
|
|
364
|
+
.authorization((allow) => [
|
|
365
|
+
allow.authenticated("identityPool"),
|
|
366
|
+
])
|
|
367
|
+
.handler(a.handler.function(categoryAction)),
|
|
368
|
+
approveCurationDelegation: a
|
|
369
|
+
.mutation()
|
|
370
|
+
.arguments({
|
|
371
|
+
userCode: a.string().required(),
|
|
372
|
+
})
|
|
373
|
+
.returns(a.ref("CurationDelegationResult"))
|
|
374
|
+
.authorization((allow) => [
|
|
375
|
+
allow.groups(categoryWriteGroups),
|
|
376
|
+
])
|
|
377
|
+
.handler(a.handler.function(categoryAction)),
|
|
378
|
+
denyCurationDelegation: a
|
|
379
|
+
.mutation()
|
|
380
|
+
.arguments({
|
|
381
|
+
userCode: a.string().required(),
|
|
382
|
+
})
|
|
383
|
+
.returns(a.ref("CurationDelegationResult"))
|
|
384
|
+
.authorization((allow) => [
|
|
385
|
+
allow.groups(categoryWriteGroups),
|
|
386
|
+
])
|
|
387
|
+
.handler(a.handler.function(categoryAction)),
|
|
388
|
+
getCurationDelegationStatus: a
|
|
389
|
+
.query()
|
|
390
|
+
.arguments({
|
|
391
|
+
delegationId: a.id().required(),
|
|
392
|
+
})
|
|
393
|
+
.returns(a.ref("CurationDelegationStatusResult"))
|
|
394
|
+
.authorization((allow) => [
|
|
395
|
+
allow.authenticated("identityPool"),
|
|
396
|
+
])
|
|
397
|
+
.handler(a.handler.function(categoryAction)),
|
|
335
398
|
recordDelegatedCuration: a
|
|
336
399
|
.mutation()
|
|
337
400
|
.arguments({
|
|
@@ -346,6 +409,7 @@ const schema = a.schema({
|
|
|
346
409
|
reasonCode: a.string(),
|
|
347
410
|
decisionRelationId: a.id(),
|
|
348
411
|
shareable: a.boolean(),
|
|
412
|
+
sectionId: a.id(),
|
|
349
413
|
})
|
|
350
414
|
.returns(a.ref("ReferenceCurationActionResult"))
|
|
351
415
|
.authorization((allow) => [
|
package/amplify/data/resource.ts
CHANGED
|
@@ -236,6 +236,27 @@ const schema = a.schema({
|
|
|
236
236
|
grantorLabel: a.string(),
|
|
237
237
|
expiresAt: a.datetime().required(),
|
|
238
238
|
revokedAt: a.datetime(),
|
|
239
|
+
state: a.string(),
|
|
240
|
+
userCode: a.string(),
|
|
241
|
+
requestedHours: a.integer(),
|
|
242
|
+
pendingExpiresAt: a.datetime(),
|
|
243
|
+
approvedAt: a.datetime(),
|
|
244
|
+
deniedAt: a.datetime(),
|
|
245
|
+
}),
|
|
246
|
+
|
|
247
|
+
CurationDelegationRequestResult: a.customType({
|
|
248
|
+
ok: a.boolean().required(),
|
|
249
|
+
delegationId: a.id().required(),
|
|
250
|
+
userCode: a.string().required(),
|
|
251
|
+
pendingExpiresAt: a.datetime().required(),
|
|
252
|
+
requestedHours: a.integer().required(),
|
|
253
|
+
}),
|
|
254
|
+
|
|
255
|
+
CurationDelegationStatusResult: a.customType({
|
|
256
|
+
delegationId: a.id().required(),
|
|
257
|
+
state: a.string().required(),
|
|
258
|
+
expiresAt: a.datetime().required(),
|
|
259
|
+
grantorLabel: a.string(),
|
|
239
260
|
}),
|
|
240
261
|
|
|
241
262
|
ReferenceCurationActionResult: a.customType({
|
|
@@ -324,6 +345,7 @@ const schema = a.schema({
|
|
|
324
345
|
reasonCode: a.string(),
|
|
325
346
|
decisionRelationId: a.id(),
|
|
326
347
|
shareable: a.boolean(),
|
|
348
|
+
sectionId: a.id(),
|
|
327
349
|
})
|
|
328
350
|
.returns(a.ref("ReferenceCurationActionResult"))
|
|
329
351
|
.authorization((allow) => [
|
|
@@ -362,6 +384,53 @@ const schema = a.schema({
|
|
|
362
384
|
])
|
|
363
385
|
.handler(a.handler.function(categoryAction)),
|
|
364
386
|
|
|
387
|
+
requestCurationDelegation: a
|
|
388
|
+
.mutation()
|
|
389
|
+
.arguments({
|
|
390
|
+
delegationId: a.id().required(),
|
|
391
|
+
tokenHash: a.string().required(),
|
|
392
|
+
agentLabel: a.string().required(),
|
|
393
|
+
hours: a.integer(),
|
|
394
|
+
})
|
|
395
|
+
.returns(a.ref("CurationDelegationRequestResult"))
|
|
396
|
+
.authorization((allow) => [
|
|
397
|
+
allow.authenticated("identityPool"),
|
|
398
|
+
])
|
|
399
|
+
.handler(a.handler.function(categoryAction)),
|
|
400
|
+
|
|
401
|
+
approveCurationDelegation: a
|
|
402
|
+
.mutation()
|
|
403
|
+
.arguments({
|
|
404
|
+
userCode: a.string().required(),
|
|
405
|
+
})
|
|
406
|
+
.returns(a.ref("CurationDelegationResult"))
|
|
407
|
+
.authorization((allow) => [
|
|
408
|
+
allow.groups(categoryWriteGroups),
|
|
409
|
+
])
|
|
410
|
+
.handler(a.handler.function(categoryAction)),
|
|
411
|
+
|
|
412
|
+
denyCurationDelegation: a
|
|
413
|
+
.mutation()
|
|
414
|
+
.arguments({
|
|
415
|
+
userCode: a.string().required(),
|
|
416
|
+
})
|
|
417
|
+
.returns(a.ref("CurationDelegationResult"))
|
|
418
|
+
.authorization((allow) => [
|
|
419
|
+
allow.groups(categoryWriteGroups),
|
|
420
|
+
])
|
|
421
|
+
.handler(a.handler.function(categoryAction)),
|
|
422
|
+
|
|
423
|
+
getCurationDelegationStatus: a
|
|
424
|
+
.query()
|
|
425
|
+
.arguments({
|
|
426
|
+
delegationId: a.id().required(),
|
|
427
|
+
})
|
|
428
|
+
.returns(a.ref("CurationDelegationStatusResult"))
|
|
429
|
+
.authorization((allow) => [
|
|
430
|
+
allow.authenticated("identityPool"),
|
|
431
|
+
])
|
|
432
|
+
.handler(a.handler.function(categoryAction)),
|
|
433
|
+
|
|
365
434
|
recordDelegatedCuration: a
|
|
366
435
|
.mutation()
|
|
367
436
|
.arguments({
|
|
@@ -376,6 +445,7 @@ const schema = a.schema({
|
|
|
376
445
|
reasonCode: a.string(),
|
|
377
446
|
decisionRelationId: a.id(),
|
|
378
447
|
shareable: a.boolean(),
|
|
448
|
+
sectionId: a.id(),
|
|
379
449
|
})
|
|
380
450
|
.returns(a.ref("ReferenceCurationActionResult"))
|
|
381
451
|
.authorization((allow) => [
|
package/amplify/data/schema.js
CHANGED
|
@@ -211,6 +211,25 @@ const baseDefinitions = {
|
|
|
211
211
|
grantorLabel: a.string(),
|
|
212
212
|
expiresAt: a.datetime().required(),
|
|
213
213
|
revokedAt: a.datetime(),
|
|
214
|
+
state: a.string(),
|
|
215
|
+
userCode: a.string(),
|
|
216
|
+
requestedHours: a.integer(),
|
|
217
|
+
pendingExpiresAt: a.datetime(),
|
|
218
|
+
approvedAt: a.datetime(),
|
|
219
|
+
deniedAt: a.datetime(),
|
|
220
|
+
}),
|
|
221
|
+
CurationDelegationRequestResult: a.customType({
|
|
222
|
+
ok: a.boolean().required(),
|
|
223
|
+
delegationId: a.id().required(),
|
|
224
|
+
userCode: a.string().required(),
|
|
225
|
+
pendingExpiresAt: a.datetime().required(),
|
|
226
|
+
requestedHours: a.integer().required(),
|
|
227
|
+
}),
|
|
228
|
+
CurationDelegationStatusResult: a.customType({
|
|
229
|
+
delegationId: a.id().required(),
|
|
230
|
+
state: a.string().required(),
|
|
231
|
+
expiresAt: a.datetime().required(),
|
|
232
|
+
grantorLabel: a.string(),
|
|
214
233
|
}),
|
|
215
234
|
ReferenceCurationActionResult: a.customType({
|
|
216
235
|
ok: a.boolean().required(),
|
|
@@ -256,6 +275,7 @@ const baseDefinitions = {
|
|
|
256
275
|
reasonCode: a.string(),
|
|
257
276
|
decisionRelationId: a.id(),
|
|
258
277
|
shareable: a.boolean(),
|
|
278
|
+
sectionId: a.id(),
|
|
259
279
|
})
|
|
260
280
|
.returns(a.ref("ReferenceCurationActionResult"))
|
|
261
281
|
.authorization((allow) => [
|
|
@@ -290,6 +310,49 @@ const baseDefinitions = {
|
|
|
290
310
|
allow.groups(categoryWriteGroups),
|
|
291
311
|
])
|
|
292
312
|
.handler(a.handler.function(categoryAction)),
|
|
313
|
+
requestCurationDelegation: a
|
|
314
|
+
.mutation()
|
|
315
|
+
.arguments({
|
|
316
|
+
delegationId: a.id().required(),
|
|
317
|
+
tokenHash: a.string().required(),
|
|
318
|
+
agentLabel: a.string().required(),
|
|
319
|
+
hours: a.integer(),
|
|
320
|
+
})
|
|
321
|
+
.returns(a.ref("CurationDelegationRequestResult"))
|
|
322
|
+
.authorization((allow) => [
|
|
323
|
+
allow.authenticated("identityPool"),
|
|
324
|
+
])
|
|
325
|
+
.handler(a.handler.function(categoryAction)),
|
|
326
|
+
approveCurationDelegation: a
|
|
327
|
+
.mutation()
|
|
328
|
+
.arguments({
|
|
329
|
+
userCode: a.string().required(),
|
|
330
|
+
})
|
|
331
|
+
.returns(a.ref("CurationDelegationResult"))
|
|
332
|
+
.authorization((allow) => [
|
|
333
|
+
allow.groups(categoryWriteGroups),
|
|
334
|
+
])
|
|
335
|
+
.handler(a.handler.function(categoryAction)),
|
|
336
|
+
denyCurationDelegation: a
|
|
337
|
+
.mutation()
|
|
338
|
+
.arguments({
|
|
339
|
+
userCode: a.string().required(),
|
|
340
|
+
})
|
|
341
|
+
.returns(a.ref("CurationDelegationResult"))
|
|
342
|
+
.authorization((allow) => [
|
|
343
|
+
allow.groups(categoryWriteGroups),
|
|
344
|
+
])
|
|
345
|
+
.handler(a.handler.function(categoryAction)),
|
|
346
|
+
getCurationDelegationStatus: a
|
|
347
|
+
.query()
|
|
348
|
+
.arguments({
|
|
349
|
+
delegationId: a.id().required(),
|
|
350
|
+
})
|
|
351
|
+
.returns(a.ref("CurationDelegationStatusResult"))
|
|
352
|
+
.authorization((allow) => [
|
|
353
|
+
allow.authenticated("identityPool"),
|
|
354
|
+
])
|
|
355
|
+
.handler(a.handler.function(categoryAction)),
|
|
293
356
|
recordDelegatedCuration: a
|
|
294
357
|
.mutation()
|
|
295
358
|
.arguments({
|
|
@@ -304,6 +367,7 @@ const baseDefinitions = {
|
|
|
304
367
|
reasonCode: a.string(),
|
|
305
368
|
decisionRelationId: a.id(),
|
|
306
369
|
shareable: a.boolean(),
|
|
370
|
+
sectionId: a.id(),
|
|
307
371
|
})
|
|
308
372
|
.returns(a.ref("ReferenceCurationActionResult"))
|
|
309
373
|
.authorization((allow) => [
|
package/amplify/data/schema.ts
CHANGED
|
@@ -230,6 +230,27 @@ const baseDefinitions = {
|
|
|
230
230
|
grantorLabel: a.string(),
|
|
231
231
|
expiresAt: a.datetime().required(),
|
|
232
232
|
revokedAt: a.datetime(),
|
|
233
|
+
state: a.string(),
|
|
234
|
+
userCode: a.string(),
|
|
235
|
+
requestedHours: a.integer(),
|
|
236
|
+
pendingExpiresAt: a.datetime(),
|
|
237
|
+
approvedAt: a.datetime(),
|
|
238
|
+
deniedAt: a.datetime(),
|
|
239
|
+
}),
|
|
240
|
+
|
|
241
|
+
CurationDelegationRequestResult: a.customType({
|
|
242
|
+
ok: a.boolean().required(),
|
|
243
|
+
delegationId: a.id().required(),
|
|
244
|
+
userCode: a.string().required(),
|
|
245
|
+
pendingExpiresAt: a.datetime().required(),
|
|
246
|
+
requestedHours: a.integer().required(),
|
|
247
|
+
}),
|
|
248
|
+
|
|
249
|
+
CurationDelegationStatusResult: a.customType({
|
|
250
|
+
delegationId: a.id().required(),
|
|
251
|
+
state: a.string().required(),
|
|
252
|
+
expiresAt: a.datetime().required(),
|
|
253
|
+
grantorLabel: a.string(),
|
|
233
254
|
}),
|
|
234
255
|
|
|
235
256
|
ReferenceCurationActionResult: a.customType({
|
|
@@ -280,6 +301,7 @@ const baseDefinitions = {
|
|
|
280
301
|
reasonCode: a.string(),
|
|
281
302
|
decisionRelationId: a.id(),
|
|
282
303
|
shareable: a.boolean(),
|
|
304
|
+
sectionId: a.id(),
|
|
283
305
|
})
|
|
284
306
|
.returns(a.ref("ReferenceCurationActionResult"))
|
|
285
307
|
.authorization((allow) => [
|
|
@@ -318,6 +340,53 @@ const baseDefinitions = {
|
|
|
318
340
|
])
|
|
319
341
|
.handler(a.handler.function(categoryAction)),
|
|
320
342
|
|
|
343
|
+
requestCurationDelegation: a
|
|
344
|
+
.mutation()
|
|
345
|
+
.arguments({
|
|
346
|
+
delegationId: a.id().required(),
|
|
347
|
+
tokenHash: a.string().required(),
|
|
348
|
+
agentLabel: a.string().required(),
|
|
349
|
+
hours: a.integer(),
|
|
350
|
+
})
|
|
351
|
+
.returns(a.ref("CurationDelegationRequestResult"))
|
|
352
|
+
.authorization((allow) => [
|
|
353
|
+
allow.authenticated("identityPool"),
|
|
354
|
+
])
|
|
355
|
+
.handler(a.handler.function(categoryAction)),
|
|
356
|
+
|
|
357
|
+
approveCurationDelegation: a
|
|
358
|
+
.mutation()
|
|
359
|
+
.arguments({
|
|
360
|
+
userCode: a.string().required(),
|
|
361
|
+
})
|
|
362
|
+
.returns(a.ref("CurationDelegationResult"))
|
|
363
|
+
.authorization((allow) => [
|
|
364
|
+
allow.groups(categoryWriteGroups),
|
|
365
|
+
])
|
|
366
|
+
.handler(a.handler.function(categoryAction)),
|
|
367
|
+
|
|
368
|
+
denyCurationDelegation: a
|
|
369
|
+
.mutation()
|
|
370
|
+
.arguments({
|
|
371
|
+
userCode: a.string().required(),
|
|
372
|
+
})
|
|
373
|
+
.returns(a.ref("CurationDelegationResult"))
|
|
374
|
+
.authorization((allow) => [
|
|
375
|
+
allow.groups(categoryWriteGroups),
|
|
376
|
+
])
|
|
377
|
+
.handler(a.handler.function(categoryAction)),
|
|
378
|
+
|
|
379
|
+
getCurationDelegationStatus: a
|
|
380
|
+
.query()
|
|
381
|
+
.arguments({
|
|
382
|
+
delegationId: a.id().required(),
|
|
383
|
+
})
|
|
384
|
+
.returns(a.ref("CurationDelegationStatusResult"))
|
|
385
|
+
.authorization((allow) => [
|
|
386
|
+
allow.authenticated("identityPool"),
|
|
387
|
+
])
|
|
388
|
+
.handler(a.handler.function(categoryAction)),
|
|
389
|
+
|
|
321
390
|
recordDelegatedCuration: a
|
|
322
391
|
.mutation()
|
|
323
392
|
.arguments({
|
|
@@ -332,6 +401,7 @@ const baseDefinitions = {
|
|
|
332
401
|
reasonCode: a.string(),
|
|
333
402
|
decisionRelationId: a.id(),
|
|
334
403
|
shareable: a.boolean(),
|
|
404
|
+
sectionId: a.id(),
|
|
335
405
|
})
|
|
336
406
|
.returns(a.ref("ReferenceCurationActionResult"))
|
|
337
407
|
.authorization((allow) => [
|
|
@@ -4,7 +4,7 @@ import { Amplify } from "aws-amplify";
|
|
|
4
4
|
import { generateClient } from "aws-amplify/data";
|
|
5
5
|
import type { Schema } from "../../data/resource";
|
|
6
6
|
import { putJsonModelPayload, putTextModelPayload, readJsonModelPayload } from "../shared/model-payloads";
|
|
7
|
-
import { curationActorKind, referenceCurationMetadata } from "../shared/reference-curation-metadata";
|
|
7
|
+
import { curationActorKind, referenceCurationMetadata, validatedCurationSectionId } from "../shared/reference-curation-metadata";
|
|
8
8
|
import {
|
|
9
9
|
CURATION_DELEGATION_OWNER_TYPE,
|
|
10
10
|
CURATION_DELEGATION_PAYLOAD_KIND,
|
|
@@ -12,14 +12,28 @@ import {
|
|
|
12
12
|
delegationRefusalMessage,
|
|
13
13
|
delegationVerdict,
|
|
14
14
|
newDelegationToken,
|
|
15
|
+
PENDING_REQUEST_GRANTOR_SUB,
|
|
15
16
|
type CurationDelegation,
|
|
16
17
|
} from "../shared/curation-delegation";
|
|
18
|
+
import {
|
|
19
|
+
approveDelegation,
|
|
20
|
+
delegationResult as flowDelegationResult,
|
|
21
|
+
delegationStatus,
|
|
22
|
+
denyDelegation,
|
|
23
|
+
livePendingRequests,
|
|
24
|
+
requestDelegation,
|
|
25
|
+
type DelegationStore,
|
|
26
|
+
} from "../shared/curation-delegation-flow";
|
|
17
27
|
|
|
18
28
|
type ReviewHandler = Schema["reviewSteeringProposal"]["functionHandler"];
|
|
19
29
|
type ReferenceCurationHandler = Schema["reviewReferenceCuration"]["functionHandler"];
|
|
20
30
|
type CreateCurationDelegationHandler = Schema["createCurationDelegation"]["functionHandler"];
|
|
21
31
|
type RevokeCurationDelegationHandler = Schema["revokeCurationDelegation"]["functionHandler"];
|
|
22
32
|
type ListCurationDelegationsHandler = Schema["listCurationDelegations"]["functionHandler"];
|
|
33
|
+
type RequestCurationDelegationHandler = Schema["requestCurationDelegation"]["functionHandler"];
|
|
34
|
+
type ApproveCurationDelegationHandler = Schema["approveCurationDelegation"]["functionHandler"];
|
|
35
|
+
type DenyCurationDelegationHandler = Schema["denyCurationDelegation"]["functionHandler"];
|
|
36
|
+
type GetCurationDelegationStatusHandler = Schema["getCurationDelegationStatus"]["functionHandler"];
|
|
23
37
|
type RecordDelegatedCurationHandler = Schema["recordDelegatedCuration"]["functionHandler"];
|
|
24
38
|
type ReferenceQualityHandler = Schema["setReferenceQualityRating"]["functionHandler"];
|
|
25
39
|
type ReferenceNoteHandler = Schema["createReferenceNote"]["functionHandler"];
|
|
@@ -39,6 +53,10 @@ type CategoryActionEvent =
|
|
|
39
53
|
| Parameters<CreateCurationDelegationHandler>[0]
|
|
40
54
|
| Parameters<RevokeCurationDelegationHandler>[0]
|
|
41
55
|
| Parameters<ListCurationDelegationsHandler>[0]
|
|
56
|
+
| Parameters<RequestCurationDelegationHandler>[0]
|
|
57
|
+
| Parameters<ApproveCurationDelegationHandler>[0]
|
|
58
|
+
| Parameters<DenyCurationDelegationHandler>[0]
|
|
59
|
+
| Parameters<GetCurationDelegationStatusHandler>[0]
|
|
42
60
|
| Parameters<RecordDelegatedCurationHandler>[0]
|
|
43
61
|
| Parameters<ReferenceQualityHandler>[0]
|
|
44
62
|
| Parameters<ReferenceNoteHandler>[0]
|
|
@@ -108,6 +126,10 @@ export const handler = async (event: CategoryActionEvent) => {
|
|
|
108
126
|
if (fieldName === "createCurationDelegation") return createCurationDelegation(event as Parameters<CreateCurationDelegationHandler>[0]);
|
|
109
127
|
if (fieldName === "revokeCurationDelegation") return revokeCurationDelegation(event as Parameters<RevokeCurationDelegationHandler>[0]);
|
|
110
128
|
if (fieldName === "listCurationDelegations") return listCurationDelegations(event as Parameters<ListCurationDelegationsHandler>[0]);
|
|
129
|
+
if (fieldName === "requestCurationDelegation") return requestCurationDelegationAction(event as Parameters<RequestCurationDelegationHandler>[0]);
|
|
130
|
+
if (fieldName === "approveCurationDelegation") return approveCurationDelegationAction(event as Parameters<ApproveCurationDelegationHandler>[0]);
|
|
131
|
+
if (fieldName === "denyCurationDelegation") return denyCurationDelegationAction(event as Parameters<DenyCurationDelegationHandler>[0]);
|
|
132
|
+
if (fieldName === "getCurationDelegationStatus") return getCurationDelegationStatusAction(event as Parameters<GetCurationDelegationStatusHandler>[0]);
|
|
111
133
|
if (fieldName === "recordDelegatedCuration") return recordDelegatedCuration(event as Parameters<RecordDelegatedCurationHandler>[0]);
|
|
112
134
|
if (fieldName === "setReferenceQualityRating") return setReferenceQualityRating(event as Parameters<ReferenceQualityHandler>[0]);
|
|
113
135
|
if (fieldName === "createReferenceNote") return createReferenceNote(event as Parameters<ReferenceNoteHandler>[0]);
|
|
@@ -193,6 +215,11 @@ async function reviewReferenceCuration(
|
|
|
193
215
|
const nextStatus = referenceCurationStatusForAction(action);
|
|
194
216
|
const reasonCode = normalizeReferenceRejectionReasonCode(event.arguments.reasonCode, action === "reject");
|
|
195
217
|
const reference = await getRequiredRecord(client.models.Reference, referenceId, "Reference");
|
|
218
|
+
const requestedSectionId = normalizeOptionalString(event.arguments.sectionId);
|
|
219
|
+
const sectionRecord = requestedSectionId
|
|
220
|
+
? (await client.models.NewsroomSection.get({ id: requestedSectionId })).data ?? null
|
|
221
|
+
: null;
|
|
222
|
+
const sectionId = validatedCurationSectionId(requestedSectionId, action, sectionRecord);
|
|
196
223
|
const now = new Date().toISOString();
|
|
197
224
|
const actorSub = normalizeOptionalString(event.arguments.actorSub) ?? getIdentitySub(event);
|
|
198
225
|
const actorLabel = normalizeOptionalString(event.arguments.actorLabel) ?? getIdentityLabel(event);
|
|
@@ -259,6 +286,7 @@ async function reviewReferenceCuration(
|
|
|
259
286
|
decisionRelationId: normalizeOptionalString(event.arguments.decisionRelationId),
|
|
260
287
|
shareable: event.arguments.shareable ?? null,
|
|
261
288
|
actorKind: delegation ? "human" : curationActorKind(event.identity),
|
|
289
|
+
sectionId,
|
|
262
290
|
delegation,
|
|
263
291
|
}),
|
|
264
292
|
{ filename: "metadata.json", now },
|
|
@@ -370,17 +398,68 @@ async function writeCurationDelegation(client: DataClient, delegation: CurationD
|
|
|
370
398
|
}
|
|
371
399
|
|
|
372
400
|
function delegationResult(delegation: CurationDelegation, token: string | null) {
|
|
401
|
+
return { ...flowDelegationResult(delegation, new Date().toISOString()), token };
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
async function listPendingCurationDelegations(client: DataClient): Promise<CurationDelegation[]> {
|
|
405
|
+
const pending: CurationDelegation[] = [];
|
|
406
|
+
let nextToken: string | null | undefined;
|
|
407
|
+
do {
|
|
408
|
+
const page: any = await (client.models.KnowledgeRawPayload as any).listKnowledgeRawPayloadsByOwnerAndKind(
|
|
409
|
+
{ ownerId: PENDING_REQUEST_GRANTOR_SUB, payloadKind: { eq: CURATION_DELEGATION_PAYLOAD_KIND } },
|
|
410
|
+
{ nextToken },
|
|
411
|
+
);
|
|
412
|
+
assertNoDataErrors(page.errors, "list pending curation delegations");
|
|
413
|
+
for (const payload of page.data ?? []) {
|
|
414
|
+
const delegation = await readCurationDelegation(client, payload.id);
|
|
415
|
+
if (delegation) pending.push(delegation);
|
|
416
|
+
}
|
|
417
|
+
nextToken = page.nextToken;
|
|
418
|
+
} while (nextToken);
|
|
419
|
+
return pending;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
function curationDelegationStore(client: DataClient): DelegationStore {
|
|
373
423
|
return {
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
agentLabel: delegation.agentLabel,
|
|
378
|
-
grantorLabel: delegation.grantorLabel,
|
|
379
|
-
expiresAt: delegation.expiresAt,
|
|
380
|
-
revokedAt: delegation.revokedAt,
|
|
424
|
+
read: (delegationId) => readCurationDelegation(client, delegationId),
|
|
425
|
+
write: (delegation, now, created) => writeCurationDelegation(client, delegation, now, created),
|
|
426
|
+
listPending: () => listPendingCurationDelegations(client),
|
|
381
427
|
};
|
|
382
428
|
}
|
|
383
429
|
|
|
430
|
+
async function requestCurationDelegationAction(event: Parameters<RequestCurationDelegationHandler>[0]) {
|
|
431
|
+
const client = await getDataClient();
|
|
432
|
+
return requestDelegation(
|
|
433
|
+
curationDelegationStore(client),
|
|
434
|
+
{
|
|
435
|
+
delegationId: normalizeRequiredString(event.arguments.delegationId, "delegationId"),
|
|
436
|
+
tokenHash: normalizeRequiredString(event.arguments.tokenHash, "tokenHash"),
|
|
437
|
+
agentLabel: normalizeRequiredString(event.arguments.agentLabel, "agentLabel"),
|
|
438
|
+
hours: event.arguments.hours,
|
|
439
|
+
},
|
|
440
|
+
new Date().toISOString(),
|
|
441
|
+
);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
async function approveCurationDelegationAction(event: Parameters<ApproveCurationDelegationHandler>[0]) {
|
|
445
|
+
const person = requireSignedInPerson(event);
|
|
446
|
+
const client = await getDataClient();
|
|
447
|
+
const now = new Date().toISOString();
|
|
448
|
+
return { ...(await approveDelegation(curationDelegationStore(client), person, normalizeRequiredString(event.arguments.userCode, "userCode"), now)), token: null };
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
async function denyCurationDelegationAction(event: Parameters<DenyCurationDelegationHandler>[0]) {
|
|
452
|
+
const person = requireSignedInPerson(event);
|
|
453
|
+
const client = await getDataClient();
|
|
454
|
+
const now = new Date().toISOString();
|
|
455
|
+
return { ...(await denyDelegation(curationDelegationStore(client), person, normalizeRequiredString(event.arguments.userCode, "userCode"), now)), token: null };
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
async function getCurationDelegationStatusAction(event: Parameters<GetCurationDelegationStatusHandler>[0]) {
|
|
459
|
+
const client = await getDataClient();
|
|
460
|
+
return delegationStatus(curationDelegationStore(client), normalizeRequiredString(event.arguments.delegationId, "delegationId"), new Date().toISOString());
|
|
461
|
+
}
|
|
462
|
+
|
|
384
463
|
async function createCurationDelegation(event: Parameters<CreateCurationDelegationHandler>[0]) {
|
|
385
464
|
const person = requireSignedInPerson(event);
|
|
386
465
|
const client = await getDataClient();
|
|
@@ -406,7 +485,7 @@ async function revokeCurationDelegation(event: Parameters<RevokeCurationDelegati
|
|
|
406
485
|
const client = await getDataClient();
|
|
407
486
|
const delegation = await readCurationDelegation(client, normalizeRequiredString(event.arguments.delegationId, "delegationId"));
|
|
408
487
|
if (!delegation) throw new Error("That delegation was not found.");
|
|
409
|
-
if (delegation.grantorSub !== person.sub && !person.isAdmin) throw new Error("Only the person who granted a delegation can revoke it.");
|
|
488
|
+
if (delegation.grantorSub !== person.sub && delegation.grantorSub !== PENDING_REQUEST_GRANTOR_SUB && !person.isAdmin) throw new Error("Only the person who granted a delegation can revoke it.");
|
|
410
489
|
const now = new Date().toISOString();
|
|
411
490
|
const revoked = { ...delegation, revokedAt: delegation.revokedAt ?? now };
|
|
412
491
|
await writeCurationDelegation(client, revoked, now, false);
|
|
@@ -430,6 +509,8 @@ async function listCurationDelegations(event: Parameters<ListCurationDelegations
|
|
|
430
509
|
}
|
|
431
510
|
nextToken = page.nextToken;
|
|
432
511
|
} while (nextToken);
|
|
512
|
+
const now = new Date().toISOString();
|
|
513
|
+
delegations.push(...(await livePendingRequests(curationDelegationStore(client), now)));
|
|
433
514
|
return delegations
|
|
434
515
|
.sort((first, second) => second.createdAt.localeCompare(first.createdAt))
|
|
435
516
|
.map((delegation) => delegationResult(delegation, null));
|
|
@@ -463,6 +544,7 @@ async function recordDelegatedCuration(event: Parameters<RecordDelegatedCuration
|
|
|
463
544
|
reasonCode: event.arguments.reasonCode,
|
|
464
545
|
decisionRelationId: event.arguments.decisionRelationId,
|
|
465
546
|
shareable: event.arguments.shareable,
|
|
547
|
+
sectionId: event.arguments.sectionId,
|
|
466
548
|
actorSub: delegation.grantorSub,
|
|
467
549
|
actorLabel: delegation.grantorLabel,
|
|
468
550
|
},
|