@quesmed/types 1.3.13 → 1.3.17

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.
Files changed (84) hide show
  1. package/gql_input_output_types/User.js +1 -2
  2. package/gql_input_output_types/index.js +1 -2
  3. package/index.js +4 -7
  4. package/models/Author.js +1 -2
  5. package/models/Book.js +1 -2
  6. package/models/Card.js +1 -2
  7. package/models/Chapter.js +1 -2
  8. package/models/Concept.js +1 -2
  9. package/models/Difficulty.js +2 -5
  10. package/models/Feedback.js +1 -2
  11. package/models/File.js +1 -2
  12. package/models/Marksheet.js +2 -5
  13. package/models/MockTest.js +1 -2
  14. package/models/OsceMarksheet.js +4 -7
  15. package/models/OsceStation.js +3 -6
  16. package/models/Picture.js +1 -2
  17. package/models/Promo.js +1 -2
  18. package/models/Question.js +8 -15
  19. package/models/Subscription.js +2 -5
  20. package/models/Todo.js +1 -2
  21. package/models/Token.js +1 -2
  22. package/models/Topic.js +2 -5
  23. package/models/Type.js +1 -2
  24. package/models/University.js +1 -2
  25. package/models/User.d.ts +1 -0
  26. package/models/User.js +1 -2
  27. package/models/Video.js +1 -2
  28. package/models/index.js +23 -35
  29. package/package.json +15 -3
  30. package/resolvers/apollo.d.ts +8 -0
  31. package/resolvers/apollo.js +1 -0
  32. package/resolvers/mutation/admin/algoliaSync.js +1 -2
  33. package/resolvers/mutation/admin/index.js +2 -14
  34. package/resolvers/mutation/admin/token.js +1 -2
  35. package/resolvers/mutation/index.js +2 -14
  36. package/resolvers/mutation/restricted/agora.js +1 -2
  37. package/resolvers/mutation/restricted/contactUs.js +1 -2
  38. package/resolvers/mutation/restricted/index.js +10 -22
  39. package/resolvers/mutation/restricted/marksheet.js +1 -2
  40. package/resolvers/mutation/restricted/mockTest.js +1 -2
  41. package/resolvers/mutation/restricted/osce.d.ts +4 -0
  42. package/resolvers/mutation/restricted/osce.js +1 -2
  43. package/resolvers/mutation/restricted/questionDiscussion.js +1 -2
  44. package/resolvers/mutation/restricted/todo.d.ts +5 -0
  45. package/resolvers/mutation/restricted/todo.js +25 -2
  46. package/resolvers/mutation/restricted/token.js +1 -2
  47. package/resolvers/mutation/restricted/users.js +1 -2
  48. package/resolvers/mutation/restricted/video.js +1 -2
  49. package/resolvers/mutation/stripe.js +1 -2
  50. package/resolvers/mutation/users.js +1 -2
  51. package/resolvers/mutation/validUserToken/index.js +1 -13
  52. package/resolvers/mutation/validUserToken/user.js +1 -2
  53. package/resolvers/offlineLink.d.ts +64 -0
  54. package/resolvers/offlineLink.js +230 -0
  55. package/resolvers/query/admin/getUserToken.js +1 -2
  56. package/resolvers/query/admin/index.js +1 -13
  57. package/resolvers/query/author.js +1 -2
  58. package/resolvers/query/book.js +1 -2
  59. package/resolvers/query/feedback.js +1 -2
  60. package/resolvers/query/index.js +9 -21
  61. package/resolvers/query/restricted/anatomy.js +1 -2
  62. package/resolvers/query/restricted/index.js +10 -22
  63. package/resolvers/query/restricted/marksheet.js +1 -2
  64. package/resolvers/query/restricted/mockTests.js +1 -2
  65. package/resolvers/query/restricted/osce.js +1 -2
  66. package/resolvers/query/restricted/quesBook.js +1 -2
  67. package/resolvers/query/restricted/todos.js +1 -2
  68. package/resolvers/query/restricted/topics.js +1 -2
  69. package/resolvers/query/restricted/university.js +1 -2
  70. package/resolvers/query/restricted/user.js +1 -2
  71. package/resolvers/query/restricted/video.js +1 -2
  72. package/resolvers/query/sampleCards.js +1 -2
  73. package/resolvers/query/sampleQuestions.js +1 -2
  74. package/resolvers/query/subscription.js +1 -2
  75. package/resolvers/query/university.js +1 -2
  76. package/resolvers/query/user.js +1 -2
  77. package/resolvers/query/video.js +1 -2
  78. package/resolvers/subscription/index.js +1 -13
  79. package/resolvers/subscription/osce.js +10 -14
  80. package/utils/commonFunctions.js +11 -17
  81. package/utils/lightgallery.d.ts +4 -2
  82. package/utils/lightgallery.js +5 -6
  83. package/utils/uuid4.js +1 -3
  84. package/utils/wordsToNumber.js +1 -5
