@quesmed/types 2.2.87 → 2.2.89

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 (25) hide show
  1. package/dist/cjs/models/Notification.d.ts +0 -3
  2. package/dist/cjs/models/Question.d.ts +1 -0
  3. package/dist/cjs/resolvers/mutation/restricted/notification.d.ts +5 -1
  4. package/dist/cjs/resolvers/mutation/restricted/notification.js +64 -0
  5. package/dist/cjs/resolvers/query/restricted/index.d.ts +1 -0
  6. package/dist/cjs/resolvers/query/restricted/index.js +1 -0
  7. package/dist/cjs/resolvers/query/restricted/notification.d.ts +1 -0
  8. package/dist/cjs/resolvers/query/restricted/notification.js +31 -0
  9. package/dist/cjs/resolvers/query/restricted/question.d.ts +7 -0
  10. package/dist/cjs/resolvers/query/restricted/question.js +508 -0
  11. package/dist/cjs/resolvers/subscription/notification.d.ts +4 -1
  12. package/dist/cjs/resolvers/subscription/notification.js +26 -1
  13. package/dist/mjs/models/Notification.d.ts +0 -3
  14. package/dist/mjs/models/Question.d.ts +1 -0
  15. package/dist/mjs/resolvers/mutation/restricted/notification.d.ts +5 -1
  16. package/dist/mjs/resolvers/mutation/restricted/notification.js +62 -1
  17. package/dist/mjs/resolvers/query/restricted/index.d.ts +1 -0
  18. package/dist/mjs/resolvers/query/restricted/index.js +1 -0
  19. package/dist/mjs/resolvers/query/restricted/notification.d.ts +1 -0
  20. package/dist/mjs/resolvers/query/restricted/notification.js +30 -1
  21. package/dist/mjs/resolvers/query/restricted/question.d.ts +7 -0
  22. package/dist/mjs/resolvers/query/restricted/question.js +505 -0
  23. package/dist/mjs/resolvers/subscription/notification.d.ts +4 -1
  24. package/dist/mjs/resolvers/subscription/notification.js +24 -0
  25. package/package.json +1 -1
@@ -1,4 +1,29 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ON_NOTIFICATION_ARISE = void 0;
3
+ exports.onNotificationArise = exports.ON_NOTIFICATION_ARISE = void 0;
4
+ const restricted_1 = require("../query/restricted");
4
5
  exports.ON_NOTIFICATION_ARISE = 'ON_NOTIFICATION_ARISE';
6
+ const onNotificationArise = ({ client, subscriptionData, }) => {
7
+ const { onNotificationArise } = subscriptionData.data || {};
8
+ if (onNotificationArise) {
9
+ const prevData = client.readQuery({
10
+ query: restricted_1.NOTIFICATIONS,
11
+ });
12
+ if (prevData) {
13
+ client.writeQuery({
14
+ query: restricted_1.NOTIFICATIONS,
15
+ data: {
16
+ ...prevData,
17
+ restricted: {
18
+ ...prevData.restricted,
19
+ notifications: [
20
+ ...onNotificationArise,
21
+ ...prevData.restricted.notifications,
22
+ ],
23
+ },
24
+ },
25
+ });
26
+ }
27
+ }
28
+ };
29
+ exports.onNotificationArise = onNotificationArise;
@@ -1,4 +1,3 @@
1
- import { IConcept } from './Concept';
2
1
  import { IQuestionComment } from './Question';
3
2
  import { Id } from './Type';
4
3
  import { IUser } from './User';
