@oxide/turnstile.ts 0.7.0-rc.0 → 0.7.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/validate.js CHANGED
@@ -91,6 +91,7 @@ var TurnstilePermission = z.preprocess(
91
91
  "WithdrawApplicationsAssigned",
92
92
  "ManageApplicationsAssigned",
93
93
  "ManageApplicationsAll",
94
+ "GetApplicationSummariesAll",
94
95
  "GetDocumentsAssigned",
95
96
  "GetDocumentsAll",
96
97
  "CreateDocument",
@@ -509,15 +510,26 @@ var ApplicationStateRecord = z.preprocess(
509
510
  })
510
511
  );
511
512
  var ListingPoolAssociation = z.preprocess(processResponseBody, z.enum(["first", "early_positive", "positive"]));
513
+ var TriageReason = z.preprocess(
514
+ processResponseBody,
515
+ z.enum([
516
+ "has_no_ratings",
517
+ "likely_next_steps",
518
+ "likely_pass",
519
+ "possibly_next_steps",
520
+ "possibly_pass",
521
+ "very_likely_pass",
522
+ "unknown"
523
+ ])
524
+ );
512
525
  var PoolAction = z.preprocess(
513
526
  processResponseBody,
514
527
  z.union([
528
+ z.enum(["drop", "wait"]),
515
529
  z.object({
516
- "action": z.enum(["add"]),
517
- "association": ListingPoolAssociation,
518
- "count": z.number().min(0).max(4294967295)
530
+ "add": z.object({ "association": ListingPoolAssociation, "count": z.number().min(0).max(4294967295) })
519
531
  }),
520
- z.object({ "action": z.enum(["triage"]) })
532
+ z.object({ "triage": z.object({ "reason": TriageReason }) })
521
533
  ])
522
534
  );
