@quesmed/types 2.6.67 → 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;
@@ -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
+ }
@@ -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,
@@ -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
+ `;
@@ -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,6 +62,19 @@ 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;
65
78
  export declare const getQuestionHighlightOptimisticResponse: (userId: number, highlights: IHighlightNode[], questionId: number) => {
66
79
  restricted: {
67
80
  addQuestionHighlight: {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getQuestionHighlightOptimisticResponse = 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,6 +378,46 @@ 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;
381
421
  const getQuestionHighlightOptimisticResponse = (userId, highlights, questionId) => {
382
422
  const date = new Date().getTime();
383
423
  return {
@@ -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;
@@ -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
+ }
@@ -65,6 +65,11 @@ export var EUserLearningStatus;
65
65
  EUserLearningStatus[EUserLearningStatus["REVISING"] = 3] = "REVISING";
66
66
  EUserLearningStatus[EUserLearningStatus["URGENT"] = 4] = "URGENT";
67
67
  })(EUserLearningStatus || (EUserLearningStatus = {}));
68
+ export var EUserLearningPoint;
69
+ (function (EUserLearningPoint) {
70
+ EUserLearningPoint[EUserLearningPoint["NOT_RELEVANT"] = 0] = "NOT_RELEVANT";
71
+ EUserLearningPoint[EUserLearningPoint["RELEVANT"] = 1] = "RELEVANT";
72
+ })(EUserLearningPoint || (EUserLearningPoint = {}));
68
73
  export const classYearGroup = {
69
74
  'Year 1': EClassYearGroup.PRECLINICAL,
70
75
  'Year 2': EClassYearGroup.PRECLINICAL,
@@ -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;
@@ -107,7 +107,9 @@ export const QUESTION_FIELDS = gql `
107
107
  difficulty
108
108
  dislikes
109
109
  explanation
110
+ learningPoint
110
111
  isLikedByMe
112
+ userPoint
111
113
  likes
112
114
  question
113
115
  totalVotes
@@ -167,3 +169,9 @@ export const QUESTION_WITH_COMMENT_FIELDS = gql `
167
169
  }
168
170
  }
169
171
  `;
172
+ // used in cache updator
173
+ export const QUESTION_WITH_LEARNING_FIELDS = gql `
174
+ fragment QuestionWithLearningFields on Question {
175
+ userPoint
176
+ }
177
+ `;
@@ -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,6 +62,19 @@ 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;
65
78
  export declare const getQuestionHighlightOptimisticResponse: (userId: number, highlights: IHighlightNode[], questionId: number) => {
66
79
  restricted: {
67
80
  addQuestionHighlight: {
@@ -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 { HIGHLIGHT_FIELDS, 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, QUESTION_WITH_LEARNING_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) {
@@ -366,6 +366,45 @@ export const updateQuestionHighlights = (typeId) => (cache, result, options) =>
366
366
  console.error(error);
367
367
  }
368
368
  };
369
+ export const ADD_QUESTION_LEARNING_POINT = gql `
370
+ mutation AddQuestionLearningPoint(
371
+ $input: [AddQuestionLearningPointInput!]!
372
+ $marksheetId: Int
373
+ ) {
374
+ restricted {
375
+ addQuestionLearningPoint(input: $input, marksheetId: $marksheetId) {
376
+ id
377
+ questionId
378
+ userId
379
+ userPoint
380
+ }
381
+ }
382
+ }
383
+ `;
384
+ export const updateQuestionLearningPoint = (typeId) => (cache, result, options) => {
385
+ const { addQuestionLearningPoint } = result?.data?.restricted ?? {};
386
+ const { variables } = options || {};
387
+ if (!variables || !addQuestionLearningPoint) {
388
+ return;
389
+ }
390
+ try {
391
+ for (const { id, userPoint } of addQuestionLearningPoint) {
392
+ cache.writeFragment({
393
+ id: cache.identify({
394
+ id,
395
+ __typename: getQuestionTypeName(typeId),
396
+ }),
397
+ data: {
398
+ userPoint,
399
+ },
400
+ fragment: QUESTION_WITH_LEARNING_FIELDS,
401
+ });
402
+ }
403
+ }
404
+ catch (error) {
405
+ console.error(error);
406
+ }
407
+ };
369
408
  export const getQuestionHighlightOptimisticResponse = (userId, highlights, questionId) => {
370
409
  const date = new Date().getTime();
371
410
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quesmed/types",
3
- "version": "2.6.67",
3
+ "version": "2.6.68",
4
4
  "description": "Typescript types for Quesmed",
5
5
  "keywords": [
6
6
  "quesmed",