@quesmed/types 2.6.68 → 2.6.69

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.
@@ -39,11 +39,11 @@ export declare const getChapterHighlightOptimisticResponse: (userId: number, hig
39
39
  updatedAt: number;
40
40
  deletedAt: number;
41
41
  highlights: {
42
+ part: string;
42
43
  start: number;
43
44
  end: number;
44
45
  text: string;
45
46
  color: string;
46
- part?: string | undefined;
47
47
  tag: string;
48
48
  __typename: string;
49
49
  }[];
@@ -7,9 +7,17 @@ const fragments_1 = require("../../fragments");
7
7
  * upsertChapterNote
8
8
  */
9
9
  exports.UPSERT_CHAPTER_NOTE = (0, client_1.gql) `
10
- mutation UpsertChapterNote($chapterId: Int!, $note: String!, $marksheetId: Int) {
10
+ mutation UpsertChapterNote(
11
+ $chapterId: Int!
12
+ $note: String!
13
+ $marksheetId: Int
14
+ ) {
11
15
  restricted {
12
- upsertChapterNote(chapterId: $chapterId, note: $note, marksheetId: $marksheetId) {
16
+ upsertChapterNote(
17
+ chapterId: $chapterId
18
+ note: $note
19
+ marksheetId: $marksheetId
20
+ ) {
13
21
  id
14
22
  chapterId
15
23
  userId
@@ -113,6 +121,7 @@ const getChapterHighlightOptimisticResponse = (userId, highlights, chapterId) =>
113
121
  tag: '',
114
122
  color: '',
115
123
  ...highlight,
124
+ part: highlight.part || '',
116
125
  })),
117
126
  __typename: 'ChapterHighlight',
118
127
  },
@@ -1,5 +1,5 @@
1
1
  import { ApolloCache } from '@apollo/client';
2
- import { IVideo, Id } from '../../../models';
2
+ import { EEntitlementType, IVideo, Id } from '../../../models';
3
3
  import { ApolloUpdateResultRestricted } from '../../apollo';
4
4
  import { RestrictedData, graphqlNormalize } from '../../types';
5
5
  export declare const VIDEO_WATCHED: import("@apollo/client").DocumentNode;
@@ -7,4 +7,4 @@ export interface IVideoWatchedVar {
7
7
  id: Id;
8
8
  }
9
9
  export type IVideoWatchedData = RestrictedData<graphqlNormalize & IVideo, 'videoWatched'>;
10
- export declare const updateCacheOnVideoWatched: (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IVideoWatchedData>) => void;
10
+ export declare const updateCacheOnVideoWatched: (entitlementId?: EEntitlementType | null) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IVideoWatchedData>) => void;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.updateCacheOnVideoWatched = exports.VIDEO_WATCHED = void 0;
4
4
  const client_1 = require("@apollo/client");
5
5
  const fragments_1 = require("../../fragments");
6
+ const osce_1 = require("../../query/restricted/osce");
6
7
  exports.VIDEO_WATCHED = (0, client_1.gql) `
7
8
  mutation VideoWatched($id: Int!) {
8
9
  restricted {
@@ -14,7 +15,7 @@ exports.VIDEO_WATCHED = (0, client_1.gql) `
14
15
  }
15
16
  }
16
17
  `;
17
- const updateCacheOnVideoWatched = (cache, result) => {
18
+ const updateCacheOnVideoWatched = (entitlementId) => (cache, result) => {
18
19
  const { videoWatched } = result?.data?.restricted || {};
19
20
  if (!videoWatched) {
20
21
  return;
@@ -27,5 +28,34 @@ const updateCacheOnVideoWatched = (cache, result) => {
27
28
  },
28
29
  fragment: fragments_1.VIDEO_USER_VIEWED_FRAGMENT,
29
30
  });
31
+ if (entitlementId) {
32
+ const prevOsceStats = cache?.readQuery({
33
+ query: osce_1.OSCE_STATS,
34
+ variables: { solo: true },
35
+ });
36
+ if (prevOsceStats) {
37
+ const { completed, types } = prevOsceStats.restricted.osceStats;
38
+ cache.writeQuery({
39
+ query: osce_1.OSCE_STATS,
40
+ data: {
41
+ ...prevOsceStats,
42
+ restricted: {
43
+ ...prevOsceStats.restricted,
44
+ osceStats: {
45
+ ...prevOsceStats.restricted.osceStats,
46
+ completed: Number(completed) + 1,
47
+ types: types?.map(({ id, completed, ...rest }) => ({
48
+ id,
49
+ completed: Number(id) === Number(entitlementId)
50
+ ? Number(completed) + 1
51
+ : completed,
52
+ ...rest,
53
+ })),
54
+ },
55
+ },
56
+ },
57
+ });
58
+ }
59
+ }
30
60
  };
31
61
  exports.updateCacheOnVideoWatched = updateCacheOnVideoWatched;
@@ -39,11 +39,11 @@ export declare const getChapterHighlightOptimisticResponse: (userId: number, hig
39
39
  updatedAt: number;
40
40
  deletedAt: number;
41
41
  highlights: {
42
+ part: string;
42
43
  start: number;
43
44
  end: number;
44
45
  text: string;
45
46
  color: string;
46
- part?: string | undefined;
47
47
  tag: string;
48
48
  __typename: string;
49
49
  }[];
@@ -4,9 +4,17 @@ import { CHAPTER_WITH_HIGHLIGHT_FIELDS, HIGHLIGHT_FIELDS, UPSERT_CHAPTER_NOTE_FR
4
4
  * upsertChapterNote
5
5
  */
6
6
  export const UPSERT_CHAPTER_NOTE = gql `
7
- mutation UpsertChapterNote($chapterId: Int!, $note: String!, $marksheetId: Int) {
7
+ mutation UpsertChapterNote(
8
+ $chapterId: Int!
9
+ $note: String!
10
+ $marksheetId: Int
11
+ ) {
8
12
  restricted {
9
- upsertChapterNote(chapterId: $chapterId, note: $note, marksheetId: $marksheetId) {
13
+ upsertChapterNote(
14
+ chapterId: $chapterId
15
+ note: $note
16
+ marksheetId: $marksheetId
17
+ ) {
10
18
  id
11
19
  chapterId
12
20
  userId
@@ -107,6 +115,7 @@ export const getChapterHighlightOptimisticResponse = (userId, highlights, chapte
107
115
  tag: '',
108
116
  color: '',
109
117
  ...highlight,
118
+ part: highlight.part || '',
110
119
  })),
111
120
  __typename: 'ChapterHighlight',
112
121
  },
@@ -1,5 +1,5 @@
1
1
  import { ApolloCache } from '@apollo/client';
2
- import { IVideo, Id } from '../../../models';
2
+ import { EEntitlementType, IVideo, Id } from '../../../models';
3
3
  import { ApolloUpdateResultRestricted } from '../../apollo';
4
4
  import { RestrictedData, graphqlNormalize } from '../../types';
5
5
  export declare const VIDEO_WATCHED: import("@apollo/client").DocumentNode;
@@ -7,4 +7,4 @@ export interface IVideoWatchedVar {
7
7
  id: Id;
8
8
  }
9
9
  export type IVideoWatchedData = RestrictedData<graphqlNormalize & IVideo, 'videoWatched'>;
10
- export declare const updateCacheOnVideoWatched: (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IVideoWatchedData>) => void;
10
+ export declare const updateCacheOnVideoWatched: (entitlementId?: EEntitlementType | null) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IVideoWatchedData>) => void;
@@ -1,5 +1,6 @@
1
1
  import { gql } from '@apollo/client';
2
2
  import { VIDEO_USER_VIEWED_FRAGMENT } from '../../fragments';
3
+ import { OSCE_STATS, } from '../../query/restricted/osce';
3
4
  export const VIDEO_WATCHED = gql `
4
5
  mutation VideoWatched($id: Int!) {
5
6
  restricted {
@@ -11,7 +12,7 @@ export const VIDEO_WATCHED = gql `
11
12
  }
12
13
  }
13
14
  `;
14
- export const updateCacheOnVideoWatched = (cache, result) => {
15
+ export const updateCacheOnVideoWatched = (entitlementId) => (cache, result) => {
15
16
  const { videoWatched } = result?.data?.restricted || {};
16
17
  if (!videoWatched) {
17
18
  return;
@@ -24,4 +25,33 @@ export const updateCacheOnVideoWatched = (cache, result) => {
24
25
  },
25
26
  fragment: VIDEO_USER_VIEWED_FRAGMENT,
26
27
  });
28
+ if (entitlementId) {
29
+ const prevOsceStats = cache?.readQuery({
30
+ query: OSCE_STATS,
31
+ variables: { solo: true },
32
+ });
33
+ if (prevOsceStats) {
34
+ const { completed, types } = prevOsceStats.restricted.osceStats;
35
+ cache.writeQuery({
36
+ query: OSCE_STATS,
37
+ data: {
38
+ ...prevOsceStats,
39
+ restricted: {
40
+ ...prevOsceStats.restricted,
41
+ osceStats: {
42
+ ...prevOsceStats.restricted.osceStats,
43
+ completed: Number(completed) + 1,
44
+ types: types?.map(({ id, completed, ...rest }) => ({
45
+ id,
46
+ completed: Number(id) === Number(entitlementId)
47
+ ? Number(completed) + 1
48
+ : completed,
49
+ ...rest,
50
+ })),
51
+ },
52
+ },
53
+ },
54
+ });
55
+ }
56
+ }
27
57
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quesmed/types",
3
- "version": "2.6.68",
3
+ "version": "2.6.69",
4
4
  "description": "Typescript types for Quesmed",
5
5
  "keywords": [
6
6
  "quesmed",