@quesmed/types 2.2.68 → 2.2.72

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 +1,2 @@
1
1
  export declare const USER_FIELDS: import("@apollo/client").DocumentNode;
2
+ export declare const COMPLETED_CARDS: import("@apollo/client").DocumentNode;
@@ -1,6 +1,6 @@
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
5
  exports.USER_FIELDS = (0, client_1.gql) `
6
6
  fragment UserFields on User {
@@ -34,3 +34,53 @@ exports.USER_FIELDS = (0, client_1.gql) `
34
34
  # completedRedCardsCount
35
35
  }
36
36
  `;
37
+ exports.COMPLETED_CARDS = (0, client_1.gql) `
38
+ fragment UserCompletedCards on User {
39
+ completedCards {
40
+ id
41
+ createdAt
42
+ updatedAt
43
+ concept {
44
+ id
45
+ name
46
+ }
47
+ lastSeen
48
+ reviewDate
49
+ score
50
+ iteration
51
+ optimalFactor
52
+ cardId
53
+ card {
54
+ id
55
+ conceptId
56
+ concept {
57
+ id
58
+ name
59
+ }
60
+ topic {
61
+ id
62
+ name
63
+ }
64
+ question
65
+ explanation
66
+ pictures {
67
+ id
68
+ createdAt
69
+ updatedAt
70
+ name
71
+ caption
72
+ path
73
+ path512
74
+ path256
75
+ topicId
76
+ topic {
77
+ id
78
+ name
79
+ typeId
80
+ }
81
+ }
82
+ }
83
+ }
84
+ completedCardsCount
85
+ }
86
+ `;
@@ -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) `
@@ -1821,6 +1821,42 @@ exports.REMOVE_FLAGGED_QUESTION = (0, client_1.gql) `
1821
1821
  }
1822
1822
  }
1823
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;
1824
1860
  exports.START_OR_JOIN_MARKSHEET = (0, client_1.gql) `