523
535
  var ReviewScore = z.preprocess(
@@ -637,7 +649,7 @@ var CreatePool = z.preprocess(
637
649
  z.object({
638
650
  "description": z.string().optional(),
639
651
  "name": z.string(),
640
- "reviwers": TypedUuidForReviewerId.array().optional()
652
+ "reviewers": TypedUuidForReviewerId.array().optional()
641
653
  })
642
654
  );
643
655
  var CreateReview = z.preprocess(
@@ -658,7 +670,7 @@ var CreateReviewAssignments = z.preprocess(
658
670
  );
659
671
  var ReviewAssignmentCreationError = z.preprocess(
660
672
  processResponseBody,
661
- z.enum(["DoesNotExist", "Forbidden", "Internal"])
673
+ z.enum(["Conflict", "DoesNotExist", "Forbidden", "Internal"])
662
674
  );
663
675
  var TypedUuidForReviewAssignmentId = z.preprocess(processResponseBody, z.string().uuid());
664
676
  var ReviewAssignmentState = z.preprocess(processResponseBody, z.enum(["pending", "complete"]));
@@ -2294,6 +2306,7 @@ export {
2294
2306
  TransitionApplicationToWithdrawnParams,
2295
2307
  TransitionBody,
2296
2308
  TransitionMessage,
2309
+ TriageReason,
2297
2310
  TurnstilePermission,
2298
2311
  TypedUuidForAccessGroupId,
2299
2312
  TypedUuidForApiKeyId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxide/turnstile.ts",
3
- "version": "0.7.0-rc.0",
3
+ "version": "0.7.0",
4
4
  "description": "TypeScript client for the Turnstile API",
5
5
  "engines": {
6
6
  "node": ">=18"
package/src/Api.ts CHANGED
@@ -82,6 +82,7 @@ export type TurnstilePermission =
82
82
  | 'WithdrawApplicationsAssigned'
83
83
  | 'ManageApplicationsAssigned'
84
84
  | 'ManageApplicationsAll'
85
+ | 'GetApplicationSummariesAll'
85
86
  | 'GetDocumentsAssigned'
86
87
  | 'GetDocumentsAll'
87
88
  | 'CreateDocument'
@@ -487,9 +488,20 @@ export type ListingPoolAssociation =
487
488
  | 'early_positive'
488
489
  | 'positive'
489
490
 
491
+ export type TriageReason =
492
+ | 'has_no_ratings'
493
+ | 'likely_next_steps'
494
+ | 'likely_pass'
495
+ | 'possibly_next_steps'
496
+ | 'possibly_pass'
497
+ | 'very_likely_pass'
498
+ | 'unknown'
499
+
490
500
  export type PoolAction =
491
- | { 'action': 'add'; 'association': ListingPoolAssociation; 'count': number }
492
- | { 'action': 'triage' }
501
+ | 'drop'
502
+ | 'wait'
503
+ | { 'add': { 'association': ListingPoolAssociation; 'count': number } }
504
+ | { 'triage': { 'reason': TriageReason } }
493
505
 
494
506
  export type ReviewScore =
495
507
  | 'emphatic_yes'
@@ -527,9 +539,19 @@ export type ApplicationSummariesResponse = { 'summaries': ExpandedApplicationSum
527
539
 
528
540
  export type ApplicationSummaryResponse = { 'summary': ExpandedApplicationSummary; 'users': Evaluator[] }
529
541
 
530
- export type AssignPool = { 'association': ListingPoolAssociation; 'listing': TypedUuidForListingId }
542
+ export type AssignPool = {
543
+ /** Review stage of the listing this pool should be associated to */
544
+ 'association': ListingPoolAssociation
545
+ /** Listing to assign this pool to */
546
+ 'listing': TypedUuidForListingId
547
+ }
531
548
 
532
- export type AttachDocument = { 'externalId': string; 'mime'?: string }
549
+ export type AttachDocument = {
550
+ /** Id assigned to the document by the external datastore */
551
+ 'externalId': string
552
+ /** Mime type of the document */
553
+ 'mime'?: string
554
+ }
533
555
 
534
556
  export type EmailConfig = {
535
557
  'from': string
@@ -544,19 +566,30 @@ export type TransitionMessage =
544
566
  | 'omit'
545
567
  | { 'custom': EmailConfig }
546
568
 
547
- export type TransitionBody = { 'message': TransitionMessage }
569
+ export type TransitionBody = {
570
+ /** The message to send to the applicant */
571
+ 'message': TransitionMessage
572
+ }
548
573
 
549
574
  export type BatchParameter_for_TransitionBody =
550
575
  | { 'all': TransitionBody }
551
576
  | { 'each': TransitionBody[] }
552
577
 
553
- export type ViewApplication = { 'application': TypedUuidForApplicationId }
578
+ export type ViewApplication = {
579
+ /** Application to operate on */
580
+ 'application': TypedUuidForApplicationId
581
+ }
554
582
 
555
583
  export type BatchParameter_for_ViewApplication =
556
584
  | { 'all': ViewApplication }
557
585
  | { 'each': ViewApplication[] }
558
586
 
559
- export type CreateApplication = { 'applicant': TypedUuidForApplicantId; 'listing': TypedUuidForListingId }
587
+ export type CreateApplication = {
588
+ /** Applicant to create an application for */
589
+ 'applicant': TypedUuidForApplicantId
590
+ /** Listing to apply to */
591
+ 'listing': TypedUuidForListingId
592
+ }
560
593
 
561
594
  export type CreateDepartment = { 'name': string }
562
595
 
@@ -577,7 +610,14 @@ export type CreateListing = { 'name': string; 'role': TypedUuidForRoleId; 'statu
577
610
 
578
611
  export type CreateMapper = { 'maxActivations'?: number; 'name': string; 'rule': Record<string, unknown> }
579
612
 
580
- export type CreatePool = { 'description'?: string; 'name': string; 'reviwers'?: TypedUuidForReviewerId[] }
613
+ export type CreatePool = {
614
+ /** Optional description of the pool */
615
+ 'description'?: string
616
+ /** Required display name for the pool */
617
+ 'name': string
618
+ /** List of reviewers to assign to this pool */
619
+ 'reviewers'?: TypedUuidForReviewerId[]
620
+ }
581
621
 
582
622
  export type CreateReview = {
583
623
  'application': TypedUuidForApplicationId
@@ -598,6 +638,8 @@ export type CreateReviewAssignments = { 'reviewers': TypedUuidForReviewerId[] }
598
638
  * Failures that can occur when assigning a reviewer
599
639
  */
600
640
  export type ReviewAssignmentCreationError =
641
+ /** A requested object resource already exist */
642
+ | 'Conflict'
601
643
  /** A requested object resource does not exist */
602
644
  | 'DoesNotExist'
603
645
  /** Caller does not have access to a require object resource */
@@ -940,7 +982,10 @@ export type Operation_for_TurnstilePermission_and_TransitionApplicationToDeferre
940
982
  'updatedAt': Date
941
983
  }
942
984
 
943
- export type OptionalTransitionBody = { 'message'?: EmailConfig }
985
+ export type OptionalTransitionBody = {
986
+ /** An optional message to send to the applicant */
987
+ 'message'?: EmailConfig
988
+ }
944
989
 
945
990
  export type Pool = {
946
991
  'createdAt': Date
@@ -1603,6 +1648,9 @@ export class Api extends HttpClient {
1603
1648
  ...params,
1604
1649
  })
1605
1650
  },
1651
+ /**
1652
+ * View all applications
1653
+ */
1606
1654
  listApplications: (_: EmptyObj, params: FetchParams = {}) => {
1607
1655
  return this.request<Application[]>({
1608
1656
  path: `/application`,
@@ -1610,6 +1658,9 @@ export class Api extends HttpClient {
1610
1658
  ...params,
1611
1659
  })
1612
1660
  },
1661
+ /**
1662
+ * Create a new application
1663
+ */
1613
1664
  createApplication: ({
1614
1665
  body,
1615
1666
  }: { body: CreateApplication }, params: FetchParams = {}) => {
@@ -1620,6 +1671,9 @@ export class Api extends HttpClient {
1620
1671
  ...params,
1621
1672
  })
1622
1673
  },
1674
+ /**
1675
+ * View an application
1676
+ */
1623
1677
  viewApplication: ({
1624
1678
  path,
1625
1679
  }: { path: ViewApplicationPathParams }, params: FetchParams = {}) => {
@@ -1679,6 +1733,9 @@ export class Api extends HttpClient {
1679
1733
  ...params,
1680
1734
  })
1681
1735
  },
1736
+ /**
1737
+ * Attach an uploaded document to an application
1738
+ */
1682
1739
  attachDocument: ({
1683
1740
  path,
1684
1741
  body,
@@ -1690,6 +1747,9 @@ export class Api extends HttpClient {
1690
1747
  ...params,
1691
1748
  })
1692
1749
  },
1750
+ /**
1751
+ * Generate a pre-signed upload url for uploading a document to an application
1752
+ */
1693
1753
  createDocumentUploadUrl: ({
1694
1754
  path,
1695
1755
  }: { path: CreateDocumentUploadUrlPathParams }, params: FetchParams = {}) => {
@@ -1699,6 +1759,9 @@ export class Api extends HttpClient {
1699
1759
  ...params,
1700
1760
  })
1701
1761
  },
1762
+ /**
1763
+ * Retrieve the interview code associated with an application
1764
+ */
1702
1765
  getApplicationInterviewCode: ({
1703
1766
  path,
1704
1767
  }: { path: GetApplicationInterviewCodePathParams }, params: FetchParams = {}) => {
@@ -1720,6 +1783,9 @@ export class Api extends HttpClient {
1720
1783
  ...params,
1721
1784
  })
1722
1785
  },
1786
+ /**
1787
+ * Submit an application that has all required documents attached
1788
+ */
1723
1789
  submitApplication: ({
1724
1790
  path,
1725
1791
  }: { path: SubmitApplicationPathParams }, params: FetchParams = {}) => {
@@ -1729,6 +1795,9 @@ export class Api extends HttpClient {
1729
1795
  ...params,
1730
1796
  })
1731
1797
  },
1798
+ /**
1799
+ * Move an application to the Declined stage
1800
+ */
1732
1801
  transitionApplicationToDeclined: ({
1733
1802
  path,
1734
1803
  body,
@@ -1740,6 +1809,9 @@ export class Api extends HttpClient {
1740
1809
  ...params,
1741
1810
  })
1742
1811
  },
1812
+ /**
1813
+ * Move an application to the Deferred stage
1814
+ */
1743
1815
  transitionApplicationToDeferred: ({
1744
1816
  path,
1745
1817
  body,
@@ -1751,6 +1823,9 @@ export class Api extends HttpClient {
1751
1823
  ...params,
1752
1824
  })
1753
1825
  },
1826
+ /**
1827
+ * Move an application to the Interviewing stage
1828
+ */
1754
1829
  transitionApplicationToInterviewing: (
1755
1830
  {
1756
1831
  path,
@@ -1765,6 +1840,9 @@ export class Api extends HttpClient {
1765
1840
  ...params,
1766
1841
  })
1767
1842
  },
1843
+ /**
1844
+ * Move an application to the Next Steps stage
1845
+ */
1768
1846
  transitionApplicationToNextSteps: (
1769
1847
  {
1770
1848
  path,
@@ -1779,6 +1857,9 @@ export class Api extends HttpClient {
1779
1857
  ...params,
1780
1858
  })
1781
1859
  },
1860
+ /**
1861
+ * Move an application to the Offer stage
1862
+ */
1782
1863
  transitionApplicationToOffer: (
1783
1864
  {
1784
1865
  path,
@@ -1793,6 +1874,9 @@ export class Api extends HttpClient {
1793
1874
  ...params,
1794
1875
  })
1795
1876
  },
1877
+ /**
1878
+ * Move an application to the Withdrawn stage
1879
+ */
1796
1880
  transitionApplicationToWithdrawn: (
1797
1881
  {
1798
1882
  path,
@@ -1807,6 +1891,9 @@ export class Api extends HttpClient {
1807
1891
  ...params,
1808
1892
  })
1809
1893
  },
1894
+ /**
1895
+ * List all application summaries
1896
+ */
1810
1897
  listApplicationSummaries: ({
1811
1898
  query = {},
1812
1899
  }: { query?: ListApplicationSummariesQueryParams }, params: FetchParams = {}) => {
@@ -1817,6 +1904,9 @@ export class Api extends HttpClient {
1817
1904
  ...params,
1818
1905
  })
1819
1906
  },
1907
+ /**
1908
+ * View a summary that includes an application and the related evaluations
1909
+ */
1820
1910
  viewApplicationSummary: ({
1821
1911
  path,
1822
1912
  }: { path: ViewApplicationSummaryPathParams }, params: FetchParams = {}) => {
@@ -2431,6 +2521,9 @@ export class Api extends HttpClient {
2431
2521
  ...params,
2432
2522
  })
2433
2523
  },
