@oxide/turnstile.ts 0.6.7 → 0.7.0-rc.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/dist/{Api-tAayYJvL.d.cts → Api-Z7zZcVks.d.cts} +145 -34
- package/dist/{Api-tAayYJvL.d.ts → Api-Z7zZcVks.d.ts} +145 -34
- package/dist/Api.cjs +87 -0
- package/dist/Api.d.cts +1 -1
- package/dist/Api.d.ts +1 -1
- package/dist/Api.js +87 -0
- package/dist/retry.cjs +87 -0
- package/dist/retry.d.cts +1 -1
- package/dist/retry.d.ts +1 -1
- package/dist/retry.js +87 -0
- package/dist/validate.cjs +196 -41
- package/dist/validate.d.cts +1438 -663
- package/dist/validate.d.ts +1438 -663
- package/dist/validate.js +180 -41
- package/package.json +1 -1
- package/src/Api.ts +200 -32
- package/src/util.ts +1 -1
- package/src/validate.ts +195 -47
package/src/Api.ts
CHANGED
|
@@ -36,6 +36,8 @@ export type TypedUuidForRoleId = string
|
|
|
36
36
|
|
|
37
37
|
export type TypedUuidForListingId = string
|
|
38
38
|
|
|
39
|
+
export type TypedUuidForPoolId = string
|
|
40
|
+
|
|
39
41
|
export type TypedUuidForReviewerId = string
|
|
40
42
|
|
|
41
43
|
export type TypedUuidForReviewId = string
|
|
@@ -97,6 +99,10 @@ export type TurnstilePermission =
|
|
|
97
99
|
| 'GetListingsAll'
|
|
98
100
|
| 'CreateListing'
|
|
99
101
|
| 'ManageListingsAll'
|
|
102
|
+
| 'GetPoolsAssigned'
|
|
103
|
+
| 'GetPoolsAll'
|
|
104
|
+
| 'CreatePool'
|
|
105
|
+
| 'ManagePoolsAll'
|
|
100
106
|
| 'GetReviewersAssigned'
|
|
101
107
|
| 'GetReviewersAll'
|
|
102
108
|
| 'GetReviewerSelf'
|
|
@@ -206,6 +212,8 @@ export type TurnstilePermission =
|
|
|
206
212
|
| { 'GetRoles': TypedUuidForRoleId[] }
|
|
207
213
|
| { 'GetListing': TypedUuidForListingId }
|
|
208
214
|
| { 'GetListings': TypedUuidForListingId[] }
|
|
215
|
+
| { 'GetPool': TypedUuidForPoolId }
|
|
216
|
+
| { 'GetPools': TypedUuidForPoolId[] }
|
|
209
217
|
| { 'GetReviewer': TypedUuidForReviewerId }
|
|
210
218
|
| { 'GetReviewers': TypedUuidForReviewerId[] }
|
|
211
219
|
| { 'CreateReviewer': TypedUuidForUserId }
|
|
@@ -474,6 +482,15 @@ export type ApplicationStateRecord = {
|
|
|
474
482
|
'updatedAt': Date
|
|
475
483
|
}
|
|
476
484
|
|
|
485
|
+
export type ListingPoolAssociation =
|
|
486
|
+
| 'first'
|
|
487
|
+
| 'early_positive'
|
|
488
|
+
| 'positive'
|
|
489
|
+
|
|
490
|
+
export type PoolAction =
|
|
491
|
+
| { 'action': 'add'; 'association': ListingPoolAssociation; 'count': number }
|
|
492
|
+
| { 'action': 'triage' }
|
|
493
|
+
|
|
477
494
|
export type ReviewScore =
|
|
478
495
|
| 'emphatic_yes'
|
|
479
496
|
| 'yes'
|
|
@@ -491,6 +508,7 @@ export type Reviews = {
|
|
|
491
508
|
}
|
|
492
509
|
|
|
493
510
|
export type ExpandedApplicationSummary = {
|
|
511
|
+
'action': PoolAction
|
|
494
512
|
'applicant': ApplicantInfo
|
|
495
513
|
'application': Application
|
|
496
514
|
'documents': Document[]
|
|
@@ -509,6 +527,8 @@ export type ApplicationSummariesResponse = { 'summaries': ExpandedApplicationSum
|
|
|
509
527
|
|
|
510
528
|
export type ApplicationSummaryResponse = { 'summary': ExpandedApplicationSummary; 'users': Evaluator[] }
|
|
511
529
|
|
|
530
|
+
export type AssignPool = { 'association': ListingPoolAssociation; 'listing': TypedUuidForListingId }
|
|
531
|
+
|
|
512
532
|
export type AttachDocument = { 'externalId': string; 'mime'?: string }
|
|
513
533
|
|
|
514
534
|
export type EmailConfig = {
|
|
@@ -557,6 +577,8 @@ export type CreateListing = { 'name': string; 'role': TypedUuidForRoleId; 'statu
|
|
|
557
577
|
|
|
558
578
|
export type CreateMapper = { 'maxActivations'?: number; 'name': string; 'rule': Record<string, unknown> }
|
|
559
579
|
|
|
580
|
+
export type CreatePool = { 'description'?: string; 'name': string; 'reviwers'?: TypedUuidForReviewerId[] }
|
|
581
|
+
|
|
560
582
|
export type CreateReview = {
|
|
561
583
|
'application': TypedUuidForApplicationId
|
|
562
584
|
'content': string
|
|
@@ -572,9 +594,15 @@ export type CreateReview = {
|
|
|
572
594
|
*/
|
|
573
595
|
export type CreateReviewAssignments = { 'reviewers': TypedUuidForReviewerId[] }
|
|
574
596
|
|
|
597
|
+
/**
|
|
598
|
+
* Failures that can occur when assigning a reviewer
|
|
599
|
+
*/
|
|
575
600
|
export type ReviewAssignmentCreationError =
|
|
601
|
+
/** A requested object resource does not exist */
|
|
576
602
|
| 'DoesNotExist'
|
|
603
|
+
/** Caller does not have access to a require object resource */
|
|
577
604
|
| 'Forbidden'
|
|
605
|
+
/** Internal server error */
|
|
578
606
|
| 'Internal'
|
|
579
607
|
|
|
580
608
|
export type TypedUuidForReviewAssignmentId = string
|
|
@@ -593,37 +621,14 @@ export type ReviewAssignment = {
|
|
|
593
621
|
'updatedAt': Date
|
|
594
622
|
}
|
|
595
623
|
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
export type RenderedEmail = { 'from': string; 'html'?: string; 'name': string; 'subject': string; 'text': string }
|
|
601
|
-
|
|
602
|
-
export type RecipientId =
|
|
603
|
-
| { 'Applicant': TypedUuidForApplicantId }
|
|
604
|
-
| { 'Custom': string }
|
|
605
|
-
| { 'Reviewer': TypedUuidForReviewerId }
|
|
606
|
-
|
|
607
|
-
export type NotificationStatus =
|
|
608
|
-
| 'Failed'
|
|
609
|
-
| 'Pending'
|
|
610
|
-
| 'Scheduled'
|
|
611
|
-
| 'Sent'
|
|
612
|
-
|
|
613
|
-
export type Notification_for_RenderedEmail = {
|
|
614
|
-
'createdAt': Date
|
|
615
|
-
'deletedAt'?: Date
|
|
616
|
-
'id': TypedUuidForNotificationId
|
|
617
|
-
'kind': string
|
|
618
|
-
'medium': NotificationMedium
|
|
619
|
-
'message'?: RenderedEmail
|
|
620
|
-
'recipient': RecipientId
|
|
621
|
-
'status': NotificationStatus
|
|
622
|
-
'updatedAt': Date
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
export type CreatedAssignment = { 'assignment': ReviewAssignment; 'notification': Notification_for_RenderedEmail }
|
|
624
|
+
/**
|
|
625
|
+
* Wrapper containing the assignment object
|
|
626
|
+
*/
|
|
627
|
+
export type CreatedAssignment = { 'assignment': ReviewAssignment }
|
|
626
628
|
|
|
629
|
+
/**
|
|
630
|
+
* Aggregate collection of results indexed by the reviewer ids that were requested to be assigned to the applcation
|
|
631
|
+
*/
|
|
627
632
|
export type CreateReviewAssignmentsResponse = {
|
|
628
633
|
'failure': Record<string, ReviewAssignmentCreationError>
|
|
629
634
|
'success': Record<string, CreatedAssignment>
|
|
@@ -722,6 +727,18 @@ export type Listing = {
|
|
|
722
727
|
'updatedAt': Date
|
|
723
728
|
}
|
|
724
729
|
|
|
730
|
+
export type TypedUuidForListingPoolId = string
|
|
731
|
+
|
|
732
|
+
export type ListingPool = {
|
|
733
|
+
'association': ListingPoolAssociation
|
|
734
|
+
'createdAt': Date
|
|
735
|
+
'deletedAt'?: Date
|
|
736
|
+
'id': TypedUuidForListingPoolId
|
|
737
|
+
'listingId': TypedUuidForListingId
|
|
738
|
+
'poolId': TypedUuidForPoolId
|
|
739
|
+
'updatedAt': Date
|
|
740
|
+
}
|
|
741
|
+
|
|
725
742
|
export type TypedUuidForMagicLinkRedirectUriId = string
|
|
726
743
|
|
|
727
744
|
export type MagicLinkRedirectUri = {
|
|
@@ -783,9 +800,38 @@ export type Mapper = {
|
|
|
783
800
|
'updatedAt': Date
|
|
784
801
|
}
|
|
785
802
|
|
|
803
|
+
export type NotificationMedium = 'Email'
|
|
804
|
+
|
|
805
|
+
export type NotificationStatus =
|
|
806
|
+
| 'Failed'
|
|
807
|
+
| 'Pending'
|
|
808
|
+
| 'Scheduled'
|
|
809
|
+
| 'Sent'
|
|
810
|
+
|
|
811
|
+
export type TypedUuidForNotificationId = string
|
|
812
|
+
|
|
813
|
+
export type RenderedEmail = { 'from': string; 'html'?: string; 'name': string; 'subject': string; 'text': string }
|
|
814
|
+
|
|
815
|
+
export type RecipientId =
|
|
816
|
+
| { 'Applicant': TypedUuidForApplicantId }
|
|
817
|
+
| { 'Custom': string }
|
|
818
|
+
| { 'Reviewer': TypedUuidForReviewerId }
|
|
819
|
+
|
|
820
|
+
export type Notification_for_RenderedEmail = {
|
|
821
|
+
'createdAt': Date
|
|
822
|
+
'deletedAt'?: Date
|
|
823
|
+
'id': TypedUuidForNotificationId
|
|
824
|
+
'kind': string
|
|
825
|
+
'medium': NotificationMedium
|
|
826
|
+
'message'?: RenderedEmail
|
|
827
|
+
'recipient': RecipientId
|
|
828
|
+
'status': NotificationStatus
|
|
829
|
+
'updatedAt': Date
|
|
830
|
+
}
|
|
831
|
+
|
|
786
832
|
export type OAuthAuthzCodeExchangeBody = {
|
|
787
|
-
'clientId'
|
|
788
|
-
'clientSecret'
|
|
833
|
+
'clientId'?: TypedUuidForOAuthClientId
|
|
834
|
+
'clientSecret'?: SecretString
|
|
789
835
|
'code': string
|
|
790
836
|
'grantType': string
|
|
791
837
|
'pkceVerifier'?: string
|
|
@@ -896,6 +942,17 @@ export type Operation_for_TurnstilePermission_and_TransitionApplicationToDeferre
|
|
|
896
942
|
|
|
897
943
|
export type OptionalTransitionBody = { 'message'?: EmailConfig }
|
|
898
944
|
|
|
945
|
+
export type Pool = {
|
|
946
|
+
'createdAt': Date
|
|
947
|
+
'deletedAt'?: Date
|
|
948
|
+
'description'?: string
|
|
949
|
+
'id': TypedUuidForPoolId
|
|
950
|
+
'listings': ListingPool[]
|
|
951
|
+
'name': string
|
|
952
|
+
'reviewers': TypedUuidForReviewerId[]
|
|
953
|
+
'updatedAt': Date
|
|
954
|
+
}
|
|
955
|
+
|
|
899
956
|
export type RegisterApplicant = { 'email': string }
|
|
900
957
|
|
|
901
958
|
export type Review = {
|
|
@@ -1035,6 +1092,10 @@ export interface ViewApplicationPathParams {
|
|
|
1035
1092
|
application: TypedUuidForApplicationId
|
|
1036
1093
|
}
|
|
1037
1094
|
|
|
1095
|
+
export interface ApplyReviewActionPathParams {
|
|
1096
|
+
application: TypedUuidForApplicationId
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1038
1099
|
export interface ListApplicationReviewAssignmentsPathParams {
|
|
1039
1100
|
application: TypedUuidForApplicationId
|
|
1040
1101
|
}
|
|
@@ -1063,6 +1124,10 @@ export interface GetApplicationInterviewCodePathParams {
|
|
|
1063
1124
|
application: TypedUuidForApplicationId
|
|
1064
1125
|
}
|
|
1065
1126
|
|
|
1127
|
+
export interface SimulateReviewActionPathParams {
|
|
1128
|
+
application: TypedUuidForApplicationId
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1066
1131
|
export interface SubmitApplicationPathParams {
|
|
1067
1132
|
application: TypedUuidForApplicationId
|
|
1068
1133
|
}
|
|
@@ -1277,6 +1342,22 @@ export interface DeleteOauthClientSecretPathParams {
|
|
|
1277
1342
|
secretId: TypedUuidForOAuthSecretId
|
|
1278
1343
|
}
|
|
1279
1344
|
|
|
1345
|
+
export interface ViewPoolPathParams {
|
|
1346
|
+
pool: TypedUuidForPoolId
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
export interface UpdatePoolPathParams {
|
|
1350
|
+
pool: TypedUuidForPoolId
|
|
1351
|
+
}
|
|
1352
|
+
|
|
1353
|
+
export interface AssignPoolPathParams {
|
|
1354
|
+
pool: TypedUuidForPoolId
|
|
1355
|
+
}
|
|
1356
|
+
|
|
1357
|
+
export interface UnassignPoolPathParams {
|
|
1358
|
+
assignment: TypedUuidForListingPoolId
|
|
1359
|
+
}
|
|
1360
|
+
|
|
1280
1361
|
export interface ListReviewsQueryParams {
|
|
1281
1362
|
application?: TypedUuidForApplicationId
|
|
1282
1363
|
reviewer?: TypedUuidForReviewerId
|
|
@@ -1548,6 +1629,21 @@ export class Api extends HttpClient {
|
|
|
1548
1629
|
...params,
|
|
1549
1630
|
})
|
|
1550
1631
|
},
|
|
1632
|
+
/**
|
|
1633
|
+
* Compute the next review action to take on this application and apply the necessary changes
|
|
1634
|
+
*/
|
|
1635
|
+
applyReviewAction: ({
|
|
1636
|
+
path,
|
|
1637
|
+
}: { path: ApplyReviewActionPathParams }, params: FetchParams = {}) => {
|
|
1638
|
+
return this.request<ReviewAssignment[]>({
|
|
1639
|
+
path: `/application/${path.application}/apply-review-action`,
|
|
1640
|
+
method: 'POST',
|
|
1641
|
+
...params,
|
|
1642
|
+
})
|
|
1643
|
+
},
|
|
1644
|
+
/**
|
|
1645
|
+
* List the individual reviewers that are assigned to this application
|
|
1646
|
+
*/
|
|
1551
1647
|
listApplicationReviewAssignments: ({
|
|
1552
1648
|
path,
|
|
1553
1649
|
}: { path: ListApplicationReviewAssignmentsPathParams }, params: FetchParams = {}) => {
|
|
@@ -1557,6 +1653,9 @@ export class Api extends HttpClient {
|
|
|
1557
1653
|
...params,
|
|
1558
1654
|
})
|
|
1559
1655
|
},
|
|
1656
|
+
/**
|
|
1657
|
+
* Assign individual reviewers to this application
|
|
1658
|
+
*/
|
|
1560
1659
|
createApplicationReviewAssignments: (
|
|
1561
1660
|
{
|
|
1562
1661
|
path,
|
|
@@ -1609,6 +1708,18 @@ export class Api extends HttpClient {
|
|
|
1609
1708
|
...params,
|
|
1610
1709
|
})
|
|
1611
1710
|
},
|
|
1711
|
+
/**
|
|
1712
|
+
* Simulate the selection of the next review action without performing any changes
|
|
1713
|
+
*/
|
|
1714
|
+
simulateReviewAction: ({
|
|
1715
|
+
path,
|
|
1716
|
+
}: { path: SimulateReviewActionPathParams }, params: FetchParams = {}) => {
|
|
1717
|
+
return this.request<PoolAction>({
|
|
1718
|
+
path: `/application/${path.application}/simulate-review-action`,
|
|
1719
|
+
method: 'GET',
|
|
1720
|
+
...params,
|
|
1721
|
+
})
|
|
1722
|
+
},
|
|
1612
1723
|
submitApplication: ({
|
|
1613
1724
|
path,
|
|
1614
1725
|
}: { path: SubmitApplicationPathParams }, params: FetchParams = {}) => {
|
|
@@ -2320,6 +2431,63 @@ export class Api extends HttpClient {
|
|
|
2320
2431
|
...params,
|
|
2321
2432
|
})
|
|
2322
2433
|
},
|
|
2434
|
+
listPools: (_: EmptyObj, params: FetchParams = {}) => {
|
|
2435
|
+
return this.request<Pool[]>({
|
|
2436
|
+
path: `/pool`,
|
|
2437
|
+
method: 'GET',
|
|
2438
|
+
...params,
|
|
2439
|
+
})
|
|
2440
|
+
},
|
|
2441
|
+
createPool: ({
|
|
2442
|
+
body,
|
|
2443
|
+
}: { body: CreatePool }, params: FetchParams = {}) => {
|
|
2444
|
+
return this.request<Pool>({
|
|
2445
|
+
path: `/pool`,
|
|
2446
|
+
method: 'POST',
|
|
2447
|
+
body,
|
|
2448
|
+
...params,
|
|
2449
|
+
})
|
|
2450
|
+
},
|
|
2451
|
+
viewPool: ({
|
|
2452
|
+
path,
|
|
2453
|
+
}: { path: ViewPoolPathParams }, params: FetchParams = {}) => {
|
|
2454
|
+
return this.request<Pool>({
|
|
2455
|
+
path: `/pool/${path.pool}`,
|
|
2456
|
+
method: 'GET',
|
|
2457
|
+
...params,
|
|
2458
|
+
})
|
|
2459
|
+
},
|
|
2460
|
+
updatePool: ({
|
|
2461
|
+
path,
|
|
2462
|
+
body,
|
|
2463
|
+
}: { path: UpdatePoolPathParams; body: CreatePool }, params: FetchParams = {}) => {
|
|
2464
|
+
return this.request<Pool>({
|
|
2465
|
+
path: `/pool/${path.pool}`,
|
|
2466
|
+
method: 'POST',
|
|
2467
|
+
body,
|
|
2468
|
+
...params,
|
|
2469
|
+
})
|
|
2470
|
+
},
|
|
2471
|
+
assignPool: ({
|
|
2472
|
+
path,
|
|
2473
|
+
body,
|
|
2474
|
+
}: { path: AssignPoolPathParams; body: AssignPool }, params: FetchParams = {}) => {
|
|
2475
|
+
return this.request<Pool>({
|
|
2476
|
+
path: `/pool/${path.pool}/assignment`,
|
|
2477
|
+
method: 'POST',
|
|
2478
|
+
body,
|
|
2479
|
+
...params,
|
|
2480
|
+
})
|
|
2481
|
+
},
|
|
2482
|
+
unassignPool: ({
|
|
2483
|
+
path,
|
|
2484
|
+
}: { path: UnassignPoolPathParams }, params: FetchParams = {}) => {
|
|
2485
|
+
return this.request<void>({
|
|
2486
|
+
path: `/pool-assignment/${path.assignment}`,
|
|
2487
|
+
method: 'DELETE',
|
|
2488
|
+
...params,
|
|
2489
|
+
})
|
|
2490
|
+
},
|
|
2323
2491
|
listReviews: ({
|
|
2324
2492
|
query = {},
|
|
2325
2493
|
}: { query?: ListReviewsQueryParams }, params: FetchParams = {}) => {
|
package/src/util.ts
CHANGED
|
@@ -43,7 +43,7 @@ export const mapObj = (
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
export const parseIfDate = (k: string | undefined, v: unknown) => {
|
|
46
|
-
|
|
46
|
+
if (typeof v === 'string' && (k?.startsWith('time_') || k === 'timestamp' || k?.endsWith('_at') || k?.endsWith('_time'))) {
|
|
47
47
|
const d = new Date(v)
|
|
48
48
|
if (isNaN(d.getTime())) { return v }
|
|
49
49
|
return d
|