@@ -0,0 +1,64 @@
1
+ /// <reference types="node" />
2
+ import { ApolloClient, ApolloLink, MutationOptions, NextLink, Observable, Operation } from '@apollo/client';
3
+ import AsyncStorage from '@react-native-async-storage/async-storage';
4
+ import Localforage from 'localforage';
5
+ export interface IOfflineLinkParam {
6
+ storage: typeof Localforage | typeof AsyncStorage;
7
+ retryInterval?: number;
8
+ sequential?: boolean;
9
+ retryOnServerError?: boolean;
10
+ }
11
+ export declare class OfflineLink extends ApolloLink {
12
+ storage: typeof Localforage | typeof AsyncStorage;
13
+ retryInterval: number;
14
+ sequential: boolean;
15
+ retryOnServerError: boolean;
16
+ queue: Map<string, MutationOptions>;
17
+ prefix: string;
18
+ client?: ApolloClient<any>;
19
+ timeoutId?: NodeJS.Timeout;
20
+ /**
21
+ * storage
22
+ * Provider that will persist the mutation queue. This can be any AsyncStorage compatible storage instance.
23
+ *
24
+ * retryInterval
25
+ * Milliseconds between attempts to retry failed mutations. Defaults to 0, which disables automatic retry.
26
+ *
27
+ * sequential
28
+ * Indicates if the attempts should be retried in order. Defaults to false which retries all failed mutations in parallel.
29
+ *
30
+ * retryOnServerError
31
+ * Indicates if mutations should be reattempted if there are server side errors, useful to retry mutations on session expiration. Defaults to false.
32
+ */
33
+ constructor({ storage, retryInterval, sequential, retryOnServerError, }: IOfflineLinkParam);
34
+ request(operation: Operation, forward: NextLink): Observable<any>;
35
+ /**
36
+ * Obtains the queue of mutations that must be sent to the server.
37
+ * These are kept in a Map to preserve the order of the mutations in the queue.
38
+ */
39
+ getQueue(): Promise<Map<any, any>>;
40
+ /**
41
+ * Persist the queue so mutations can be retried at a later point in time.
42
+ */
43
+ private saveQueue;
44
+ /**
45
+ * Add a mutation attempt to the queue so that it can be retried at a later point in time.
46
+ */
47
+ private add;
48
+ /**
49
+ * Remove a mutation attempt from the queue.
50
+ */
51
+ private remove;
52
+ /**
53
+ * Takes the mutations in the queue and try to send them to the server again.
54
+ */
55
+ sync(): Promise<void>;
56
+ /**
57
+ * Runs sync() after the retryInterval
58
+ */
59
+ private delayedSync;
60
+ /**
61
+ * Configure the link to use Apollo Client and immediately try to sync the queue (if there's anything there).
62
+ */
63
+ setup(client: ApolloClient<any>): Promise<void>;
64
+ }
@@ -0,0 +1,230 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { ApolloLink, Observable, } from '@apollo/client';
11
+ import uuid from '../utils/uuid4';
12
+ export class OfflineLink extends ApolloLink {
13
+ /**
14
+ * storage
15
+ * Provider that will persist the mutation queue. This can be any AsyncStorage compatible storage instance.
16
+ *
17
+ * retryInterval
18
+ * Milliseconds between attempts to retry failed mutations. Defaults to 0, which disables automatic retry.
19
+ *
20
+ * sequential
21
+ * Indicates if the attempts should be retried in order. Defaults to false which retries all failed mutations in parallel.
22
+ *
23
+ * retryOnServerError
24
+ * Indicates if mutations should be reattempted if there are server side errors, useful to retry mutations on session expiration. Defaults to false.
25
+ */
26
+ constructor({ storage, retryInterval = 0, sequential = false, retryOnServerError = false, }) {
27
+ super();
28
+ this.queue = new Map();
29
+ this.prefix = 'offlineLink:';
30
+ if (!storage) {
31
+ throw new Error('Storage is required, it can be an AsyncStorage compatible storage instance.');
32
+ }
33
+ this.storage = storage;
34
+ this.sequential = sequential;
35
+ this.retryInterval = retryInterval;
36
+ this.retryOnServerError = retryOnServerError;
37
+ }
38
+ request(operation, forward) {
39
+ const context = operation.getContext();
40
+ const { query, variables } = operation || {};
41
+ if (!context.optimisticResponse) {
42
+ // If the mutation does not have an optimisticResponse then we can't defer it
43
+ return forward(operation);
44
+ }
45
+ return new Observable((observer) => {
46
+ const mutationId = uuid.asBase64();
47
+ this.add({
48
+ mutation: query,
49
+ variables,
50
+ optimisticResponse: context.optimisticResponse,
51
+ }, mutationId);
52
+ const subscription = forward(operation).subscribe({
53
+ next: (result) => __awaiter(this, void 0, void 0, function* () {
54
+ yield this.remove(mutationId);
55
+ observer.next(result);
56
+ }),
57
+ error: () => {
58
+ // Mutation failed so we try again after a certain amount of time.
59
+ this.delayedSync();
60
+ // Resolve the mutation with the optimistic response so the UI can be updated
61
+ observer.next({
62
+ data: context.optimisticResponse,
63
+ dataPresent: true,
64
+ errors: [],
65
+ });
66
+ // Say we're all done so the UI is re-rendered.
67
+ observer.complete();
68
+ },
69
+ complete: () => observer.complete(),
70
+ });
71
+ return () => {
72
+ subscription.unsubscribe();
73
+ };
74
+ });
75
+ }
76
+ /**
77
+ * Obtains the queue of mutations that must be sent to the server.
78
+ * These are kept in a Map to preserve the order of the mutations in the queue.
79
+ */
80
+ getQueue() {
81
+ return __awaiter(this, void 0, void 0, function* () {
82
+ const map = new Map();
83
+ try {
84
+ const storedMutations = yield this.storage.getItem(this.prefix + 'Mutations');
85
+ if (!storedMutations) {
86
+ return map;
87
+ }
88
+ const mutationIds = storedMutations.split(',');
89
+ for (const mutationId of mutationIds) {
90
+ const storedMutation = yield this.storage.getItem(this.prefix + mutationId);
91
+ if (!storedMutation) {
92
+ continue;
93
+ }
94
+ map.set(mutationId, JSON.parse(storedMutation));
95
+ }
96
+ return map;
97
+ }
98
+ catch (e) {
99
+ console.error(e);
100
+ return map;
101
+ }
102
+ });
103
+ }
104
+ /**
105
+ * Persist the queue so mutations can be retried at a later point in time.
106
+ */
107
+ saveQueue(mutationId, mutation) {
108
+ return __awaiter(this, void 0, void 0, function* () {
109
+ try {
110
+ if (mutationId && mutation) {
111
+ yield this.storage.setItem(this.prefix + mutationId, JSON.stringify(mutation));
112
+ }
113
+ yield this.storage.setItem(this.prefix + 'Mutations', [...this.queue.keys()].join());
114
+ }
115
+ catch (e) {
116
+ console.error(e);
117
+ }
118
+ });
119
+ }
120
+ /**
121
+ * Add a mutation attempt to the queue so that it can be retried at a later point in time.
122
+ */
123
+ add(item, mutationId) {
124
+ return __awaiter(this, void 0, void 0, function* () {
125
+ // We give the mutation attempt a random id so that it is easy to remove when needed (in sync loop)
126
+ if (!mutationId) {
127
+ mutationId = uuid.asBase64();
128
+ }
129
+ this.queue.set(mutationId, item);
130
+ yield this.saveQueue(mutationId, item);
131
+ return mutationId;
132
+ });
133
+ }
134
+ /**
135
+ * Remove a mutation attempt from the queue.
136
+ */
137
+ remove(mutationId) {
138
+ return __awaiter(this, void 0, void 0, function* () {
139
+ this.queue.delete(mutationId);
140
+ yield this.storage.removeItem(this.prefix + mutationId);
141
+ yield this.saveQueue();
142
+ });
143
+ }
144
+ /**
145
+ * Takes the mutations in the queue and try to send them to the server again.
146
+ */
147
+ sync() {
148
+ return __awaiter(this, void 0, void 0, function* () {
149
+ if (!this.client) {
150
+ throw new Error('Offline Link not setup with ApolloClient');
151
+ }
152
+ if (this.queue.size === 0) {
153
+ return;
154
+ }
155
+ const attempts = Array.from(this.queue);
156
+ if (this.sequential) {
157
+ for (const [mutationId, attempt] of attempts) {
158
+ let serverProcessed = false;
159
+ try {
160
+ yield this.client.mutate(Object.assign(Object.assign({}, attempt), { optimisticResponse: undefined }));
161
+ serverProcessed = true;
162
+ }
163
+ catch (e) {
164
+ const err = e;
165
+ const networkError = err.networkError;
166
+ if (!this.retryOnServerError && (networkError === null || networkError === void 0 ? void 0 : networkError.response)) {
167
+ // There are GraphQL errors, which means the server processed the request so we can remove the mutation from the queue
168
+ serverProcessed = true;
169
+ }
170
+ }
171
+ if (serverProcessed) {
172
+ try {
173
+ yield this.remove(mutationId);
174
+ }
175
+ catch (e) {
176
+ console.error(e);
177
+ }
178
+ }
179
+ }
180
+ }
181
+ else {
182
+ yield Promise.all(attempts.map(([mutationId, attempt]) => __awaiter(this, void 0, void 0, function* () {
183
+ var _a;
184
+ let serverProcessed = false;
185
+ try {
186
+ yield ((_a = this.client) === null || _a === void 0 ? void 0 : _a.mutate(Object.assign(Object.assign({}, attempt), { optimisticResponse: undefined })));
187
+ serverProcessed = true;
188
+ }
189
+ catch (e) {
190
+ const err = e;
191
+ const networkError = err.networkError;
192
+ if (!this.retryOnServerError && (networkError === null || networkError === void 0 ? void 0 : networkError.response)) {
193
+ serverProcessed = true;
194
+ }
195
+ }
196
+ if (serverProcessed) {
197
+ yield this.remove(mutationId);
198
+ }
199
+ })));
200
+ }
201
+ // Remaining mutations in the queue are persisted
202
+ yield this.saveQueue();
203
+ if (this.queue.size !== 0 || this.retryInterval !== 0) {
204
+ this.delayedSync();
205
+ }
206
+ });
207
+ }
208
+ /**
209
+ * Runs sync() after the retryInterval
210
+ */
211
+ delayedSync() {
212
+ if (this.retryInterval === 0) {
213
+ return;
214
+ }
215
+ if (this.timeoutId) {
216
+ clearTimeout(this.timeoutId);
217
+ }
218
+ this.timeoutId = setTimeout(() => this.sync, this.retryInterval);
219
+ }
220
+ /**
221
+ * Configure the link to use Apollo Client and immediately try to sync the queue (if there's anything there).
222
+ */
223
+ setup(client) {
224
+ return __awaiter(this, void 0, void 0, function* () {
225
+ this.client = client;
226
+ this.queue = yield this.getQueue();
227
+ yield this.sync();
228
+ });
229
+ }
230
+ }
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,13 +1 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- __exportStar(require("./getUserToken"), exports);
1
+ export * from './getUserToken';
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,21 +1,9 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- __exportStar(require("./author"), exports);
14
- __exportStar(require("./book"), exports);
15
- __exportStar(require("./feedback"), exports);
16
- __exportStar(require("./sampleCards"), exports);
17
- __exportStar(require("./sampleQuestions"), exports);
18
- __exportStar(require("./subscription"), exports);
19
- __exportStar(require("./university"), exports);
20
- __exportStar(require("./user"), exports);
21
- __exportStar(require("./video"), exports);
1
+ export * from './author';
2
+ export * from './book';
3
+ export * from './feedback';
4
+ export * from './sampleCards';
5
+ export * from './sampleQuestions';
6
+ export * from './subscription';
7
+ export * from './university';
8
+ export * from './user';
9
+ export * from './video';
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,22 +1,10 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- __exportStar(require("./anatomy"), exports);
14
- __exportStar(require("./marksheet"), exports);
15
- __exportStar(require("./mockTests"), exports);
16
- __exportStar(require("./osce"), exports);
17
- __exportStar(require("./quesBook"), exports);
18
- __exportStar(require("./todos"), exports);
19
- __exportStar(require("./topics"), exports);
20
- __exportStar(require("./university"), exports);
21
- __exportStar(require("./user"), exports);
22
- __exportStar(require("./video"), exports);
1
+ export * from './anatomy';
2
+ export * from './marksheet';
3
+ export * from './mockTests';
4
+ export * from './osce';
5
+ export * from './quesBook';
6
+ export * from './todos';
7
+ export * from './topics';
8
+ export * from './university';
9
+ export * from './user';
10
+ export * from './video';
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,13 +1 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- __exportStar(require("./osce"), exports);
1
+ export * from './osce';
@@ -1,19 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OsceGroupInit = exports.OSCE_MATCHMAKING_USERS = exports.OSCE_MATCHMAKING = exports.OSCE_MARKSHEET_ACTION = exports.ROLE_CHANGED = void 0;
4
- const models_1 = require("../../models");
5
- exports.ROLE_CHANGED = 'ROLE_CHANGED';
6
- exports.OSCE_MARKSHEET_ACTION = 'OSCE_MARKSHEET_ACTION';
7
- exports.OSCE_MATCHMAKING = 'OSCE_MATCHMAKING';
8
- exports.OSCE_MATCHMAKING_USERS = 'OSCE_MATCHMAKING_USERS';
9
- const OsceGroupInit = (osceMarksheetId) => [
1
+ import { EOsceRoles, } from '../../models';
2
+ export const ROLE_CHANGED = 'ROLE_CHANGED';
3
+ export const OSCE_MARKSHEET_ACTION = 'OSCE_MARKSHEET_ACTION';
4
+ export const OSCE_MATCHMAKING = 'OSCE_MATCHMAKING';
5
+ export const OSCE_MATCHMAKING_USERS = 'OSCE_MATCHMAKING_USERS';
6
+ export const OsceGroupInit = (osceMarksheetId) => [
10
7
  {
11
8
  id: null,
12
9
  createdAt: null,
13
10
  osceMarksheetId,
14
11
  userId: null,
15
12
  user: null,
16
- role: models_1.EOsceRoles.CANDIDATE,
13
+ role: EOsceRoles.CANDIDATE,
17
14
  },
18
15
  {
19
16
  id: null,
@@ -21,7 +18,7 @@ const OsceGroupInit = (osceMarksheetId) => [
21
18
  osceMarksheetId,
22
19
  userId: null,
23
20
  user: null,
24
- role: models_1.EOsceRoles.EXAMINER,
21
+ role: EOsceRoles.EXAMINER,
25
22
  },
26
23
  {
27
24
  id: null,
@@ -29,7 +26,7 @@ const OsceGroupInit = (osceMarksheetId) => [
29
26
  osceMarksheetId,
30
27
  userId: null,
31
28
  user: null,
32
- role: models_1.EOsceRoles.ACTOR,
29
+ role: EOsceRoles.ACTOR,
33
30
  },
34
31
  {
35
32
  id: null,
@@ -37,7 +34,6 @@ const OsceGroupInit = (osceMarksheetId) => [
37
34
  osceMarksheetId,
38
35
  userId: null,
39
36
  user: null,
40
- role: models_1.EOsceRoles.OBSERVER,
37
+ role: EOsceRoles.OBSERVER,
41
38
  },
42
39
  ];
43
- exports.OsceGroupInit = OsceGroupInit;
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.correctMark = exports.formatPrescribeAnswer = exports.mapPrescribeMarkToAnswer = void 0;
4
- const models_1 = require("../models");
5
- const wordsToNumber_1 = require("./wordsToNumber");
1
+ import { EQuestionType, } from '../models';
2
+ import { wordsToNumber } from './wordsToNumber';
6
3
  const floatRegex = /([0-9]*[.])?[0-9]+/gm;
7
4
  const ACCEPTED_FREQ = ['stat', 'od', 'bd', 'tds', 'qds'];
8
- function mapPrescribeMarkToAnswer(obj) {
5
+ export function mapPrescribeMarkToAnswer(obj) {
9
6
  return {
10
7
  drug: {
11
8
  value: obj.drug,
@@ -33,8 +30,7 @@ function mapPrescribeMarkToAnswer(obj) {
33
30
  },
34
31
  };
35
32
  }
36
- exports.mapPrescribeMarkToAnswer = mapPrescribeMarkToAnswer;
37
- function formatPrescribeAnswer(obj) {
33
+ export function formatPrescribeAnswer(obj) {
38
34
  obj.drug.value = obj.drug.value.toLowerCase().replace(/\s/g, '');
39
35
  obj.route.value = obj.route.value.toLowerCase().replace(/\s/g, '');
40
36
  if (obj.route.value === 'oral') {
@@ -79,7 +75,7 @@ function formatPrescribeAnswer(obj) {
79
75
  }
80
76
  m.forEach((match) => durationMatches.add(match));
81
77
  }
82
- const durationWords = (0, wordsToNumber_1.wordsToNumber)(obj.duration.value, false);
78
+ const durationWords = wordsToNumber(obj.duration.value, false);
83
79
  if (durationWords !== 0) {
84
80
  durationMatches.add(durationWords.toString());
85
81
  }
@@ -108,13 +104,12 @@ function formatPrescribeAnswer(obj) {
108
104
  obj.frequency.value = 'qds';
109
105
  }
110
106
  else if (!ACCEPTED_FREQ.includes(obj.frequency.value)) {
111
- obj.frequency.value = (0, wordsToNumber_1.wordsToNumber)(orgFrequencyValue, true).toString();
107
+ obj.frequency.value = wordsToNumber(orgFrequencyValue, true).toString();
112
108
  }
113
109
  return obj;
114
110
  }
115
- exports.formatPrescribeAnswer = formatPrescribeAnswer;
116
111
  const answerRegex = /answer/gi;
117
- function correctMark(mark) {
112
+ export function correctMark(mark) {
118
113
  const data = {
119
114
  correct: false,
120
115
  incorrect: false,
@@ -129,7 +124,7 @@ function correctMark(mark) {
129
124
  const answer = mark.question[answerKey];
130
125
  const flatAnswer = answer[0];
131
126
  const flatAttempt = mark.mark[0];
132
- if (models_1.EQuestionType.SINGLE_BEST_ANSWER === mark.question.typeId) {
127
+ if (EQuestionType.SINGLE_BEST_ANSWER === mark.question.typeId) {
133
128
  const answer = flatAnswer;
134
129
  const attempt = flatAttempt;
135
130
  if (answer === attempt) {
@@ -139,7 +134,7 @@ function correctMark(mark) {
139
134
  data.incorrect = true;
140
135
  }
141
136
  }
142
- else if (models_1.EQuestionType.QUESTION_ANSWER === mark.question.typeId) {
137
+ else if (EQuestionType.QUESTION_ANSWER === mark.question.typeId) {
143
138
  const answer = flatAnswer.dose.toLowerCase().replace(/\s/g, '');
144
139
  let attempt = '';
145
140
  if (flatAttempt) {
@@ -152,7 +147,7 @@ function correctMark(mark) {
152
147
  data.incorrect = true;
153
148
  }
154
149
  }
155
- else if (models_1.EQuestionType.MULTIPLE_ANSWERS === mark.question.typeId) {
150
+ else if (EQuestionType.MULTIPLE_ANSWERS === mark.question.typeId) {
156
151
  const [answerA, answerB] = answer.map((x) => x.sort());
157
152
  let [attemptA, attemptB] = [[], []];
158
153
  if (Array.isArray(mark.mark) &&
@@ -172,7 +167,7 @@ function correctMark(mark) {
172
167
  data.incorrect = true;
173
168
  }
174
169
  }
175
- else if (models_1.EQuestionType.PRESCRIPTION_ANSWER === mark.question.typeId) {
170
+ else if (EQuestionType.PRESCRIPTION_ANSWER === mark.question.typeId) {
176
171
  const answers = answer.map(formatPrescribeAnswer);
177
172
  let attempt = formatPrescribeAnswer(mapPrescribeMarkToAnswer({
178
173
  drug: '',
@@ -220,4 +215,3 @@ function correctMark(mark) {
220
215
  }
221
216
  return data;
222
217
  }
223
- exports.correctMark = correctMark;
@@ -1,7 +1,9 @@
1
+ import { Platform } from 'react-native';
2
+ import { CacheManager } from 'react-native-expo-image-cache';
1
3
  import { IOsceMarksheet, IOsceStation } from '../models';
2
4
  export interface ILightGalleryCache {
3
- CacheManager: any;
4
- Platform: any;
5
+ CacheManager: typeof CacheManager;
6
+ Platform: typeof Platform;
5
7
  }
6
8
  export declare function lightgalleryOsceResolve(data: IOsceStation, cache?: ILightGalleryCache): Promise<IOsceStation>;
7
9
  export declare function lightgalleryOsceResolve(data: IOsceMarksheet, cache?: ILightGalleryCache): Promise<IOsceMarksheet>;