2524
+ /**
2525
+ * List reviewer pools and their associations
2526
+ */
2434
2527
  listPools: (_: EmptyObj, params: FetchParams = {}) => {
2435
2528
  return this.request<Pool[]>({
2436
2529
  path: `/pool`,
@@ -2438,6 +2531,9 @@ export class Api extends HttpClient {
2438
2531
  ...params,
2439
2532
  })
2440
2533
  },
2534
+ /**
2535
+ * Create a new pool
2536
+ */
2441
2537
  createPool: ({
2442
2538
  body,
2443
2539
  }: { body: CreatePool }, params: FetchParams = {}) => {
@@ -2448,6 +2544,9 @@ export class Api extends HttpClient {
2448
2544
  ...params,
2449
2545
  })
2450
2546
  },
2547
+ /**
2548
+ * View a pool and its associations
2549
+ */
2451
2550
  viewPool: ({
2452
2551
  path,
2453
2552
  }: { path: ViewPoolPathParams }, params: FetchParams = {}) => {
@@ -2457,6 +2556,9 @@ export class Api extends HttpClient {
2457
2556
  ...params,
2458
2557
  })
2459
2558
  },
2559
+ /**
2560
+ * Update a pool
2561
+ */
2460
2562
  updatePool: ({
2461
2563
  path,
2462
2564
  body,
@@ -2468,17 +2570,23 @@ export class Api extends HttpClient {
2468
2570
  ...params,
2469
2571
  })
2470
2572
  },
