@quesmed/types 1.4.22 → 1.4.26
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/index.d.ts +1 -0
- package/index.js +5 -4
- package/index.mjs +1 -0
- package/models/User.d.ts +10 -0
- package/models/User.js +68 -0
- package/models/User.mjs +65 -1
- package/models/index.d.ts +1 -1
- package/models/index.js +1 -1
- package/models/index.mjs +1 -1
- package/package.json +3 -2
- package/resolvers/subscription/osce.d.ts +4 -1
- package/utils/index.d.ts +1 -0
- package/utils/index.js +1 -0
- package/utils/index.mjs +1 -0
- package/utils/webSocketLink.d.ts +7 -0
- package/utils/webSocketLink.js +22 -0
- package/utils/webSocketLink.mjs +18 -0
- package/test.d.ts +0 -0
- package/test.js +0 -1
- package/test.mjs +0 -1
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -11,9 +11,6 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
11
11
|
}) : function(o, v) {
|
|
12
12
|
o["default"] = v;
|
|
13
13
|
});
|
|
14
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
|
-
};
|
|
17
14
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
18
15
|
if (mod && mod.__esModule) return mod;
|
|
19
16
|
var result = {};
|
|
@@ -21,8 +18,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
21
18
|
__setModuleDefault(result, mod);
|
|
22
19
|
return result;
|
|
23
20
|
};
|
|
21
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
22
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
23
|
+
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.termsAndConditions = exports.EPlatformId = exports.FCM_TOPICS = exports.ERRORS = exports.utils = void 0;
|
|
25
|
+
exports.termsAndConditions = exports.EPlatformId = exports.FCM_TOPICS = exports.ERRORS = exports.utils = exports.Models = void 0;
|
|
26
|
+
exports.Models = __importStar(require("./models"));
|
|
26
27
|
__exportStar(require("./resolvers"), exports);
|
|
27
28
|
exports.utils = __importStar(require("./utils"));
|
|
28
29
|
exports.ERRORS = {
|
package/index.mjs
CHANGED
package/models/User.d.ts
CHANGED
|
@@ -6,6 +6,14 @@ import { ISubscription } from './Subscription';
|
|
|
6
6
|
import { ITopic } from './Topic';
|
|
7
7
|
import { Id } from './Type';
|
|
8
8
|
export declare type IClassYear = 'Year 1' | 'Year 2' | 'Year 3' | 'Year 4' | 'Year 5' | 'Graduated' | 'PhD' | 'BSc' | 'MSc' | 'Beta Tester';
|
|
9
|
+
export declare const classYears: IClassYear[];
|
|
10
|
+
export declare enum EClassYearGroup {
|
|
11
|
+
PRECLINICAL = 0,
|
|
12
|
+
CLINICAL = 1
|
|
13
|
+
}
|
|
14
|
+
export declare const classYearGroup: {
|
|
15
|
+
[key: string]: EClassYearGroup;
|
|
16
|
+
};
|
|
9
17
|
export interface IPayload {
|
|
10
18
|
id: Id;
|
|
11
19
|
displayName: string;
|
|
@@ -46,6 +54,8 @@ export interface IUser {
|
|
|
46
54
|
stripeSubscriptionEndDate: number | Date | null;
|
|
47
55
|
stripePriceNickname: string | null;
|
|
48
56
|
}
|
|
57
|
+
export declare function currentClassYear(createdAtUnix: number, classYear: IClassYear): IClassYear;
|
|
58
|
+
export declare function currentClassGroup(createdAtUnix: number, classYear: IClassYear): EClassYearGroup;
|
|
49
59
|
export interface IUserCompletedQuestions {
|
|
50
60
|
id: Id;
|
|
51
61
|
createdAt: number | Date;
|
package/models/User.js
CHANGED
|
@@ -1,2 +1,70 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.currentClassGroup = exports.currentClassYear = exports.classYearGroup = exports.EClassYearGroup = exports.classYears = void 0;
|
|
4
|
+
exports.classYears = [
|
|
5
|
+
'Year 1',
|
|
6
|
+
'Year 2',
|
|
7
|
+
'Year 3',
|
|
8
|
+
'Year 4',
|
|
9
|
+
'Year 5',
|
|
10
|
+
'Graduated',
|
|
11
|
+
];
|
|
12
|
+
var EClassYearGroup;
|
|
13
|
+
(function (EClassYearGroup) {
|
|
14
|
+
EClassYearGroup[EClassYearGroup["PRECLINICAL"] = 0] = "PRECLINICAL";
|
|
15
|
+
EClassYearGroup[EClassYearGroup["CLINICAL"] = 1] = "CLINICAL";
|
|
16
|
+
})(EClassYearGroup = exports.EClassYearGroup || (exports.EClassYearGroup = {}));
|
|
17
|
+
exports.classYearGroup = {
|
|
18
|
+
'Year 1': EClassYearGroup.PRECLINICAL,
|
|
19
|
+
'Year 2': EClassYearGroup.PRECLINICAL,
|
|
20
|
+
'Year 3': EClassYearGroup.CLINICAL,
|
|
21
|
+
'Year 4': EClassYearGroup.CLINICAL,
|
|
22
|
+
'Year 5': EClassYearGroup.CLINICAL,
|
|
23
|
+
Graduated: EClassYearGroup.CLINICAL,
|
|
24
|
+
PhD: EClassYearGroup.CLINICAL,
|
|
25
|
+
BSc: EClassYearGroup.PRECLINICAL,
|
|
26
|
+
MSc: EClassYearGroup.CLINICAL,
|
|
27
|
+
'Beta Tester': EClassYearGroup.CLINICAL,
|
|
28
|
+
};
|
|
29
|
+
function currentClassYear(createdAtUnix, classYear) {
|
|
30
|
+
if (createdAtUnix === 0) {
|
|
31
|
+
throw new Error('createdAt not given in Unix');
|
|
32
|
+
}
|
|
33
|
+
if (!createdAtUnix) {
|
|
34
|
+
return classYear;
|
|
35
|
+
}
|
|
36
|
+
const lastClassYearIdx = exports.classYears.length - 1;
|
|
37
|
+
const classYearsIdx = exports.classYears.findIndex((x) => x === classYear);
|
|
38
|
+
if (classYearsIdx === -1) {
|
|
39
|
+
return exports.classYears[lastClassYearIdx];
|
|
40
|
+
}
|
|
41
|
+
const now = new Date();
|
|
42
|
+
const currentYear = now.getFullYear();
|
|
43
|
+
const createdAt = new Date(createdAtUnix * 1000);
|
|
44
|
+
if (createdAt.getFullYear() > now.getFullYear()) {
|
|
45
|
+
throw new Error('createdAt not given in Unix');
|
|
46
|
+
}
|
|
47
|
+
const createdYear = createdAt.getFullYear();
|
|
48
|
+
let yearsAdded = currentYear - createdYear;
|
|
49
|
+
const createdAcademicYear = new Date(createdYear, 7, 1);
|
|
50
|
+
const nowAcademicYear = new Date(currentYear, 7, 1);
|
|
51
|
+
if (createdAt > createdAcademicYear) {
|
|
52
|
+
yearsAdded--;
|
|
53
|
+
}
|
|
54
|
+
if (now > nowAcademicYear) {
|
|
55
|
+
yearsAdded++;
|
|
56
|
+
}
|
|
57
|
+
const newClassYearIdx = classYearsIdx + yearsAdded;
|
|
58
|
+
return newClassYearIdx > lastClassYearIdx
|
|
59
|
+
? exports.classYears[lastClassYearIdx]
|
|
60
|
+
: exports.classYears[newClassYearIdx];
|
|
61
|
+
}
|
|
62
|
+
exports.currentClassYear = currentClassYear;
|
|
63
|
+
function currentClassGroup(createdAtUnix, classYear) {
|
|
64
|
+
const currentClass = currentClassYear(createdAtUnix, classYear);
|
|
65
|
+
if (!exports.classYearGroup.hasOwnProperty(currentClass)) {
|
|
66
|
+
return EClassYearGroup.CLINICAL;
|
|
67
|
+
}
|
|
68
|
+
return exports.classYearGroup[currentClass];
|
|
69
|
+
}
|
|
70
|
+
exports.currentClassGroup = currentClassGroup;
|
package/models/User.mjs
CHANGED
|
@@ -1 +1,65 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const classYears = [
|
|
2
|
+
'Year 1',
|
|
3
|
+
'Year 2',
|
|
4
|
+
'Year 3',
|
|
5
|
+
'Year 4',
|
|
6
|
+
'Year 5',
|
|
7
|
+
'Graduated',
|
|
8
|
+
];
|
|
9
|
+
export var EClassYearGroup;
|
|
10
|
+
(function (EClassYearGroup) {
|
|
11
|
+
EClassYearGroup[EClassYearGroup["PRECLINICAL"] = 0] = "PRECLINICAL";
|
|
12
|
+
EClassYearGroup[EClassYearGroup["CLINICAL"] = 1] = "CLINICAL";
|
|
13
|
+
})(EClassYearGroup || (EClassYearGroup = {}));
|
|
14
|
+
export const classYearGroup = {
|
|
15
|
+
'Year 1': EClassYearGroup.PRECLINICAL,
|
|
16
|
+
'Year 2': EClassYearGroup.PRECLINICAL,
|
|
17
|
+
'Year 3': EClassYearGroup.CLINICAL,
|
|
18
|
+
'Year 4': EClassYearGroup.CLINICAL,
|
|
19
|
+
'Year 5': EClassYearGroup.CLINICAL,
|
|
20
|
+
Graduated: EClassYearGroup.CLINICAL,
|
|
21
|
+
PhD: EClassYearGroup.CLINICAL,
|
|
22
|
+
BSc: EClassYearGroup.PRECLINICAL,
|
|
23
|
+
MSc: EClassYearGroup.CLINICAL,
|
|
24
|
+
'Beta Tester': EClassYearGroup.CLINICAL,
|
|
25
|
+
};
|
|
26
|
+
export function currentClassYear(createdAtUnix, classYear) {
|
|
27
|
+
if (createdAtUnix === 0) {
|
|
28
|
+
throw new Error('createdAt not given in Unix');
|
|
29
|
+
}
|
|
30
|
+
if (!createdAtUnix) {
|
|
31
|
+
return classYear;
|
|
32
|
+
}
|
|
33
|
+
const lastClassYearIdx = classYears.length - 1;
|
|
34
|
+
const classYearsIdx = classYears.findIndex((x) => x === classYear);
|
|
35
|
+
if (classYearsIdx === -1) {
|
|
36
|
+
return classYears[lastClassYearIdx];
|
|
37
|
+
}
|
|
38
|
+
const now = new Date();
|
|
39
|
+
const currentYear = now.getFullYear();
|
|
40
|
+
const createdAt = new Date(createdAtUnix * 1000);
|
|
41
|
+
if (createdAt.getFullYear() > now.getFullYear()) {
|
|
42
|
+
throw new Error('createdAt not given in Unix');
|
|
43
|
+
}
|
|
44
|
+
const createdYear = createdAt.getFullYear();
|
|
45
|
+
let yearsAdded = currentYear - createdYear;
|
|
46
|
+
const createdAcademicYear = new Date(createdYear, 7, 1);
|
|
47
|
+
const nowAcademicYear = new Date(currentYear, 7, 1);
|
|
48
|
+
if (createdAt > createdAcademicYear) {
|
|
49
|
+
yearsAdded--;
|
|
50
|
+
}
|
|
51
|
+
if (now > nowAcademicYear) {
|
|
52
|
+
yearsAdded++;
|
|
53
|
+
}
|
|
54
|
+
const newClassYearIdx = classYearsIdx + yearsAdded;
|
|
55
|
+
return newClassYearIdx > lastClassYearIdx
|
|
56
|
+
? classYears[lastClassYearIdx]
|
|
57
|
+
: classYears[newClassYearIdx];
|
|
58
|
+
}
|
|
59
|
+
export function currentClassGroup(createdAtUnix, classYear) {
|
|
60
|
+
const currentClass = currentClassYear(createdAtUnix, classYear);
|
|
61
|
+
if (!classYearGroup.hasOwnProperty(currentClass)) {
|
|
62
|
+
return EClassYearGroup.CLINICAL;
|
|
63
|
+
}
|
|
64
|
+
return classYearGroup[currentClass];
|
|
65
|
+
}
|
package/models/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from './Author';
|
|
2
|
+
export * from './Blog';
|
|
2
3
|
export * from './Book';
|
|
3
4
|
export * from './Card';
|
|
4
5
|
export * from './Chapter';
|
|
@@ -21,4 +22,3 @@ export * from './Type';
|
|
|
21
22
|
export * from './University';
|
|
22
23
|
export * from './User';
|
|
23
24
|
export * from './Video';
|
|
24
|
-
export * from './Blog';
|
package/models/index.js
CHANGED
|
@@ -11,6 +11,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
__exportStar(require("./Author"), exports);
|
|
14
|
+
__exportStar(require("./Blog"), exports);
|
|
14
15
|
__exportStar(require("./Book"), exports);
|
|
15
16
|
__exportStar(require("./Card"), exports);
|
|
16
17
|
__exportStar(require("./Chapter"), exports);
|
|
@@ -33,4 +34,3 @@ __exportStar(require("./Type"), exports);
|
|
|
33
34
|
__exportStar(require("./University"), exports);
|
|
34
35
|
__exportStar(require("./User"), exports);
|
|
35
36
|
__exportStar(require("./Video"), exports);
|
|
36
|
-
__exportStar(require("./Blog"), exports);
|
package/models/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from './Author';
|
|
2
|
+
export * from './Blog';
|
|
2
3
|
export * from './Book';
|
|
3
4
|
export * from './Card';
|
|
4
5
|
export * from './Chapter';
|
|
@@ -21,4 +22,3 @@ export * from './Type';
|
|
|
21
22
|
export * from './University';
|
|
22
23
|
export * from './User';
|
|
23
24
|
export * from './Video';
|
|
24
|
-
export * from './Blog';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quesmed/types",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.26",
|
|
4
4
|
"description": "Typescript types for Quesmed",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.mjs",
|
|
@@ -33,7 +33,8 @@
|
|
|
33
33
|
"react-native-expo-image-cache": "^4.1.0"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"graphql": "^16",
|
|
36
|
+
"graphql": "^16.2.0",
|
|
37
|
+
"graphql-ws": "^5.5.5",
|
|
37
38
|
"react": "^17"
|
|
38
39
|
}
|
|
39
40
|
}
|
|
@@ -50,5 +50,8 @@ export interface IOsceMatchmakingVar {
|
|
|
50
50
|
userId: Id;
|
|
51
51
|
}
|
|
52
52
|
export declare const OSCE_MATCHMAKING_USERS: import("@apollo/client").DocumentNode;
|
|
53
|
-
export declare type IOsceMatchmakingUsersData = RootData<
|
|
53
|
+
export declare type IOsceMatchmakingUsersData = RootData<[
|
|
54
|
+
number,
|
|
55
|
+
number
|
|
56
|
+
], 'osceMatchmakingUsers'>;
|
|
54
57
|
export declare type IOsceMatchmakingUsersVar = null;
|
package/utils/index.d.ts
CHANGED
package/utils/index.js
CHANGED
|
@@ -17,6 +17,7 @@ exports.Uuid4 = void 0;
|
|
|
17
17
|
__exportStar(require("./commonFunctions"), exports);
|
|
18
18
|
__exportStar(require("./lightgallery"), exports);
|
|
19
19
|
__exportStar(require("./offlineLink"), exports);
|
|
20
|
+
__exportStar(require("./webSocketLink"), exports);
|
|
20
21
|
__exportStar(require("./wordsToNumber"), exports);
|
|
21
22
|
const uuid4_1 = __importDefault(require("./uuid4"));
|
|
22
23
|
exports.Uuid4 = uuid4_1.default;
|
package/utils/index.mjs
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ApolloLink, FetchResult, Observable, Operation } from '@apollo/client/core';
|
|
2
|
+
import { ClientOptions } from 'graphql-ws';
|
|
3
|
+
export declare class WebSocketLink extends ApolloLink {
|
|
4
|
+
private client;
|
|
5
|
+
constructor(options: ClientOptions);
|
|
6
|
+
request(operation: Operation): Observable<FetchResult>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WebSocketLink = void 0;
|
|
4
|
+
const core_1 = require("@apollo/client/core");
|
|
5
|
+
const graphql_1 = require("graphql");
|
|
6
|
+
const graphql_ws_1 = require("graphql-ws");
|
|
7
|
+
class WebSocketLink extends core_1.ApolloLink {
|
|
8
|
+
constructor(options) {
|
|
9
|
+
super();
|
|
10
|
+
this.client = (0, graphql_ws_1.createClient)(options);
|
|
11
|
+
}
|
|
12
|
+
request(operation) {
|
|
13
|
+
return new core_1.Observable((sink) => {
|
|
14
|
+
return this.client.subscribe(Object.assign(Object.assign({}, operation), { query: (0, graphql_1.print)(operation.query) }), {
|
|
15
|
+
next: sink.next.bind(sink),
|
|
16
|
+
complete: sink.complete.bind(sink),
|
|
17
|
+
error: sink.error.bind(sink),
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.WebSocketLink = WebSocketLink;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ApolloLink, Observable, } from '@apollo/client/core';
|
|
2
|
+
import { print } from 'graphql';
|
|
3
|
+
import { createClient } from 'graphql-ws';
|
|
4
|
+
export class WebSocketLink extends ApolloLink {
|
|
5
|
+
constructor(options) {
|
|
6
|
+
super();
|
|
7
|
+
this.client = createClient(options);
|
|
8
|
+
}
|
|
9
|
+
request(operation) {
|
|
10
|
+
return new Observable((sink) => {
|
|
11
|
+
return this.client.subscribe(Object.assign(Object.assign({}, operation), { query: print(operation.query) }), {
|
|
12
|
+
next: sink.next.bind(sink),
|
|
13
|
+
complete: sink.complete.bind(sink),
|
|
14
|
+
error: sink.error.bind(sink),
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
package/test.d.ts
DELETED
|
File without changes
|
package/test.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
package/test.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|