@quesmed/types-rn 2.2.67 → 2.2.71

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quesmed/types-rn",
3
- "version": "2.2.67",
3
+ "version": "2.2.71",
4
4
  "description": "Typescript types for Quesmed",
5
5
  "keywords": [
6
6
  "quesmed",
@@ -1 +1,2 @@
1
1
  export declare const USER_FIELDS: import("@apollo/client").DocumentNode;
2
+ export declare const COMPLETED_CARDS: import("@apollo/client").DocumentNode;
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.USER_FIELDS = void 0;
3
+ exports.COMPLETED_CARDS = exports.USER_FIELDS = void 0;
4
4
  const client_1 = require("@apollo/client");
5
+ const picture_1 = require("./picture");
5
6
  exports.USER_FIELDS = (0, client_1.gql) `
6
7
  fragment UserFields on User {
7
8
  id
@@ -34,3 +35,41 @@ exports.USER_FIELDS = (0, client_1.gql) `
34
35
  # completedRedCardsCount
35
36
  }
36
37
  `;
38
+ exports.COMPLETED_CARDS = (0, client_1.gql) `
39
+ ${picture_1.PICTURE_FIELDS}
40
+ fragment UserCompletedCards on User {
41
+ completedCards {
42
+ id
43
+ createdAt
44
+ updatedAt
45
+ concept {
46
+ id
47
+ name
48
+ }
49
+ lastSeen
50
+ reviewDate
51
+ score
52
+ iteration
53
+ optimalFactor
54
+ cardId
55
+ card {
56
+ id
57
+ conceptId
58
+ concept {
59
+ id
60
+ name
61
+ }
62
+ topic {
63
+ id
64
+ name
65
+ }
66
+ question
67
+ explanation
68
+ pictures {
69
+ ...PictureFields
70
+ }
71
+ }
72
+ }
73
+ completedCardsCount
74
+ }
75
+ `;
@@ -73,6 +73,9 @@ export interface IRemoveFlaggedQuestionVar {
73
73
  questionId: Id;
74
74
  }
75
75
  export declare type IRemoveFlaggedQuestionData = RestrictedData<(graphqlNormalize & IUserFlaggedQuestion)[], 'removeFlaggedQuestion'>;
76
+ export declare const MARK_FLAGGED_FIELD: import("@apollo/client").DocumentNode;
77
+ export declare const updateCacheAddFlaggedQuestion: (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IAddFlaggedQuestionData>) => void;
78
+ export declare const updateCacheRemoveFlaggedQuestion: (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IRemoveFlaggedQuestionData>) => void;
76
79
  /**
77
80
  * startOrJoinMarksheet
78
81
  */
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TOGGLE_STRIKE_OPTIONS = exports.END_MARKSHEET = exports.LEAVE_MARKSHEET = exports.MODIFY_MARKSHEET_INFO = exports.optimisticModifyMarksheetBuilderConfig = exports.START_OR_JOIN_MARKSHEET = exports.REMOVE_FLAGGED_QUESTION = exports.ADD_FLAGGED_QUESTION = exports.optimisticSaveMarksheets = exports.updateMarksheets = exports.SAVE_MARKSHEET = exports.RE_BUILD_MARKSHEET = exports.BUILD_MARKSHEET = exports.BUILD_QUESTION_MARKSHEET = void 0;
3
+ exports.TOGGLE_STRIKE_OPTIONS = exports.END_MARKSHEET = exports.LEAVE_MARKSHEET = exports.MODIFY_MARKSHEET_INFO = exports.optimisticModifyMarksheetBuilderConfig = exports.START_OR_JOIN_MARKSHEET = exports.updateCacheRemoveFlaggedQuestion = exports.updateCacheAddFlaggedQuestion = exports.MARK_FLAGGED_FIELD = exports.REMOVE_FLAGGED_QUESTION = exports.ADD_FLAGGED_QUESTION = exports.optimisticSaveMarksheets = exports.updateMarksheets = exports.SAVE_MARKSHEET = exports.RE_BUILD_MARKSHEET = exports.BUILD_MARKSHEET = exports.BUILD_QUESTION_MARKSHEET = void 0;
4
4
  const client_1 = require("@apollo/client");
5
5
  const restricted_1 = require("../../query/restricted");
6
6
  exports.BUILD_QUESTION_MARKSHEET = (0, client_1.gql) `
