@quesmed/types 1.4.24 → 1.4.28

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 CHANGED
@@ -18,3 +18,5 @@ export declare enum EPlatformId {
18
18
  OSCE = 1
19
19
  }
20
20
  export declare const termsAndConditions = "# Group Study Conduct Policy\n\nAs future clinicians, we expect that you treat your colleagues fairly and with respect.\nAs a result, we will not tolerate the following actions during use of the Quesmed platform:\n\n- Violent threats\n- Wishing, hoping or calling for serious harm on a person or group of people\n- Incitement against individuals or groups\n- Slurs, racist and sexist tropes\n- Degrading others\n- Unwanted sexual advances\n\nWhen determining the penalty for violating our conduct policy, we consider a number of factors including the severity of the violation and the individual's record of violations. We reserve the right to immediately de-activate any account that violates our conduct policy. We may also consider raising concerns to the individual's licensing body (e.g. GMC) on a case-by-case basis.\n\nBy using the platform, you agree to be bound by our conduct policy as described above.";
21
+ export declare const medicalWords: string[][];
22
+ export declare function generateDisplayName(firstName: string, lastName: string): string;
package/index.js CHANGED
@@ -22,7 +22,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
22
22
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
23
23
  };
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.termsAndConditions = exports.EPlatformId = exports.FCM_TOPICS = exports.ERRORS = exports.utils = exports.Models = void 0;
25
+ exports.generateDisplayName = exports.medicalWords = exports.termsAndConditions = exports.EPlatformId = exports.FCM_TOPICS = exports.ERRORS = exports.utils = exports.Models = void 0;
26
+ const random_1 = require("./utils/random");
26
27
  exports.Models = __importStar(require("./models"));
27
28
  __exportStar(require("./resolvers"), exports);
28
29
  exports.utils = __importStar(require("./utils"));
@@ -58,3 +59,61 @@ As a result, we will not tolerate the following actions during use of the Quesme
58
59
  When determining the penalty for violating our conduct policy, we consider a number of factors including the severity of the violation and the individual's record of violations. We reserve the right to immediately de-activate any account that violates our conduct policy. We may also consider raising concerns to the individual's licensing body (e.g. GMC) on a case-by-case basis.
59
60
 
