@quesmed/types 2.6.54 → 2.6.56

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 (37) hide show
  1. package/dist/cjs/models/Chapter.d.ts +2 -0
  2. package/dist/cjs/models/Highlight.d.ts +29 -0
  3. package/dist/cjs/models/Highlight.js +2 -0
  4. package/dist/cjs/models/Question.d.ts +2 -20
  5. package/dist/cjs/models/User.d.ts +2 -3
  6. package/dist/cjs/models/index.d.ts +1 -0
  7. package/dist/cjs/models/index.js +1 -0
  8. package/dist/cjs/resolvers/fragments/chapter.d.ts +1 -0
  9. package/dist/cjs/resolvers/fragments/chapter.js +20 -1
  10. package/dist/cjs/resolvers/fragments/highlight.d.ts +1 -0
  11. package/dist/cjs/resolvers/fragments/highlight.js +14 -0
  12. package/dist/cjs/resolvers/fragments/index.d.ts +1 -0
  13. package/dist/cjs/resolvers/fragments/index.js +1 -0
  14. package/dist/cjs/resolvers/fragments/question.js +3 -6
  15. package/dist/cjs/resolvers/mutation/restricted/chapter.d.ts +18 -2
  16. package/dist/cjs/resolvers/mutation/restricted/chapter.js +47 -1
  17. package/dist/cjs/resolvers/mutation/restricted/questionDiscussion.d.ts +5 -4
  18. package/dist/cjs/resolvers/mutation/restricted/questionDiscussion.js +10 -12
  19. package/dist/mjs/models/Chapter.d.ts +2 -0
  20. package/dist/mjs/models/Highlight.d.ts +29 -0
  21. package/dist/mjs/models/Highlight.js +1 -0
  22. package/dist/mjs/models/Question.d.ts +2 -20
  23. package/dist/mjs/models/User.d.ts +2 -3
  24. package/dist/mjs/models/index.d.ts +1 -0
  25. package/dist/mjs/models/index.js +1 -0
  26. package/dist/mjs/resolvers/fragments/chapter.d.ts +1 -0
  27. package/dist/mjs/resolvers/fragments/chapter.js +19 -0
  28. package/dist/mjs/resolvers/fragments/highlight.d.ts +1 -0
  29. package/dist/mjs/resolvers/fragments/highlight.js +11 -0
  30. package/dist/mjs/resolvers/fragments/index.d.ts +1 -0
  31. package/dist/mjs/resolvers/fragments/index.js +1 -0
  32. package/dist/mjs/resolvers/fragments/question.js +3 -6
  33. package/dist/mjs/resolvers/mutation/restricted/chapter.d.ts +18 -2
  34. package/dist/mjs/resolvers/mutation/restricted/chapter.js +46 -1
  35. package/dist/mjs/resolvers/mutation/restricted/questionDiscussion.d.ts +5 -4
  36. package/dist/mjs/resolvers/mutation/restricted/questionDiscussion.js +11 -13
  37. package/package.json +1 -1
@@ -1,4 +1,5 @@
1
1
  import { IFile } from './File';
2
+ import { IHighlightNode } from './Highlight';
2
3
  import { IPicture } from './Picture';
3
4
  import { ETopicType } from './Topic';
4
5
  import { Id } from './Type';
@@ -13,4 +14,5 @@ export interface IChapter {
13
14
  pictures?: IPicture[];
14
15
  files?: IFile[];
15
16
  userNote: null | IUserChapterNote;
17
+ highlights?: IHighlightNode[];
16
18
  }
