@registrystack/client 0.29.0 → 0.30.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.
@@ -0,0 +1,435 @@
1
+ export type SafeInteger = number
2
+ export type JsonScalar = string | number | boolean | null
3
+ export type JsonValue = JsonScalar | ReadonlyArray<JsonValue> | { readonly [key: string]: JsonValue }
4
+ export type JsonObject = { readonly [key: string]: JsonValue }
5
+
6
+ export interface CaseworkClientConfig {
7
+ baseUrl: string
8
+ requestTimeoutMilliseconds?: SafeInteger | null
9
+ connectTimeoutMilliseconds?: SafeInteger | null
10
+ maxResponseBytes?: SafeInteger | null
11
+ userAgent?: string | null
12
+ trustedRootCertificates?: string | null
13
+ }
14
+
15
+ export type InboxView = 'mine' | 'my_teams' | 'team_holdings' | 'overdue' | 'completed_by_me'
16
+ export type OccurrenceKind = 'review' | 'application' | 'hosted'
17
+ export type OccurrenceState = 'open' | 'claimed' | 'waiting_applicant' | 'waiting_application' | 'synchronizing' | 'completed' | 'superseded' | 'cancelled'
18
+ export type OperationName = string
19
+ export type AttemptState = 'pending' | 'uncertain' | 'completed' | 'refused'
20
+ export type PageStatus = 'complete' | 'budget_exhausted' | 'source_unavailable'
21
+ 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'
22
+
23
+ export interface IssuerPrincipal { issuer: string; subject: string }
24
+ export interface DirectoryMember { issuer: string; subject: string; displayName?: string | null }
25
+ export interface SubjectRef { sourceId: string; kind: string; id: string }
26
+ export interface SourceBinding {
27
+ sourceRevision: string
28
+ version: string
29
+ integrity?: string
30
+ generation: string
31
+ }
32
+ export type CaseworkActionName = 'claim' | 'release' | OperationName
33
+ export interface CaseworkAction { operation: CaseworkActionName; href: string; ifMatch: string }
34
+ export interface CorrectionRoutingCopy {
35
+ sourceBinding: SourceBinding
36
+ reason?: string
37
+ flaggedFields: ReadonlyArray<string>
38
+ }
39
+ export interface WorkItemRouting {
40
+ ruleId?: string
41
+ because?: string
42
+ policyDigest?: string
43
+ }
44
+ export interface WorkItem {
45
+ itemId: string
46
+ subject: SubjectRef
47
+ occurrenceKind: OccurrenceKind
48
+ stage?: string
49
+ binding: SourceBinding
50
+ bindingReference: string
51
+ displayReference?: string
52
+ state: OccurrenceState
53
+ queueId: string
54
+ holder?: IssuerPrincipal
55
+ heldSince?: string
56
+ assignment?: AssignmentContext
57
+ revision: SafeInteger
58
+ firstObservedAt: string
59
+ passiveDueAt?: string
60
+ updatedAt: string
61
+ actions: ReadonlyArray<CaseworkAction>
62
+ routingCopy?: CorrectionRoutingCopy
63
+ hosted?: HostedWorkItemContext
64
+ routing?: WorkItemRouting
65
+ clockOccurrences?: ReadonlyArray<ClockOccurrenceView>
66
+ liveAttempt?: AttemptStatus
67
+ }
68
+ export interface Page<T> { items: ReadonlyArray<T>; nextCursor?: string; status: PageStatus }
69
+ export interface WorkItemPage extends Page<WorkItem> { servedQueues: ReadonlyArray<string> }
70
+ export type DirectoryTargetPurpose = 'assignment' | 'absence_person' | 'absence_cover'
71
+ export type DirectoryTargetsQuery = {
72
+ cursor?: string
73
+ limit?: SafeInteger
74
+ } & (
75
+ | { purpose: 'assignment'; queue: string; personIssuer?: never; personSubject?: never }
76
+ | { purpose: 'absence_person'; queue?: never; personIssuer?: never; personSubject?: never }
77
+ | { purpose: 'absence_cover'; queue?: never; personIssuer: string; personSubject: string }
78
+ )
79
+ export type DirectoryTargetPage = Page<DirectoryMember>
80
+ export type ListWorkItemsQuery = {
81
+ view: InboxView
82
+ sort?: InboxSort
83
+ queue?: string
84
+ cursor?: string
85
+ limit?: SafeInteger
86
+ } & (
87
+ | { sourceId: string; subjectKind: string; subjectId: string; reference?: never }
88
+ | { reference: string; sourceId?: never; subjectKind?: never; subjectId?: never }
89
+ | { reference?: never; sourceId?: never; subjectKind?: never; subjectId?: never }
90
+ )
91
+ export type InboxSort = 'due' | 'age' | 'type'
92
+ export interface NextWorkItemQuery { queue?: string; cursor?: string }
93
+ export interface SaveDraftRequest {
94
+ binding: SourceBinding
95
+ reason: string
96
+ flaggedFields?: ReadonlyArray<string>
97
+ }
98
+ export interface Draft {
99
+ itemId: string
100
+ author: IssuerPrincipal
101
+ binding: SourceBinding
102
+ reason: string
103
+ flaggedFields: ReadonlyArray<string>
104
+ revision: SafeInteger
105
+ updatedAt: string
106
+ }
107
+ export interface DraftResponse { draft: Draft }
108
+ export interface DecideRequest {
109
+ displayedBinding: SourceBinding
110
+ sourceProfileId: string
111
+ operation: OperationName
112
+ reason?: string
113
+ flaggedFields?: ReadonlyArray<string>
114
+ }
115
+ export interface RecoverAttemptRequest { sourceProfileId: string }
116
+ export interface SourceReceipt {
117
+ sourceRevision: string
118
+ resultingState: string
119
+ binding: SourceBinding
120
+ actorReference?: string
121
+ metadata: Readonly<Record<string, string>>
122
+ }
123
+ export interface AttemptStatus {
124
+ attemptId: string
125
+ itemId: string
126
+ state: AttemptState
127
+ itemRevision: SafeInteger
128
+ operation: OperationName
129
+ createdAt: string
130
+ receipt?: SourceReceipt
131
+ }
132
+ export interface MutationResponse { item: WorkItem; attempt?: AttemptStatus }
133
+ export interface HistoryEntryBase {
134
+ eventId: string
135
+ itemId: string
136
+ itemRevision: SafeInteger
137
+ kind: HistoryKind
138
+ occurredAt: string
139
+ actor?: IssuerPrincipal
140
+ profileId: string
141
+ }
142
+ export interface AttemptReservedHistoryEntry extends HistoryEntryBase {
143
+ kind: 'attempt_reserved'
144
+ detail: JsonObject & { attemptId: string; bindingReference: string; operation: OperationName }
145
+ }
146
+ export interface AttemptUncertainHistoryEntry extends HistoryEntryBase {
147
+ kind: 'attempt_uncertain'
148
+ detail: JsonObject & { attemptId: string; bindingReference: string; sourceRevision?: string | null; definitivelyRefused?: boolean }
149
+ }
150
+ export interface ActionCompletedHistoryEntry extends HistoryEntryBase {
151
+ kind: 'action_completed'
152
+ detail: JsonObject & { attemptId: string; bindingReference: string; sourceRevision: string; sourceReceipt: SourceReceipt }
153
+ }
154
+ export interface AttemptSettledHistoryEntry extends HistoryEntryBase {
155
+ kind: 'attempt_settled'
156
+ detail: JsonObject & { attemptId: string; bindingReference: string; operation: OperationName; outcome: 'applied' | 'not_applied'; reason: string; decidedBy: string }
157
+ }
158
+ export interface OtherHistoryEntry extends HistoryEntryBase {
159
+ kind: Exclude<HistoryKind, 'attempt_reserved' | 'attempt_uncertain' | 'action_completed' | 'attempt_settled'>
160
+ detail: JsonValue
161
+ }
162
+ export type HistoryEntry = AttemptReservedHistoryEntry | AttemptUncertainHistoryEntry | ActionCompletedHistoryEntry | AttemptSettledHistoryEntry | OtherHistoryEntry
163
+ export interface HoldingSummary {
164
+ principal: IssuerPrincipal
165
+ queueId: string
166
+ activeItems: SafeInteger
167
+ overdueItems: SafeInteger
168
+ }
169
+ export interface QueueRecord { id: string; label: string }
170
+ export interface PassiveTargetPolicy { id: string; after: { elapsed: string } }
171
+ export type RoutingPredicate = { equals: JsonValue } | { oneOf: ReadonlyArray<JsonValue> }
172
+ export interface RoutingCondition { activity?: 'review' | 'apply'; stage?: string; fields?: Readonly<Record<string, RoutingPredicate>> }
173
+ export interface RoutingRule { id: string; because: string; when: RoutingCondition; queue: string }
174
+ export interface DisplayReferencePolicy { field: string }
175
+ export interface SourceRequestPolicy { entity: string; queue: string; projection?: ReadonlyArray<string>; routing?: ReadonlyArray<RoutingRule>; displayReference?: DisplayReferencePolicy; clock?: string; target?: PassiveTargetPolicy }
176
+ export type WorkingWeekday = 'monday' | 'tuesday' | 'wednesday' | 'thursday' | 'friday' | 'saturday' | 'sunday'
177
+ export interface CalendarPolicy { id: string; timezone: string; workingWeekdays: ReadonlyArray<WorkingWeekday>; holidaySet: string }
178
+ export interface ClockReminder { id: string; workingDaysBefore: SafeInteger }
179
+ export interface ClockStep { id: string; because: string; at: 'due'; action: { reassign: { queue: string } } }
180
+ export type ClockPolicy = {
181
+ scope: 'subject'; id: string; anchor: 'firstSubmittedAt'; completeOn: 'reviewCompleted'; after: { elapsed: string }; pauseWhile: ReadonlyArray<'awaitingApplicant'>
182
+ } | {
183
+ scope: 'activity'; id: string; anchor: 'stageEnteredAt'; calendar: string; after: { workingDays: SafeInteger }; dueTime: string;
184
+ atRisk?: { workingDaysBefore: SafeInteger }; reminders?: ReadonlyArray<ClockReminder>; steps?: ReadonlyArray<ClockStep>
185
+ }
186
+ export interface SourcePolicy {
187
+ id: string
188
+ adapter: string
189
+ description: string
190
+ requests: ReadonlyArray<SourceRequestPolicy>
191
+ }
192
+ export interface HostedRetentionPolicy { terminalDays: SafeInteger; accountabilityDays: SafeInteger }
193
+ export interface HostedOutcomePolicy { id: string; label: string; reasonRequired: boolean }
194
+ export interface HostedKindPolicy {
195
+ id: string
196
+ version: string
197
+ queue: string
198
+ decidingProfiles: ReadonlyArray<string>
199
+ retention: HostedRetentionPolicy
200
+ displaySchema: JsonValue
201
+ outcomes: ReadonlyArray<HostedOutcomePolicy>
202
+ }
203
+ export interface HostedWorkItemContext {
204
+ requesterReference: string
205
+ kind: string
206
+ version: string
207
+ display: JsonValue
208
+ kindPolicyDigest: string
209
+ outcomes: ReadonlyArray<HostedOutcomePolicy>
210
+ }
211
+ export interface HostedCreateRequest { kind: string; requesterReference: string; display: JsonValue }
212
+ export interface HostedNoteRequest { note: string }
213
+ export interface HostedCancelRequest { reason: string }
214
+ export interface HostedDecisionRequest { outcome: string; reason?: string }
215
+ export interface RequesterHostedItem {
216
+ itemId: string
217
+ requesterReference: string
218
+ kind: string
219
+ version: string
220
+ display: JsonValue
221
+ state: OccurrenceState
222
+ revision: SafeInteger
223
+ kindPolicyDigest: string
224
+ createdAt: string
225
+ updatedAt: string
226
+ }
227
+ export type HostedTerminalResult = {
228
+ itemId: string
229
+ eventId: string
230
+ requesterReference: string
231
+ kindPolicyDigest: string
232
+ terminalAt: string
233
+ } & (
234
+ | { state: 'completed'; outcome: string; actorRef: string }
235
+ | { state: 'cancelled'; cancellationReason: string }
236
+ )
237
+ export interface HostedTerminalQuery { cursor?: string; limit?: SafeInteger }
238
+ export interface HostedPageQuery { cursor?: string; limit?: SafeInteger }
239
+ export interface HostedNote {
240
+ noteId: string
241
+ itemId: string
242
+ note: string
243
+ itemRevision: SafeInteger
244
+ recordedAt: string
245
+ }
246
+ export type HostedHistoryKind = 'created' | 'claimed' | 'assigned' | 'delegated' | 'caseload_moved' | 'released' | 'note_added' | 'completed' | 'cancelled'
247
+ export interface HostedHistoryEntry {
248
+ eventId: string
249
+ itemId: string
250
+ itemRevision: SafeInteger
251
+ kind: HostedHistoryKind
252
+ occurredAt: string
253
+ actorRef?: string
254
+ assignment?: AssignmentContext
255
+ note?: string
256
+ outcome?: string
257
+ reason?: string
258
+ cancellationReason?: string
259
+ }
260
+ export interface HostedAccountabilityRecord {
261
+ itemId: string
262
+ eventId: string
263
+ actorRef: string
264
+ actor: IssuerPrincipal
265
+ profileId: string
266
+ outcome: string
267
+ reason?: string
268
+ recordedAt: string
269
+ retainedUntil: string
270
+ }
271
+ export interface Description {
272
+ projectId: string
273
+ policyVersion: string
274
+ queues: ReadonlyArray<QueueRecord>
275
+ sources: ReadonlyArray<SourcePolicy>
276
+ calendars: ReadonlyArray<CalendarPolicy>
277
+ clocks: ReadonlyArray<ClockPolicy>
278
+ hostedKinds: ReadonlyArray<HostedKindPolicy>
279
+ }
280
+ export interface TeamRecord {
281
+ id: string
282
+ members: ReadonlyArray<DirectoryMember>
283
+ supervisors: ReadonlyArray<DirectoryMember>
284
+ servedQueues: ReadonlyArray<string>
285
+ revision: SafeInteger
286
+ }
287
+ export interface DirectoryTeamUpdateRequest { staff: ReadonlyArray<DirectoryMember>; supervisors: ReadonlyArray<DirectoryMember>; servedQueues: ReadonlyArray<string> }
288
+ export interface DirectoryResponse { revision: SafeInteger; teams: ReadonlyArray<TeamRecord> }
289
+ export interface AbsenceInput { person: IssuerPrincipal; from: string; until: string; cover: IssuerPrincipal }
290
+ export interface AbsenceRecord extends AbsenceInput { absenceId: string; revision: SafeInteger }
291
+ export interface AbsencesQuery { cursor?: string; limit?: SafeInteger }
292
+ export interface AbsenceList { directoryRevision: SafeInteger; items: ReadonlyArray<AbsenceRecord>; nextCursor?: string }
293
+ export interface AssignmentContext { owner?: IssuerPrincipal; assignedBy?: IssuerPrincipal; absenceIds: ReadonlyArray<string>; staffingDiagnostic?: 'no_cover_available' }
294
+ export interface AssignmentRequest { assignee: IssuerPrincipal; reason?: string }
295
+ export interface DelegateRequest { delegate: IssuerPrincipal; reason?: string }
296
+ export interface CaseloadMoveRequest { from: IssuerPrincipal; to: IssuerPrincipal; queueId?: string; reason: string }
297
+ export interface CaseloadItemSelection { itemId: string; expectedRevision: SafeInteger }
298
+ export interface CaseloadApplyRequest { movement: CaseloadMoveRequest; items: ReadonlyArray<CaseloadItemSelection> }
299
+ export interface CaseloadPreviewQuery { cursor?: string; limit?: SafeInteger }
300
+ export interface CaseloadItemResult { itemId: string; result: 'moved' | 'not_visible' | 'not_eligible' | 'attempt_in_progress' | 'conflict'; revision?: SafeInteger }
301
+ export interface BootstrapDirectoryRequest {
302
+ teamId: string
303
+ staff: ReadonlyArray<IssuerPrincipal>
304
+ supervisors: ReadonlyArray<IssuerPrincipal>
305
+ queueId: string
306
+ }
307
+ export interface HoldingsQuery { cursor?: string; limit?: SafeInteger }
308
+ export interface CaseworkOutcome<T> { kind: 'complete'; value: T; traceId: string }
309
+
310
+ export type KnownCaseworkProblemCode =
311
+ | 'absence.cover-cycle'
312
+ | 'absence.invalid-period'
313
+ | 'absence.overlap'
314
+ | 'absence.self-cover'
315
+ | 'authentication.refused'
316
+ | 'clock.recompute-preview-expired' | 'cursor.expired'
317
+ | 'cursor.invalid'
318
+ | 'idempotency.expired'
319
+ | 'idempotency.key-reused'
320
+ | 'operation.not-authorized'
321
+ | 'precondition.failed'
322
+ | 'precondition.required'
323
+ | 'profile.not-authorized'
324
+ | 'profile.not-human'
325
+ | 'request.body-too-large'
326
+ | 'request.invalid'
327
+ | 'request.method-not-allowed'
328
+ | 'request.not-found'
329
+ | 'request.unprocessable'
330
+ | 'request.unsupported-media-type'
331
+ | 'runtime.failure'
332
+ | 'service.unavailable'
333
+ | 'source.bad-gateway'
334
+ | 'source.not-found'
335
+ | 'source.signature-invalid'
336
+ | 'work-item.already-claimed'
337
+ | 'work-item.not-holder'
338
+ | 'work-item.not-offered'
339
+ | 'work-item.not-visible'
340
+ | 'work-item.proposal-changed'
341
+ | 'work-item.recovery-pending'
342
+ | 'work-item.source-unavailable'
343
+ | 'work-item.superseded'
344
+ export type CaseworkProblemCode = KnownCaseworkProblemCode | (string & {})
345
+
346
+ export class CaseworkClientError extends Error {
347
+ readonly kind: 'configuration' | 'invalid_request' | 'transport' | 'problem' | 'protocol'
348
+ readonly code?: CaseworkProblemCode
349
+ readonly detail?: string
350
+ readonly status?: SafeInteger
351
+ readonly traceId?: string
352
+ readonly originalAttemptId?: string
353
+ readonly validation?: {
354
+ readonly path: string
355
+ readonly reason: 'kind_not_allowed' | 'reference_invalid' | 'object_required' | 'maximum_bytes_exceeded' | 'maximum_depth_exceeded' | 'schema_mismatch' | 'outcome_not_declared' | 'reason_required' | 'text_invalid'
356
+ }
357
+ readonly transportKind?: string
358
+ readonly protocolFailure?: string
359
+ }
360
+
361
+ export type ClockRuntimeState = 'running' | 'paused' | 'completed' | 'cancelled' | 'verification_pending' | 'source_facts_missing'
362
+ export type ClockNextEffect =
363
+ | { kind: 'reminder'; id: string; at: string }
364
+ | { kind: 'reassign'; id: string; at: string; because: string; queueId: string }
365
+ export interface ClockOccurrenceView {
366
+ clockOccurrenceId: string
367
+ subject: SubjectRef
368
+ clockId: string
369
+ state: ClockRuntimeState
370
+ policyDigest: string
371
+ calculationGeneration: SafeInteger
372
+ recomputeGeneration: SafeInteger
373
+ anchorAt?: string
374
+ startedAt?: string
375
+ dueAt?: string
376
+ atRiskAt?: string
377
+ completedAt?: string
378
+ nextEffect?: ClockNextEffect
379
+ upcomingEffects?: ReadonlyArray<ClockNextEffect>
380
+ }
381
+ export interface HolidaySetDocument { holidaySet: string; revision: SafeInteger; dates: ReadonlyArray<string> }
382
+ export interface HolidaySetRevisionInput { document: HolidaySetDocument }
383
+ export interface ClockRecomputeRequest { clockId: string; holidaySet: string; holidayRevision: SafeInteger }
384
+ export interface ClockRecomputeChange { clockOccurrenceId: string; itemId: string; expectedCalculationGeneration: SafeInteger; oldDueAt: string; proposedDueAt: string }
385
+ export interface ClockRecomputePreview { previewId: string; clockId: string; holidaySet: string; holidayRevision: SafeInteger; expiresAt: string; changes: ReadonlyArray<ClockRecomputeChange> }
386
+ export interface ClockRecomputeApplyRequest { previewId: string }
387
+ export interface ClockRecomputeResult { previewId: string; appliedOccurrences: ReadonlyArray<string> }
388
+
389
+ export class CaseworkClient {
390
+ constructor(config: CaseworkClientConfig)
391
+ description(token: string, profile: string): Promise<CaseworkOutcome<Description>>
392
+ createHostedItem(token: string, profile: string, idempotencyKey: string, request: HostedCreateRequest): Promise<CaseworkOutcome<RequesterHostedItem>>
393
+ getHostedItem(token: string, profile: string, itemId: string): Promise<CaseworkOutcome<RequesterHostedItem>>
394
+ addHostedNote(token: string, profile: string, itemId: string, expectedRevision: SafeInteger, idempotencyKey: string, note: HostedNoteRequest): Promise<CaseworkOutcome<RequesterHostedItem>>
395
+ requesterHostedNotes(token: string, profile: string, itemId: string, query?: HostedPageQuery | null): Promise<CaseworkOutcome<Page<HostedNote>>>
396
+ cancelHostedItem(token: string, profile: string, itemId: string, expectedRevision: SafeInteger, idempotencyKey: string, cancellation: HostedCancelRequest): Promise<CaseworkOutcome<HostedTerminalResult>>
397
+ hostedTerminalItems(token: string, profile: string, query?: HostedTerminalQuery | null): Promise<CaseworkOutcome<Page<HostedTerminalResult>>>
398
+ listHostedWorkItems(token: string, profile: string, query: ListWorkItemsQuery): Promise<CaseworkOutcome<WorkItemPage>>
399
+ getHostedWorkItem(token: string, profile: string, itemId: string): Promise<CaseworkOutcome<WorkItem>>
400
+ hostedWorkItemHistory(token: string, profile: string, itemId: string, query?: HostedPageQuery | null): Promise<CaseworkOutcome<Page<HostedHistoryEntry>>>
401
+ hostedAccountabilityRecord(token: string, profile: string, eventId: string): Promise<CaseworkOutcome<HostedAccountabilityRecord>>
402
+ claimHostedWorkItem(token: string, profile: string, action: CaseworkAction, idempotencyKey: string): Promise<CaseworkOutcome<MutationResponse>>
403
+ releaseHostedWorkItem(token: string, profile: string, action: CaseworkAction, idempotencyKey: string): Promise<CaseworkOutcome<MutationResponse>>
404
+ decideHostedWorkItem(token: string, profile: string, action: CaseworkAction, idempotencyKey: string, decision: HostedDecisionRequest): Promise<CaseworkOutcome<HostedTerminalResult>>
405
+ listWorkItems(token: string, profile: string, sourceProfile: string, query: ListWorkItemsQuery): Promise<CaseworkOutcome<WorkItemPage>>
406
+ nextWorkItem(token: string, profile: string, sourceProfile: string, query?: NextWorkItemQuery | null): Promise<CaseworkOutcome<WorkItemPage>>
407
+ getWorkItem(token: string, profile: string, sourceProfile: string, itemId: string): Promise<CaseworkOutcome<WorkItem>>
408
+ claimWorkItem(token: string, profile: string, sourceProfile: string, action: CaseworkAction, idempotencyKey: string): Promise<CaseworkOutcome<MutationResponse>>
409
+ releaseWorkItem(token: string, profile: string, sourceProfile: string, action: CaseworkAction, idempotencyKey: string): Promise<CaseworkOutcome<MutationResponse>>
410
+ getDraft(token: string, profile: string, sourceProfile: string, itemId: string): Promise<CaseworkOutcome<DraftResponse>>
411
+ saveDraft(token: string, profile: string, sourceProfile: string, itemId: string, expectedRevision: SafeInteger, idempotencyKey: string, draft: SaveDraftRequest): Promise<CaseworkOutcome<DraftResponse>>
412
+ deleteDraft(token: string, profile: string, sourceProfile: string, itemId: string, expectedRevision: SafeInteger, idempotencyKey: string): Promise<CaseworkOutcome<null>>
413
+ decideWorkItem(token: string, profile: string, sourceProfile: string, action: CaseworkAction, idempotencyKey: string, decision: DecideRequest): Promise<CaseworkOutcome<MutationResponse>>
414
+ recoverDecision(token: string, profile: string, sourceProfile: string, itemId: string, attemptId: string, recovery: RecoverAttemptRequest): Promise<CaseworkOutcome<MutationResponse>>
415
+ recoverDecisionByKey(token: string, profile: string, sourceProfile: string, itemId: string, idempotencyKey: string, recovery: RecoverAttemptRequest): Promise<CaseworkOutcome<MutationResponse>>
416
+ workItemHistory(token: string, profile: string, sourceProfile: string, itemId: string, query?: HostedPageQuery | null): Promise<CaseworkOutcome<Page<HistoryEntry>>>
417
+ holdings(token: string, profile: string, sourceProfile: string, query?: HoldingsQuery | null): Promise<CaseworkOutcome<Page<HoldingSummary>>>
418
+ directory(token: string, profile: string): Promise<CaseworkOutcome<DirectoryResponse>>
419
+ directoryTargets(token: string, profile: string, query: DirectoryTargetsQuery): Promise<CaseworkOutcome<DirectoryTargetPage>>
420
+ bootstrapDirectory(token: string, profile: string, expectedRevision: SafeInteger, idempotencyKey: string, request: BootstrapDirectoryRequest): Promise<CaseworkOutcome<DirectoryResponse>>
421
+ updateDirectoryTeam(token: string, profile: string, teamId: string, expectedRevision: SafeInteger, idempotencyKey: string, request: DirectoryTeamUpdateRequest): Promise<CaseworkOutcome<DirectoryResponse>>
422
+ workItemClocks(token: string, profile: string, sourceProfile: string, itemId: string): Promise<CaseworkOutcome<ReadonlyArray<ClockOccurrenceView>>>
423
+ holidayRevision(token: string, profile: string, holidaySet: string, revision: SafeInteger): Promise<CaseworkOutcome<HolidaySetDocument>>
424
+ createHolidayRevision(token: string, profile: string, idempotencyKey: string, request: HolidaySetRevisionInput): Promise<CaseworkOutcome<HolidaySetDocument>>
425
+ previewClockRecompute(token: string, profile: string, request: ClockRecomputeRequest): Promise<CaseworkOutcome<ClockRecomputePreview>>
426
+ applyClockRecompute(token: string, profile: string, idempotencyKey: string, request: ClockRecomputeApplyRequest): Promise<CaseworkOutcome<ClockRecomputeResult>>
427
+ absences(token: string, profile: string, query?: AbsencesQuery | null): Promise<CaseworkOutcome<AbsenceList>>
428
+ createAbsence(token: string, profile: string, expectedRevision: SafeInteger, idempotencyKey: string, request: AbsenceInput): Promise<CaseworkOutcome<AbsenceRecord>>
429
+ updateAbsence(token: string, profile: string, absenceId: string, expectedRevision: SafeInteger, idempotencyKey: string, request: AbsenceInput): Promise<CaseworkOutcome<AbsenceRecord>>
430
+ deleteAbsence(token: string, profile: string, absenceId: string, expectedRevision: SafeInteger, idempotencyKey: string): Promise<CaseworkOutcome<null>>
431
+ assignWorkItem(token: string, profile: string, itemId: string, expectedRevision: SafeInteger, idempotencyKey: string, request: AssignmentRequest, sourceProfile?: string | null): Promise<CaseworkOutcome<MutationResponse>>
432
+ delegateWorkItem(token: string, profile: string, itemId: string, expectedRevision: SafeInteger, idempotencyKey: string, request: DelegateRequest, sourceProfile?: string | null): Promise<CaseworkOutcome<MutationResponse>>
433
+ previewCaseloadMove(token: string, profile: string, movement: CaseloadMoveRequest, query?: CaseloadPreviewQuery | null, sourceProfile?: string | null): Promise<CaseworkOutcome<Page<WorkItem>>>
434
+ applyCaseloadMove(token: string, profile: string, idempotencyKey: string, request: CaseloadApplyRequest, sourceProfile?: string | null): Promise<CaseworkOutcome<ReadonlyArray<CaseloadItemResult>>>
435
+ }
@@ -0,0 +1,155 @@
1
+ 'use strict';
2
+
3
+ const { types: { isProxy } } = require('node:util');
4
+ const native = require('./index');
5
+
6
+ const MAX_JSON_DEPTH = 64;
7
+ const MAX_JSON_NODES = 20_000;
8
+ const MAX_JSON_STRING_BYTES = 1024 * 1024;
9
+
10
+ class CaseworkClientError extends Error {
11
+ constructor(envelope) {
12
+ super(envelope.message);
13
+ this.name = 'CaseworkClientError';
14
+ this.kind = envelope.kind;
15
+ for (const field of ['code', 'detail', 'status', 'traceId', 'originalAttemptId', 'validation', 'transportKind', 'protocolFailure']) {
16
+ if (envelope[field] !== undefined && envelope[field] !== null) this[field] = envelope[field];
17
+ }
18
+ }
19
+ }
20
+
21
+ function normalized(error, fallbackKind) {
22
+ if (error instanceof CaseworkClientError) return error;
23
+ if (error instanceof Error && typeof error.message === 'string') {
24
+ try {
25
+ const envelope = JSON.parse(error.message);
26
+ if (envelope && typeof envelope.kind === 'string') return new CaseworkClientError(envelope);
27
+ } catch {
28
+ // napi argument conversion errors have no mapped envelope.
29
+ }
30
+ }
31
+ if (fallbackKind) {
32
+ return new CaseworkClientError({
33
+ kind: fallbackKind,
34
+ message: fallbackKind === 'configuration'
35
+ ? 'Casework client configuration is invalid'
36
+ : 'Casework client arguments are invalid',
37
+ });
38
+ }
39
+ return error;
40
+ }
41
+
42
+ function cloneJson(value, budget, depth) {
43
+ if (depth > MAX_JSON_DEPTH || ++budget.nodes > MAX_JSON_NODES) throw normalized({}, 'invalid_request');
44
+ if (value === null || typeof value === 'boolean') return value;
45
+ if (typeof value === 'string') {
46
+ budget.bytes += Buffer.byteLength(value, 'utf8');
47
+ if (budget.bytes > MAX_JSON_STRING_BYTES) throw normalized({}, 'invalid_request');
48
+ return value;
49
+ }
50
+ if (typeof value === 'number') {
51
+ if (!Number.isFinite(value) || (Number.isInteger(value) && !Number.isSafeInteger(value))) {
52
+ throw normalized({}, 'invalid_request');
53
+ }
54
+ return value;
55
+ }
56
+ if (value === undefined || typeof value !== 'object' || isProxy(value)) {
57
+ throw normalized({}, 'invalid_request');
58
+ }
59
+ const array = Array.isArray(value);
60
+ const prototype = Object.getPrototypeOf(value);
61
+ if (array ? prototype !== Array.prototype : prototype !== Object.prototype && prototype !== null) {
62
+ throw normalized({}, 'invalid_request');
63
+ }
64
+ if (budget.active.has(value)) throw normalized({}, 'invalid_request');
65
+ budget.active.add(value);
66
+ try {
67
+ if (array) return value.map((member) => cloneJson(member, budget, depth + 1));
68
+ const result = Object.create(null);
69
+ for (const key of Reflect.ownKeys(value)) {
70
+ if (typeof key !== 'string') throw normalized({}, 'invalid_request');
71
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
72
+ if (!descriptor || !Object.hasOwn(descriptor, 'value')) throw normalized({}, 'invalid_request');
73
+ if (descriptor.enumerable) result[key] = cloneJson(descriptor.value, budget, depth + 1);
74
+ }
75
+ return result;
76
+ } finally {
77
+ budget.active.delete(value);
78
+ }
79
+ }
80
+
81
+ function sanitize(value) {
82
+ return cloneJson(value, { nodes: 0, bytes: 0, active: new WeakSet() }, 0);
83
+ }
84
+
85
+ const NativeCaseworkClient = native.CaseworkClient;
86
+
87
+ class CaseworkClient {
88
+ constructor(config) {
89
+ try {
90
+ this.native = new NativeCaseworkClient(sanitize(config));
91
+ } catch (error) {
92
+ throw normalized(error, 'configuration');
93
+ }
94
+ }
95
+ }
96
+
97
+ for (const [method, jsonIndexes] of [
98
+ ['description', []],
99
+ ['createHostedItem', [3]],
100
+ ['getHostedItem', []],
101
+ ['addHostedNote', [5]],
102
+ ['requesterHostedNotes', [3]],
103
+ ['cancelHostedItem', [5]],
104
+ ['hostedTerminalItems', [2]],
105
+ ['listHostedWorkItems', [2]],
106
+ ['getHostedWorkItem', []],
107
+ ['hostedWorkItemHistory', [3]],
108
+ ['hostedAccountabilityRecord', []],
109
+ ['claimHostedWorkItem', [2]],
110
+ ['releaseHostedWorkItem', [2]],
111
+ ['decideHostedWorkItem', [2, 4]],
112
+ ['listWorkItems', [3]],
113
+ ['nextWorkItem', [3]],
114
+ ['getWorkItem', []],
115
+ ['claimWorkItem', [3]],
116
+ ['releaseWorkItem', [3]],
117
+ ['getDraft', []],
118
+ ['saveDraft', [6]],
119
+ ['deleteDraft', []],
120
+ ['decideWorkItem', [3, 5]],
121
+ ['recoverDecision', [5]],
122
+ ['recoverDecisionByKey', [5]],
123
+ ['workItemHistory', [4]],
124
+ ['holdings', [3]],
125
+ ['directory', []],
126
+ ['directoryTargets', [2]],
127
+ ['bootstrapDirectory', [4]],
128
+ ['updateDirectoryTeam', [5]],
129
+ ['workItemClocks', []],
130
+ ['holidayRevision', []],
131
+ ['createHolidayRevision', [3]],
132
+ ['previewClockRecompute', [2]],
133
+ ['applyClockRecompute', [3]],
134
+ ['absences', [2]],
135
+ ['createAbsence', [4]],
136
+ ['updateAbsence', [5]],
137
+ ['deleteAbsence', []],
138
+ ['assignWorkItem', [5]],
139
+ ['delegateWorkItem', [5]],
140
+ ['previewCaseloadMove', [2, 3]],
141
+ ['applyCaseloadMove', [3]],
142
+ ]) {
143
+ CaseworkClient.prototype[method] = function (...args) {
144
+ try {
145
+ for (const index of jsonIndexes) {
146
+ if (args[index] !== undefined && args[index] !== null) args[index] = sanitize(args[index]);
147
+ }
148
+ return this.native[method](...args).catch((error) => { throw normalized(error); });
149
+ } catch (error) {
150
+ throw normalized(error, 'invalid_request');
151
+ }
152
+ };
153
+ }
154
+
155
+ module.exports = { CaseworkClient, CaseworkClientError };
@@ -0,0 +1,64 @@
1
+ /* auto-generated by NAPI-RS */
2
+ /* eslint-disable */
3
+ export declare class CaseworkClient {
4
+ constructor(config: CaseworkClientConfig)
5
+ description(token: string, profile: string): Promise<CaseworkOutcome>
6
+ createHostedItem(token: string, profile: string, idempotencyKey: string, request: any): Promise<CaseworkOutcome>
7
+ getHostedItem(token: string, profile: string, itemId: string): Promise<CaseworkOutcome>
8
+ addHostedNote(token: string, profile: string, itemId: string, expectedRevision: number, idempotencyKey: string, note: any): Promise<CaseworkOutcome>
9
+ requesterHostedNotes(token: string, profile: string, itemId: string, query?: any | undefined | null): Promise<CaseworkOutcome>
10
+ cancelHostedItem(token: string, profile: string, itemId: string, expectedRevision: number, idempotencyKey: string, cancellation: any): Promise<CaseworkOutcome>
11
+ hostedTerminalItems(token: string, profile: string, query?: any | undefined | null): Promise<CaseworkOutcome>
12
+ listHostedWorkItems(token: string, profile: string, query: any): Promise<CaseworkOutcome>
13
+ getHostedWorkItem(token: string, profile: string, itemId: string): Promise<CaseworkOutcome>
14
+ hostedWorkItemHistory(token: string, profile: string, itemId: string, query?: any | undefined | null): Promise<CaseworkOutcome>
15
+ hostedAccountabilityRecord(token: string, profile: string, eventId: string): Promise<CaseworkOutcome>
16
+ claimHostedWorkItem(token: string, profile: string, action: any, idempotencyKey: string): Promise<CaseworkOutcome>
17
+ releaseHostedWorkItem(token: string, profile: string, action: any, idempotencyKey: string): Promise<CaseworkOutcome>
18
+ decideHostedWorkItem(token: string, profile: string, action: any, idempotencyKey: string, decision: any): Promise<CaseworkOutcome>
19
+ listWorkItems(token: string, profile: string, sourceProfile: string, query: any): Promise<CaseworkOutcome>
20
+ nextWorkItem(token: string, profile: string, sourceProfile: string, query?: any | undefined | null): Promise<CaseworkOutcome>
21
+ getWorkItem(token: string, profile: string, sourceProfile: string, itemId: string): Promise<CaseworkOutcome>
22
+ claimWorkItem(token: string, profile: string, sourceProfile: string, action: any, idempotencyKey: string): Promise<CaseworkOutcome>
23
+ releaseWorkItem(token: string, profile: string, sourceProfile: string, action: any, idempotencyKey: string): Promise<CaseworkOutcome>
24
+ getDraft(token: string, profile: string, sourceProfile: string, itemId: string): Promise<CaseworkOutcome>
25
+ saveDraft(token: string, profile: string, sourceProfile: string, itemId: string, expectedRevision: number, idempotencyKey: string, draft: any): Promise<CaseworkOutcome>
26
+ deleteDraft(token: string, profile: string, sourceProfile: string, itemId: string, expectedRevision: number, idempotencyKey: string): Promise<CaseworkOutcome>
27
+ decideWorkItem(token: string, profile: string, sourceProfile: string, action: any, idempotencyKey: string, decision: any): Promise<CaseworkOutcome>
28
+ recoverDecision(token: string, profile: string, sourceProfile: string, itemId: string, attemptId: string, recovery: any): Promise<CaseworkOutcome>
29
+ recoverDecisionByKey(token: string, profile: string, sourceProfile: string, itemId: string, idempotencyKey: string, recovery: any): Promise<CaseworkOutcome>
30
+ workItemHistory(token: string, profile: string, sourceProfile: string, itemId: string, query?: any | undefined | null): Promise<CaseworkOutcome>
31
+ holdings(token: string, profile: string, sourceProfile: string, query?: any | undefined | null): Promise<CaseworkOutcome>
32
+ directory(token: string, profile: string): Promise<CaseworkOutcome>
33
+ directoryTargets(token: string, profile: string, query: any): Promise<CaseworkOutcome>
34
+ bootstrapDirectory(token: string, profile: string, expectedRevision: number, idempotencyKey: string, bootstrap: any): Promise<CaseworkOutcome>
35
+ absences(token: string, profile: string, query?: any | undefined | null): Promise<CaseworkOutcome>
36
+ createAbsence(token: string, profile: string, expectedRevision: number, idempotencyKey: string, request: any): Promise<CaseworkOutcome>
37
+ updateAbsence(token: string, profile: string, absenceId: string, expectedRevision: number, idempotencyKey: string, request: any): Promise<CaseworkOutcome>
38
+ deleteAbsence(token: string, profile: string, absenceId: string, expectedRevision: number, idempotencyKey: string): Promise<CaseworkOutcome>
39
+ assignWorkItem(token: string, profile: string, itemId: string, expectedRevision: number, idempotencyKey: string, request: any, sourceProfile?: string | undefined | null): Promise<CaseworkOutcome>
40
+ delegateWorkItem(token: string, profile: string, itemId: string, expectedRevision: number, idempotencyKey: string, request: any, sourceProfile?: string | undefined | null): Promise<CaseworkOutcome>
41
+ previewCaseloadMove(token: string, profile: string, movement: any, query?: any | undefined | null, sourceProfile?: string | undefined | null): Promise<CaseworkOutcome>
42
+ applyCaseloadMove(token: string, profile: string, idempotencyKey: string, request: any, sourceProfile?: string | undefined | null): Promise<CaseworkOutcome>
43
+ updateDirectoryTeam(token: string, profile: string, teamId: string, expectedRevision: number, idempotencyKey: string, request: any): Promise<CaseworkOutcome>
44
+ workItemClocks(token: string, profile: string, sourceProfile: string, itemId: string): Promise<CaseworkOutcome>
45
+ holidayRevision(token: string, profile: string, holidaySet: string, revision: number): Promise<CaseworkOutcome>
46
+ createHolidayRevision(token: string, profile: string, idempotencyKey: string, request: any): Promise<CaseworkOutcome>
47
+ previewClockRecompute(token: string, profile: string, request: any): Promise<CaseworkOutcome>
48
+ applyClockRecompute(token: string, profile: string, idempotencyKey: string, request: any): Promise<CaseworkOutcome>
49
+ }
50
+
51
+ export interface CaseworkClientConfig {
52
+ baseUrl: string
53
+ requestTimeoutMilliseconds?: number
54
+ connectTimeoutMilliseconds?: number
55
+ maxResponseBytes?: number
56
+ userAgent?: string
57
+ trustedRootCertificates?: string
58
+ }
59
+
60
+ export interface CaseworkOutcome {
61
+ kind: string
62
+ value: any
63
+ traceId: string
64
+ }
@@ -0,0 +1,3 @@
1
+ 'use strict';
2
+
3
+ module.exports = require('../native').load('casework');
package/index.d.ts CHANGED
@@ -2,5 +2,6 @@ import * as discovery from './discovery/client'
2
2
  import * as evidence from './evidence/client'
3
3
  import * as relay from './relay/client'
4
4
  import * as breg from './breg/client'
5
+ import * as casework from './casework/client'
5
6
 
6
- export { discovery, evidence, relay, breg }
7
+ export { discovery, evidence, relay, breg, casework }