60
61
  By using the platform, you agree to be bound by our conduct policy as described above.`;
62
+ exports.medicalWords = [
63
+ ['Abrasion', 'Abscess', 'Acute', 'Amnesia', 'Anterior', 'Axillary'],
64
+ ['Benign', 'Biopsy', 'Botox', 'Bladder', 'Body', 'Bradykinin'],
65
+ ['Chronic', 'Contusion', 'Cystic', 'Complement', 'CT'],
66
+ ['Defibrillator', 'Dermis', 'DNA', 'Dorsal'],
67
+ ['Edema', 'Embolism', 'Epidermis', 'Endoscope'],
68
+ ['Fracture', 'Fibrillation', 'Flutter', 'Fever', 'Fungal', 'Fibrosis'],
69
+ ['Gland', 'Gastro', 'Gas', 'Gallbladder'],
70
+ ['Hypertension', 'Hematoma', 'Haemophilus', 'Hallux', 'Hereditary'],
71
+ ['Inpatient', 'Intravenous', 'Intubation'],
72
+ ['JAK', 'Juice', 'Jargon', 'Jaundice'],
73
+ ['Kinin', 'Ketone', 'Kawasaki', 'Kinase'],
74
+ ['Lung', 'Liver', 'Lymph', 'Loose', 'Lumbar', 'Lateral'],
75
+ ['Malignant', 'Monoclonal', 'Myopathy', 'Myotonia', 'Metabolism'],
76
+ ['Neoplasia', 'NICU', 'Nightshift'],
77
+ ['Outpatient', 'Osteoporosis', 'Otitis', 'Odor'],
78
+ ['Prognosis', 'Power', 'Poisoning', 'Pudendal', 'Polyps', 'Prone'],
79
+ ['QRS', 'Qwave'],
80
+ ['Relapse', 'Rhinoplasty', 'Retrograde', 'RNA'],
81
+ [
82
+ 'Suture',
83
+ 'Serotonin',
84
+ 'Sclerosis',
85
+ 'Stasis',
86
+ 'Serpiginous',
87
+ 'Syndrome',
88
+ 'Supine',
89
+ ],
90
+ [
91
+ 'Transplant',
92
+ 'Thermoregulator',
93
+ 'Tyrosine',
94
+ 'Tachycardia',
95
+ 'Tazocin',
96
+ 'Tanoy',
97
+ ],
98
+ ['Uveitis', 'Uremic', 'Urology', 'Upright', 'Uwave'],
99
+ ['Viral', 'Vaccine', 'Vitamin', 'Versicolor', 'Ventral'],
100
+ ['Wilsons', 'WBC', 'Womb'],
101
+ ['X-ray'],
102
+ ['Yellow', 'Yersinia', 'Yeast'],
103
+ ['Zika', 'Zebras', 'Zygomatic', 'Zline'],
104
+ ];
105
+ function generateDisplayName(firstName, lastName) {
106
+ const firstNameChar = firstName.toLowerCase().charCodeAt(0) - 97 ||
107
+ Math.round(Math.random() * 26);
108
+ const lastNameChar = lastName.toLowerCase().charCodeAt(0) - 97 || Math.round(Math.random() * 26);
109
+ let displayName;
110
+ const medWordsFirstName = (0, random_1.getRandom)(exports.medicalWords[firstNameChar], 2);
111
+ if (firstNameChar === lastNameChar) {
112
+ displayName = `${medWordsFirstName[0]} ${medWordsFirstName[1]}`;
113
+ }
114
+ else {
115
+ displayName = `${medWordsFirstName[0]} ${(0, random_1.getRandom)(exports.medicalWords[lastNameChar], 1)[0]}`;
116
+ }
117
+ return displayName;
118
+ }
119
+ exports.generateDisplayName = generateDisplayName;
package/index.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ import { getRandom } from './utils/random';
1
2
  export * as Models from './models';
2
3
  export * from './resolvers';
3
4
  export * as utils from './utils';
@@ -33,3 +34,60 @@ As a result, we will not tolerate the following actions during use of the Quesme
33
34
  When determining the penalty for violating our conduct policy, we consider a number of factors including the severity of the violation and the individual's record of violations. We reserve the right to immediately de-activate any account that violates our conduct policy. We may also consider raising concerns to the individual's licensing body (e.g. GMC) on a case-by-case basis.
34
35
 
35
36
  By using the platform, you agree to be bound by our conduct policy as described above.`;