@@ -0,0 +1,29 @@
1
+ import { IChapter } from './Chapter';
2
+ import { IQuestion } from './Question';
3
+ import { Id } from './Type';
4
+ import { IUser } from './User';
5
+ export interface IHighlightNode {
6
+ start: number;
7
+ end: number;
8
+ text: string;
9
+ color?: string;
10
+ part?: string;
11
+ tag?: string;
12
+ }
13
+ export interface IHighlight {
14
+ id: Id;
15
+ createdAt: number | Date;
16
+ updatedAt: number | Date;
17
+ deletedAt: number | Date;
18
+ userId?: Id;
19
+ user?: IUser;
20
+ highlights?: IHighlightNode[];
21
+ }
22
+ export interface IQuestionHighlight extends IHighlight {
23
+ questionId?: Id;
24
+ question?: IQuestion;
25
+ }
26
+ export interface IChapterHighlight extends IHighlight {
27
+ chapterId?: Id;
28
+ chapter?: IChapter;
29
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,6 +1,7 @@
1
1
  import { IConcept } from './Concept';
2
2
  import { ICondition } from './Condition';
3
3
  import { EDifficultyType } from './Difficulty';
4
+ import { IHighlightNode } from './Highlight';
4
5
  import { IPicture } from './Picture';
5
6
  import { IPresentation } from './Presentation';
6
7
  import { ITopic } from './Topic';
@@ -90,26 +91,7 @@ export interface IQuestion {
90
91
  dislikes?: number;
91
92
  isLikedByMe?: EQuestionLike;
92
93
  comments?: IQuestionComment[];
93
- highlights?: Array<IHighlight>;
94
- }
95
- export interface IHighlight {
96
- start: number;
97
- end: number;
98
- text: string;
99
- color?: string;
100
- part?: string;
101
- tag?: string;
102
- }
103
- export interface IQuestionHighlights {
104
- id: Id;
105
- createdAt: number | Date;
106
- updatedAt: number | Date;
107
- deletedAt: number | Date;
108
- userId?: Id;
109
- questionId?: Id;
110
- user?: IUser;
111
- question?: IQuestion;
112
- highlights?: Array<IHighlight>;
94
+ highlights?: IHighlightNode[];
113
95
  }
114
96
  export interface IQuestionChoice {
115
97
  id: Id;
@@ -1,17 +1,17 @@
1
1
  import { ExtractKeysWithPattern } from '../resolvers/types';
2
2
  import { ICard } from './Card';
3
+ import { IChapter } from './Chapter';
3
4
  import { IConcept } from './Concept';
4
5
  import { IMarksheet } from './Marksheet';
5
6
  import { INotification } from './Notification';
6
7
  import { IOsceStation } from './OsceStation';
7
8
  import { EProductType } from './Product';
8
- import { IQuestion, IQuestionHighlights } from './Question';
9
+ import { IQuestion } from './Question';
9
10
  import { ISubscription } from './Subscription';
10
11
  import { ITodo } from './Todo';
11
12
  import { Id } from './Type';
12
13
  import { IUniversity } from './University';
13
14
  import { IVideo } from './Video';
14
- import { IChapter } from './Chapter';
15
15
  export type IUserSubsriptionDates = keyof ExtractKeysWithPattern<IPayload, 'EndDate'>;
16
16
  export declare enum IAccessLevel {
17
17
  SUBSCRIBER = "subscriber",
@@ -142,7 +142,6 @@ export interface IUser {
142
142
  radiologyInterviewSubscriptionEndDate: number | Date | null;
143
143
  plab1SubscriptionEndDate: number | Date | null;
144
144
  plab2SubscriptionEndDate: number | Date | null;
145
- questionHighlights?: IQuestionHighlights[];
146
145
  }
147
146
  export declare function currentClassYear(createdAtUnix: number, classYear: IClassYear, compareUnix?: number): IClassYear;
148
147
  export declare function currentClassGroup(createdAtUnix: number, classYear: IClassYear): EClassYearGroup;
@@ -8,6 +8,7 @@ export * from './Condition';
8
8
  export * from './Difficulty';
9
9
  export * from './Feedback';
10
10
  export * from './File';
11
+ export * from './Highlight';
11
12
  export * from './Marksheet';
12
13
  export * from './MockTest';
13
14
  export * from './Notification';
@@ -24,6 +24,7 @@ __exportStar(require("./Condition"), exports);
24
24
  __exportStar(require("./Difficulty"), exports);
25
25
  __exportStar(require("./Feedback"), exports);
26
26
  __exportStar(require("./File"), exports);
27
+ __exportStar(require("./Highlight"), exports);
27
28
  __exportStar(require("./Marksheet"), exports);
28
29
  __exportStar(require("./MockTest"), exports);
29
30
  __exportStar(require("./Notification"), exports);
@@ -1,2 +1,3 @@
1
1
  export declare const CHAPTER_FIELDS: import("@apollo/client").DocumentNode;
2
2
  export declare const UPSERT_CHAPTER_NOTE_FRAGMENT: import("@apollo/client").DocumentNode;
3
+ export declare const CHAPTER_WITH_HIGHLIGHT_FIELDS: import("@apollo/client").DocumentNode;
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UPSERT_CHAPTER_NOTE_FRAGMENT = exports.CHAPTER_FIELDS = void 0;
3
+ exports.CHAPTER_WITH_HIGHLIGHT_FIELDS = exports.UPSERT_CHAPTER_NOTE_FRAGMENT = exports.CHAPTER_FIELDS = void 0;
4
4
  const client_1 = require("@apollo/client");
5
5
  const picture_1 = require("./picture");
6
+ const highlight_1 = require("./highlight");
6
7
  exports.CHAPTER_FIELDS = (0, client_1.gql) `
7
8
  ${picture_1.PICTURE_FIELDS}
9
+ ${highlight_1.HIGHLIGHT_FIELDS}
8
10
  fragment ChapterFields on Chapter {
9
11
  id
10
12
  explanation
@@ -12,6 +14,9 @@ exports.CHAPTER_FIELDS = (0, client_1.gql) `
12
14
  pictures {
13
15
  ...PictureFields
14
16
  }
17
+ highlights {
18
+ ...HighlightFields
19
+ }
15
20
  userNote {
16
21
  id
17
22
  userId
@@ -28,6 +33,7 @@ exports.CHAPTER_FIELDS = (0, client_1.gql) `
28
33
  }
29
34
  }
30
35
  `;
36
+ // used in cache updator
31
37
  exports.UPSERT_CHAPTER_NOTE_FRAGMENT = (0, client_1.gql) `
32
38
  fragment UpsertChapterNoteFragment on Chapter {
33
39
  userNote {
@@ -39,3 +45,16 @@ exports.UPSERT_CHAPTER_NOTE_FRAGMENT = (0, client_1.gql) `
39
45
  }
40
46
  }
41
47
  `;
48
+ // used in cache updator
49
+ exports.CHAPTER_WITH_HIGHLIGHT_FIELDS = (0, client_1.gql) `
50
+ fragment ChapterWithHighlightFields on Chapter {
51
+ highlights {
52
+ start
53
+ end
54
+ text
55
+ part
56
+ tag
57
+ color
58
+ }
59
+ }
60
+ `;
@@ -0,0 +1 @@
1
+ export declare const HIGHLIGHT_FIELDS: import("@apollo/client").DocumentNode;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HIGHLIGHT_FIELDS = void 0;
4
+ const client_1 = require("@apollo/client");
5
+ exports.HIGHLIGHT_FIELDS = (0, client_1.gql) `
6
+ fragment HighlightFields on HighlightNode {
7
+ start
8
+ end
9
+ text
10
+ part
11
+ tag
12
+ color
13
+ }
14
+ `;
@@ -1,6 +1,7 @@
1
1
  export * from './blog';
2
2
  export * from './chapter';
3
3
  export * from './concept';
4
+ export * from './highlight';
4
5
  export * from './marksheet';
5
6
  export * from './mockTest';
6
7
  export * from './osce';
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./blog"), exports);
18
18
  __exportStar(require("./chapter"), exports);
19
19
  __exportStar(require("./concept"), exports);
20
+ __exportStar(require("./highlight"), exports);
20
21
  __exportStar(require("./marksheet"), exports);
21
22
  __exportStar(require("./mockTest"), exports);
22
23
  __exportStar(require("./osce"), exports);
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.QUESTION_WITH_COMMENT_FIELDS = exports.QUESTION_WITH_HIGHLIGHT_FIELDS = exports.QUESTION_FIELDS = exports.QUESTION_CATEGORY_FIELDS = exports.QUESTION_COMMENT_FIELDS = void 0;
4
4
  const client_1 = require("@apollo/client");
5
5
  const concept_1 = require("./concept");
6
+ const highlight_1 = require("./highlight");
6
7
  const picture_1 = require("./picture");
7
8
  exports.QUESTION_COMMENT_FIELDS = (0, client_1.gql) `
8
9
  fragment QuestionCommentFields on QuestionComment {
@@ -98,6 +99,7 @@ exports.QUESTION_CATEGORY_FIELDS = (0, client_1.gql) `
98
99
  }
99
100
  `;
100
101
  exports.QUESTION_FIELDS = (0, client_1.gql) `
102
+ ${highlight_1.HIGHLIGHT_FIELDS}
101
103
  ${exports.QUESTION_CATEGORY_FIELDS}
102
104
  ${exports.QUESTION_COMMENT_FIELDS}
103
105
  ${concept_1.CONCEPT_FIELDS}
@@ -115,12 +117,7 @@ exports.QUESTION_FIELDS = (0, client_1.gql) `
115
117
  typeId
116
118
  psaSectionId
117
119
  highlights {
118
- start
119
- end
120
- text
121
- part
122
- tag
123
- color
120
+ ...HighlightFields
124
121
  }
125
122
  choices {
126
123
  id
@@ -1,7 +1,10 @@
1
1
  import { ApolloCache } from '@apollo/client';
2
- import { IUserChapterNote } from '../../../models';
2
+ import { IChapterHighlight, IHighlightNode, IUserChapterNote, Id } from '../../../models';
3
3
  import { ApolloUpdateOptions, ApolloUpdateResultRestricted } from '../../apollo';
4
- import { RestrictedData } from '../../types';
4
+ import { RestrictedData, graphqlNormalize } from '../../types';
5
+ /**
6
+ * upsertChapterNote
7
+ */
5
8
  export declare const UPSERT_CHAPTER_NOTE: import("@apollo/client").DocumentNode;
6
9
  export interface IUpsertChapterNoteVar {
7
10
  chapterId: number;
@@ -23,3 +26,16 @@ export declare const optimisticUpsertChapterNote: (data: IUpsertChapterNoteVar &
23
26
  };
24
27
  };
25
28
  };
29
+ /**
30
+ * addChapterHighlight
31
+ */
32
+ export interface IAddChapterHighlightVar {
33
+ marksheetId?: number;
34
+ input: {
35
+ chapterId: Id;
36
+ highlights: IHighlightNode[];
37
+ }[];
38
+ }
39
+ export type IAddChapterHighlightData = RestrictedData<(graphqlNormalize & IChapterHighlight)[], 'addChapterHighlight'>;
40
+ export declare const ADD_CHAPTER_HIGHLIGHT: import("@apollo/client").DocumentNode;
41
+ export declare const updateChapterHighlights: (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IAddChapterHighlightData>, options: ApolloUpdateOptions<IAddChapterHighlightVar>) => void;
@@ -1,8 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.optimisticUpsertChapterNote = exports.updateCacheOnUpsertChapterNote = exports.UPSERT_CHAPTER_NOTE = void 0;
3
+ exports.updateChapterHighlights = exports.ADD_CHAPTER_HIGHLIGHT = exports.optimisticUpsertChapterNote = exports.updateCacheOnUpsertChapterNote = exports.UPSERT_CHAPTER_NOTE = void 0;
4
4
  const client_1 = require("@apollo/client");
5
5
  const fragments_1 = require("../../fragments");
6
+ /**
7
+ * upsertChapterNote
8
+ */
6
9
  exports.UPSERT_CHAPTER_NOTE = (0, client_1.gql) `
7
10
  mutation UpsertChapterNote($chapterId: Int!, $note: String!) {
8
11
  restricted {
@@ -48,3 +51,46 @@ const optimisticUpsertChapterNote = (data) => {
48
51
  };
49
52
  };
50
53
  exports.optimisticUpsertChapterNote = optimisticUpsertChapterNote;
54
+ exports.ADD_CHAPTER_HIGHLIGHT = (0, client_1.gql) `
55
+ ${fragments_1.HIGHLIGHT_FIELDS}
56
+ mutation AddChapterHighlight(
57
+ $input: [AddChapterHighlightInput!]!
58
+ $marksheetId: Int
59
+ ) {
60
+ restricted {
61
+ addChapterHighlight(input: $input, marksheetId: $marksheetId) {
62
+ id
63
+ chapterId
64
+ userId
65
+ highlights {
66
+ ...HighlightFields
67
+ }
68
+ }
69
+ }
70
+ }
71
+ `;
72
+ const updateChapterHighlights = (cache, result, options) => {
73
+ const { addChapterHighlight } = result?.data?.restricted ?? {};
74
+ const { variables } = options || {};
75
+ if (!variables || !addChapterHighlight) {
76
+ return;
77
+ }
78
+ try {
79
+ for (const { chapterId, highlights } of variables.input) {
80
+ cache.writeFragment({
81
+ id: cache.identify({
82
+ id: chapterId,
83
+ __typename: 'Chapter',
84
+ }),
85
+ data: {
86
+ highlights,
87
+ },
88
+ fragment: fragments_1.CHAPTER_WITH_HIGHLIGHT_FIELDS,
89
+ });
90
+ }
91
+ }
92
+ catch (error) {
93
+ console.error(error);
94
+ }
95
+ };
96
+ exports.updateChapterHighlights = updateChapterHighlights;
@@ -1,6 +1,6 @@
1
1
  import { ApolloCache } from '@apollo/client';
2
2
  import { ApolloUpdateOptions, ApolloUpdateResultRestricted } from '../..';
3
- import { EQuestionLike, EQuestionType, IAccessLevel, IHighlight, IQuestion, IQuestionComment, IQuestionHighlights, Id } from '../../../models';
3
+ import { EQuestionLike, EQuestionType, IAccessLevel, IHighlightNode, IQuestion, IQuestionComment, IQuestionHighlight, Id } from '../../../models';
4
4
  import { RestrictedData, graphqlNormalize } from '../../types';
5
5
  interface LikeData {
6
6
  likes?: number;
@@ -53,12 +53,13 @@ export type IQuestionCommentRemoveData = RestrictedData<graphqlNormalize & IQues
53
53
  * addQuestionHighlight
54
54
  */
55
55
  export interface IAddQuestionHighlightVar {
56
+ marksheetId?: number;
56
57
  input: {
57
58
  questionId: Id;
58
- highlights: IHighlight[];
59
+ highlights: IHighlightNode[];
59
60
  }[];
60
61
  }
61
- export type IAddQuestionHighlightData = RestrictedData<(graphqlNormalize & IQuestionHighlights)[], 'addQuestionHighlight'>;
62
+ export type IAddQuestionHighlightData = RestrictedData<(graphqlNormalize & IQuestionHighlight)[], 'addQuestionHighlight'>;
62
63
  export declare const ADD_QUESTION_HIGHLIGHT: import("@apollo/client").DocumentNode;
63
- export declare const updateQuestionHighlights: (typeId: EQuestionType) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IAddQuestionHighlightData>, options: ApolloUpdateOptions) => void;
64
+ export declare const updateQuestionHighlights: (typeId: EQuestionType) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IAddQuestionHighlightData>, options: ApolloUpdateOptions<IAddQuestionHighlightVar>) => void;
64
65
  export {};
@@ -336,19 +336,18 @@ const optimisticQuestionCommentRemove = (comments, input, parentId) => {
336
336
  };
337
337
  exports.optimisticQuestionCommentRemove = optimisticQuestionCommentRemove;
338
338
  exports.ADD_QUESTION_HIGHLIGHT = (0, client_1.gql) `
339
- mutation AddHighlight($input: [AddQuestionHighlightInput!]!) {
339
+ ${fragments_1.HIGHLIGHT_FIELDS}
340
+ mutation AddQuestionHighlight(
341
+ $input: [AddQuestionHighlightInput!]!
342
+ $marksheetId: Int
343
+ ) {
340
344
  restricted {
341
- addQuestionHighlight(input: $input) {
345
+ addQuestionHighlight(input: $input, marksheetId: $marksheetId) {
342
346
  id
343
347
  questionId
344
348
  userId
345
349
  highlights {
346
- start
347
- end
348
- text
349
- part
350
- tag
351
- color
350
+ ...HighlightFields
352
351
  }
353
352
  }
354
353
  }
@@ -360,20 +359,19 @@ const updateQuestionHighlights = (typeId) => (cache, result, options) => {
360
359
  if (!variables || !addQuestionHighlight) {
361
360
  return;
362
361
  }
363
- const { input } = variables;
364
362
  try {
365
- input.forEach(({ questionId }) => {
363
+ for (const { questionId, highlights } of variables.input) {
366
364
  cache.writeFragment({
367
365
  id: cache.identify({
368
366
  id: questionId,
369
367
  __typename: (0, exports.getQuestionTypeName)(typeId),
370
368
  }),
371
369
  data: {
372
- highlights: addQuestionHighlight[0].highlights,
370
+ highlights,
373
371
  },
374
372
  fragment: fragments_1.QUESTION_WITH_HIGHLIGHT_FIELDS,
375
373
  });
376
- });
374
+ }
377
375
  }
378
376
  catch (error) {
379
377
  console.error(error);
@@ -1,4 +1,5 @@
1
1
  import { IFile } from './File';
2
+ import { IHighlightNode } from './Highlight';
2
3
  import { IPicture } from './Picture';
3
4
  import { ETopicType } from './Topic';
4
5
  import { Id } from './Type';
@@ -13,4 +14,5 @@ export interface IChapter {
13
14
  pictures?: IPicture[];
14
15
  files?: IFile[];
15
16
  userNote: null | IUserChapterNote;
17
+ highlights?: IHighlightNode[];
16
18
  }
@@ -0,0 +1,29 @@
1
+ import { IChapter } from './Chapter';
2
+ import { IQuestion } from './Question';
3
+ import { Id } from './Type';
4
+ import { IUser } from './User';
5
+ export interface IHighlightNode {
6
+ start: number;
7
+ end: number;
8
+ text: string;
9
+ color?: string;
10
+ part?: string;
11
+ tag?: string;
12
+ }
13
+ export interface IHighlight {
14
+ id: Id;
15
+ createdAt: number | Date;
16
+ updatedAt: number | Date;
17
+ deletedAt: number | Date;
18
+ userId?: Id;
19
+ user?: IUser;
20
+ highlights?: IHighlightNode[];
21
+ }
22
+ export interface IQuestionHighlight extends IHighlight {
23
+ questionId?: Id;
24
+ question?: IQuestion;
25
+ }
26
+ export interface IChapterHighlight extends IHighlight {
27
+ chapterId?: Id;
28
+ chapter?: IChapter;
29
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,6 +1,7 @@
1
1
  import { IConcept } from './Concept';
2
2
  import { ICondition } from './Condition';
3
3
  import { EDifficultyType } from './Difficulty';
4
+ import { IHighlightNode } from './Highlight';
4
5
  import { IPicture } from './Picture';
5
6
  import { IPresentation } from './Presentation';
6
7
  import { ITopic } from './Topic';
@@ -90,26 +91,7 @@ export interface IQuestion {
90
91
  dislikes?: number;
91
92
  isLikedByMe?: EQuestionLike;
92
93
  comments?: IQuestionComment[];
93
- highlights?: Array<IHighlight>;
94
- }
95
- export interface IHighlight {
96
- start: number;
97
- end: number;
98
- text: string;
99
- color?: string;
100
- part?: string;
101
- tag?: string;
102
- }
103
- export interface IQuestionHighlights {
104
- id: Id;
105
- createdAt: number | Date;
106
- updatedAt: number | Date;
107
- deletedAt: number | Date;
108
- userId?: Id;
109
- questionId?: Id;
110
- user?: IUser;
111
- question?: IQuestion;
112
- highlights?: Array<IHighlight>;
94
+ highlights?: IHighlightNode[];
113
95
  }
114
96
  export interface IQuestionChoice {
115
97
  id: Id;
@@ -1,17 +1,17 @@
1
1
  import { ExtractKeysWithPattern } from '../resolvers/types';
2
2
  import { ICard } from './Card';
3
+ import { IChapter } from './Chapter';
3
4
  import { IConcept } from './Concept';
4
5
  import { IMarksheet } from './Marksheet';
5
6
  import { INotification } from './Notification';
6
7
  import { IOsceStation } from './OsceStation';
7
8
  import { EProductType } from './Product';
8
- import { IQuestion, IQuestionHighlights } from './Question';
9
+ import { IQuestion } from './Question';
9
10
  import { ISubscription } from './Subscription';
10
11
  import { ITodo } from './Todo';
11
12
  import { Id } from './Type';
12
13
  import { IUniversity } from './University';
13
14
  import { IVideo } from './Video';
14
- import { IChapter } from './Chapter';
15
15
  export type IUserSubsriptionDates = keyof ExtractKeysWithPattern<IPayload, 'EndDate'>;
16
16
  export declare enum IAccessLevel {
17
17
  SUBSCRIBER = "subscriber",
@@ -142,7 +142,6 @@ export interface IUser {
142
142
  radiologyInterviewSubscriptionEndDate: number | Date | null;
143
143
  plab1SubscriptionEndDate: number | Date | null;
144
144
  plab2SubscriptionEndDate: number | Date | null;
145
- questionHighlights?: IQuestionHighlights[];
146
145
  }
147
146
  export declare function currentClassYear(createdAtUnix: number, classYear: IClassYear, compareUnix?: number): IClassYear;
148
147
  export declare function currentClassGroup(createdAtUnix: number, classYear: IClassYear): EClassYearGroup;
@@ -8,6 +8,7 @@ export * from './Condition';
8
8
  export * from './Difficulty';
9
9
  export * from './Feedback';
10
10
  export * from './File';
11
+ export * from './Highlight';
11
12
  export * from './Marksheet';
12
13
  export * from './MockTest';
13
14
  export * from './Notification';
@@ -8,6 +8,7 @@ export * from './Condition';
8
8
  export * from './Difficulty';
9
9
  export * from './Feedback';
10
10
  export * from './File';
11
+ export * from './Highlight';
11
12
  export * from './Marksheet';
12
13
  export * from './MockTest';
13
14
  export * from './Notification';
@@ -1,2 +1,3 @@
1
1
  export declare const CHAPTER_FIELDS: import("@apollo/client").DocumentNode;
2
2
  export declare const UPSERT_CHAPTER_NOTE_FRAGMENT: import("@apollo/client").DocumentNode;
3
+ export declare const CHAPTER_WITH_HIGHLIGHT_FIELDS: import("@apollo/client").DocumentNode;
@@ -1,7 +1,9 @@
1
1
  import { gql } from '@apollo/client';
2
2
  import { PICTURE_FIELDS } from './picture';
3
+ import { HIGHLIGHT_FIELDS } from './highlight';
3
4
  export const CHAPTER_FIELDS = gql `
4
5
  ${PICTURE_FIELDS}
6
+ ${HIGHLIGHT_FIELDS}
5
7
  fragment ChapterFields on Chapter {
6
8
  id
7
9
  explanation
@@ -9,6 +11,9 @@ export const CHAPTER_FIELDS = gql `
9
11
  pictures {
10
12
  ...PictureFields
11
13
  }
14
+ highlights {
15
+ ...HighlightFields
16
+ }
12
17
  userNote {
13
18
  id
14
19
  userId
@@ -25,6 +30,7 @@ export const CHAPTER_FIELDS = gql `
25
30
  }
26
31
  }
27
32
  `;
33
+ // used in cache updator
28
34
  export const UPSERT_CHAPTER_NOTE_FRAGMENT = gql `
29
35
  fragment UpsertChapterNoteFragment on Chapter {
30
36
  userNote {
@@ -36,3 +42,16 @@ export const UPSERT_CHAPTER_NOTE_FRAGMENT = gql `
36
42
  }
37
43
  }
38
44
  `;
45
+ // used in cache updator
46
+ export const CHAPTER_WITH_HIGHLIGHT_FIELDS = gql `
47
+ fragment ChapterWithHighlightFields on Chapter {
48
+ highlights {
49
+ start
50
+ end
51
+ text
52
+ part
53
+ tag
54
+ color
55
+ }
56
+ }
57
+ `;
@@ -0,0 +1 @@
1
+ export declare const HIGHLIGHT_FIELDS: import("@apollo/client").DocumentNode;
@@ -0,0 +1,11 @@
1
+ import { gql } from '@apollo/client';
2
+ export const HIGHLIGHT_FIELDS = gql `
3
+ fragment HighlightFields on HighlightNode {
4
+ start
5
+ end
6
+ text
7
+ part
8
+ tag
9
+ color
10
+ }
11
+ `;
@@ -1,6 +1,7 @@
1
1
  export * from './blog';
2
2
  export * from './chapter';
3
3
  export * from './concept';
4
+ export * from './highlight';
4
5
  export * from './marksheet';
5
6
  export * from './mockTest';
6
7
  export * from './osce';
@@ -1,6 +1,7 @@
1
1
  export * from './blog';
2
2
  export * from './chapter';
3
3
  export * from './concept';
4
+ export * from './highlight';
4
5
  export * from './marksheet';
5
6
  export * from './mockTest';
6
7
  export * from './osce';
@@ -1,5 +1,6 @@
1
1
  import { gql } from '@apollo/client';
2
2
  import { CONCEPT_FIELDS } from './concept';
3
+ import { HIGHLIGHT_FIELDS } from './highlight';
3
4
  import { PICTURE_FIELDS } from './picture';
4
5
  export const QUESTION_COMMENT_FIELDS = gql `
5
6
  fragment QuestionCommentFields on QuestionComment {
@@ -95,6 +96,7 @@ export const QUESTION_CATEGORY_FIELDS = gql `
95
96
  }
96
97
  `;
97
98
  export const QUESTION_FIELDS = gql `
99
+ ${HIGHLIGHT_FIELDS}
98
100
  ${QUESTION_CATEGORY_FIELDS}
99
101
  ${QUESTION_COMMENT_FIELDS}
100
102
  ${CONCEPT_FIELDS}
@@ -112,12 +114,7 @@ export const QUESTION_FIELDS = gql `
112
114
  typeId
113
115
  psaSectionId
114
116
  highlights {
115
- start
116
- end
117
- text
118
- part
119
- tag
120
- color
117
+ ...HighlightFields
121
118
  }
122
119
  choices {
123
120
  id
@@ -1,7 +1,10 @@
1
1
  import { ApolloCache } from '@apollo/client';
2
- import { IUserChapterNote } from '../../../models';
2
+ import { IChapterHighlight, IHighlightNode, IUserChapterNote, Id } from '../../../models';
3
3
  import { ApolloUpdateOptions, ApolloUpdateResultRestricted } from '../../apollo';
4
- import { RestrictedData } from '../../types';
4
+ import { RestrictedData, graphqlNormalize } from '../../types';
5
+ /**
6
+ * upsertChapterNote
7
+ */
5
8
  export declare const UPSERT_CHAPTER_NOTE: import("@apollo/client").DocumentNode;
6
9
  export interface IUpsertChapterNoteVar {
7
10
  chapterId: number;
@@ -23,3 +26,16 @@ export declare const optimisticUpsertChapterNote: (data: IUpsertChapterNoteVar &
23
26
  };
24
27
  };
25
28
  };
29
+ /**
30
+ * addChapterHighlight
31
+ */
32
+ export interface IAddChapterHighlightVar {
33
+ marksheetId?: number;
34
+ input: {
35
+ chapterId: Id;
36
+ highlights: IHighlightNode[];
37
+ }[];
38
+ }
39
+ export type IAddChapterHighlightData = RestrictedData<(graphqlNormalize & IChapterHighlight)[], 'addChapterHighlight'>;
40
+ export declare const ADD_CHAPTER_HIGHLIGHT: import("@apollo/client").DocumentNode;
41
+ export declare const updateChapterHighlights: (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IAddChapterHighlightData>, options: ApolloUpdateOptions<IAddChapterHighlightVar>) => void;
@@ -1,5 +1,8 @@
1
1
  import { gql } from '@apollo/client';
2
- import { UPSERT_CHAPTER_NOTE_FRAGMENT } from '../../fragments';
2
+ import { CHAPTER_WITH_HIGHLIGHT_FIELDS, HIGHLIGHT_FIELDS, UPSERT_CHAPTER_NOTE_FRAGMENT, } from '../../fragments';
3
+ /**
4
+ * upsertChapterNote
5
+ */
3
6
  export const UPSERT_CHAPTER_NOTE = gql `
4
7
  mutation UpsertChapterNote($chapterId: Int!, $note: String!) {
5
8
  restricted {
@@ -43,3 +46,45 @@ export const optimisticUpsertChapterNote = (data) => {
43
46
  },
44
47
  };
45
48
  };
49
+ export const ADD_CHAPTER_HIGHLIGHT = gql `
50
+ ${HIGHLIGHT_FIELDS}
51
+ mutation AddChapterHighlight(
52
+ $input: [AddChapterHighlightInput!]!
53
+ $marksheetId: Int
54
+ ) {
55
+ restricted {
56
+ addChapterHighlight(input: $input, marksheetId: $marksheetId) {
57
+ id
58
+ chapterId
59
+ userId
60
+ highlights {
61
+ ...HighlightFields
62
+ }
63
+ }
64
+ }
65
+ }
66
+ `;
67
+ export const updateChapterHighlights = (cache, result, options) => {
68
+ const { addChapterHighlight } = result?.data?.restricted ?? {};
69
+ const { variables } = options || {};
70
+ if (!variables || !addChapterHighlight) {
71
+ return;
72
+ }
73
+ try {
74
+ for (const { chapterId, highlights } of variables.input) {
75
+ cache.writeFragment({
76
+ id: cache.identify({
77
+ id: chapterId,
78
+ __typename: 'Chapter',
79
+ }),
80
+ data: {
81
+ highlights,
82
+ },
83
+ fragment: CHAPTER_WITH_HIGHLIGHT_FIELDS,
84
+ });
85
+ }
86
+ }
87
+ catch (error) {
88
+ console.error(error);
89
+ }
90
+ };
@@ -1,6 +1,6 @@
1
1
  import { ApolloCache } from '@apollo/client';
2
2
  import { ApolloUpdateOptions, ApolloUpdateResultRestricted } from '../..';
3
- import { EQuestionLike, EQuestionType, IAccessLevel, IHighlight, IQuestion, IQuestionComment, IQuestionHighlights, Id } from '../../../models';
3
+ import { EQuestionLike, EQuestionType, IAccessLevel, IHighlightNode, IQuestion, IQuestionComment, IQuestionHighlight, Id } from '../../../models';
4
4
  import { RestrictedData, graphqlNormalize } from '../../types';
5
5
  interface LikeData {
6
6
  likes?: number;
@@ -53,12 +53,13 @@ export type IQuestionCommentRemoveData = RestrictedData<graphqlNormalize & IQues
53
53
  * addQuestionHighlight
54
54
  */
55
55
  export interface IAddQuestionHighlightVar {
56
+ marksheetId?: number;
56
57
  input: {
57
58
  questionId: Id;
58
- highlights: IHighlight[];
59
+ highlights: IHighlightNode[];
59
60
  }[];
60
61
  }
61
- export type IAddQuestionHighlightData = RestrictedData<(graphqlNormalize & IQuestionHighlights)[], 'addQuestionHighlight'>;
62
+ export type IAddQuestionHighlightData = RestrictedData<(graphqlNormalize & IQuestionHighlight)[], 'addQuestionHighlight'>;
62
63
  export declare const ADD_QUESTION_HIGHLIGHT: import("@apollo/client").DocumentNode;
63
- export declare const updateQuestionHighlights: (typeId: EQuestionType) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IAddQuestionHighlightData>, options: ApolloUpdateOptions) => void;
64
+ export declare const updateQuestionHighlights: (typeId: EQuestionType) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IAddQuestionHighlightData>, options: ApolloUpdateOptions<IAddQuestionHighlightVar>) => void;
64
65
  export {};
@@ -1,7 +1,7 @@
1
1
  import { gql } from '@apollo/client';
2
2
  import { DateTime } from 'luxon';
3
3
  import { EQuestionLike, EQuestionType, } from '../../../models';
4
- import { QUESTION_COMMENT_FIELDS, QUESTION_WITH_COMMENT_FIELDS, QUESTION_WITH_HIGHLIGHT_FIELDS, } from '../../fragments';
4
+ import { HIGHLIGHT_FIELDS, QUESTION_COMMENT_FIELDS, QUESTION_WITH_COMMENT_FIELDS, QUESTION_WITH_HIGHLIGHT_FIELDS, } from '../../fragments';
5
5
  export const getLikeData = (like, item) => {
6
6
  let { likes = 0, dislikes = 0, isLikedByMe } = item;
7
7
  if (isLikedByMe === EQuestionLike.LIKE) {
@@ -325,19 +325,18 @@ export const optimisticQuestionCommentRemove = (comments, input, parentId) => {
325
325
  };
326
326
  };
327
327
  export const ADD_QUESTION_HIGHLIGHT = gql `
328
- mutation AddHighlight($input: [AddQuestionHighlightInput!]!) {
328
+ ${HIGHLIGHT_FIELDS}
329
+ mutation AddQuestionHighlight(
330
+ $input: [AddQuestionHighlightInput!]!
331
+ $marksheetId: Int
332
+ ) {
329
333
  restricted {
330
- addQuestionHighlight(input: $input) {
334
+ addQuestionHighlight(input: $input, marksheetId: $marksheetId) {
331
335
  id
332
336
  questionId
333
337
  userId
334
338
  highlights {
335
- start
336
- end
337
- text
338
- part
339
- tag
340
- color
339
+ ...HighlightFields
341
340
  }
342
341
  }
343
342
  }
@@ -349,20 +348,19 @@ export const updateQuestionHighlights = (typeId) => (cache, result, options) =>
349
348
  if (!variables || !addQuestionHighlight) {
350
349
  return;
351
350
  }
352
- const { input } = variables;
353
351
  try {
354
- input.forEach(({ questionId }) => {
352
+ for (const { questionId, highlights } of variables.input) {
355
353
  cache.writeFragment({
356
354
  id: cache.identify({
357
355
  id: questionId,
358
356
  __typename: getQuestionTypeName(typeId),
359
357
  }),
360
358
  data: {
361
- highlights: addQuestionHighlight[0].highlights,
359
+ highlights,
362
360
  },
363
361
  fragment: QUESTION_WITH_HIGHLIGHT_FIELDS,
364
362
  });
365
- });
363
+ }
366
364
  }
367
365
  catch (error) {
368
366
  console.error(error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quesmed/types",
3
- "version": "2.6.54",
3
+ "version": "2.6.56",
4
4
  "description": "Typescript types for Quesmed",
5
5
  "keywords": [
6
6
  "quesmed",