@@ -1138,14 +1138,29 @@ exports.RE_BUILD_MARKSHEET = (0, client_1.gql) `
1138
1138
  restricted {
1139
1139
  reBuildMarksheet(marksheetId: $marksheetId) {
1140
1140
  id
1141
- createdAt
1142
- startedAt
1143
- endedAt
1141
+ topicConceptData
1142
+ currentMarkId
1143
+ completed
1144
+ timeTaken
1144
1145
  topicIds
1145
1146
  topicNames
1147
+ mockTestId
1148
+ totalQuestions
1149
+ solo
1150
+ agoraId
1146
1151
  state
1147
- currentMarkId
1148
- topicConceptData
1152
+ user {
1153
+ id
1154
+ displayName
1155
+ }
1156
+ users {
1157
+ id
1158
+ displayName
1159
+ }
1160
+ activeUsers {
1161
+ id
1162
+ displayName
1163
+ }
1149
1164
  builderConfig {
1150
1165
  difficulty
1151
1166
  isTest
@@ -1161,19 +1176,13 @@ exports.RE_BUILD_MARKSHEET = (0, client_1.gql) `
1161
1176
  seenIncorrect
1162
1177
  unseen
1163
1178
  }
1179
+ createdAt
1180
+ startedAt
1181
+ endedAt
1182
+ isTestMarksheet
1164
1183
  source
1165
- activeUsers {
1166
- id
1167
- displayName
1168
- }
1169
- users {
1170
- id
1171
- displayName
1172
- }
1173
- user {
1174
- displayName
1175
- id
1176
- }
1184
+ correct
1185
+ incorrect
1177
1186
  marks {
1178
1187
  id
1179
1188
  flagged
@@ -1683,11 +1692,6 @@ exports.RE_BUILD_MARKSHEET = (0, client_1.gql) `
1683
1692
  }
1684
1693
  }
1685
1694
  }
1686
- mockTestId
1687
- correct
1688
- incorrect
1689
- totalQuestions
1690
- isTestMarksheet
1691
1695
  }
1692
1696
  }
1693
1697
  }
@@ -1817,6 +1821,42 @@ exports.REMOVE_FLAGGED_QUESTION = (0, client_1.gql) `
1817
1821
  }
1818
1822
  }
1819
1823
  `;
1824
+ exports.MARK_FLAGGED_FIELD = (0, client_1.gql) `
1825
+ fragment MarksheetMarkFlagged on MarksheetMark {
1826
+ flagged
1827
+ }
1828
+ `;
1829
+ const updateCacheAddFlaggedQuestion = (cache, result) => {
1830
+ const { addFlaggedQuestion } = result?.data?.restricted || {};
1831
+ if (!addFlaggedQuestion) {
1832
+ return;
1833
+ }
1834
+ const { markId } = addFlaggedQuestion;
1835
+ cache.writeFragment({
1836
+ id: cache.identify({ id: markId, __typename: 'MarksheetMark' }),
1837
+ data: {
1838
+ flagged: true,
1839
+ },
1840
+ fragment: exports.MARK_FLAGGED_FIELD,
1841
+ });
1842
+ };
1843
+ exports.updateCacheAddFlaggedQuestion = updateCacheAddFlaggedQuestion;
1844
+ const updateCacheRemoveFlaggedQuestion = (cache, result) => {
1845
+ const { removeFlaggedQuestion } = result?.data?.restricted || {};
1846
+ if (!removeFlaggedQuestion) {
1847
+ return;
1848
+ }
1849
+ removeFlaggedQuestion.forEach(({ markId }) => {
1850
+ cache.writeFragment({
1851
+ id: cache.identify({ id: Number(markId), __typename: 'MarksheetMark' }),
1852
+ data: {
1853
+ flagged: false,
1854
+ },
1855
+ fragment: exports.MARK_FLAGGED_FIELD,
1856
+ });
1857
+ });
1858
+ };
1859
+ exports.updateCacheRemoveFlaggedQuestion = updateCacheRemoveFlaggedQuestion;
1820
1860
  exports.START_OR_JOIN_MARKSHEET = (0, client_1.gql) `