37
+ export const medicalWords = [
38
+ ['Abrasion', 'Abscess', 'Acute', 'Amnesia', 'Anterior', 'Axillary'],
39
+ ['Benign', 'Biopsy', 'Botox', 'Bladder', 'Body', 'Bradykinin'],
40
+ ['Chronic', 'Contusion', 'Cystic', 'Complement', 'CT'],
41
+ ['Defibrillator', 'Dermis', 'DNA', 'Dorsal'],
42
+ ['Edema', 'Embolism', 'Epidermis', 'Endoscope'],
43
+ ['Fracture', 'Fibrillation', 'Flutter', 'Fever', 'Fungal', 'Fibrosis'],
44
+ ['Gland', 'Gastro', 'Gas', 'Gallbladder'],
45
+ ['Hypertension', 'Hematoma', 'Haemophilus', 'Hallux', 'Hereditary'],
46
+ ['Inpatient', 'Intravenous', 'Intubation'],
47
+ ['JAK', 'Juice', 'Jargon', 'Jaundice'],
48
+ ['Kinin', 'Ketone', 'Kawasaki', 'Kinase'],
49
+ ['Lung', 'Liver', 'Lymph', 'Loose', 'Lumbar', 'Lateral'],
50
+ ['Malignant', 'Monoclonal', 'Myopathy', 'Myotonia', 'Metabolism'],
51
+ ['Neoplasia', 'NICU', 'Nightshift'],
52
+ ['Outpatient', 'Osteoporosis', 'Otitis', 'Odor'],
53
+ ['Prognosis', 'Power', 'Poisoning', 'Pudendal', 'Polyps', 'Prone'],
54
+ ['QRS', 'Qwave'],
55
+ ['Relapse', 'Rhinoplasty', 'Retrograde', 'RNA'],
56
+ [
57
+ 'Suture',
58
+ 'Serotonin',
59
+ 'Sclerosis',
60
+ 'Stasis',
61
+ 'Serpiginous',
62
+ 'Syndrome',
63
+ 'Supine',
64
+ ],
65
+ [
66
+ 'Transplant',
67
+ 'Thermoregulator',
68
+ 'Tyrosine',
69
+ 'Tachycardia',
70
+ 'Tazocin',
71
+ 'Tanoy',
72
+ ],
73
+ ['Uveitis', 'Uremic', 'Urology', 'Upright', 'Uwave'],
74
+ ['Viral', 'Vaccine', 'Vitamin', 'Versicolor', 'Ventral'],
75
+ ['Wilsons', 'WBC', 'Womb'],
76
+ ['X-ray'],
77
+ ['Yellow', 'Yersinia', 'Yeast'],
78
+ ['Zika', 'Zebras', 'Zygomatic', 'Zline'],
79
+ ];
80
+ export function generateDisplayName(firstName, lastName) {
81
+ const firstNameChar = firstName.toLowerCase().charCodeAt(0) - 97 ||
82
+ Math.round(Math.random() * 26);
83
+ const lastNameChar = lastName.toLowerCase().charCodeAt(0) - 97 || Math.round(Math.random() * 26);
84
+ let displayName;
85
+ const medWordsFirstName = getRandom(medicalWords[firstNameChar], 2);
86
+ if (firstNameChar === lastNameChar) {
87
+ displayName = `${medWordsFirstName[0]} ${medWordsFirstName[1]}`;
88
+ }
89
+ else {
90
+ displayName = `${medWordsFirstName[0]} ${getRandom(medicalWords[lastNameChar], 1)[0]}`;
91
+ }
92
+ return displayName;
93
+ }
package/models/User.js CHANGED
@@ -27,6 +27,9 @@ exports.classYearGroup = {
27
27
  'Beta Tester': EClassYearGroup.CLINICAL,
28
28
  };
