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