@quesmed/types 2.4.11 → 2.4.12

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.
@@ -79,6 +79,26 @@ export interface IQuestion {
79
79
  dislikes?: number;
80
80
  isLikedByMe?: EQuestionLike;
81
81
  comments?: IQuestionComment[];
82
+ highlights?: Array<IHighlight>;
83
+ }
84
+ export interface IHighlight {
85
+ start: number;
86
+ end: number;
87
+ text: string;
88
+ color?: string;
89
+ part?: string;
90
+ tag?: string;
91
+ }
92
+ export interface IQuestionHighlights {
93
+ id: Id;
94
+ createdAt: number | Date;
95
+ updatedAt: number | Date;
96
+ deletedAt: number | Date;
97
+ userId?: Id;
98
+ questionId?: Id;
99
+ user?: IUser;
100
+ question?: IQuestion;
101
+ highlights?: Array<IHighlight>;
82
102
  }
83
103
  export interface IQuestionChoice {
84
104
  id: Id;
@@ -1,6 +1,7 @@
1
1
  import { ICard } from './Card';
2
2
  import { IConcept } from './Concept';
3
3
  import { IMarksheet, IMarksheetMark } from './Marksheet';
4
+ import { IQuestionHighlights } from './Question';
4
5
  import { INotification } from './Notification';
5
6
  import { IQuestion } from './Question';
6
7
  import { ISubscription } from './Subscription';
@@ -93,6 +94,7 @@ export interface IUser {
93
94
  qbankSubscriptionEndDate: number | Date | null;
94
95
  osceSubscriptionEndDate: number | Date | null;
95
96
  bundleSubscriptionEndDate: number | Date | null;
97
+ questionHighlights?: IQuestionHighlights[];
96
98
  }
97
99
  export declare function currentClassYear(createdAtUnix: number, classYear: IClassYear, compareUnix?: number): IClassYear;
98
100
  export declare function currentClassGroup(createdAtUnix: number, classYear: IClassYear): EClassYearGroup;
@@ -68,6 +68,14 @@ exports.BUILD_QUESTION_MARKSHEET = (0, client_1.gql) `
68
68
  question
69
69
  totalVotes
70
70
  typeId
71
+ highlights {
72
+ start
73
+ end
74
+ text
75
+ part
76
+ tag
77
+ color
78
+ }
71
79
  choices {
72
80
  id
73
81
  explanation
@@ -188,6 +196,14 @@ exports.BUILD_QUESTION_MARKSHEET = (0, client_1.gql) `
188
196
  question
189
197
  totalVotes
190
198
  typeId
199
+ highlights {
200
+ start
201
+ end
202
+ text
203
+ part
204
+ tag
205
+ color
206
+ }
191
207
  choices {
192
208
  id
193
209
  explanation
@@ -311,6 +327,14 @@ exports.BUILD_QUESTION_MARKSHEET = (0, client_1.gql) `
311
327
  question
312
328
  totalVotes
313
329
  typeId
330
+ highlights {
331
+ start
332
+ end
333
+ text
334
+ part
335
+ tag
336
+ color
337
+ }
314
338
  choices {
315
339
  id
316
340
  explanation
@@ -431,6 +455,14 @@ exports.BUILD_QUESTION_MARKSHEET = (0, client_1.gql) `
431
455
  question
432
456
  totalVotes
433
457
  typeId
458
+ highlights {
459
+ start
460
+ end
461
+ text
462
+ part
463
+ tag
464
+ color
465
+ }
434
466
  choices {
435
467
  id
436
468
  explanation
@@ -646,6 +678,14 @@ exports.BUILD_MARKSHEET = (0, client_1.gql) `
646
678
  question
647
679
  totalVotes
648
680
  typeId
681
+ highlights {
682
+ start
683
+ end
684
+ text
685
+ part
686
+ tag
687
+ color
688
+ }
649
689
  choices {
650
690
  id
651
691
  explanation
@@ -766,6 +806,14 @@ exports.BUILD_MARKSHEET = (0, client_1.gql) `
766
806
  question
767
807
  totalVotes
768
808
  typeId
809
+ highlights {
810
+ start
811
+ end
812
+ text
813
+ part
814
+ tag
815
+ color
816
+ }
769
817
  choices {
770
818
  id
771
819
  explanation
@@ -889,6 +937,14 @@ exports.BUILD_MARKSHEET = (0, client_1.gql) `
889
937
  question
890
938
  totalVotes
891
939
  typeId
940
+ highlights {
941
+ start
942
+ end
943
+ text
944
+ part
945
+ tag
946
+ color
947
+ }
892
948
  choices {
893
949
  id
894
950
  explanation
@@ -1009,6 +1065,14 @@ exports.BUILD_MARKSHEET = (0, client_1.gql) `
1009
1065
  question
1010
1066
  totalVotes
1011
1067
  typeId
1068
+ highlights {
1069
+ start
1070
+ end
1071
+ text
1072
+ part
1073
+ tag
1074
+ color
1075
+ }
1012
1076
  choices {
1013
1077
  id
1014
1078
  explanation
@@ -1229,6 +1293,14 @@ exports.RE_BUILD_MARKSHEET = (0, client_1.gql) `
1229
1293
  question
1230
1294
  totalVotes
1231
1295
  typeId
1296
+ highlights {
1297
+ start
1298
+ end
1299
+ text
1300
+ part
1301
+ tag
1302
+ color
1303
+ }
1232
1304
  choices {
1233
1305
  id
1234
1306
  explanation
@@ -1349,6 +1421,14 @@ exports.RE_BUILD_MARKSHEET = (0, client_1.gql) `
1349
1421
  question
1350
1422
  totalVotes
1351
1423
  typeId
1424
+ highlights {
1425
+ start
1426
+ end
1427
+ text
1428
+ part
1429
+ tag
1430
+ color
1431
+ }
1352
1432
  choices {
1353
1433
  id
1354
1434
  explanation
@@ -1472,6 +1552,14 @@ exports.RE_BUILD_MARKSHEET = (0, client_1.gql) `
1472
1552
  question
1473
1553
  totalVotes
1474
1554
  typeId
1555
+ highlights {
1556
+ start
1557
+ end
1558
+ text
1559
+ part
1560
+ tag
1561
+ color
1562
+ }
1475
1563
  choices {
1476
1564
  id
1477
1565
  explanation
@@ -1592,6 +1680,14 @@ exports.RE_BUILD_MARKSHEET = (0, client_1.gql) `
1592
1680
  question
1593
1681
  totalVotes
1594
1682
  typeId
1683
+ highlights {
1684
+ start
1685
+ end
1686
+ text
1687
+ part
1688
+ tag
1689
+ color
1690
+ }
1595
1691
  choices {
1596
1692
  id
1597
1693
  explanation
@@ -1,6 +1,6 @@
1
1
  import { ApolloCache, DocumentNode } from '@apollo/client';
2
2
  import { ApolloUpdateOptions, ApolloUpdateResultRestricted } from '../..';
3
- import { EQuestionLike, EQuestionType, Id, IQuestion, IQuestionComment } from '../../../models';
3
+ import { EQuestionLike, EQuestionType, Id, IHighlight, IQuestion, IQuestionComment, IQuestionHighlights } from '../../../models';
4
4
  import { graphqlNormalize, RestrictedData } from '../../types';
5
5
  interface LikeData {
6
6
  likes?: number;
@@ -9,9 +9,14 @@ interface LikeData {
9
9
  }
10
10
  export declare const QUESTION_SBA_COMMENT_FIELDS: DocumentNode;
11
11
  export declare const QUESTION_QA_COMMENT_FIELDS: DocumentNode;
12
+ export declare const QUESTION_QA_HIGHLIGHT_FIELDS: DocumentNode;
13
+ export declare const QUESTION_SBA_HIGHLIGHT_FIELDS: DocumentNode;
14
+ export declare const QUESTION_MULTIA_HIGHLIGHT_FIELDS: DocumentNode;
15
+ export declare const QUESTION_PRESCRIPTION_HIGHLIGHT_FIELDS: DocumentNode;
12
16
  export declare const QUESTION_MULTIA_COMMENT_FIELDS: DocumentNode;
13
17
  export declare const QUESTION_PRESCRIPTION_COMMENT_FIELDS: DocumentNode;
14
18
  export declare const getLikeData: (like: EQuestionLike, item: LikeData) => LikeData;
19
+ export declare const getQuestionHighlightsFragment: (typeId: EQuestionType) => DocumentNode;
15
20
  export declare const getQuestionTypeName: (typeId: EQuestionType) => string;
16
21
  export declare const QUESTION_LIKE: DocumentNode;
17
22
  export declare const optimisticQuestionLike: (input: IQuestionLikeVar, question: IQuestion) => IQuestionLikeData;
@@ -52,4 +57,16 @@ export interface IQuestionCommentRemoveVar {
52
57
  commentId: Id;
53
58
  }
54
59
  export declare type IQuestionCommentRemoveData = RestrictedData<graphqlNormalize & IQuestionComment, 'questionCommentRemove'>;
60
+ /**
61
+ * addQuestionHighlight
62
+ */
63
+ export interface IAddQuestionHighlightVar {
64
+ input: {
65
+ questionId: Id;
66
+ highlights: IHighlight[];
67
+ }[];
68
+ }
69
+ export declare type IAddQuestionHighlightData = RestrictedData<(graphqlNormalize & IQuestionHighlights)[], 'addQuestionHighlight'>;
70
+ export declare const ADD_QUESTION_HIGHLIGHT: DocumentNode;
71
+ export declare const updateQuestionHighlights: (typeId: EQuestionType) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IAddQuestionHighlightData>, options: ApolloUpdateOptions) => void;
55
72
  export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.optimisticQuestionCommentRemove = exports.updateQuestionCommentsRemove = exports.QUESTION_COMMENT_REMOVE = exports.optimisticCommentLike = exports.QUESTION_COMMENT_LIKE = exports.optimisticQuestionComment = exports.updateQuestionComments = exports.QUESTION_COMMENTS = exports.optimisticQuestionLike = exports.QUESTION_LIKE = exports.getQuestionTypeName = exports.getLikeData = exports.QUESTION_PRESCRIPTION_COMMENT_FIELDS = exports.QUESTION_MULTIA_COMMENT_FIELDS = exports.QUESTION_QA_COMMENT_FIELDS = exports.QUESTION_SBA_COMMENT_FIELDS = void 0;
3
+ exports.updateQuestionHighlights = exports.ADD_QUESTION_HIGHLIGHT = exports.optimisticQuestionCommentRemove = exports.updateQuestionCommentsRemove = exports.QUESTION_COMMENT_REMOVE = exports.optimisticCommentLike = exports.QUESTION_COMMENT_LIKE = exports.optimisticQuestionComment = exports.updateQuestionComments = exports.QUESTION_COMMENTS = exports.optimisticQuestionLike = exports.QUESTION_LIKE = exports.getQuestionTypeName = exports.getQuestionHighlightsFragment = exports.getLikeData = exports.QUESTION_PRESCRIPTION_COMMENT_FIELDS = exports.QUESTION_MULTIA_COMMENT_FIELDS = exports.QUESTION_PRESCRIPTION_HIGHLIGHT_FIELDS = exports.QUESTION_MULTIA_HIGHLIGHT_FIELDS = exports.QUESTION_SBA_HIGHLIGHT_FIELDS = exports.QUESTION_QA_HIGHLIGHT_FIELDS = exports.QUESTION_QA_COMMENT_FIELDS = exports.QUESTION_SBA_COMMENT_FIELDS = void 0;
4
4
  const client_1 = require("@apollo/client");
5
5
  const models_1 = require("../../../models");
6
6
  exports.QUESTION_SBA_COMMENT_FIELDS = (0, client_1.gql) `
@@ -9,6 +9,14 @@ exports.QUESTION_SBA_COMMENT_FIELDS = (0, client_1.gql) `
9
9
  likes
10
10
  dislikes
11
11
  isLikedByMe
12
+ highlights {
13
+ start
14
+ end
15
+ text
16
+ part
17
+ tag
18
+ color
19
+ }
12
20
  comments {
13
21
  id
14
22
  createdAt
@@ -45,6 +53,14 @@ exports.QUESTION_QA_COMMENT_FIELDS = (0, client_1.gql) `
45
53
  likes
46
54
  dislikes
47
55
  isLikedByMe
56
+ highlights {
57
+ start
58
+ end
59
+ text
60
+ part
61
+ tag
62
+ color
63
+ }
48
64
  comments {
49
65
  id
50
66
  createdAt
@@ -75,12 +91,68 @@ exports.QUESTION_QA_COMMENT_FIELDS = (0, client_1.gql) `
75
91
  }
76
92
  }
77
93
  `;
94
+ exports.QUESTION_QA_HIGHLIGHT_FIELDS = (0, client_1.gql) `
95
+ fragment QuestionQAHighlights on QuestionQA {
96
+ highlights {
97
+ start
98
+ end
99
+ text
100
+ part
101
+ tag
102
+ color
103
+ }
104
+ }
105
+ `;
106
+ exports.QUESTION_SBA_HIGHLIGHT_FIELDS = (0, client_1.gql) `
107
+ fragment QuestionSBAHighlights on QuestionSBA {
108
+ highlights {
109
+ start
110
+ end
111
+ text
112
+ part
113
+ tag
114
+ color
115
+ }
116
+ }
117
+ `;
118
+ exports.QUESTION_MULTIA_HIGHLIGHT_FIELDS = (0, client_1.gql) `
119
+ fragment QuestionMultiAHighlights on QuestionMultiA {
120
+ highlights {
121
+ start
122
+ end
123
+ text
124
+ part
125
+ tag
126
+ color
127
+ }
128
+ }
129
+ `;
130
+ exports.QUESTION_PRESCRIPTION_HIGHLIGHT_FIELDS = (0, client_1.gql) `
131
+ fragment QuestionPrescriptionHighlights on QuestionPrescription {
132
+ highlights {
133
+ start
134
+ end
135
+ text
136
+ part
137
+ tag
138
+ color
139
+ }
140
+ }
141
+ `;
78
142
  exports.QUESTION_MULTIA_COMMENT_FIELDS = (0, client_1.gql) `
79
143
  fragment QuestionMultiAComments on QuestionMultiA {
80
144
  id
81
145
  likes
82
146
  dislikes
83
147
  isLikedByMe
148
+ highlights {
149
+ start
150
+ end
151
+ text
152
+ part
153
+ tag
154
+ color
155
+ }
84
156
  comments {
85
157
  id
86
158
  createdAt
@@ -117,6 +189,14 @@ exports.QUESTION_PRESCRIPTION_COMMENT_FIELDS = (0, client_1.gql) `
117
189
  likes
118
190
  dislikes
119
191
  isLikedByMe
192
+ highlights {
193
+ start
194
+ end
195
+ text
196
+ part
197
+ tag
198
+ color
199
+ }
120
200
  comments {
121
201
  id
122
202
  createdAt
@@ -172,6 +252,20 @@ const getLikeData = (like, item) => {
172
252
  return { likes, dislikes, isLikedByMe: like };
173
253
  };
174
254
  exports.getLikeData = getLikeData;
255
+ const getQuestionHighlightsFragment = (typeId) => {
256
+ switch (typeId) {
257
+ case models_1.EQuestionType.QUESTION_ANSWER:
258
+ return exports.QUESTION_QA_HIGHLIGHT_FIELDS;
259
+ case models_1.EQuestionType.PRESCRIPTION_ANSWER:
260
+ return exports.QUESTION_PRESCRIPTION_HIGHLIGHT_FIELDS;
261
+ case models_1.EQuestionType.MULTIPLE_ANSWERS:
262
+ return exports.QUESTION_MULTIA_HIGHLIGHT_FIELDS;
263
+ case models_1.EQuestionType.SINGLE_BEST_ANSWER:
264
+ default:
265
+ return exports.QUESTION_SBA_HIGHLIGHT_FIELDS;
266
+ }
267
+ };
268
+ exports.getQuestionHighlightsFragment = getQuestionHighlightsFragment;
175
269
  const getQuestionTypeName = (typeId) => {
176
270
  switch (typeId) {
177
271
  case models_1.EQuestionType.QUESTION_ANSWER:
@@ -527,3 +621,48 @@ const optimisticQuestionCommentRemove = (comments, input, parentId) => {
527
621
  };
528
622
  };
529
623
  exports.optimisticQuestionCommentRemove = optimisticQuestionCommentRemove;
624
+ exports.ADD_QUESTION_HIGHLIGHT = (0, client_1.gql) `
625
+ mutation AddHighlight($input: [AddQuestionHighlightInput!]!) {
626
+ restricted {
627
+ addQuestionHighlight(input: $input) {
628
+ id
629
+ questionId
630
+ userId
631
+ highlights {
632
+ start
633
+ end
634
+ text
635
+ part
636
+ tag
637
+ color
638
+ }
639
+ }
640
+ }
641
+ }
642
+ `;
643
+ const updateQuestionHighlights = (typeId) => (cache, result, options) => {
644
+ const { addQuestionHighlight } = result?.data?.restricted ?? {};
645
+ const { variables } = options || {};
646
+ if (!variables || !addQuestionHighlight) {
647
+ return;
648
+ }
649
+ const { input } = variables;
650
+ try {
651
+ input.forEach(({ questionId }) => {
652
+ cache.writeFragment({
653
+ id: cache.identify({
654
+ id: questionId,
655
+ __typename: (0, exports.getQuestionTypeName)(typeId),
656
+ }),
657
+ data: {
658
+ highlights: addQuestionHighlight[0].highlights,
659
+ },
660
+ fragment: (0, exports.getQuestionHighlightsFragment)(typeId),
661
+ });
662
+ });
663
+ }
664
+ catch (error) {
665
+ console.error(error);
666
+ }
667
+ };
668
+ exports.updateQuestionHighlights = updateQuestionHighlights;
@@ -74,6 +74,14 @@ exports.MARKSHEET = (0, client_1.gql) `
74
74
  question
75
75
  totalVotes
76
76
  typeId
77
+ highlights {
78
+ start
79
+ end
80
+ text
81
+ part
82
+ tag
83
+ color
84
+ }
77
85
  choices {
78
86
  id
79
87
  explanation
@@ -194,6 +202,14 @@ exports.MARKSHEET = (0, client_1.gql) `
194
202
  question
195
203
  totalVotes
196
204
  typeId
205
+ highlights {
206
+ start
207
+ end
208
+ text
209
+ part
210
+ tag
211
+ color
212
+ }
197
213
  choices {
198
214
  id
199
215
  explanation
@@ -317,6 +333,14 @@ exports.MARKSHEET = (0, client_1.gql) `
317
333
  question
318
334
  totalVotes
319
335
  typeId
336
+ highlights {
337
+ start
338
+ end
339
+ text
340
+ part
341
+ tag
342
+ color
343
+ }
320
344
  choices {
321
345
  id
322
346
  explanation
@@ -437,6 +461,14 @@ exports.MARKSHEET = (0, client_1.gql) `
437
461
  question
438
462
  totalVotes
439
463
  typeId
464
+ highlights {
465
+ start
466
+ end
467
+ text
468
+ part
469
+ tag
470
+ color
471
+ }
440
472
  choices {
441
473
  id
442
474
  explanation
@@ -637,6 +669,14 @@ exports.FLAGGED_QUESTIONS = (0, client_1.gql) `
637
669
  question
638
670
  totalVotes
639
671
  typeId
672
+ highlights {
673
+ start
674
+ end
675
+ text
676
+ part
677
+ tag
678
+ color
679
+ }
640
680
  choices {
641
681
  id
642
682
  explanation
@@ -764,6 +804,14 @@ exports.FLAGGED_QUESTIONS = (0, client_1.gql) `
764
804
  question
765
805
  totalVotes
766
806
  typeId
807
+ highlights {
808
+ start
809
+ end
810
+ text
811
+ part
812
+ tag
813
+ color
814
+ }
767
815
  choices {
768
816
  id
769
817
  explanation
@@ -884,6 +932,14 @@ exports.FLAGGED_QUESTIONS = (0, client_1.gql) `
884
932
  question
885
933
  totalVotes
886
934
  typeId
935
+ highlights {
936
+ start
937
+ end
938
+ text
939
+ part
940
+ tag
941
+ color
942
+ }
887
943
  choices {
888
944
  id
889
945
  explanation
@@ -1007,6 +1063,14 @@ exports.FLAGGED_QUESTIONS = (0, client_1.gql) `
1007
1063
  question
1008
1064
  totalVotes
1009
1065
  typeId
1066
+ highlights {
1067
+ start
1068
+ end
1069
+ text
1070
+ part
1071
+ tag
1072
+ color
1073
+ }
1010
1074
  choices {
1011
1075
  id
1012
1076
  explanation
@@ -1127,6 +1191,14 @@ exports.FLAGGED_QUESTIONS = (0, client_1.gql) `
1127
1191
  question
1128
1192
  totalVotes
1129
1193
  typeId
1194
+ highlights {
1195
+ start
1196
+ end
1197
+ text
1198
+ part
1199
+ tag
1200
+ color
1201
+ }
1130
1202
  choices {
1131
1203
  id
1132
1204
  explanation
@@ -1335,6 +1407,14 @@ exports.FLAGGED_QUESTIONS_MARKSHEET = (0, client_1.gql) `
1335
1407
  question
1336
1408
  totalVotes
1337
1409
  typeId
1410
+ highlights {
1411
+ start
1412
+ end
1413
+ text
1414
+ part
1415
+ tag
1416
+ color
1417
+ }
1338
1418
  choices {
1339
1419
  id
1340
1420
  explanation
@@ -1455,6 +1535,14 @@ exports.FLAGGED_QUESTIONS_MARKSHEET = (0, client_1.gql) `
1455
1535
  question
1456
1536
  totalVotes
1457
1537
  typeId
1538
+ highlights {
1539
+ start
1540
+ end
1541
+ text
1542
+ part
1543
+ tag
1544
+ color
1545
+ }
1458
1546
  choices {
1459
1547
  id
1460
1548
  explanation
@@ -1578,6 +1666,14 @@ exports.FLAGGED_QUESTIONS_MARKSHEET = (0, client_1.gql) `
1578
1666
  question
1579
1667
  totalVotes
1580
1668
  typeId
1669
+ highlights {
1670
+ start
1671
+ end
1672
+ text
1673
+ part
1674
+ tag
1675
+ color
1676
+ }
1581
1677
  choices {
1582
1678
  id
1583
1679
  explanation
@@ -1698,6 +1794,14 @@ exports.FLAGGED_QUESTIONS_MARKSHEET = (0, client_1.gql) `
1698
1794
  question
1699
1795
  totalVotes
1700
1796
  typeId
1797
+ highlights {
1798
+ start
1799
+ end
1800
+ text
1801
+ part
1802
+ tag
1803
+ color
1804
+ }
1701
1805
  choices {
1702
1806
  id
1703
1807
  explanation
@@ -79,6 +79,26 @@ export interface IQuestion {
79
79
  dislikes?: number;
80
80
  isLikedByMe?: EQuestionLike;
81
81
  comments?: IQuestionComment[];
82
+ highlights?: Array<IHighlight>;
83
+ }
84
+ export interface IHighlight {
85
+ start: number;
86
+ end: number;
87
+ text: string;
88
+ color?: string;
89
+ part?: string;
90
+ tag?: string;
91
+ }
92
+ export interface IQuestionHighlights {
93
+ id: Id;
94
+ createdAt: number | Date;
95
+ updatedAt: number | Date;
96
+ deletedAt: number | Date;
97
+ userId?: Id;
98
+ questionId?: Id;
99
+ user?: IUser;
100
+ question?: IQuestion;
101
+ highlights?: Array<IHighlight>;
82
102
  }
83
103
  export interface IQuestionChoice {
84
104
  id: Id;
@@ -1,6 +1,7 @@
1
1
  import { ICard } from './Card';
2
2
  import { IConcept } from './Concept';
3
3
  import { IMarksheet, IMarksheetMark } from './Marksheet';
4
+ import { IQuestionHighlights } from './Question';
4
5
  import { INotification } from './Notification';
5
6
  import { IQuestion } from './Question';
6
7
  import { ISubscription } from './Subscription';
@@ -93,6 +94,7 @@ export interface IUser {
93
94
  qbankSubscriptionEndDate: number | Date | null;
94
95
  osceSubscriptionEndDate: number | Date | null;
95
96
  bundleSubscriptionEndDate: number | Date | null;
97
+ questionHighlights?: IQuestionHighlights[];
96
98
  }
97
99
  export declare function currentClassYear(createdAtUnix: number, classYear: IClassYear, compareUnix?: number): IClassYear;
98
100
  export declare function currentClassGroup(createdAtUnix: number, classYear: IClassYear): EClassYearGroup;
@@ -65,6 +65,14 @@ export const BUILD_QUESTION_MARKSHEET = gql `
65
65
  question
66
66
  totalVotes
67
67
  typeId
68
+ highlights {
69
+ start
70
+ end
71
+ text
72
+ part
73
+ tag
74
+ color
75
+ }
68
76
  choices {
69
77
  id
70
78
  explanation
@@ -185,6 +193,14 @@ export const BUILD_QUESTION_MARKSHEET = gql `
185
193
  question
186
194
  totalVotes
187
195
  typeId
196
+ highlights {
197
+ start
198
+ end
199
+ text
200
+ part
201
+ tag
202
+ color
203
+ }
188
204
  choices {
189
205
  id
190
206
  explanation
@@ -308,6 +324,14 @@ export const BUILD_QUESTION_MARKSHEET = gql `
308
324
  question
309
325
  totalVotes
310
326
  typeId
327
+ highlights {
328
+ start
329
+ end
330
+ text
331
+ part
332
+ tag
333
+ color
334
+ }
311
335
  choices {
312
336
  id
313
337
  explanation
@@ -428,6 +452,14 @@ export const BUILD_QUESTION_MARKSHEET = gql `
428
452
  question
429
453
  totalVotes
430
454
  typeId
455
+ highlights {
456
+ start
457
+ end
458
+ text
459
+ part
460
+ tag
461
+ color
462
+ }
431
463
  choices {
432
464
  id
433
465
  explanation
@@ -643,6 +675,14 @@ export const BUILD_MARKSHEET = gql `
643
675
  question
644
676
  totalVotes
645
677
  typeId
678
+ highlights {
679
+ start
680
+ end
681
+ text
682
+ part
683
+ tag
684
+ color
685
+ }
646
686
  choices {
647
687
  id
648
688
  explanation
@@ -763,6 +803,14 @@ export const BUILD_MARKSHEET = gql `
763
803
  question
764
804
  totalVotes
765
805
  typeId
806
+ highlights {
807
+ start
808
+ end
809
+ text
810
+ part
811
+ tag
812
+ color
813
+ }
766
814
  choices {
767
815
  id
768
816
  explanation
@@ -886,6 +934,14 @@ export const BUILD_MARKSHEET = gql `
886
934
  question
887
935
  totalVotes
888
936
  typeId
937
+ highlights {
938
+ start
939
+ end
940
+ text
941
+ part
942
+ tag
943
+ color
944
+ }
889
945
  choices {
890
946
  id
891
947
  explanation
@@ -1006,6 +1062,14 @@ export const BUILD_MARKSHEET = gql `
1006
1062
  question
1007
1063
  totalVotes
1008
1064
  typeId
1065
+ highlights {
1066
+ start
1067
+ end
1068
+ text
1069
+ part
1070
+ tag
1071
+ color
1072
+ }
1009
1073
  choices {
1010
1074
  id
1011
1075
  explanation
@@ -1226,6 +1290,14 @@ export const RE_BUILD_MARKSHEET = gql `
1226
1290
  question
1227
1291
  totalVotes
1228
1292
  typeId
1293
+ highlights {
1294
+ start
1295
+ end
1296
+ text
1297
+ part
1298
+ tag
1299
+ color
1300
+ }
1229
1301
  choices {
1230
1302
  id
1231
1303
  explanation
@@ -1346,6 +1418,14 @@ export const RE_BUILD_MARKSHEET = gql `
1346
1418
  question
1347
1419
  totalVotes
1348
1420
  typeId
1421
+ highlights {
1422
+ start
1423
+ end
1424
+ text
1425
+ part
1426
+ tag
1427
+ color
1428
+ }
1349
1429
  choices {
1350
1430
  id
1351
1431
  explanation
@@ -1469,6 +1549,14 @@ export const RE_BUILD_MARKSHEET = gql `
1469
1549
  question
1470
1550
  totalVotes
1471
1551
  typeId
1552
+ highlights {
1553
+ start
1554
+ end
1555
+ text
1556
+ part
1557
+ tag
1558
+ color
1559
+ }
1472
1560
  choices {
1473
1561
  id
1474
1562
  explanation
@@ -1589,6 +1677,14 @@ export const RE_BUILD_MARKSHEET = gql `
1589
1677
  question
1590
1678
  totalVotes
1591
1679
  typeId
1680
+ highlights {
1681
+ start
1682
+ end
1683
+ text
1684
+ part
1685
+ tag
1686
+ color
1687
+ }
1592
1688
  choices {
1593
1689
  id
1594
1690
  explanation
@@ -1,6 +1,6 @@
1
1
  import { ApolloCache, DocumentNode } from '@apollo/client';
2
2
  import { ApolloUpdateOptions, ApolloUpdateResultRestricted } from '../..';
3
- import { EQuestionLike, EQuestionType, Id, IQuestion, IQuestionComment } from '../../../models';
3
+ import { EQuestionLike, EQuestionType, Id, IHighlight, IQuestion, IQuestionComment, IQuestionHighlights } from '../../../models';
4
4
  import { graphqlNormalize, RestrictedData } from '../../types';
5
5
  interface LikeData {
6
6
  likes?: number;
@@ -9,9 +9,14 @@ interface LikeData {
9
9
  }
10
10
  export declare const QUESTION_SBA_COMMENT_FIELDS: DocumentNode;
11
11
  export declare const QUESTION_QA_COMMENT_FIELDS: DocumentNode;
12
+ export declare const QUESTION_QA_HIGHLIGHT_FIELDS: DocumentNode;
13
+ export declare const QUESTION_SBA_HIGHLIGHT_FIELDS: DocumentNode;
14
+ export declare const QUESTION_MULTIA_HIGHLIGHT_FIELDS: DocumentNode;
15
+ export declare const QUESTION_PRESCRIPTION_HIGHLIGHT_FIELDS: DocumentNode;
12
16
  export declare const QUESTION_MULTIA_COMMENT_FIELDS: DocumentNode;
13
17
  export declare const QUESTION_PRESCRIPTION_COMMENT_FIELDS: DocumentNode;
14
18
  export declare const getLikeData: (like: EQuestionLike, item: LikeData) => LikeData;
19
+ export declare const getQuestionHighlightsFragment: (typeId: EQuestionType) => DocumentNode;
15
20
  export declare const getQuestionTypeName: (typeId: EQuestionType) => string;
16
21
  export declare const QUESTION_LIKE: DocumentNode;
17
22
  export declare const optimisticQuestionLike: (input: IQuestionLikeVar, question: IQuestion) => IQuestionLikeData;
@@ -52,4 +57,16 @@ export interface IQuestionCommentRemoveVar {
52
57
  commentId: Id;
53
58
  }
54
59
  export declare type IQuestionCommentRemoveData = RestrictedData<graphqlNormalize & IQuestionComment, 'questionCommentRemove'>;
60
+ /**
61
+ * addQuestionHighlight
62
+ */
63
+ export interface IAddQuestionHighlightVar {
64
+ input: {
65
+ questionId: Id;
66
+ highlights: IHighlight[];
67
+ }[];
68
+ }
69
+ export declare type IAddQuestionHighlightData = RestrictedData<(graphqlNormalize & IQuestionHighlights)[], 'addQuestionHighlight'>;
70
+ export declare const ADD_QUESTION_HIGHLIGHT: DocumentNode;
71
+ export declare const updateQuestionHighlights: (typeId: EQuestionType) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IAddQuestionHighlightData>, options: ApolloUpdateOptions) => void;
55
72
  export {};
@@ -6,6 +6,14 @@ export const QUESTION_SBA_COMMENT_FIELDS = gql `
6
6
  likes
7
7
  dislikes
8
8
  isLikedByMe
9
+ highlights {
10
+ start
11
+ end
12
+ text
13
+ part
14
+ tag
15
+ color
16
+ }
9
17
  comments {
10
18
  id
11
19
  createdAt
@@ -42,6 +50,14 @@ export const QUESTION_QA_COMMENT_FIELDS = gql `
42
50
  likes
43
51
  dislikes
44
52
  isLikedByMe
53
+ highlights {
54
+ start
55
+ end
56
+ text
57
+ part
58
+ tag
59
+ color
60
+ }
45
61
  comments {
46
62
  id
47
63
  createdAt
@@ -72,12 +88,68 @@ export const QUESTION_QA_COMMENT_FIELDS = gql `
72
88
  }
73
89
  }
74
90
  `;
91
+ export const QUESTION_QA_HIGHLIGHT_FIELDS = gql `
92
+ fragment QuestionQAHighlights on QuestionQA {
93
+ highlights {
94
+ start
95
+ end
96
+ text
97
+ part
98
+ tag
99
+ color
100
+ }
101
+ }
102
+ `;
103
+ export const QUESTION_SBA_HIGHLIGHT_FIELDS = gql `
104
+ fragment QuestionSBAHighlights on QuestionSBA {
105
+ highlights {
106
+ start
107
+ end
108
+ text
109
+ part
110
+ tag
111
+ color
112
+ }
113
+ }
114
+ `;
115
+ export const QUESTION_MULTIA_HIGHLIGHT_FIELDS = gql `
116
+ fragment QuestionMultiAHighlights on QuestionMultiA {
117
+ highlights {
118
+ start
119
+ end
120
+ text
121
+ part
122
+ tag
123
+ color
124
+ }
125
+ }
126
+ `;
127
+ export const QUESTION_PRESCRIPTION_HIGHLIGHT_FIELDS = gql `
128
+ fragment QuestionPrescriptionHighlights on QuestionPrescription {
129
+ highlights {
130
+ start
131
+ end
132
+ text
133
+ part
134
+ tag
135
+ color
136
+ }
137
+ }
138
+ `;
75
139
  export const QUESTION_MULTIA_COMMENT_FIELDS = gql `
76
140
  fragment QuestionMultiAComments on QuestionMultiA {
77
141
  id
78
142
  likes
79
143
  dislikes
80
144
  isLikedByMe
145
+ highlights {
146
+ start
147
+ end
148
+ text
149
+ part
150
+ tag
151
+ color
152
+ }
81
153
  comments {
82
154
  id
83
155
  createdAt
@@ -114,6 +186,14 @@ export const QUESTION_PRESCRIPTION_COMMENT_FIELDS = gql `
114
186
  likes
115
187
  dislikes
116
188
  isLikedByMe
189
+ highlights {
190
+ start
191
+ end
192
+ text
193
+ part
194
+ tag
195
+ color
196
+ }
117
197
  comments {
118
198
  id
119
199
  createdAt
@@ -168,6 +248,19 @@ export const getLikeData = (like, item) => {
168
248
  }
169
249
  return { likes, dislikes, isLikedByMe: like };
170
250
  };
251
+ export const getQuestionHighlightsFragment = (typeId) => {
252
+ switch (typeId) {
253
+ case EQuestionType.QUESTION_ANSWER:
254
+ return QUESTION_QA_HIGHLIGHT_FIELDS;
255
+ case EQuestionType.PRESCRIPTION_ANSWER:
256
+ return QUESTION_PRESCRIPTION_HIGHLIGHT_FIELDS;
257
+ case EQuestionType.MULTIPLE_ANSWERS:
258
+ return QUESTION_MULTIA_HIGHLIGHT_FIELDS;
259
+ case EQuestionType.SINGLE_BEST_ANSWER:
260
+ default:
261
+ return QUESTION_SBA_HIGHLIGHT_FIELDS;
262
+ }
263
+ };
171
264
  export const getQuestionTypeName = (typeId) => {
172
265
  switch (typeId) {
173
266
  case EQuestionType.QUESTION_ANSWER:
@@ -516,3 +609,47 @@ export const optimisticQuestionCommentRemove = (comments, input, parentId) => {
516
609
  },
517
610
  };
518
611
  };
612
+ export const ADD_QUESTION_HIGHLIGHT = gql `
613
+ mutation AddHighlight($input: [AddQuestionHighlightInput!]!) {
614
+ restricted {
615
+ addQuestionHighlight(input: $input) {
616
+ id
617
+ questionId
618
+ userId
619
+ highlights {
620
+ start
621
+ end
622
+ text
623
+ part
624
+ tag
625
+ color
626
+ }
627
+ }
628
+ }
629
+ }
630
+ `;
631
+ export const updateQuestionHighlights = (typeId) => (cache, result, options) => {
632
+ const { addQuestionHighlight } = result?.data?.restricted ?? {};
633
+ const { variables } = options || {};
634
+ if (!variables || !addQuestionHighlight) {
635
+ return;
636
+ }
637
+ const { input } = variables;
638
+ try {
639
+ input.forEach(({ questionId }) => {
640
+ cache.writeFragment({
641
+ id: cache.identify({
642
+ id: questionId,
643
+ __typename: getQuestionTypeName(typeId),
644
+ }),
645
+ data: {
646
+ highlights: addQuestionHighlight[0].highlights,
647
+ },
648
+ fragment: getQuestionHighlightsFragment(typeId),
649
+ });
650
+ });
651
+ }
652
+ catch (error) {
653
+ console.error(error);
654
+ }
655
+ };
@@ -71,6 +71,14 @@ export const MARKSHEET = gql `
71
71
  question
72
72
  totalVotes
73
73
  typeId
74
+ highlights {
75
+ start
76
+ end
77
+ text
78
+ part
79
+ tag
80
+ color
81
+ }
74
82
  choices {
75
83
  id
76
84
  explanation
@@ -191,6 +199,14 @@ export const MARKSHEET = gql `
191
199
  question
192
200
  totalVotes
193
201
  typeId
202
+ highlights {
203
+ start
204
+ end
205
+ text
206
+ part
207
+ tag
208
+ color
209
+ }
194
210
  choices {
195
211
  id
196
212
  explanation
@@ -314,6 +330,14 @@ export const MARKSHEET = gql `
314
330
  question
315
331
  totalVotes
316
332
  typeId
333
+ highlights {
334
+ start
335
+ end
336
+ text
337
+ part
338
+ tag
339
+ color
340
+ }
317
341
  choices {
318
342
  id
319
343
  explanation
@@ -434,6 +458,14 @@ export const MARKSHEET = gql `
434
458
  question
435
459
  totalVotes
436
460
  typeId
461
+ highlights {
462
+ start
463
+ end
464
+ text
465
+ part
466
+ tag
467
+ color
468
+ }
437
469
  choices {
438
470
  id
439
471
  explanation
@@ -634,6 +666,14 @@ export const FLAGGED_QUESTIONS = gql `
634
666
  question
635
667
  totalVotes
636
668
  typeId
669
+ highlights {
670
+ start
671
+ end
672
+ text
673
+ part
674
+ tag
675
+ color
676
+ }
637
677
  choices {
638
678
  id
639
679
  explanation
@@ -761,6 +801,14 @@ export const FLAGGED_QUESTIONS = gql `
761
801
  question
762
802
  totalVotes
763
803
  typeId
804
+ highlights {
805
+ start
806
+ end
807
+ text
808
+ part
809
+ tag
810
+ color
811
+ }
764
812
  choices {
765
813
  id
766
814
  explanation
@@ -881,6 +929,14 @@ export const FLAGGED_QUESTIONS = gql `
881
929
  question
882
930
  totalVotes
883
931
  typeId
932
+ highlights {
933
+ start
934
+ end
935
+ text
936
+ part
937
+ tag
938
+ color
939
+ }
884
940
  choices {
885
941
  id
886
942
  explanation
@@ -1004,6 +1060,14 @@ export const FLAGGED_QUESTIONS = gql `
1004
1060
  question
1005
1061
  totalVotes
1006
1062
  typeId
1063
+ highlights {
1064
+ start
1065
+ end
1066
+ text
1067
+ part
1068
+ tag
1069
+ color
1070
+ }
1007
1071
  choices {
1008
1072
  id
1009
1073
  explanation
@@ -1124,6 +1188,14 @@ export const FLAGGED_QUESTIONS = gql `
1124
1188
  question
1125
1189
  totalVotes
1126
1190
  typeId
1191
+ highlights {
1192
+ start
1193
+ end
1194
+ text
1195
+ part
1196
+ tag
1197
+ color
1198
+ }
1127
1199
  choices {
1128
1200
  id
1129
1201
  explanation
@@ -1332,6 +1404,14 @@ export const FLAGGED_QUESTIONS_MARKSHEET = gql `
1332
1404
  question
1333
1405
  totalVotes
1334
1406
  typeId
1407
+ highlights {
1408
+ start
1409
+ end
1410
+ text
1411
+ part
1412
+ tag
1413
+ color
1414
+ }
1335
1415
  choices {
1336
1416
  id
1337
1417
  explanation
@@ -1452,6 +1532,14 @@ export const FLAGGED_QUESTIONS_MARKSHEET = gql `
1452
1532
  question
1453
1533
  totalVotes
1454
1534
  typeId
1535
+ highlights {
1536
+ start
1537
+ end
1538
+ text
1539
+ part
1540
+ tag
1541
+ color
1542
+ }
1455
1543
  choices {
1456
1544
  id
1457
1545
  explanation
@@ -1575,6 +1663,14 @@ export const FLAGGED_QUESTIONS_MARKSHEET = gql `
1575
1663
  question
1576
1664
  totalVotes
1577
1665
  typeId
1666
+ highlights {
1667
+ start
1668
+ end
1669
+ text
1670
+ part
1671
+ tag
1672
+ color
1673
+ }
1578
1674
  choices {
1579
1675
  id
1580
1676
  explanation
@@ -1695,6 +1791,14 @@ export const FLAGGED_QUESTIONS_MARKSHEET = gql `
1695
1791
  question
1696
1792
  totalVotes
1697
1793
  typeId
1794
+ highlights {
1795
+ start
1796
+ end
1797
+ text
1798
+ part
1799
+ tag
1800
+ color
1801
+ }
1698
1802
  choices {
1699
1803
  id
1700
1804
  explanation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quesmed/types",
3
- "version": "2.4.11",
3
+ "version": "2.4.12",
4
4
  "description": "Typescript types for Quesmed",
5
5
  "keywords": [
6
6
  "quesmed",