1821
1861
  mutation StartOrJoinMarksheet($agoraId: String!, $solo: Boolean!) {
1822
1862
  restricted {
@@ -37,6 +37,8 @@ export interface IRemoveFromDailyStackVar {
37
37
  conceptId?: Id;
38
38
  }
39
39
  export declare type IRemoveFromDailyStackData = RestrictedData<(graphqlNormalize & IUserCompletedCard)[], 'removeFromDailyStack'>;
40
+ export declare const updateCacheRemoveFromDailyStack: (userId?: number | undefined) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IRemoveFromDailyStackData>) => void;
41
+ export declare const updateCacheAddToDailyStack: (userId?: number | undefined) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IAddToDailyStackData>) => void;
40
42
  export declare const REFRESH_DAILY_TASK: import("@apollo/client").DocumentNode;
41
43
  export declare type IRefreshDailyTaskVar = null;
42
44
  export declare type IRefreshDailyTaskData = RestrictedData<graphqlNormalize & ITodo, 'refreshDailyTask'>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.REFRESH_DAILY_TASK = exports.REMOVE_FROM_DAILY_STACK = exports.ADD_TO_DAILY_STACK = exports.saveTodosCache = exports.SAVE_TODO = exports.BUILD_TODO = void 0;
3
+ exports.REFRESH_DAILY_TASK = exports.updateCacheAddToDailyStack = exports.updateCacheRemoveFromDailyStack = exports.REMOVE_FROM_DAILY_STACK = exports.ADD_TO_DAILY_STACK = exports.saveTodosCache = exports.SAVE_TODO = exports.BUILD_TODO = void 0;
4
4
  const client_1 = require("@apollo/client");
5
5
  const fragments_1 = require("../../fragments");
6
6
  exports.BUILD_TODO = (0, client_1.gql) `
@@ -134,6 +134,49 @@ exports.REMOVE_FROM_DAILY_STACK = (0, client_1.gql) `
134
134
  }
135
135
  }
136
136
  `;
137
+ const updateCacheRemoveFromDailyStack = (userId) => (cache, result) => {
138
+ const { removeFromDailyStack } = result.data?.restricted || {};
139
+ const prevData = cache.readFragment({
140
+ id: cache.identify({ id: userId, __typename: 'User' }),
141
+ fragment: fragments_1.COMPLETED_CARDS,
142
+ });
143
+ if (prevData && removeFromDailyStack && removeFromDailyStack.length) {
144
+ const toRemove = new Set(removeFromDailyStack.map(({ id }) => id));
145
+ if (toRemove.size === 0 || !userId) {
146
+ return;
147
+ }
148
+ const newCompletedCards = prevData.completedCards.filter(({ id }) => !toRemove.has(id));
149
+ cache.writeFragment({
150
+ id: cache.identify({ id: userId, __typename: 'User' }),
151
+ data: {
152
+ completedCardsCount: newCompletedCards.length,
153
+ completedCards: newCompletedCards,
154
+ },
155
+ fragment: fragments_1.COMPLETED_CARDS,
156
+ });
157
+ }
158
+ };
159
+ exports.updateCacheRemoveFromDailyStack = updateCacheRemoveFromDailyStack;
160
+ const updateCacheAddToDailyStack = (userId) => (cache, result) => {
161
+ const { addToDailyStack } = result.data?.restricted || {};
162
+ const prevData = cache.readFragment({
163
+ id: cache.identify({ id: userId, __typename: 'User' }),
164
+ fragment: fragments_1.COMPLETED_CARDS,
165
+ });
166
+ const { completedCards = [] } = prevData || {};
167
+ if (addToDailyStack) {
168
+ const newCompletedCards = [...completedCards, ...addToDailyStack];
169
+ cache.writeFragment({
170
+ id: cache.identify({ id: userId, __typename: 'User' }),
171
+ data: {
172
+ completedCardsCount: newCompletedCards.length,
173
+ completedCards: newCompletedCards,
174
+ },
175
+ fragment: fragments_1.COMPLETED_CARDS,
176
+ });
177
+ }
178
+ };
179
+ exports.updateCacheAddToDailyStack = updateCacheAddToDailyStack;
137
180
  exports.REFRESH_DAILY_TASK = (0, client_1.gql) `
138
181
  ${fragments_1.PICTURE_FIELDS}
139
182
  mutation RefreshDailyTask {
@@ -30,3 +30,4 @@ export declare type IRenewTokenData = RestrictedData<string, 'renewToken'>;
30
30
  export declare const TOC_ACCEPT: import("@apollo/client").DocumentNode;
31
31
  export declare type ITocAcceptVar = null;
32
32
  export declare type ITocAcceptData = RestrictedData<string, 'tocAccept'>;
33
+ export declare type ICompletedCardsData = Pick<IUser, 'completedCards' | 'completedCardsCount'>;