@openstax/ts-utils 1.1.35 → 1.1.37

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.
@@ -1,5 +1,6 @@
1
1
  declare type AssertionFailed = string | Error | (() => never) | undefined;
2
2
  export declare const assertTrue: <X>(x: X, failed?: AssertionFailed) => X & true;
3
+ export declare const assertFalse: <X>(x: X, failed?: AssertionFailed) => X & false;
3
4
  export declare const assertDefined: <X>(x: X, failed?: AssertionFailed) => Exclude<X, undefined>;
4
5
  export declare const assertString: <X>(x: X, failed?: AssertionFailed) => string;
5
6
  export declare const assertNotNaN: <T>(thing: T, failed?: AssertionFailed) => T;
@@ -21,6 +21,17 @@ export const assertTrue = (x, failed) => {
21
21
  }
22
22
  return x;
23
23
  };
24
+ /*
25
+ * see note above about the failure case in the second argument
26
+ *
27
+ * const definitelyFalse = assertFalse(randomThing);
28
+ */
29
+ export const assertFalse = (x, failed) => {
30
+ if (typeof x !== 'boolean' || x !== false) {
31
+ return doThrow(failed);
32
+ }
33
+ return x;
34
+ };
24
35
  /*
25
36
  * see note above about the failure case in the second argument
26
37
  *
@@ -1,7 +1,7 @@
1
1
  import type { FetchConfig } from '../../fetch';
2
2
  import type { Track } from '../../profile';
3
3
  import type { HttpHeaders } from '../../routing';
4
- export interface User {
4
+ export interface TokenUser {
5
5
  id: number;
6
6
  name: string;
7
7
  first_name: string;
@@ -10,6 +10,8 @@ export interface User {
10
10
  uuid: string;
11
11
  faculty_status: string;
12
12
  is_administrator: boolean;
13
+ }
14
+ export interface ApiUser extends TokenUser {
13
15
  is_not_gdpr_location: boolean;
14
16
  contact_infos: Array<{
15
17
  type: string;
@@ -17,7 +19,9 @@ export interface User {
17
19
  is_verified: boolean;
18
20
  is_guessed_preferred: boolean;
19
21
  }>;
22
+ signed_contract_names: string[];
20
23
  }
24
+ export declare type User = TokenUser | ApiUser;
21
25
  export declare type AuthProvider = {
22
26
  getUser: () => Promise<User | undefined>;
23
27
  /**