@quesmed/types-rn 2.6.66 → 2.6.68

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.
@@ -7,7 +7,7 @@ import { IPresentation } from './Presentation';
7
7
  import { ITopic } from './Topic';
8
8
  import { Id } from './Type';
9
9
  import { IUkmlaTopic } from './UkmlaTopic';
10
- import { IUser } from './User';
10
+ import { EUserLearningPoint, IUser } from './User';
11
11
  export declare enum EPsaSectionType {
12
12
  PRESCRIBING = 1,
13
13
  PRESCRIPTION_REVIEW = 2,
@@ -77,6 +77,7 @@ export interface IQuestion {
77
77
  presentation?: IPresentation[];
78
78
  question: string;
79
79
  explanation?: string;
80
+ learningPoint?: string;
80
81
  answer: IQuestionAnswer;
81
82
  totalVotes: number;
82
83
  choices: IQuestionChoice[];
@@ -87,6 +88,7 @@ export interface IQuestion {
87
88
  difficulty: EDifficultyType;
88
89
  elo: number;
89
90
  psaSectionId: EPsaSectionType;
91
+ userPoint?: EUserLearningPoint | null;
90
92
  likes?: number;
91
93
  dislikes?: number;
92
94
  isLikedByMe?: EQuestionLike;
package/models/User.d.ts CHANGED
@@ -34,6 +34,10 @@ export declare enum EUserLearningStatus {
34
34
  REVISING = 3,
35
35
  URGENT = 4
36
36
  }
37
+ export declare enum EUserLearningPoint {
38
+ NOT_RELEVANT = 0,
39
+ RELEVANT = 1
40
+ }
37
41
  export declare const classYearGroup: {
38
42
  [key: string]: EClassYearGroup;
39
43
  };
@@ -248,3 +252,11 @@ export interface IUserStats {
248
252
  median: number;
249
253
  series: [x: number, y: number][];
250
254
  }
255
+ export interface IQuestionLearningPoint {
256
+ id: Id;
257
+ createdAt: number | Date;
258
+ updatedAt: number | Date;
259
+ userId: Id;
260
+ questionId: Id;
261
+ userPoint: EUserLearningPoint | null;
262
+ }
package/models/User.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.currentClassGroup = exports.currentClassYear = exports.EPracticeIntensity = exports.classYearGroup = exports.EUserLearningStatus = exports.EClassYearGroup = exports.dateProductMapping = exports.subscriptionDates = exports.classYears = exports.IAccessLevel = void 0;
3
+ exports.currentClassGroup = exports.currentClassYear = exports.EPracticeIntensity = exports.classYearGroup = exports.EUserLearningPoint = exports.EUserLearningStatus = exports.EClassYearGroup = exports.dateProductMapping = exports.subscriptionDates = exports.classYears = exports.IAccessLevel = void 0;
4
4
  const luxon_1 = require("luxon");
5
5
  const Product_1 = require("./Product");
6
6
  var IAccessLevel;
@@ -68,6 +68,11 @@ var EUserLearningStatus;
68
68
  EUserLearningStatus[EUserLearningStatus["REVISING"] = 3] = "REVISING";
69
69
  EUserLearningStatus[EUserLearningStatus["URGENT"] = 4] = "URGENT";
70
70
  })(EUserLearningStatus = exports.EUserLearningStatus || (exports.EUserLearningStatus = {}));
71
+ var EUserLearningPoint;
72
+ (function (EUserLearningPoint) {
73
+ EUserLearningPoint[EUserLearningPoint["NOT_RELEVANT"] = 0] = "NOT_RELEVANT";
74
+ EUserLearningPoint[EUserLearningPoint["RELEVANT"] = 1] = "RELEVANT";
75
+ })(EUserLearningPoint = exports.EUserLearningPoint || (exports.EUserLearningPoint = {}));
71
76
  exports.classYearGroup = {
72
77
  'Year 1': EClassYearGroup.PRECLINICAL,
73
78
  'Year 2': EClassYearGroup.PRECLINICAL,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quesmed/types-rn",
3
- "version": "2.6.66",
3
+ "version": "2.6.68",
4
4
  "description": "Typescript types for Quesmed",
5
5
  "keywords": [
6
6
  "quesmed",
@@ -3,3 +3,4 @@ export declare const QUESTION_CATEGORY_FIELDS: import("@apollo/client").Document
3
3
  export declare const QUESTION_FIELDS: import("@apollo/client").DocumentNode;
4
4
  export declare const QUESTION_WITH_HIGHLIGHT_FIELDS: import("@apollo/client").DocumentNode;
5
5
  export declare const QUESTION_WITH_COMMENT_FIELDS: import("@apollo/client").DocumentNode;
6
+ export declare const QUESTION_WITH_LEARNING_FIELDS: import("@apollo/client").DocumentNode;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.QUESTION_WITH_COMMENT_FIELDS = exports.QUESTION_WITH_HIGHLIGHT_FIELDS = exports.QUESTION_FIELDS = exports.QUESTION_CATEGORY_FIELDS = exports.QUESTION_COMMENT_FIELDS = void 0;
3
+ exports.QUESTION_WITH_LEARNING_FIELDS = 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
6
  const highlight_1 = require("./highlight");
@@ -110,7 +110,9 @@ exports.QUESTION_FIELDS = (0, client_1.gql) `
110
110
  difficulty
111
111
  dislikes
112
112
  explanation
113
+ learningPoint
113
114
  isLikedByMe
115
+ userPoint
114
116
  likes
115
117
  question
116
118
  totalVotes
@@ -170,3 +172,9 @@ exports.QUESTION_WITH_COMMENT_FIELDS = (0, client_1.gql) `
170
172
  }
171
173
  }
172
174
  `;
175
+ // used in cache updator
176
+ exports.QUESTION_WITH_LEARNING_FIELDS = (0, client_1.gql) `
177
+ fragment QuestionWithLearningFields on Question {
178
+ userPoint
179
+ }
180
+ `;
@@ -29,3 +29,25 @@ export interface IAddChapterHighlightVar {
29
29
  export type IAddChapterHighlightData = RestrictedData<(graphqlNormalize & IChapterHighlight)[], 'addChapterHighlight'>;
30
30
  export declare const ADD_CHAPTER_HIGHLIGHT: import("@apollo/client").DocumentNode;
31
31
  export declare const updateChapterHighlights: (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IAddChapterHighlightData>, options: ApolloUpdateOptions<IAddChapterHighlightVar>) => void;
32
+ export declare const getChapterHighlightOptimisticResponse: (userId: number, highlights: IHighlightNode[], chapterId: number) => {
33
+ restricted: {
34
+ addChapterHighlight: {
35
+ chapterId: number;
36
+ id: number;
37
+ userId: number;
38
+ createdAt: number;
39
+ updatedAt: number;
40
+ deletedAt: number;
41
+ highlights: {
42
+ start: number;
43
+ end: number;
44
+ text: string;
45
+ color: string;
46
+ part?: string | undefined;
47
+ tag: string;
48
+ __typename: string;
49
+ }[];
50
+ __typename: string;
51
+ }[];
52
+ };
53
+ };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.updateChapterHighlights = exports.ADD_CHAPTER_HIGHLIGHT = exports.optimisticUpsertChapterNote = exports.updateCacheOnUpsertChapterNote = exports.UPSERT_CHAPTER_NOTE = void 0;
3
+ exports.getChapterHighlightOptimisticResponse = 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
6
  /**
@@ -96,3 +96,28 @@ const updateChapterHighlights = (cache, result, options) => {
96
96
  }
97
97
  };
98
98
  exports.updateChapterHighlights = updateChapterHighlights;
99
+ const getChapterHighlightOptimisticResponse = (userId, highlights, chapterId) => {
100
+ const date = new Date().getTime();
101
+ return {
102
+ restricted: {
103
+ addChapterHighlight: [
104
+ {
105
+ chapterId,
106
+ id: date,
107
+ userId,
108
+ createdAt: date,
109
+ updatedAt: date,
110
+ deletedAt: date,
111
+ highlights: highlights.map((highlight) => ({
112
+ __typename: 'HighlightNode',
113
+ tag: '',
114
+ color: '',
115
+ ...highlight,
116
+ })),
117
+ __typename: 'ChapterHighlight',
118
+ },
119
+ ],
120
+ },
121
+ };
122
+ };
123
+ exports.getChapterHighlightOptimisticResponse = getChapterHighlightOptimisticResponse;
@@ -1,6 +1,6 @@
1
1
  import { ApolloCache } from '@apollo/client';
2
2
  import { ApolloUpdateOptions, ApolloUpdateResultRestricted } from '../..';
3
- import { EQuestionLike, EQuestionType, IAccessLevel, IHighlightNode, IQuestion, IQuestionComment, IQuestionHighlight, Id } from '../../../models';
3
+ import { EQuestionLike, EQuestionType, EUserLearningPoint, IAccessLevel, IHighlightNode, IQuestion, IQuestionComment, IQuestionHighlight, IQuestionLearningPoint, Id } from '../../../models';
4
4
  import { RestrictedData, graphqlNormalize } from '../../types';
5
5
  interface LikeData {
6
6
  likes?: number;
@@ -62,4 +62,39 @@ export interface IAddQuestionHighlightVar {
62
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
+ /**
66
+ * addQuestionLearningPoint
67
+ */
68
+ export interface IAddQuestionLearningPointVar {
69
+ marksheetId?: number;
70
+ input: {
71
+ questionId: Id;
72
+ userPoint: EUserLearningPoint;
73
+ }[];
74
+ }
75
+ export type IAddQuestionLearningPointData = RestrictedData<(graphqlNormalize & IQuestionLearningPoint)[], 'addQuestionLearningPoint'>;
76
+ export declare const ADD_QUESTION_LEARNING_POINT: import("@apollo/client").DocumentNode;
77
+ export declare const updateQuestionLearningPoint: (typeId: EQuestionType) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IAddQuestionLearningPointData>, options: ApolloUpdateOptions<IAddQuestionLearningPointVar>) => void;
78
+ export declare const getQuestionHighlightOptimisticResponse: (userId: number, highlights: IHighlightNode[], questionId: number) => {
79
+ restricted: {
80
+ addQuestionHighlight: {
81
+ questionId: number;
82
+ id: number;
83
+ userId: number;
84
+ createdAt: number;
85
+ updatedAt: number;
86
+ deletedAt: number;
87
+ highlights: {
88
+ start: number;
89
+ end: number;
90
+ text: string;
91
+ color: string;
92
+ part?: string | undefined;
93
+ tag: string;
94
+ __typename: string;
95
+ }[];
96
+ __typename: string;
97
+ }[];
98
+ };
99
+ };
65
100
  export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
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.getLikeData = void 0;
3
+ exports.getQuestionHighlightOptimisticResponse = exports.updateQuestionLearningPoint = exports.ADD_QUESTION_LEARNING_POINT = 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.getLikeData = void 0;
4
4
  const client_1 = require("@apollo/client");
5
5
  const luxon_1 = require("luxon");
6
6
  const models_1 = require("../../../models");
@@ -378,3 +378,68 @@ const updateQuestionHighlights = (typeId) => (cache, result, options) => {
378
378
  }
379
379
  };
380
380
  exports.updateQuestionHighlights = updateQuestionHighlights;
381
+ exports.ADD_QUESTION_LEARNING_POINT = (0, client_1.gql) `
382
+ mutation AddQuestionLearningPoint(
383
+ $input: [AddQuestionLearningPointInput!]!
384
+ $marksheetId: Int
385
+ ) {
386
+ restricted {
387
+ addQuestionLearningPoint(input: $input, marksheetId: $marksheetId) {
388
+ id
389
+ questionId
390
+ userId
391
+ userPoint
392
+ }
393
+ }
394
+ }
395
+ `;
396
+ const updateQuestionLearningPoint = (typeId) => (cache, result, options) => {
397
+ const { addQuestionLearningPoint } = result?.data?.restricted ?? {};
398
+ const { variables } = options || {};
399
+ if (!variables || !addQuestionLearningPoint) {
400
+ return;
401
+ }
402
+ try {
403
+ for (const { id, userPoint } of addQuestionLearningPoint) {
404
+ cache.writeFragment({
405
+ id: cache.identify({
406
+ id,
407
+ __typename: (0, exports.getQuestionTypeName)(typeId),
408
+ }),
409
+ data: {
410
+ userPoint,
411
+ },
412
+ fragment: fragments_1.QUESTION_WITH_LEARNING_FIELDS,
413
+ });
414
+ }
415
+ }
416
+ catch (error) {
417
+ console.error(error);
418
+ }
419
+ };
420
+ exports.updateQuestionLearningPoint = updateQuestionLearningPoint;
421
+ const getQuestionHighlightOptimisticResponse = (userId, highlights, questionId) => {
422
+ const date = new Date().getTime();
423
+ return {
424
+ restricted: {
425
+ addQuestionHighlight: [
426
+ {
427
+ questionId,
428
+ id: date,
429
+ userId,
430
+ createdAt: date,
431
+ updatedAt: date,
432
+ deletedAt: date,
433
+ highlights: highlights.map((highlight) => ({
434
+ __typename: 'HighlightNode',
435
+ tag: '',
436
+ color: '',
437
+ ...highlight,
438
+ })),
439
+ __typename: 'ChapterHighlight',
440
+ },
441
+ ],
442
+ },
443
+ };
444
+ };
445
+ exports.getQuestionHighlightOptimisticResponse = getQuestionHighlightOptimisticResponse;