1825
1861
  mutation StartOrJoinMarksheet($agoraId: String!, $solo: Boolean!) {
1826
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'>;
@@ -1 +1,2 @@
1
1
  export declare const USER_FIELDS: import("@apollo/client").DocumentNode;
2
+ export declare const COMPLETED_CARDS: import("@apollo/client").DocumentNode;
@@ -31,3 +31,53 @@ export const USER_FIELDS = gql `
31
31
  # completedRedCardsCount
32
32
  }
33
33
  `;
34
+ export const COMPLETED_CARDS = gql `
35
+ fragment UserCompletedCards on User {
36
+ completedCards {
37
+ id
38
+ createdAt
39
+ updatedAt
40
+ concept {
41
+ id
42
+ name
43
+ }
44
+ lastSeen
45
+ reviewDate
46
+ score
47
+ iteration
48
+ optimalFactor
49
+ cardId
50
+ card {
51
+ id
52
+ conceptId
53
+ concept {
54
+ id
55
+ name
56
+ }
57
+ topic {
58
+ id
59
+ name
60
+ }
61
+ question
62
+ explanation
63
+ pictures {
64
+ id
65
+ createdAt
66
+ updatedAt
67
+ name
68
+ caption
69
+ path
70
+ path512
71
+ path256
72
+ topicId
73
+ topic {
74
+ id
75
+ name
76
+ typeId
77
+ }
78
+ }
79
+ }
80
+ }
81
+ completedCardsCount
82
+ }
83
+ `;
@@ -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
  */
@@ -1816,6 +1816,40 @@ export const REMOVE_FLAGGED_QUESTION = gql `
1816
1816
  }
1817
1817
  }
1818
1818
  `;
1819
+ export const MARK_FLAGGED_FIELD = gql `
1820
+ fragment MarksheetMarkFlagged on MarksheetMark {
1821
+ flagged
1822
+ }
1823
+ `;
1824
+ export const updateCacheAddFlaggedQuestion = (cache, result) => {
1825
+ const { addFlaggedQuestion } = result?.data?.restricted || {};
1826
+ if (!addFlaggedQuestion) {
1827
+ return;
1828
+ }
1829
+ const { markId } = addFlaggedQuestion;
1830
+ cache.writeFragment({
1831
+ id: cache.identify({ id: markId, __typename: 'MarksheetMark' }),
1832
+ data: {
1833
+ flagged: true,
1834
+ },
1835
+ fragment: MARK_FLAGGED_FIELD,
1836
+ });
1837
+ };
1838
+ export const updateCacheRemoveFlaggedQuestion = (cache, result) => {
1839
+ const { removeFlaggedQuestion } = result?.data?.restricted || {};
1840
+ if (!removeFlaggedQuestion) {
1841
+ return;
1842
+ }
1843
+ removeFlaggedQuestion.forEach(({ markId }) => {
1844
+ cache.writeFragment({
1845
+ id: cache.identify({ id: Number(markId), __typename: 'MarksheetMark' }),
1846
+ data: {
1847
+ flagged: false,
1848
+ },
1849
+ fragment: MARK_FLAGGED_FIELD,
1850
+ });
1851
+ });
1852
+ };
1819
1853
  export const START_OR_JOIN_MARKSHEET = gql `
1820
1854
  mutation StartOrJoinMarksheet($agoraId: String!, $solo: Boolean!) {
1821
1855
  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,5 +1,5 @@
1
1
  import { gql } from '@apollo/client';
2
- import { PICTURE_FIELDS } from '../../fragments';
2
+ import { COMPLETED_CARDS, PICTURE_FIELDS } from '../../fragments';
3
3
  export const BUILD_TODO = gql `
4
4
  mutation BuildTodo($buildTodo: BuildTodoInput!) {
5
5
  restricted {
@@ -130,6 +130,47 @@ export const REMOVE_FROM_DAILY_STACK = gql `
130
130
  }
131
131
  }
132
132
  `;
133
+ export const updateCacheRemoveFromDailyStack = (userId) => (cache, result) => {
134
+ const { removeFromDailyStack } = result.data?.restricted || {};
135
+ const prevData = cache.readFragment({
136
+ id: cache.identify({ id: userId, __typename: 'User' }),
137
+ fragment: COMPLETED_CARDS,
138
+ });
139
+ if (prevData && removeFromDailyStack && removeFromDailyStack.length) {
140
+ const toRemove = new Set(removeFromDailyStack.map(({ id }) => id));
141
+ if (toRemove.size === 0 || !userId) {
142
+ return;
143
+ }
144
+ const newCompletedCards = prevData.completedCards.filter(({ id }) => !toRemove.has(id));
145
+ cache.writeFragment({
146
+ id: cache.identify({ id: userId, __typename: 'User' }),
147
+ data: {
148
+ completedCardsCount: newCompletedCards.length,
149
+ completedCards: newCompletedCards,
150
+ },
151
+ fragment: COMPLETED_CARDS,
152
+ });
153
+ }
154
+ };
155
+ export const updateCacheAddToDailyStack = (userId) => (cache, result) => {
156
+ const { addToDailyStack } = result.data?.restricted || {};
157
+ const prevData = cache.readFragment({
158
+ id: cache.identify({ id: userId, __typename: 'User' }),
159
+ fragment: COMPLETED_CARDS,
160
+ });
161
+ const { completedCards = [] } = prevData || {};
162
+ if (addToDailyStack) {
163
+ const newCompletedCards = [...completedCards, ...addToDailyStack];
164
+ cache.writeFragment({
165
+ id: cache.identify({ id: userId, __typename: 'User' }),
166
+ data: {
167
+ completedCardsCount: newCompletedCards.length,
168
+ completedCards: newCompletedCards,
169
+ },
170
+ fragment: COMPLETED_CARDS,
171
+ });
172
+ }
173
+ };
133
174
  export const REFRESH_DAILY_TASK = gql `
134
175
  ${PICTURE_FIELDS}
135
176
  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'>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quesmed/types",
3
- "version": "2.2.68",
3
+ "version": "2.2.72",
4
4
  "description": "Typescript types for Quesmed",
5
5
  "keywords": [
6
6
  "quesmed",