@quesmed/types-rn 2.6.55 → 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.
@@ -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;
package/models/User.d.ts CHANGED
@@ -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;
package/models/index.d.ts CHANGED
@@ -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';
package/models/index.js CHANGED
@@ -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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quesmed/types-rn",
3
- "version": "2.6.55",
3
+ "version": "2.6.56",
4
4
  "description": "Typescript types for Quesmed",
5
5
  "keywords": [
6
6
  "quesmed",
@@ -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;
@@ -56,10 +56,10 @@ export interface IAddQuestionHighlightVar {
56
56
  marksheetId?: number;
57
57
  input: {
58
58
  questionId: Id;
59
- highlights: IHighlight[];
59
+ highlights: IHighlightNode[];
60
60
  }[];
61
61
  }
62
- export type IAddQuestionHighlightData = RestrictedData<(graphqlNormalize & IQuestionHighlights)[], 'addQuestionHighlight'>;
62
+ export type IAddQuestionHighlightData = RestrictedData<(graphqlNormalize & IQuestionHighlight)[], 'addQuestionHighlight'>;
63
63
  export declare const ADD_QUESTION_HIGHLIGHT: import("@apollo/client").DocumentNode;
64
64
  export declare const updateQuestionHighlights: (typeId: EQuestionType) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IAddQuestionHighlightData>, options: ApolloUpdateOptions<IAddQuestionHighlightVar>) => void;
65
65
  export {};
@@ -336,7 +336,8 @@ 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(
339
+ ${fragments_1.HIGHLIGHT_FIELDS}
340
+ mutation AddQuestionHighlight(
340
341
  $input: [AddQuestionHighlightInput!]!
341
342
  $marksheetId: Int
342
343
  ) {
@@ -346,12 +347,7 @@ exports.ADD_QUESTION_HIGHLIGHT = (0, client_1.gql) `
346
347
  questionId
347
348
  userId
348
349
  highlights {
349
- start
350
- end
351
- text
352
- part
353
- tag
354
- color
350
+ ...HighlightFields
355
351
  }
356
352
  }
357
353
  }