@registrystack/client 0.39.0 → 0.40.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/README.md +30 -6
- package/breg/client.d.ts +100 -10
- package/breg/client.js +41 -34
- package/breg/index.d.ts +56 -2
- package/casework/client.d.ts +84 -30
- package/casework/client.js +22 -17
- package/casework/index.d.ts +7 -0
- package/discovery/client.d.ts +7 -7
- package/discovery/client.js +1 -1
- package/evidence/client.d.ts +1 -1
- package/evidence/index.d.ts +3 -6
- package/index.d.ts +2 -1
- package/index.js +2 -1
- package/messaging/client.d.ts +23 -4
- package/messaging/client.js +32 -21
- package/messaging/index.d.ts +1 -10
- package/native.js +2 -2
- package/package.json +9 -7
- package/scheduling/client.d.ts +226 -0
- package/scheduling/client.js +141 -0
- package/scheduling/index.d.ts +27 -0
- package/scheduling/index.js +3 -0
package/casework/client.d.ts
CHANGED
|
@@ -13,15 +13,23 @@ export interface CaseworkClientConfig {
|
|
|
13
13
|
maxResponseBytes?: SafeInteger | null
|
|
14
14
|
userAgent?: string | null
|
|
15
15
|
trustedRootCertificates?: string | null
|
|
16
|
+
/**
|
|
17
|
+
* How many times an idempotency-keyed mutation whose outcome is unknown is
|
|
18
|
+
* resent, identically and under the same key, before its error is
|
|
19
|
+
* returned: a whole number from 0 to 2, default 2; 0 sends it once. Reads,
|
|
20
|
+
* unkeyed operations, and review request create and cancel are never
|
|
21
|
+
* resent. Any other value is a `configuration` error.
|
|
22
|
+
*/
|
|
23
|
+
maxMutationRetries?: SafeInteger | null
|
|
16
24
|
}
|
|
17
25
|
|
|
18
|
-
export type InboxView = 'mine' | '
|
|
26
|
+
export type InboxView = 'mine' | 'my-teams' | 'team-holdings' | 'overdue' | 'completed-by-me'
|
|
19
27
|
export type OccurrenceKind = 'review' | 'application'
|
|
20
|
-
export type OccurrenceState = 'open' | 'claimed' | '
|
|
28
|
+
export type OccurrenceState = 'open' | 'claimed' | 'waiting-applicant' | 'waiting-application' | 'synchronizing' | 'completed' | 'superseded' | 'cancelled'
|
|
21
29
|
export type OperationName = string
|
|
22
30
|
export type AttemptState = 'pending' | 'uncertain' | 'completed' | 'refused'
|
|
23
|
-
export type PageStatus = 'complete' | '
|
|
24
|
-
export type HistoryKind = 'observed' | 'opened' | 'claimed' | 'assigned' | 'delegated' | '
|
|
31
|
+
export type PageStatus = 'complete' | 'budget-exhausted' | 'source-unavailable'
|
|
32
|
+
export type HistoryKind = 'observed' | 'opened' | 'claimed' | 'assigned' | 'delegated' | 'caseload-moved' | 'clock-reminder' | 'clock-step-applied' | 'clock-recomputed' | 'released' | 'draft-saved' | 'attempt-reserved' | 'attempt-uncertain' | 'action-completed' | 'attempt-settled' | 'superseded' | 'completed'
|
|
25
33
|
|
|
26
34
|
export interface IssuerPrincipal { issuer: string; subject: string }
|
|
27
35
|
export type TaskGrantBounds = { type: 'evidence'; requirement: string } | { type: 'breg'; permissions: ReadonlyArray<TaskPermission> } | { type: 'scheduling'; permissions: ReadonlyArray<SchedulingTaskPermission> }
|
|
@@ -94,14 +102,14 @@ export interface WorkItem {
|
|
|
94
102
|
}
|
|
95
103
|
export interface Page<T> { items: ReadonlyArray<T>; nextCursor?: string; status: PageStatus }
|
|
96
104
|
export interface WorkItemPage extends Page<WorkItem> { servedQueues: ReadonlyArray<string> }
|
|
97
|
-
export type DirectoryTargetPurpose = 'assignment' | '
|
|
105
|
+
export type DirectoryTargetPurpose = 'assignment' | 'absence-person' | 'absence-cover'
|
|
98
106
|
export type DirectoryTargetsQuery = {
|
|
99
107
|
cursor?: string
|
|
100
108
|
limit?: SafeInteger
|
|
101
109
|
} & (
|
|
102
110
|
| { purpose: 'assignment'; queue: string; personIssuer?: never; personSubject?: never }
|
|
103
|
-
| { purpose: '
|
|
104
|
-
| { purpose: '
|
|
111
|
+
| { purpose: 'absence-person'; queue?: never; personIssuer?: never; personSubject?: never }
|
|
112
|
+
| { purpose: 'absence-cover'; queue?: never; personIssuer: string; personSubject: string }
|
|
105
113
|
)
|
|
106
114
|
export type DirectoryTargetPage = Page<DirectoryMember>
|
|
107
115
|
export type ListWorkItemsQuery = {
|
|
@@ -167,11 +175,11 @@ export interface HistoryEntryBase {
|
|
|
167
175
|
profileId: string
|
|
168
176
|
}
|
|
169
177
|
export interface AttemptReservedHistoryEntry extends HistoryEntryBase {
|
|
170
|
-
kind: '
|
|
178
|
+
kind: 'attempt-reserved'
|
|
171
179
|
detail: JsonObject & { attemptId: string; bindingReference: string; operation: OperationName }
|
|
172
180
|
}
|
|
173
181
|
/**
|
|
174
|
-
* An
|
|
182
|
+
* An attempt-uncertain detail takes one of three shapes: recovery left the
|
|
175
183
|
* attempt uncertain, the source definitively refused it, or an operator marked
|
|
176
184
|
* an expired pending attempt uncertain. reason is the original decision reason.
|
|
177
185
|
*/
|
|
@@ -186,19 +194,19 @@ export type AttemptUncertainHistoryDetail = JsonObject & {
|
|
|
186
194
|
| { operatorReason: string; decidedBy: string; originalActor: IssuerPrincipal; originalProfileId: string; definitivelyRefused?: never }
|
|
187
195
|
)
|
|
188
196
|
export interface AttemptUncertainHistoryEntry extends HistoryEntryBase {
|
|
189
|
-
kind: '
|
|
197
|
+
kind: 'attempt-uncertain'
|
|
190
198
|
detail: AttemptUncertainHistoryDetail
|
|
191
199
|
}
|
|
192
200
|
export interface ActionCompletedHistoryEntry extends HistoryEntryBase {
|
|
193
|
-
kind: '
|
|
201
|
+
kind: 'action-completed'
|
|
194
202
|
detail: JsonObject & { attemptId: string; bindingReference: string; sourceRevision: string; sourceReceipt: SourceReceipt }
|
|
195
203
|
}
|
|
196
204
|
export interface AttemptSettledHistoryEntry extends HistoryEntryBase {
|
|
197
|
-
kind: '
|
|
198
|
-
detail: JsonObject & { attemptId: string; bindingReference: string; operation: OperationName; outcome: 'applied' | '
|
|
205
|
+
kind: 'attempt-settled'
|
|
206
|
+
detail: JsonObject & { attemptId: string; bindingReference: string; operation: OperationName; outcome: 'applied' | 'not-applied'; reason: string; decidedBy: string }
|
|
199
207
|
}
|
|
200
208
|
export interface OtherHistoryEntry extends HistoryEntryBase {
|
|
201
|
-
kind: Exclude<HistoryKind, '
|
|
209
|
+
kind: Exclude<HistoryKind, 'attempt-reserved' | 'attempt-uncertain' | 'action-completed' | 'attempt-settled'>
|
|
202
210
|
detail: JsonValue
|
|
203
211
|
}
|
|
204
212
|
export type HistoryEntry = AttemptReservedHistoryEntry | AttemptUncertainHistoryEntry | ActionCompletedHistoryEntry | AttemptSettledHistoryEntry | OtherHistoryEntry
|
|
@@ -220,9 +228,9 @@ export interface CalendarPolicy { id: string; timezone: string; workingWeekdays:
|
|
|
220
228
|
export interface ClockReminder { id: string; workingDaysBefore: SafeInteger }
|
|
221
229
|
export interface ClockStep { id: string; because: string; at: 'due'; action: { reassign: { queue: string } } }
|
|
222
230
|
export type ClockPolicy = {
|
|
223
|
-
|
|
231
|
+
type: 'subject'; id: string; anchor: 'first-submitted-at'; completeOn: 'review-completed'; after: { elapsed: string }; pauseWhile: ReadonlyArray<'awaiting-applicant'>
|
|
224
232
|
} | {
|
|
225
|
-
|
|
233
|
+
type: 'activity'; id: string; anchor: 'stage-entered-at'; calendar: string; after: { workingDays: SafeInteger }; dueTime: string;
|
|
226
234
|
atRisk?: { workingDaysBefore: SafeInteger }; reminders?: ReadonlyArray<ClockReminder>; steps?: ReadonlyArray<ClockStep>
|
|
227
235
|
}
|
|
228
236
|
export interface SourcePolicy {
|
|
@@ -252,14 +260,14 @@ export interface AbsenceInput { person: IssuerPrincipal; from: string; until: st
|
|
|
252
260
|
export interface AbsenceRecord extends AbsenceInput { absenceId: string; revision: SafeInteger }
|
|
253
261
|
export interface AbsencesQuery { cursor?: string; limit?: SafeInteger }
|
|
254
262
|
export interface AbsenceList { directoryRevision: SafeInteger; items: ReadonlyArray<AbsenceRecord>; nextCursor?: string }
|
|
255
|
-
export interface AssignmentContext { owner?: IssuerPrincipal; assignedBy?: IssuerPrincipal; absenceIds: ReadonlyArray<string>; staffingDiagnostic?: '
|
|
263
|
+
export interface AssignmentContext { owner?: IssuerPrincipal; assignedBy?: IssuerPrincipal; absenceIds: ReadonlyArray<string>; staffingDiagnostic?: 'no-cover-available' }
|
|
256
264
|
export interface AssignmentRequest { assignee: IssuerPrincipal; reason?: string }
|
|
257
265
|
export interface DelegateRequest { delegate: IssuerPrincipal; reason?: string }
|
|
258
266
|
export interface CaseloadMoveRequest { from: IssuerPrincipal; to: IssuerPrincipal; queueId?: string; reason: string }
|
|
259
267
|
export interface CaseloadItemSelection { itemId: string; expectedRevision: SafeInteger }
|
|
260
268
|
export interface CaseloadApplyRequest { movement: CaseloadMoveRequest; items: ReadonlyArray<CaseloadItemSelection> }
|
|
261
269
|
export interface CaseloadPreviewQuery { cursor?: string; limit?: SafeInteger }
|
|
262
|
-
export interface CaseloadItemResult { itemId: string; result: 'moved' | '
|
|
270
|
+
export interface CaseloadItemResult { itemId: string; result: 'moved' | 'not-visible' | 'not-eligible' | 'attempt-in-progress' | 'conflict'; revision?: SafeInteger }
|
|
263
271
|
export interface BootstrapDirectoryRequest {
|
|
264
272
|
teamId: string
|
|
265
273
|
staff: ReadonlyArray<IssuerPrincipal>
|
|
@@ -316,10 +324,23 @@ export type KnownCaseworkProblemCode =
|
|
|
316
324
|
| 'work-item.source-unavailable'
|
|
317
325
|
| 'work-item.superseded'
|
|
318
326
|
export type CaseworkProblemCode = KnownCaseworkProblemCode | (string & {})
|
|
319
|
-
export type CaseworkProtocolFailure = '
|
|
327
|
+
export type CaseworkProtocolFailure = 'header-bounds' | 'trace-context' | 'media-type' | 'body' | 'problem' | 'status' | 'protocol'
|
|
320
328
|
|
|
321
329
|
export class CaseworkClientError extends Error {
|
|
322
|
-
readonly kind: 'configuration' | '
|
|
330
|
+
readonly kind: 'configuration' | 'invalid-request' | 'transport' | 'problem' | 'protocol'
|
|
331
|
+
/**
|
|
332
|
+
* Whether the request may have taken effect although this error was
|
|
333
|
+
* raised: a timeout or broken exchange after sending, an unusable answer,
|
|
334
|
+
* or a 5xx. When true, recover a keyed request by sending it again under
|
|
335
|
+
* the same idempotency key; a new key could apply it twice. False for a
|
|
336
|
+
* configuration or request defect, a connection never established, and
|
|
337
|
+
* every 4xx refusal. It is false for `410 idempotency.expired` too, but
|
|
338
|
+
* there an earlier attempt under the key committed and only its stored
|
|
339
|
+
* response was erased by retention: reconcile the original operation, by
|
|
340
|
+
* reading the item, review request, or directory, before choosing a new
|
|
341
|
+
* key.
|
|
342
|
+
*/
|
|
343
|
+
readonly outcomeUnknown: boolean
|
|
323
344
|
readonly code?: CaseworkProblemCode
|
|
324
345
|
readonly detail?: string
|
|
325
346
|
readonly status?: SafeInteger
|
|
@@ -327,13 +348,13 @@ export class CaseworkClientError extends Error {
|
|
|
327
348
|
readonly originalAttemptId?: string
|
|
328
349
|
readonly validation?: {
|
|
329
350
|
readonly path: string
|
|
330
|
-
readonly reason: '
|
|
351
|
+
readonly reason: 'kind-not-allowed' | 'reference-invalid' | 'object-required' | 'maximum-bytes-exceeded' | 'maximum-depth-exceeded' | 'schema-mismatch' | 'outcome-not-declared' | 'reason-required' | 'text-invalid' | 'result-not-declared' | 'result-required' | 'field-not-declared' | 'constraint-invalid' | 'constraint-violated'
|
|
331
352
|
}
|
|
332
353
|
readonly transportKind?: string
|
|
333
354
|
readonly protocolFailure?: CaseworkProtocolFailure
|
|
334
355
|
}
|
|
335
356
|
|
|
336
|
-
export type ClockRuntimeState = 'running' | 'paused' | 'completed' | 'cancelled' | '
|
|
357
|
+
export type ClockRuntimeState = 'running' | 'paused' | 'completed' | 'cancelled' | 'verification-pending' | 'source-facts-missing'
|
|
337
358
|
export type ClockNextEffect =
|
|
338
359
|
| { kind: 'reminder'; id: string; at: string }
|
|
339
360
|
| { kind: 'reassign'; id: string; at: string; because: string; queueId: string }
|
|
@@ -382,7 +403,7 @@ export interface ReviewRequestAccepted {
|
|
|
382
403
|
policy: ReviewPolicyBinding
|
|
383
404
|
submissionDigest: ContentDigest
|
|
384
405
|
}
|
|
385
|
-
export type ReviewRequestLifecycle = 'reviewing' | 'approved' | 'rejected' | '
|
|
406
|
+
export type ReviewRequestLifecycle = 'reviewing' | 'approved' | 'rejected' | 'changes-requested' | 'answered' | 'cancelled' | 'superseded'
|
|
386
407
|
export interface ReviewRequestView extends ReviewRequestAccepted {
|
|
387
408
|
requesterReference: string
|
|
388
409
|
lifecycle: ReviewRequestLifecycle
|
|
@@ -390,7 +411,7 @@ export interface ReviewRequestView extends ReviewRequestAccepted {
|
|
|
390
411
|
createdAt: string
|
|
391
412
|
updatedAt: string
|
|
392
413
|
}
|
|
393
|
-
export type ReviewResultStatus = 'approved' | 'rejected' | '
|
|
414
|
+
export type ReviewResultStatus = 'approved' | 'rejected' | 'changes-requested' | 'answered' | 'cancelled' | 'superseded'
|
|
394
415
|
export interface ReviewResult extends ReviewRequestAccepted {
|
|
395
416
|
resultId: Uuid
|
|
396
417
|
status: ReviewResultStatus
|
|
@@ -407,11 +428,30 @@ export interface ReviewResultFeedPage { items: ReadonlyArray<ReviewResultFeedEnt
|
|
|
407
428
|
export interface ReviewCancelRequest { subject: ReviewSubjectBinding; reason: string }
|
|
408
429
|
export type ReviewCancelResponse =
|
|
409
430
|
| { outcome: 'cancelled'; result: ReviewResult }
|
|
410
|
-
| { outcome: '
|
|
431
|
+
| { outcome: 'already-terminal'; result: ReviewResult }
|
|
411
432
|
export interface ReviewPageQuery { cursor?: Uuid; limit?: SafeInteger }
|
|
412
|
-
export
|
|
433
|
+
export type ReviewTaskOwnership = 'assigned-to-me' | 'unclaimed'
|
|
434
|
+
export interface ReviewTaskQuery extends ReviewPageQuery { queue?: string; ownership?: ReviewTaskOwnership }
|
|
435
|
+
export interface SupervisoryReviewTaskQuery extends ReviewPageQuery { queue?: string; requestId?: Uuid }
|
|
436
|
+
export interface OwnReviewDecisionQuery extends ReviewPageQuery { queue?: string }
|
|
413
437
|
export interface WorkItemHistoryQuery { cursor?: string; limit?: SafeInteger }
|
|
414
438
|
export type ReviewerTaskState = 'open' | { held: { holder: IssuerPrincipal } } | 'decided'
|
|
439
|
+
export type ReviewDecisionType = 'approve' | 'reject' | 'changes-requested' | 'answer'
|
|
440
|
+
export interface ReviewDecisionReceipt {
|
|
441
|
+
policy: ReviewPolicyBinding
|
|
442
|
+
decision: ReviewDecisionType
|
|
443
|
+
outcome?: string
|
|
444
|
+
outcomeLabel?: string
|
|
445
|
+
decidedAt: string
|
|
446
|
+
}
|
|
447
|
+
export interface OwnReviewDecision {
|
|
448
|
+
taskId: Uuid
|
|
449
|
+
requestId: Uuid
|
|
450
|
+
queue: string
|
|
451
|
+
requesterReference: string
|
|
452
|
+
decisionReceipt: ReviewDecisionReceipt
|
|
453
|
+
}
|
|
454
|
+
export interface OwnReviewDecisionPage { items: ReadonlyArray<OwnReviewDecision>; nextCursor?: Uuid; status: PageStatus }
|
|
415
455
|
export interface ReviewerTask {
|
|
416
456
|
taskId: Uuid
|
|
417
457
|
requestId: Uuid
|
|
@@ -422,9 +462,20 @@ export interface ReviewerTask {
|
|
|
422
462
|
eligibleProfiles: ReadonlyArray<string>
|
|
423
463
|
state: ReviewerTaskState
|
|
424
464
|
decidedByCaller?: boolean
|
|
465
|
+
decisionReceipt?: ReviewDecisionReceipt
|
|
425
466
|
}
|
|
426
467
|
export interface ReviewTaskPage { items: ReadonlyArray<ReviewerTask>; nextCursor?: Uuid; status: PageStatus }
|
|
427
|
-
export type
|
|
468
|
+
export type SupervisoryReviewTaskState = 'open' | 'held' | 'decided'
|
|
469
|
+
export interface SupervisoryReviewTask {
|
|
470
|
+
taskId: Uuid
|
|
471
|
+
requestId: Uuid
|
|
472
|
+
queue: string
|
|
473
|
+
revision: SafeInteger
|
|
474
|
+
state: SupervisoryReviewTaskState
|
|
475
|
+
accountabilityEventId?: Uuid
|
|
476
|
+
}
|
|
477
|
+
export interface SupervisoryReviewTaskPage { items: ReadonlyArray<SupervisoryReviewTask>; nextCursor?: Uuid; status: PageStatus }
|
|
478
|
+
export type ReviewSourceBindingStatus = 'current' | 'binding-changed'
|
|
428
479
|
export interface ReviewSourceProjection { binding: SourceBinding; displayReference?: string; display: Readonly<Record<string, JsonValue>> }
|
|
429
480
|
export type ReviewTaskContextData =
|
|
430
481
|
| { strategy: 'submitted'; snapshot: Readonly<Record<string, JsonValue>> }
|
|
@@ -447,7 +498,7 @@ export interface ReviewClockOccurrence {
|
|
|
447
498
|
clockId: string
|
|
448
499
|
requestId: Uuid
|
|
449
500
|
correlation: ReviewClockCorrelation
|
|
450
|
-
state: 'running' | 'paused' | 'completed' | 'cancelled' | '
|
|
501
|
+
state: 'running' | 'paused' | 'completed' | 'cancelled' | 'source-facts-missing'
|
|
451
502
|
policyDigest: ContentDigest
|
|
452
503
|
anchorAt: string
|
|
453
504
|
dueAt?: string
|
|
@@ -458,7 +509,7 @@ export interface ReviewTaskDraftInput { body: JsonValue }
|
|
|
458
509
|
export interface ReviewTaskDraft { taskId: Uuid; author: IssuerPrincipal; body: JsonValue; revision: SafeInteger; updatedAt: string }
|
|
459
510
|
export type ReviewerDecision =
|
|
460
511
|
| { type: 'approve' }
|
|
461
|
-
| { type: 'reject' | '
|
|
512
|
+
| { type: 'reject' | 'changes-requested' | 'answer'; outcome: string; reason?: string | null; result?: JsonObject | null }
|
|
462
513
|
export interface ReviewTaskDecisionRequest { decision: ReviewerDecision }
|
|
463
514
|
export type ReviewHistoryAudience = 'reviewers' | 'requester'
|
|
464
515
|
export interface ReviewNoteRequest { audience: ReviewHistoryAudience; note: string }
|
|
@@ -468,6 +519,7 @@ export interface ReviewAccountabilityRecord {
|
|
|
468
519
|
eventId: Uuid; requestId: Uuid; taskId: Uuid; actorRef: string; actor: IssuerPrincipal
|
|
469
520
|
profileId: string; decision: string; privateReason?: string; resultDigest?: string
|
|
470
521
|
occurredAt: string; retainedUntil: string
|
|
522
|
+
decisionReceipt?: ReviewDecisionReceipt
|
|
471
523
|
}
|
|
472
524
|
export interface ReviewStagePolicy { id: string; queue: string; decidingProfiles: ReadonlyArray<string>; requiredApprovals: SafeInteger; excludeInitiator?: boolean; excludePreviousStageReviewers?: boolean }
|
|
473
525
|
export interface ReviewRetentionPolicy { terminalDays: SafeInteger; accountabilityDays: SafeInteger }
|
|
@@ -480,7 +532,7 @@ export interface ReviewKindPolicySnapshot {
|
|
|
480
532
|
retention: ReviewRetentionPolicy
|
|
481
533
|
displaySchema: JsonValue
|
|
482
534
|
resultSchema?: JsonValue
|
|
483
|
-
outcomes?: ReadonlyArray<{ id: string; label: string; settlement: 'rejected' | '
|
|
535
|
+
outcomes?: ReadonlyArray<{ id: string; label: string; settlement: 'rejected' | 'changes-requested' | 'answered'; reasonRequired: boolean; resultRequired?: boolean }>
|
|
484
536
|
}
|
|
485
537
|
|
|
486
538
|
export class CaseworkClient {
|
|
@@ -494,6 +546,8 @@ export class CaseworkClient {
|
|
|
494
546
|
reviewKinds(token: string, profile: string): Promise<CaseworkOutcome<ReadonlyArray<ReviewKindPolicySnapshot>>>
|
|
495
547
|
reviewKind(token: string, profile: string, kindId: string): Promise<CaseworkOutcome<ReviewKindPolicySnapshot>>
|
|
496
548
|
reviewTasks(token: string, profile: string, query?: ReviewTaskQuery | null, sourceProfile?: string | null): Promise<CaseworkOutcome<ReviewTaskPage>>
|
|
549
|
+
supervisoryReviewTasks(token: string, profile: string, query?: SupervisoryReviewTaskQuery | null, sourceProfile?: string | null): Promise<CaseworkOutcome<SupervisoryReviewTaskPage>>
|
|
550
|
+
ownReviewDecisions(token: string, profile: string, query?: OwnReviewDecisionQuery | null, sourceProfile?: string | null): Promise<CaseworkOutcome<OwnReviewDecisionPage>>
|
|
497
551
|
reviewTask(token: string, profile: string, taskId: Uuid, sourceProfile?: string | null): Promise<CaseworkOutcome<ReviewerTask>>
|
|
498
552
|
reviewTaskContext(token: string, profile: string, taskId: Uuid, sourceProfile?: string | null): Promise<CaseworkOutcome<ReviewTaskContext>>
|
|
499
553
|
previewReviewTaskTemplates(token: string, profile: string, sourceProfile: string, taskId: Uuid): Promise<CaseworkOutcome<TaskTemplatePreviews>>
|
package/casework/client.js
CHANGED
|
@@ -12,6 +12,7 @@ class CaseworkClientError extends Error {
|
|
|
12
12
|
super(envelope.message);
|
|
13
13
|
this.name = 'CaseworkClientError';
|
|
14
14
|
this.kind = envelope.kind;
|
|
15
|
+
this.outcomeUnknown = envelope.outcomeUnknown === true;
|
|
15
16
|
for (const field of ['code', 'detail', 'status', 'traceId', 'originalAttemptId', 'validation', 'transportKind', 'protocolFailure']) {
|
|
16
17
|
if (envelope[field] !== undefined && envelope[field] !== null) this[field] = envelope[field];
|
|
17
18
|
}
|
|
@@ -39,38 +40,38 @@ function normalized(error, fallbackKind) {
|
|
|
39
40
|
return error;
|
|
40
41
|
}
|
|
41
42
|
|
|
42
|
-
function cloneJson(value, budget, depth) {
|
|
43
|
-
if (depth > MAX_JSON_DEPTH || ++budget.nodes > MAX_JSON_NODES) throw normalized({},
|
|
43
|
+
function cloneJson(value, budget, depth, kind) {
|
|
44
|
+
if (depth > MAX_JSON_DEPTH || ++budget.nodes > MAX_JSON_NODES) throw normalized({}, kind);
|
|
44
45
|
if (value === null || typeof value === 'boolean') return value;
|
|
45
46
|
if (typeof value === 'string') {
|
|
46
47
|
budget.bytes += Buffer.byteLength(value, 'utf8');
|
|
47
|
-
if (budget.bytes > MAX_JSON_STRING_BYTES) throw normalized({},
|
|
48
|
+
if (budget.bytes > MAX_JSON_STRING_BYTES) throw normalized({}, kind);
|
|
48
49
|
return value;
|
|
49
50
|
}
|
|
50
51
|
if (typeof value === 'number') {
|
|
51
52
|
if (!Number.isFinite(value) || (Number.isInteger(value) && !Number.isSafeInteger(value))) {
|
|
52
|
-
throw normalized({},
|
|
53
|
+
throw normalized({}, kind);
|
|
53
54
|
}
|
|
54
55
|
return value;
|
|
55
56
|
}
|
|
56
57
|
if (value === undefined || typeof value !== 'object' || isProxy(value)) {
|
|
57
|
-
throw normalized({},
|
|
58
|
+
throw normalized({}, kind);
|
|
58
59
|
}
|
|
59
60
|
const array = Array.isArray(value);
|
|
60
61
|
const prototype = Object.getPrototypeOf(value);
|
|
61
62
|
if (array ? prototype !== Array.prototype : prototype !== Object.prototype && prototype !== null) {
|
|
62
|
-
throw normalized({},
|
|
63
|
+
throw normalized({}, kind);
|
|
63
64
|
}
|
|
64
|
-
if (budget.active.has(value)) throw normalized({},
|
|
65
|
+
if (budget.active.has(value)) throw normalized({}, kind);
|
|
65
66
|
budget.active.add(value);
|
|
66
67
|
try {
|
|
67
|
-
if (array) return value.map((member) => cloneJson(member, budget, depth + 1));
|
|
68
|
+
if (array) return value.map((member) => cloneJson(member, budget, depth + 1, kind));
|
|
68
69
|
const result = Object.create(null);
|
|
69
70
|
for (const key of Reflect.ownKeys(value)) {
|
|
70
|
-
if (typeof key !== 'string') throw normalized({},
|
|
71
|
+
if (typeof key !== 'string') throw normalized({}, kind);
|
|
71
72
|
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
72
|
-
if (!descriptor || !Object.hasOwn(descriptor, 'value')) throw normalized({},
|
|
73
|
-
if (descriptor.enumerable) result[key] = cloneJson(descriptor.value, budget, depth + 1);
|
|
73
|
+
if (!descriptor || !Object.hasOwn(descriptor, 'value')) throw normalized({}, kind);
|
|
74
|
+
if (descriptor.enumerable) result[key] = cloneJson(descriptor.value, budget, depth + 1, kind);
|
|
74
75
|
}
|
|
75
76
|
return result;
|
|
76
77
|
} finally {
|
|
@@ -78,8 +79,10 @@ function cloneJson(value, budget, depth) {
|
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
81
|
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
// A refusal is reported as `kind`: `configuration` for the constructor's
|
|
83
|
+
// settings, `invalid-request` for a method's arguments.
|
|
84
|
+
function sanitize(value, kind) {
|
|
85
|
+
return cloneJson(value, { nodes: 0, bytes: 0, active: new WeakSet() }, 0, kind);
|
|
83
86
|
}
|
|
84
87
|
|
|
85
88
|
const NativeCaseworkClient = native.CaseworkClient;
|
|
@@ -87,7 +90,7 @@ const NativeCaseworkClient = native.CaseworkClient;
|
|
|
87
90
|
class CaseworkClient {
|
|
88
91
|
constructor(config) {
|
|
89
92
|
try {
|
|
90
|
-
this.native = new NativeCaseworkClient(sanitize(config));
|
|
93
|
+
this.native = new NativeCaseworkClient(sanitize(config, 'configuration'));
|
|
91
94
|
} catch (error) {
|
|
92
95
|
throw normalized(error, 'configuration');
|
|
93
96
|
}
|
|
@@ -97,7 +100,7 @@ class CaseworkClient {
|
|
|
97
100
|
try {
|
|
98
101
|
return this.native.taskAssertionEndpoint(grantId);
|
|
99
102
|
} catch (error) {
|
|
100
|
-
throw normalized(error, '
|
|
103
|
+
throw normalized(error, 'invalid-request');
|
|
101
104
|
}
|
|
102
105
|
}
|
|
103
106
|
}
|
|
@@ -112,6 +115,8 @@ for (const [method, jsonIndexes] of [
|
|
|
112
115
|
['reviewKinds', []],
|
|
113
116
|
['reviewKind', []],
|
|
114
117
|
['reviewTasks', [2]],
|
|
118
|
+
['ownReviewDecisions', [2]],
|
|
119
|
+
['supervisoryReviewTasks', [2]],
|
|
115
120
|
['reviewTask', []],
|
|
116
121
|
['reviewTaskContext', []],
|
|
117
122
|
['previewReviewTaskTemplates', []],
|
|
@@ -170,11 +175,11 @@ for (const [method, jsonIndexes] of [
|
|
|
170
175
|
CaseworkClient.prototype[method] = function (...args) {
|
|
171
176
|
try {
|
|
172
177
|
for (const index of jsonIndexes) {
|
|
173
|
-
if (args[index] !== undefined && args[index] !== null) args[index] = sanitize(args[index]);
|
|
178
|
+
if (args[index] !== undefined && args[index] !== null) args[index] = sanitize(args[index], 'invalid-request');
|
|
174
179
|
}
|
|
175
180
|
return this.native[method](...args).catch((error) => { throw normalized(error); });
|
|
176
181
|
} catch (error) {
|
|
177
|
-
throw normalized(error, '
|
|
182
|
+
throw normalized(error, 'invalid-request');
|
|
178
183
|
}
|
|
179
184
|
};
|
|
180
185
|
}
|
package/casework/index.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ export declare class CaseworkClient {
|
|
|
13
13
|
reviewKind(token: string, profile: string, kindId: string): Promise<CaseworkOutcome>
|
|
14
14
|
reviewTasks(token: string, profile: string, query?: any | undefined | null, sourceProfile?: string | undefined | null): Promise<CaseworkOutcome>
|
|
15
15
|
reviewTask(token: string, profile: string, taskId: string, sourceProfile?: string | undefined | null): Promise<CaseworkOutcome>
|
|
16
|
+
ownReviewDecisions(token: string, profile: string, query?: any | undefined | null, sourceProfile?: string | undefined | null): Promise<CaseworkOutcome>
|
|
17
|
+
supervisoryReviewTasks(token: string, profile: string, query?: any | undefined | null, sourceProfile?: string | undefined | null): Promise<CaseworkOutcome>
|
|
16
18
|
reviewTaskContext(token: string, profile: string, taskId: string, sourceProfile?: string | undefined | null): Promise<CaseworkOutcome>
|
|
17
19
|
previewReviewTaskTemplates(token: string, profile: string, sourceProfile: string, taskId: string): Promise<CaseworkOutcome>
|
|
18
20
|
listReviewTaskGrants(token: string, profile: string, sourceProfile: string, taskId: string): Promise<CaseworkOutcome>
|
|
@@ -76,6 +78,11 @@ export interface CaseworkClientConfig {
|
|
|
76
78
|
maxResponseBytes?: number
|
|
77
79
|
userAgent?: string
|
|
78
80
|
trustedRootCertificates?: string
|
|
81
|
+
/**
|
|
82
|
+
* How many times a keyed mutation whose outcome is unknown is resent under
|
|
83
|
+
* the same idempotency key: 0 to 2, default 2, and 0 disables the resend.
|
|
84
|
+
*/
|
|
85
|
+
maxMutationRetries?: number
|
|
79
86
|
}
|
|
80
87
|
|
|
81
88
|
export interface CaseworkOutcome {
|
package/discovery/client.d.ts
CHANGED
|
@@ -111,13 +111,13 @@ export type ServiceSelection = CommonServiceSelection;
|
|
|
111
111
|
export type DiscoveryClientErrorKind =
|
|
112
112
|
| 'configuration'
|
|
113
113
|
| 'query'
|
|
114
|
-
| '
|
|
115
|
-
| '
|
|
116
|
-
| '
|
|
117
|
-
| '
|
|
118
|
-
| '
|
|
119
|
-
| '
|
|
120
|
-
| '
|
|
114
|
+
| 'no-matching-service'
|
|
115
|
+
| 'ambiguous-selection'
|
|
116
|
+
| 'no-matching-alternative'
|
|
117
|
+
| 'ambiguous-alternative'
|
|
118
|
+
| 'capability-mismatch'
|
|
119
|
+
| 'local-acceptance-refused'
|
|
120
|
+
| 'selection-changed'
|
|
121
121
|
| 'transport'
|
|
122
122
|
| 'problem'
|
|
123
123
|
| 'protocol'
|
package/discovery/client.js
CHANGED
|
@@ -55,7 +55,7 @@ function inputError(kind) {
|
|
|
55
55
|
|
|
56
56
|
function localAcceptanceError() {
|
|
57
57
|
return new DiscoveryClientError({
|
|
58
|
-
kind: '
|
|
58
|
+
kind: 'local-acceptance-refused',
|
|
59
59
|
message: 'the relying application refused the advertised service',
|
|
60
60
|
});
|
|
61
61
|
}
|
package/evidence/client.d.ts
CHANGED
|
@@ -351,7 +351,7 @@ export interface EvidenceRequestBatchSpec {
|
|
|
351
351
|
* is `protocol`
|
|
352
352
|
* - `code`: `denied`, `protocol` (optional), `verification`, and any `token`
|
|
353
353
|
* failure whose `tokenKind` is `refused`
|
|
354
|
-
* - `traceId`: `denied`, `
|
|
354
|
+
* - `traceId`: `denied`, `not-available`, `protocol` (all optional)
|
|
355
355
|
* - `retryAfterSeconds`: `denied`, `protocol` (both optional)
|
|
356
356
|
* - `transportKind`: `transport`, and any `token` failure whose `tokenKind`
|
|
357
357
|
* is `transport`
|
package/evidence/index.d.ts
CHANGED
|
@@ -154,11 +154,8 @@ export declare class EvidenceClient {
|
|
|
154
154
|
export declare class PreparedEvidenceRequest {
|
|
155
155
|
/** The nonce this request carries. Retain it with the transaction record. */
|
|
156
156
|
get requestNonce(): string
|
|
157
|
-
/**
|
|
158
|
-
|
|
159
|
-
* it.
|
|
160
|
-
*/
|
|
161
|
-
get policyDocument(): any
|
|
157
|
+
/** The complete enveloped policy, with the subject set as `prepare` left it. */
|
|
158
|
+
get policyDocument(): { apiVersion: 'id.registrystack.org/formats/evidence/verification-policy/v1'; kind: 'EvidenceVerificationPolicy'; [field: string]: unknown }
|
|
162
159
|
/**
|
|
163
160
|
* `"acceptFirstUse"` or `{ pinned: [{ role, binding }, ...] }`, exactly as
|
|
164
161
|
* this request was prepared.
|
|
@@ -178,7 +175,7 @@ export declare class PreparedEvidenceRequestBatch {
|
|
|
178
175
|
/** Independently generated item nonces in request order. */
|
|
179
176
|
get requestNonces(): Array<string>
|
|
180
177
|
/** Independently closed policy documents in request order. */
|
|
181
|
-
get policyDocuments(): Array<
|
|
178
|
+
get policyDocuments(): Array<{ apiVersion: 'id.registrystack.org/formats/evidence/verification-policy/v1'; kind: 'EvidenceVerificationPolicy'; [field: string]: unknown }>
|
|
182
179
|
/** Subject-verification stances in request order. */
|
|
183
180
|
get subjectExpectations(): Array<any>
|
|
184
181
|
/** Number of positional requests in this batch. */
|
package/index.d.ts
CHANGED
|
@@ -3,5 +3,6 @@ import * as evidence from './evidence/client'
|
|
|
3
3
|
import * as breg from './breg/client'
|
|
4
4
|
import * as casework from './casework/client'
|
|
5
5
|
import * as messaging from './messaging/client'
|
|
6
|
+
import * as scheduling from './scheduling/client'
|
|
6
7
|
|
|
7
|
-
export { discovery, evidence, breg, casework, messaging }
|
|
8
|
+
export { discovery, evidence, breg, casework, messaging, scheduling }
|
package/index.js
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
// One assignment per namespace, never a `module.exports` object literal: Node
|
|
4
4
|
// scans this file for these statements to synthesise the named exports an ESM
|
|
5
|
-
// consumer imports, and `require()` sees the same
|
|
5
|
+
// consumer imports, and `require()` sees the same six properties either way.
|
|
6
6
|
exports.discovery = require('./discovery/client');
|
|
7
7
|
exports.evidence = require('./evidence/client');
|
|
8
8
|
exports.breg = require('./breg/client');
|
|
9
9
|
exports.casework = require('./casework/client');
|
|
10
10
|
exports.messaging = require('./messaging/client');
|
|
11
|
+
exports.scheduling = require('./scheduling/client');
|
package/messaging/client.d.ts
CHANGED
|
@@ -14,6 +14,13 @@ export interface MessagingClientConfig {
|
|
|
14
14
|
maxResponseBytes?: SafeInteger | null
|
|
15
15
|
userAgent?: string | null
|
|
16
16
|
trustedRootCertificates?: string | null
|
|
17
|
+
/**
|
|
18
|
+
* How many times a submission whose outcome is unknown is resent,
|
|
19
|
+
* identically and under the same idempotency key, before its error is
|
|
20
|
+
* returned: a whole number from 0 to 2, default 2; 0 sends it once. Any
|
|
21
|
+
* other value is a `configuration` error.
|
|
22
|
+
*/
|
|
23
|
+
maxMutationRetries?: SafeInteger | null
|
|
17
24
|
}
|
|
18
25
|
|
|
19
26
|
export type Channel = 'email' | 'sms'
|
|
@@ -113,10 +120,21 @@ export type MessagingProblemCode =
|
|
|
113
120
|
| 'template.locale-unavailable'
|
|
114
121
|
| 'template.not-found'
|
|
115
122
|
| 'template.render-refused'
|
|
116
|
-
export type MessagingProtocolFailure = '
|
|
123
|
+
export type MessagingProtocolFailure = 'header-bounds' | 'trace-context' | 'media-type' | 'body' | 'problem' | 'status' | 'protocol'
|
|
117
124
|
|
|
118
125
|
export class MessagingClientError extends Error {
|
|
119
|
-
readonly kind: 'configuration' | '
|
|
126
|
+
readonly kind: 'configuration' | 'invalid-request' | 'transport' | 'problem' | 'protocol'
|
|
127
|
+
/**
|
|
128
|
+
* Whether the request may have taken effect although this error was
|
|
129
|
+
* raised: a timeout or broken exchange after sending, an unusable answer,
|
|
130
|
+
* or a 5xx. When true, recover a keyed request by sending it again under
|
|
131
|
+
* the same idempotency key; a new key could apply it twice. False for a
|
|
132
|
+
* configuration or request defect, a connection never established, and
|
|
133
|
+
* every 4xx refusal. It is false for `410 idempotency.expired` too, but
|
|
134
|
+
* there an earlier submission under the key was accepted and its message
|
|
135
|
+
* may have been sent: reconcile that submission before choosing a new key.
|
|
136
|
+
*/
|
|
137
|
+
readonly outcomeUnknown: boolean
|
|
120
138
|
readonly code?: MessagingProblemCode
|
|
121
139
|
readonly title?: string
|
|
122
140
|
readonly detail?: string
|
|
@@ -124,8 +142,9 @@ export class MessagingClientError extends Error {
|
|
|
124
142
|
readonly traceId?: string
|
|
125
143
|
/**
|
|
126
144
|
* Whole seconds a 429 limit refusal asked the caller to wait, from
|
|
127
|
-
* `Retry-After`, at most one day. Absent on every other failure
|
|
128
|
-
* client never waits or retries
|
|
145
|
+
* `Retry-After`, at most one day. Absent on every other failure. The
|
|
146
|
+
* client never waits on a 429 or retries it; the wait is the caller's to
|
|
147
|
+
* honor.
|
|
129
148
|
*/
|
|
130
149
|
readonly retryAfterSeconds?: SafeInteger
|
|
131
150
|
readonly transportKind?: string
|