2573
+ /**
2574
+ * Assign a pool to a listing
2575
+ */
2471
2576
  assignPool: ({
2472
2577
  path,
2473
2578
  body,
2474
2579
  }: { path: AssignPoolPathParams; body: AssignPool }, params: FetchParams = {}) => {
2475
- return this.request<Pool>({
2580
+ return this.request<ListingPool>({
2476
2581
  path: `/pool/${path.pool}/assignment`,
2477
2582
  method: 'POST',
2478
2583
  body,
2479
2584
  ...params,
2480
2585
  })
2481
2586
  },
2587
+ /**
2588
+ * Unassign a pool from a listing
2589
+ */
2482
2590
  unassignPool: ({
2483
2591
  path,
2484
2592
  }: { path: UnassignPoolPathParams }, params: FetchParams = {}) => {
package/src/validate.ts CHANGED
@@ -100,6 +100,7 @@ export const TurnstilePermission = z.preprocess(
100
100
  'WithdrawApplicationsAssigned',
101
101
  'ManageApplicationsAssigned',
102
102
  'ManageApplicationsAll',
103
+ 'GetApplicationSummariesAll',
103
104
  'GetDocumentsAssigned',
104
105
  'GetDocumentsAll',
105
106
  'CreateDocument',
@@ -557,15 +558,27 @@ export const ApplicationStateRecord = z.preprocess(
557
558
 
558
559
  export const ListingPoolAssociation = z.preprocess(processResponseBody, z.enum(['first', 'early_positive', 'positive']))
559
560
 
561
+ export const TriageReason = z.preprocess(
562
+ processResponseBody,
563
+ z.enum([
564
+ 'has_no_ratings',
565
+ 'likely_next_steps',
566
+ 'likely_pass',
567
+ 'possibly_next_steps',
568
+ 'possibly_pass',
569
+ 'very_likely_pass',
570
+ 'unknown',
571
+ ]),
572
+ )
573
+
560
574
  export const PoolAction = z.preprocess(
561
575
  processResponseBody,
562
576
  z.union([
577
+ z.enum(['drop', 'wait']),
563
578
  z.object({
564
- 'action': z.enum(['add']),
565
- 'association': ListingPoolAssociation,
566
- 'count': z.number().min(0).max(4294967295),
579
+ 'add': z.object({ 'association': ListingPoolAssociation, 'count': z.number().min(0).max(4294967295) }),
567
580
  }),
568
- z.object({ 'action': z.enum(['triage']) }),
581
+ z.object({ 'triage': z.object({ 'reason': TriageReason }) }),
569
582
  ]),
570
583
  )
571
584
 
@@ -706,7 +719,7 @@ export const CreatePool = z.preprocess(
706
719
  z.object({
707
720
  'description': z.string().optional(),
708
721
  'name': z.string(),
709
- 'reviwers': TypedUuidForReviewerId.array().optional(),
722
+ 'reviewers': TypedUuidForReviewerId.array().optional(),
710
723
  }),
711
724
  )
712
725
 
@@ -736,7 +749,7 @@ export const CreateReviewAssignments = z.preprocess(
736
749
  */
737
750
  export const ReviewAssignmentCreationError = z.preprocess(
738
751
  processResponseBody,
739
- z.enum(['DoesNotExist', 'Forbidden', 'Internal']),
752
+ z.enum(['Conflict', 'DoesNotExist', 'Forbidden', 'Internal']),
740
753
  )
741
754
 
742
755
  export const TypedUuidForReviewAssignmentId = z.preprocess(processResponseBody, z.string().uuid())