@quesmed/types-rn 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.
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quesmed/types-rn",
3
- "version": "2.2.87",
3
+ "version": "2.2.89",
4
4
  "description": "Typescript types for Quesmed",
5
5
  "keywords": [
6
6
  "quesmed",
@@ -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,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;