29
29
  function currentClassYear(createdAtUnix, classYear) {
30
+ if (createdAtUnix === 0) {
31
+ throw new Error('createdAt not given in Unix');
32
+ }
30
33
  if (!createdAtUnix) {
31
34
  return classYear;
32
35
  }
@@ -38,6 +41,9 @@ function currentClassYear(createdAtUnix, classYear) {
38
41
  const now = new Date();
39
42
  const currentYear = now.getFullYear();
40
43
  const createdAt = new Date(createdAtUnix * 1000);
44
+ if (createdAt.getFullYear() > now.getFullYear()) {
45
+ throw new Error('createdAt not given in Unix');
46
+ }
41
47
  const createdYear = createdAt.getFullYear();
42
48
  let yearsAdded = currentYear - createdYear;
43
49
  const createdAcademicYear = new Date(createdYear, 7, 1);
@@ -56,6 +62,9 @@ function currentClassYear(createdAtUnix, classYear) {
56
62
  exports.currentClassYear = currentClassYear;
57
63
  function currentClassGroup(createdAtUnix, classYear) {
58
64
  const currentClass = currentClassYear(createdAtUnix, classYear);
59
- return exports.classYearGroup[currentClass] || EClassYearGroup.CLINICAL;
65
+ if (!exports.classYearGroup.hasOwnProperty(currentClass)) {
66
+ return EClassYearGroup.CLINICAL;
67
+ }
68
+ return exports.classYearGroup[currentClass];
60
69
  }
61
70
  exports.currentClassGroup = currentClassGroup;
package/models/User.mjs CHANGED
@@ -24,6 +24,9 @@ export const classYearGroup = {
24
24
  'Beta Tester': EClassYearGroup.CLINICAL,
25
25
  };
26
26
  export function currentClassYear(createdAtUnix, classYear) {
27
+ if (createdAtUnix === 0) {
28
+ throw new Error('createdAt not given in Unix');
29
+ }
27
30
  if (!createdAtUnix) {
28
31
  return classYear;
29
32
  }
@@ -35,6 +38,9 @@ export function currentClassYear(createdAtUnix, classYear) {
35
38
  const now = new Date();
36
39
  const currentYear = now.getFullYear();
37
40
  const createdAt = new Date(createdAtUnix * 1000);
41
+ if (createdAt.getFullYear() > now.getFullYear()) {
42
+ throw new Error('createdAt not given in Unix');
43
+ }
38
44
  const createdYear = createdAt.getFullYear();
39
45
  let yearsAdded = currentYear - createdYear;
40
46
  const createdAcademicYear = new Date(createdYear, 7, 1);
@@ -52,5 +58,8 @@ export function currentClassYear(createdAtUnix, classYear) {
52
58
  }
53
59
  export function currentClassGroup(createdAtUnix, classYear) {
54
60
  const currentClass = currentClassYear(createdAtUnix, classYear);
55
- return classYearGroup[currentClass] || EClassYearGroup.CLINICAL;
61
+ if (!classYearGroup.hasOwnProperty(currentClass)) {
62
+ return EClassYearGroup.CLINICAL;
63
+ }
64
+ return classYearGroup[currentClass];
56
65
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quesmed/types",
3
- "version": "1.4.24",
3
+ "version": "1.4.28",
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
  }
package/utils/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  export * from './commonFunctions';
2
2
  export * from './lightgallery';
3
3
  export * from './offlineLink';
4
+ export * from './random';
5
+ export * from './webSocketLink';
4
6
  export * from './wordsToNumber';
5
7
  import uuid from './uuid4';
6
8
  export declare const Uuid4: typeof uuid;
package/utils/index.js CHANGED
@@ -17,6 +17,8 @@ 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("./random"), exports);
21
+ __exportStar(require("./webSocketLink"), exports);
20
22
  __exportStar(require("./wordsToNumber"), exports);
21
23
  const uuid4_1 = __importDefault(require("./uuid4"));
22
24
  exports.Uuid4 = uuid4_1.default;
package/utils/index.mjs CHANGED
@@ -1,6 +1,8 @@
1
1
  export * from './commonFunctions';
2
2
  export * from './lightgallery';
3
3
  export * from './offlineLink';
4
+ export * from './random';
5
+ export * from './webSocketLink';
4
6
  export * from './wordsToNumber';
5
7
  import uuid from './uuid4';
6
8
  export const Uuid4 = uuid;
@@ -0,0 +1 @@
1
+ export declare function getRandom<T>(arr: T[], n?: number): T[];
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getRandom = void 0;
4
+ function getRandom(arr, n) {
5
+ if (n === undefined || n === null) {
6
+ n = arr.length;
7
+ }
8
+ const result = new Array(n);
9
+ let len = arr.length;
10
+ const taken = new Array(len);
11
+ if (n > len)
12
+ throw new RangeError('getRandom: more elements taken than available');
13
+ while (n--) {
14
+ const x = Math.floor(Math.random() * len);
15
+ result[n] = arr[x in taken ? taken[x] : x];
16
+ taken[x] = --len in taken ? taken[len] : len;
17
+ }
18
+ return result;
19
+ }
20
+ exports.getRandom = getRandom;
@@ -0,0 +1,16 @@
1
+ export function getRandom(arr, n) {
2
+ if (n === undefined || n === null) {
3
+ n = arr.length;
4
+ }
5
+ const result = new Array(n);
6
+ let len = arr.length;
7
+ const taken = new Array(len);
8
+ if (n > len)
9
+ throw new RangeError('getRandom: more elements taken than available');
10
+ while (n--) {
11
+ const x = Math.floor(Math.random() * len);
12
+ result[n] = arr[x in taken ? taken[x] : x];
13
+ taken[x] = --len in taken ? taken[len] : len;
14
+ }
15
+ return result;
16
+ }
@@ -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
+ }