@@ -29,8 +28,6 @@ export interface INotification {
29
28
  comment?: IQuestionComment;
30
29
  fromUserCommentId: Id | null;
31
30
  fromUserComment?: IQuestionComment;
32
- conceptId: Id | null;
33
- concept?: IConcept;
34
31
  description: string;
35
32
  actionType: ENotificationActionType;
36
33
  type: ENotificationType;
@@ -32,6 +32,7 @@ export interface IQuestionComment {
32
32
  deletedAt: number | Date;
33
33
  userId: Id;
34
34
  user?: IUser;
35
+ question?: IQuestion;
35
36
  questionId: Id;
36
37
  parentId: Id;
37
38
  parent?: IQuestionComment;
@@ -1,3 +1,5 @@
1
+ import { ApolloCache } from '@apollo/client';
2
+ import { ApolloUpdateOptions, ApolloUpdateResultRestricted } from '../..';
1
3
  import { ENotificationActionType, ENotificationType, Id, INotification } from '../../../models';
2
4
  import { graphqlNormalize, RestrictedData } from '../../types';
3
5
  export interface IAddNotificationInput {
@@ -5,7 +7,6 @@ export interface IAddNotificationInput {
5
7
  userId: Id | null;
6
8
  fromUserCommentId: Id | null;
7
9
  commentId: Id | null;
8
- conceptId: Id | null;
9
10
  description: string;
10
11
  actionType: ENotificationActionType;
11
12
  type: ENotificationType;
@@ -24,5 +25,8 @@ export declare type IMarkNotificationAsReadVar = {
24
25
  id: Id;
25
26
  };
26
27
  export declare type IMarkNotificationAsReadData = RestrictedData<graphqlNormalize & INotification, 'markNotificationAsRead'>;
28
+ export declare const MARK_AS_READ: import("@apollo/client").DocumentNode;
29
+ export declare const updateNotificatonsOnMarkAsRead: (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IMarkNotificationAsReadData>, options: ApolloUpdateOptions) => void;
27
30
  export declare type IMarkAllNotificationsAsReadVar = null;
28
31
  export declare type IMarkAllNotificationsAsReadData = RestrictedData<graphqlNormalize & INotification[], 'markAllNotificationsAsRead'>;
32
+ export declare const MARK_ALL_AS_READ: import("@apollo/client").DocumentNode;
@@ -1 +1,62 @@
1
- export {};
1
+ import { gql } from '@apollo/client';
2
+ import { NOTIFICATIONS, } from '../../query/restricted';
3
+ export const MARK_AS_READ = gql `
4
+ mutation MarkNotificationAsread($id: Int!) {
5
+ restricted {
6
+ markNotificationAsRead(id: $id) {
7
+ actionType
8
+ id
9
+ read
10
+ }
11
+ }
12
+ }
13
+ `;
14
+ export const updateNotificatonsOnMarkAsRead = (cache, result, options) => {
15
+ const { markNotificationAsRead } = result?.data?.restricted || {};
16
+ const { variables } = options || {};
17
+ if (!variables || !markNotificationAsRead) {
18
+ return;
19
+ }
20
+ const { read } = markNotificationAsRead || {};
21
+ if (read) {
22
+ const prevData = cache.readQuery({
23
+ query: NOTIFICATIONS,
24
+ });
25
+ if (prevData) {
26
+ const { id: notificationId } = variables;
27
+ const { notifications } = prevData.restricted;
28
+ const index = notifications.findIndex(({ id }) => Number(id) === Number(notificationId));
29
+ const updatedNotications = [
30
+ ...notifications.slice(0, index),
31
+ { ...notifications[index], read: true },
32
+ ...notifications.slice(index + 1),
33
+ ].sort((n1, n2) => {
34
+ if (n1.read === n2.read) {
35
+ return n1.createdAt < n2.createdAt ? -1 : 1;
36
+ }
37
+ return n1.read ? 1 : -1;
38
+ });
39
+ cache.writeQuery({
40
+ query: NOTIFICATIONS,
41
+ data: {
42
+ ...prevData,
43
+ restricted: {
44
+ ...prevData.restricted,
45
+ notifications: updatedNotications,
46
+ },
47
+ },
48
+ });
49
+ }
50
+ }
51
+ };
52
+ export const MARK_ALL_AS_READ = gql `
53
+ mutation MarkAllNotificationsAsRead {
54
+ restricted {
55
+ markAllNotificationsAsRead {
56
+ actionType
57
+ id
58
+ read
59
+ }
60
+ }
61
+ }
62
+ `;
@@ -5,6 +5,7 @@ export * from './notification';
5
5
  export * from './osce';
6
6
  export * from './qBank';
7
7
  export * from './quesBook';
8
+ export * from './question';
8
9
  export * from './replication';
9
10
  export * from './todos';
10
11
  export * from './topics';
@@ -5,6 +5,7 @@ export * from './notification';
5
5
  export * from './osce';
6
6
  export * from './qBank';
7
7
  export * from './quesBook';
8
+ export * from './question';
8
9
  export * from './replication';
9
10
  export * from './todos';
10
11
  export * from './topics';
@@ -7,3 +7,4 @@ export interface INotificationsVar {
7
7
  };
8
8
  }
9
9
  export declare type INotificationsData = RestrictedData<graphqlNormalize & INotification[], 'notifications'>;
10
+ export declare const NOTIFICATIONS: import("@apollo/client").DocumentNode;
@@ -1 +1,30 @@
1
- export {};
1
+ import { gql } from '@apollo/client';
2
+ export const NOTIFICATIONS = gql `
3
+ query Notifications {
4
+ restricted {
5
+ notifications {
6
+ read
7
+ type
8
+ id
9
+ description
10
+ actionType
11
+ createdAt
12
+ fromUser {
13
+ id
14
+ displayName
15
+ }
16
+ comment {
17
+ id
18
+ comment
19
+ question {
20
+ id
21
+ concept {
22
+ id
23
+ name
24
+ }
25
+ }
26
+ }
27
+ }
28
+ }
29
+ }
30
+ `;
@@ -0,0 +1,7 @@
1
+ import { Id, IQuestion } from '../../../models';
2
+ import { graphqlNormalize, RestrictedData } from '../../types';
3
+ export interface IQuestionVar {
4
+ id: Id;
5
+ }
6
+ export declare type IQuestionData = RestrictedData<graphqlNormalize & IQuestion, 'question'>;
7
+ export declare const QUESTION: import("@apollo/client").DocumentNode;
@@ -0,0 +1,505 @@
1
+ import { gql } from '@apollo/client';
2
+ export const QUESTION = gql `
3
+ query Question($id: Int!) {
4
+ restricted {
5
+ question(id: $id) {
6
+ ... on QuestionSBA {
7
+ conceptId
8
+ difficulty
9
+ dislikes
10
+ explanation
11
+ id
12
+ isLikedByMe
13
+ likes
14
+ question
15
+ totalVotes
16
+ typeId
17
+ choices {
18
+ id
19
+ explanation
20
+ name
21
+ label
22
+ answer
23
+ votes
24
+ picture {
25
+ id
26
+ createdAt
27
+ updatedAt
28
+ name
29
+ caption
30
+ path
31
+ path512
32
+ path256
33
+ }
34
+ }
35
+ comments {
36
+ id
37
+ createdAt
38
+ comment
39
+ likes
40
+ user {
41
+ id
42
+ displayName
43
+ }
44
+ dislikes
45
+ isLikedByMe
46
+ questionId
47
+ replies {
48
+ id
49
+ createdAt
50
+ comment
51
+ user {
52
+ id
53
+ displayName
54
+ }
55
+ likes
56
+ dislikes
57
+ isLikedByMe
58
+ questionId
59
+ }
60
+ }
61
+ concept {
62
+ id
63
+ name
64
+ chapter {
65
+ id
66
+ explanation
67
+ pictures {
68
+ id
69
+ createdAt
70
+ updatedAt
71
+ name
72
+ caption
73
+ path
74
+ path512
75
+ path256
76
+ topicId
77
+ topic {
78
+ id
79
+ name
80
+ typeId
81
+ }
82
+ }
83
+ }
84
+ videos {
85
+ id
86
+ title
87
+ museId
88
+ startTime
89
+ endTime
90
+ thumbnail
91
+ concepts {
92
+ id
93
+ name
94
+ }
95
+ live
96
+ description
97
+ duration
98
+ }
99
+ }
100
+ pictures {
101
+ id
102
+ createdAt
103
+ updatedAt
104
+ name
105
+ caption
106
+ path
107
+ path512
108
+ path256
109
+ topicId
110
+ topic {
111
+ id
112
+ name
113
+ typeId
114
+ }
115
+ }
116
+ difficulty
117
+ psaSectionId
118
+ likes
119
+ dislikes
120
+ isLikedByMe
121
+ sbaAnswer: answer
122
+ }
123
+ ... on QuestionQA {
124
+ conceptId
125
+ difficulty
126
+ dislikes
127
+ explanation
128
+ id
129
+ isLikedByMe
130
+ likes
131
+ question
132
+ totalVotes
133
+ typeId
134
+ choices {
135
+ id
136
+ explanation
137
+ name
138
+ label
139
+ answer
140
+ votes
141
+ picture {
142
+ id
143
+ createdAt
144
+ updatedAt
145
+ name
146
+ caption
147
+ path
148
+ path512
149
+ path256
150
+ }
151
+ }
152
+ comments {
153
+ id
154
+ createdAt
155
+ comment
156
+ likes
157
+ user {
158
+ id
159
+ displayName
160
+ }
161
+ dislikes
162
+ isLikedByMe
163
+ questionId
164
+ replies {
165
+ id
166
+ createdAt
167
+ comment
168
+ user {
169
+ id
170
+ displayName
171
+ }
172
+ likes
173
+ dislikes
174
+ isLikedByMe
175
+ questionId
176
+ }
177
+ }
178
+ concept {
179
+ id
180
+ name
181
+ chapter {
182
+ id
183
+ explanation
184
+ pictures {
185
+ id
186
+ createdAt
187
+ updatedAt
188
+ name
189
+ caption
190
+ path
191
+ path512
192
+ path256
193
+ topicId
194
+ topic {
195
+ id
196
+ name
197
+ typeId
198
+ }
199
+ }
200
+ }
201
+ videos {
202
+ id
203
+ title
204
+ museId
205
+ startTime
206
+ endTime
207
+ thumbnail
208
+ concepts {
209
+ id
210
+ name
211
+ }
212
+ live
213
+ description
214
+ duration
215
+ }
216
+ }
217
+ pictures {
218
+ id
219
+ createdAt
220
+ updatedAt
221
+ name
222
+ caption
223
+ path
224
+ path512
225
+ path256
226
+ topicId
227
+ topic {
228
+ id
229
+ name
230
+ typeId
231
+ }
232
+ }
233
+ difficulty
234
+ psaSectionId
235
+ likes
236
+ dislikes
237
+ isLikedByMe
238
+ qaAnswer: answer {
239
+ dose
240
+ units
241
+ }
242
+ }
243
+ ... on QuestionMultiA {
244
+ conceptId
245
+ difficulty
246
+ dislikes
247
+ explanation
248
+ id
249
+ isLikedByMe
250
+ likes
251
+ question
252
+ totalVotes
253
+ typeId
254
+ choices {
255
+ id
256
+ explanation
257
+ name
258
+ label
259
+ answer
260
+ votes
261
+ picture {
262
+ id
263
+ createdAt
264
+ updatedAt
265
+ name
266
+ caption
267
+ path
268
+ path512
269
+ path256
270
+ }
271
+ }
272
+ comments {
273
+ id
274
+ createdAt
275
+ comment
276
+ likes
277
+ user {
278
+ id
279
+ displayName
280
+ }
281
+ dislikes
282
+ isLikedByMe
283
+ questionId
284
+ replies {
285
+ id
286
+ createdAt
287
+ comment
288
+ user {
289
+ id
290
+ displayName
291
+ }
292
+ likes
293
+ dislikes
294
+ isLikedByMe
295
+ questionId
296
+ }
297
+ }
298
+ concept {
299
+ id
300
+ name
301
+ chapter {
302
+ id
303
+ explanation
304
+ pictures {
305
+ id
306
+ createdAt
307
+ updatedAt
308
+ name
309
+ caption
310
+ path
311
+ path512
312
+ path256
313
+ topicId
314
+ topic {
315
+ id
316
+ name
317
+ typeId
318
+ }
319
+ }
320
+ }
321
+ videos {
322
+ id
323
+ title
324
+ museId
325
+ startTime
326
+ endTime
327
+ thumbnail
328
+ concepts {
329
+ id
330
+ name
331
+ }
332
+ live
333
+ description
334
+ duration
335
+ }
336
+ }
337
+ pictures {
338
+ id
339
+ createdAt
340
+ updatedAt
341
+ name
342
+ caption
343
+ path
344
+ path512
345
+ path256
346
+ topicId
347
+ topic {
348
+ id
349
+ name
350
+ typeId
351
+ }
352
+ }
353
+ difficulty
354
+ psaSectionId
355
+ likes
356
+ dislikes
357
+ isLikedByMe
358
+ multiAnswer: answer
359
+ }
360
+ ... on QuestionPrescription {
361
+ conceptId
362
+ difficulty
363
+ dislikes
364
+ explanation
365
+ id
366
+ isLikedByMe
367
+ likes
368
+ question
369
+ totalVotes
370
+ typeId
371
+ choices {
372
+ id
373
+ explanation
374
+ name
375
+ label
376
+ answer
377
+ votes
378
+ picture {
379
+ id
380
+ createdAt
381
+ updatedAt
382
+ name
383
+ caption
384
+ path
385
+ path512
386
+ path256
387
+ }
388
+ }
389
+ comments {
390
+ id
391
+ createdAt
392
+ comment
393
+ likes
394
+ user {
395
+ id
396
+ displayName
397
+ }
398
+ dislikes
399
+ isLikedByMe
400
+ questionId
401
+ replies {
402
+ id
403
+ createdAt
404
+ comment
405
+ user {
406
+ id
407
+ displayName
408
+ }
409
+ likes
410
+ dislikes
411
+ isLikedByMe
412
+ questionId
413
+ }
414
+ }
415
+ concept {
416
+ id
417
+ name
418
+ chapter {
419
+ id
420
+ explanation
421
+ pictures {
422
+ id
423
+ createdAt
424
+ updatedAt
425
+ name
426
+ caption
427
+ path
428
+ path512
429
+ path256
430
+ topicId
431
+ topic {
432
+ id
433
+ name
434
+ typeId
435
+ }
436
+ }
437
+ }
438
+ videos {
439
+ id
440
+ title
441
+ museId
442
+ startTime
443
+ endTime
444
+ thumbnail
445
+ concepts {
446
+ id
447
+ name
448
+ }
449
+ live
450
+ description
451
+ duration
452
+ }
453
+ }
454
+ pictures {
455
+ id
456
+ createdAt
457
+ updatedAt
458
+ name
459
+ caption
460
+ path
461
+ path512
462
+ path256
463
+ topicId
464
+ topic {
465
+ id
466
+ name
467
+ typeId
468
+ }
469
+ }
470
+ difficulty
471
+ psaSectionId
472
+ likes
473
+ dislikes
474
+ isLikedByMe
475
+ prescribeAnswer: answer {
476
+ dose {
477
+ value
478
+ display
479
+ }
480
+ drug {
481
+ value
482
+ display
483
+ }
484
+ route {
485
+ value
486
+ display
487
+ }
488
+ frequency {
489
+ display
490
+ value
491
+ }
492
+ duration {
493
+ display
494
+ value
495
+ }
496
+ units {
497
+ display
498
+ value
499
+ }
500
+ }
501
+ }
502
+ }
503
+ }
504
+ }
505
+ `;