@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.
- package/dist/cjs/assertions.d.ts +1 -0
- package/dist/cjs/assertions.js +13 -1
- package/dist/cjs/services/authProvider/index.d.ts +5 -1
- package/dist/cjs/tsconfig.without-specs.cjs.tsbuildinfo +1 -1
- package/dist/esm/assertions.d.ts +1 -0
- package/dist/esm/assertions.js +11 -0
- package/dist/esm/services/authProvider/index.d.ts +5 -1
- package/dist/esm/tsconfig.without-specs.esm.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/cjs/assertions.d.ts
CHANGED
|
@@ -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;
|
package/dist/cjs/assertions.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assertErrorInstanceOf = exports.assertInstanceOf = exports.notNaN = exports.assertNotNaN = exports.assertString = exports.assertDefined = exports.assertTrue = void 0;
|
|
3
|
+
exports.assertErrorInstanceOf = exports.assertInstanceOf = exports.notNaN = exports.assertNotNaN = exports.assertString = exports.assertDefined = exports.assertFalse = exports.assertTrue = void 0;
|
|
4
4
|
const doThrow = (failed) => {
|
|
5
5
|
if (typeof failed === 'string') {
|
|
6
6
|
throw new Error(failed);
|
|
@@ -25,6 +25,18 @@ const assertTrue = (x, failed) => {
|
|
|
25
25
|
return x;
|
|
26
26
|
};
|
|
27
27
|
exports.assertTrue = assertTrue;
|
|
28
|
+
/*
|
|
29
|
+
* see note above about the failure case in the second argument
|
|
30
|
+
*
|
|
31
|
+
* const definitelyFalse = assertFalse(randomThing);
|
|
32
|
+
*/
|
|
33
|
+
const assertFalse = (x, failed) => {
|
|
34
|
+
if (typeof x !== 'boolean' || x !== false) {
|
|
35
|
+
return doThrow(failed);
|
|
36
|
+
}
|
|
37
|
+
return x;
|
|
38
|
+
};
|
|
39
|
+
exports.assertFalse = assertFalse;
|
|
28
40
|
/*
|
|
29
41
|
* see note above about the failure case in the second argument
|
|
30
42
|
*
|
|
@@ -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
|
|
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
|
/**
|