@quesmed/types-rn 2.2.99 → 2.2.100

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.99",
3
+ "version": "2.2.100",
4
4
  "description": "Typescript types for Quesmed",
5
5
  "keywords": [
6
6
  "quesmed",
@@ -1,3 +1,5 @@
1
+ import { ApolloCache } from '@apollo/client';
2
+ import { ApolloUpdateOptions, ApolloUpdateResultRestricted } from '../..';
1
3
  import { Id, IMarksheet, IMarksheetMark } from '../../../models';
2
4
  import { graphqlNormalize, RestrictedData } from '../../types';
3
5
  export declare const BUILD_MOCK_TEST_MARKSHEET: import("@apollo/client").DocumentNode;
@@ -7,12 +9,74 @@ export interface IBuildMockTestMarksheetVar {
7
9
  }
8
10
  export declare type IBuildMockTestMarksheetData = RestrictedData<graphqlNormalize & IMarksheet, 'buildMockTestMarksheet'>;
9
11
  export declare const TOGGLE_FLAGGED_MARK: import("@apollo/client").DocumentNode;
12
+ export declare const MARK_FLAGGED_QUESTION: import("@apollo/client").DocumentNode;
13
+ export declare const updateCacheToggleFlaggedQuestion: (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IToggleFlaggedMarkData>) => void;
14
+ export declare const optimisticToggleFlaggedQuestion: (mark: IMarksheetMark, flagged: boolean) => {
15
+ restricted: {
16
+ __typename: string;
17
+ toggleFlaggedMark: {
18
+ flagged: boolean;
19
+ id: number;
20
+ createdAt: number | Date;
21
+ updatedAt: number | Date;
22
+ index: number;
23
+ marksheetId: number;
24
+ questionChoiceId: number | null;
25
+ questionChoices?: import("../../../models").IQuestionChoice | undefined;
26
+ timeTaken: number;
27
+ questionId: number;
28
+ question: import("../../../models").IQuestion;
29
+ mark: import("../../../models").IMarksheetMarkJSONB;
30
+ marksheet?: IMarksheet | undefined;
31
+ isAnswered: boolean;
32
+ striked: number[];
33
+ };
34
+ };
35
+ };
10
36
  export interface IToggleFlaggedMarkVar {
11
37
  markId: Id;
12
38
  isFlagged: boolean;
13
39
  }
14
40
  export declare type IToggleFlaggedMarkData = RestrictedData<graphqlNormalize & IMarksheetMark, 'toggleFlaggedMark'>;
15
41
  export declare const END_MOCK_TEST: import("@apollo/client").DocumentNode;
42
+ export declare const updateCacheOnEndMockTest: (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IEndMockTestData>, options: ApolloUpdateOptions) => void;
43
+ export declare const optimisticEndMockTest: (marksheet: IMarksheet) => {
44
+ restricted: {
45
+ __typename: string;
46
+ endMockTest: {
47
+ completed: boolean;
48
+ id: number;
49
+ createdAt: number | Date;
50
+ updatedAt: number | Date;
51
+ deletedAt: number | Date;
52
+ startedAt: number | Date;
53
+ type: import("../../../models").EMarksheetType;
54
+ endedAt: number | Date;
55
+ topicIds: number[];
56
+ topicNames?: string[] | undefined;
57
+ source: string;
58
+ userId: number;
59
+ user?: import("../../../models").IUser | undefined;
60
+ marks: IMarksheetMark[];
61
+ mockTestId: number | null;
62
+ correct?: number | undefined;
63
+ incorrect?: number | undefined;
64
+ totalQuestions?: number | undefined;
65
+ isTestMarksheet?: boolean | undefined;
66
+ solo: boolean;
67
+ agoraId: string;
68
+ users: import("../../../models").IUser[];
69
+ activeUsers?: import("../../../models").IUser[] | undefined;
70
+ state: import("../../../models").EMarksheetState;
71
+ timeTaken: number;
72
+ currentMarkId?: number | undefined;
73
+ topicConceptData?: string | undefined;
74
+ preBuildData?: import("./marksheet").IPreBuildMarksheet | undefined;
75
+ builderConfig?: import("./marksheet").IBuildConfigData | undefined;
76
+ __typename: string;
77
+ };
78
+ };
79
+ };
16
80
  export interface IEndMockTestVar {
17
81
  marksheetId: Id;
18
82
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.END_MOCK_TEST = exports.TOGGLE_FLAGGED_MARK = exports.BUILD_MOCK_TEST_MARKSHEET = void 0;
3
+ exports.optimisticEndMockTest = exports.updateCacheOnEndMockTest = exports.END_MOCK_TEST = exports.optimisticToggleFlaggedQuestion = exports.updateCacheToggleFlaggedQuestion = exports.MARK_FLAGGED_QUESTION = exports.TOGGLE_FLAGGED_MARK = exports.BUILD_MOCK_TEST_MARKSHEET = void 0;
4
4
  const client_1 = require("@apollo/client");
5
5
  exports.BUILD_MOCK_TEST_MARKSHEET = (0, client_1.gql) `
6
6
  mutation BuildMockTestMarksheet($mockTestId: Int!, $duration: Int!) {
@@ -16,10 +16,41 @@ exports.TOGGLE_FLAGGED_MARK = (0, client_1.gql) `
16
16
  restricted {
17
17
  toggleFlaggedMark(markId: $markId, isFlagged: $isFlagged) {
18
18
  id
19
+ flagged
19
20
  }
20
21
  }
21
22
  }
22
23
  `;
24
+ exports.MARK_FLAGGED_QUESTION = (0, client_1.gql) `
25
+ fragment MarksheetMarkFlagged on MarksheetMark {
26
+ flagged
27
+ }
28
+ `;
29
+ const updateCacheToggleFlaggedQuestion = (cache, result) => {
30
+ const { toggleFlaggedMark } = result?.data?.restricted || {};
31
+ if (!toggleFlaggedMark) {
32
+ return;
33
+ }
34
+ const { id, flagged } = toggleFlaggedMark;
35
+ cache.writeFragment({
36
+ id: cache.identify({ id, __typename: 'MarksheetMark' }),
37
+ data: {
38
+ flagged,
39
+ },
40
+ fragment: exports.MARK_FLAGGED_QUESTION,
41
+ });
42
+ };
43
+ exports.updateCacheToggleFlaggedQuestion = updateCacheToggleFlaggedQuestion;
44
+ const optimisticToggleFlaggedQuestion = (mark, flagged) => ({
45
+ restricted: {
46
+ __typename: 'RestrictedMutation',
47
+ toggleFlaggedMark: {
48
+ ...mark,
49
+ flagged,
50
+ },
51
+ },
52
+ });
53
+ exports.optimisticToggleFlaggedQuestion = optimisticToggleFlaggedQuestion;
23
54
  exports.END_MOCK_TEST = (0, client_1.gql) `
24
55
  mutation EndMockTest($marksheetId: Int!) {
25
56
  restricted {
@@ -30,3 +61,35 @@ exports.END_MOCK_TEST = (0, client_1.gql) `
30
61
  }
31
62
  }
32
63
  `;
64
+ const COMPLETED_MOCK_TEST_FRAGMENT = (0, client_1.gql) `
65
+ fragment MockTestCompleted on Marksheet {
66
+ completed
67
+ }
68
+ `;
69
+ const updateCacheOnEndMockTest = (cache, result, options) => {
70
+ const { endMockTest } = result?.data?.restricted || {};
71
+ const { variables } = options || {};
72
+ if (!variables || !endMockTest) {
73
+ return;
74
+ }
75
+ const { marksheetId: id } = variables;
76
+ cache.writeFragment({
77
+ id: cache.identify({ id, __typename: 'Marksheet' }),
78
+ data: {
79
+ completed: true,
80
+ },
81
+ fragment: COMPLETED_MOCK_TEST_FRAGMENT,
82
+ });
83
+ };
84
+ exports.updateCacheOnEndMockTest = updateCacheOnEndMockTest;
85
+ const optimisticEndMockTest = (marksheet) => ({
86
+ restricted: {
87
+ __typename: 'RestrictedMutation',
88
+ endMockTest: {
89
+ __typename: 'Marksheet',
90
+ ...marksheet,
91
+ completed: true,
92
+ },
93
+ },
94
+ });
95
+ exports.optimisticEndMockTest = optimisticEndMockTest;