@quesmed/types 2.6.200 → 2.6.201

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.
@@ -70,7 +70,7 @@ export type IUpsertUserConceptStatusVar = {
70
70
  };
71
71
  export type IUpsertUserConceptStatusData = RestrictedData<graphqlNormalize & IUserConceptStatus[], 'upsertUserConceptStatus'>;
72
72
  export declare const UPSERT_USER_CONCEPT_STATUS: import("@apollo/client").DocumentNode;
73
- export declare const updateCacheOnConceptLearningStatusUpdate: (topicId: number, prevStatus?: EUserLearningStatus | null) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IUpsertUserConceptStatusData>, options: ApolloUpdateOptions) => void;
73
+ export declare const updateCacheOnConceptLearningStatusUpdate: (topicId: number, prevStatus?: EUserLearningStatus | null, entitlement?: number) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IUpsertUserConceptStatusData>, options: ApolloUpdateOptions) => void;
74
74
  export declare const optimisticConceptLearningStatus: (id: number, conceptIds: number[], userId: number, status: EUserLearningStatus) => IUpsertUserConceptStatusData;
75
75
  export type IUpsertUserStationStatusVar = {
76
76
  osceStationIds: Id[];
@@ -86,5 +86,5 @@ export type IUpsertUserVideoStatusVar = {
86
86
  };
87
87
  export type IUpsertUserVideoStatusData = RestrictedData<graphqlNormalize & IUserVideoStatus[], 'upsertUserVideoStatus'>;
88
88
  export declare const UPSERT_USER_VIDEO_STATUS: import("@apollo/client").DocumentNode;
89
- export declare const updateCacheOnVideoLearningStatusUpdate: (prevStatus?: EUserLearningStatus | null) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IUpsertUserVideoStatusData>, options: ApolloUpdateOptions) => void;
89
+ export declare const updateCacheOnVideoLearningStatusUpdate: (prevStatus?: EUserLearningStatus | null, entitlement?: number) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IUpsertUserVideoStatusData>, options: ApolloUpdateOptions) => void;
90
90
  export declare const optimisticVideoLearningStatus: (id: number, videoIds: number[], userId: number, status: EUserLearningStatus) => IUpsertUserVideoStatusData;
@@ -202,7 +202,7 @@ const getConceptUpdatedFieldNames = (newStatus, prevStatus) => [
202
202
  getConceptStatsFieldName(prevStatus),
203
203
  getConceptStatsFieldName(newStatus),
204
204
  ];
205
- const updateCacheOnConceptLearningStatusUpdate = (topicId, prevStatus) => (cache, result, options) => {
205
+ const updateCacheOnConceptLearningStatusUpdate = (topicId, prevStatus, entitlement) => (cache, result, options) => {
206
206
  const { upsertUserConceptStatus } = result?.data?.restricted || {};
207
207
  const { variables } = options || {};
208
208
  if (!variables || !upsertUserConceptStatus) {
@@ -212,17 +212,24 @@ const updateCacheOnConceptLearningStatusUpdate = (topicId, prevStatus) => (cache
212
212
  conceptIds.forEach((id) => {
213
213
  cache.writeFragment({
214
214
  id: cache.identify({ id, __typename: 'Concept' }),
215
- data: {
216
- status,
217
- },
215
+ data: { status },
218
216
  fragment: STATUS_CONCEPT_FRAGMENT,
219
217
  });
220
218
  });
221
- const prevData = cache.readFragment({
222
- id: cache.identify({
223
- id: topicId,
224
- __typename: 'Topic',
219
+ const topicFragmentId = cache.identify({
220
+ id: topicId.toString(),
221
+ ...(entitlement && {
222
+ entitlement: {
223
+ __ref: cache.identify({
224
+ id: entitlement,
225
+ __typename: 'Entitlement',
226
+ }),
227
+ },
225
228
  }),
229
+ __typename: 'Topic',
230
+ });
231
+ const prevData = cache.readFragment({
232
+ id: topicFragmentId,
226
233
  fragment: TOPIC_CONCEPT_STATUS_STATS_FRAGMENT,
227
234
  });
228
235
  if (prevData) {
@@ -238,7 +245,7 @@ const updateCacheOnConceptLearningStatusUpdate = (topicId, prevStatus) => (cache
238
245
  (prevData[prevStatName] || 0) - conceptIds.length;
239
246
  }
240
247
  cache.writeFragment({
241
- id: cache.identify({ id: topicId, __typename: 'Topic' }),
248
+ id: topicFragmentId,
242
249
  data: {
243
250
  ...newData,
244
251
  },
@@ -376,7 +383,7 @@ const getVideoUpdatedFieldNames = (newStatus, prevStatus) => [
376
383
  getVideoStatsFieldName(prevStatus),
377
384
  getVideoStatsFieldName(newStatus),
378
385
  ];
379
- const updateCacheOnVideoLearningStatusUpdate = (prevStatus) => (cache, result, options) => {
386
+ const updateCacheOnVideoLearningStatusUpdate = (prevStatus, entitlement) => (cache, result, options) => {
380
387
  const { upsertUserVideoStatus } = result?.data?.restricted || {};
381
388
  const { variables } = options || {};
382
389
  if (!variables || !upsertUserVideoStatus) {
@@ -386,9 +393,7 @@ const updateCacheOnVideoLearningStatusUpdate = (prevStatus) => (cache, result, o
386
393
  videoIds.forEach((id) => {
387
394
  cache.writeFragment({
388
395
  id: cache.identify({ id, __typename: 'Video' }),
389
- data: {
390
- status,
391
- },
396
+ data: { status },
392
397
  fragment: VIDEO_STATUS_FRAGMENT,
393
398
  });
394
399
  });
@@ -405,11 +410,20 @@ const updateCacheOnVideoLearningStatusUpdate = (prevStatus) => (cache, result, o
405
410
  return;
406
411
  }
407
412
  [...topicIds].forEach((topicId) => {
408
- const prevData = cache.readFragment({
409
- id: cache.identify({
410
- id: topicId,
411
- __typename: 'Topic',
413
+ const topicFragmentId = cache.identify({
414
+ id: topicId.toString(),
415
+ ...(entitlement && {
416
+ entitlement: {
417
+ __ref: cache.identify({
418
+ id: entitlement,
419
+ __typename: 'Entitlement',
420
+ }),
421
+ },
412
422
  }),
423
+ __typename: 'Topic',
424
+ });
425
+ const prevData = cache.readFragment({
426
+ id: topicFragmentId,
413
427
  fragment: TOPIC_VIDEO_STATUS_STATS_FRAGMENT,
414
428
  });
415
429
  if (prevData) {
@@ -425,7 +439,7 @@ const updateCacheOnVideoLearningStatusUpdate = (prevStatus) => (cache, result, o
425
439
  (prevData[prevStatName] || 0) - videoIds.length;
426
440
  }
427
441
  cache.writeFragment({
428
- id: cache.identify({ id: topicId, __typename: 'Topic' }),
442
+ id: topicFragmentId,
429
443
  data: {
430
444
  ...newData,
431
445
  },
@@ -70,7 +70,7 @@ export type IUpsertUserConceptStatusVar = {
70
70
  };
71
71
  export type IUpsertUserConceptStatusData = RestrictedData<graphqlNormalize & IUserConceptStatus[], 'upsertUserConceptStatus'>;
72
72
  export declare const UPSERT_USER_CONCEPT_STATUS: import("@apollo/client").DocumentNode;
73
- export declare const updateCacheOnConceptLearningStatusUpdate: (topicId: number, prevStatus?: EUserLearningStatus | null) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IUpsertUserConceptStatusData>, options: ApolloUpdateOptions) => void;
73
+ export declare const updateCacheOnConceptLearningStatusUpdate: (topicId: number, prevStatus?: EUserLearningStatus | null, entitlement?: number) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IUpsertUserConceptStatusData>, options: ApolloUpdateOptions) => void;
74
74
  export declare const optimisticConceptLearningStatus: (id: number, conceptIds: number[], userId: number, status: EUserLearningStatus) => IUpsertUserConceptStatusData;
75
75
  export type IUpsertUserStationStatusVar = {
76
76
  osceStationIds: Id[];
@@ -86,5 +86,5 @@ export type IUpsertUserVideoStatusVar = {
86
86
  };
87
87
  export type IUpsertUserVideoStatusData = RestrictedData<graphqlNormalize & IUserVideoStatus[], 'upsertUserVideoStatus'>;
88
88
  export declare const UPSERT_USER_VIDEO_STATUS: import("@apollo/client").DocumentNode;
89
- export declare const updateCacheOnVideoLearningStatusUpdate: (prevStatus?: EUserLearningStatus | null) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IUpsertUserVideoStatusData>, options: ApolloUpdateOptions) => void;
89
+ export declare const updateCacheOnVideoLearningStatusUpdate: (prevStatus?: EUserLearningStatus | null, entitlement?: number) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IUpsertUserVideoStatusData>, options: ApolloUpdateOptions) => void;
90
90
  export declare const optimisticVideoLearningStatus: (id: number, videoIds: number[], userId: number, status: EUserLearningStatus) => IUpsertUserVideoStatusData;
@@ -196,7 +196,7 @@ const getConceptUpdatedFieldNames = (newStatus, prevStatus) => [
196
196
  getConceptStatsFieldName(prevStatus),
197
197
  getConceptStatsFieldName(newStatus),
198
198
  ];
199
- export const updateCacheOnConceptLearningStatusUpdate = (topicId, prevStatus) => (cache, result, options) => {
199
+ export const updateCacheOnConceptLearningStatusUpdate = (topicId, prevStatus, entitlement) => (cache, result, options) => {
200
200
  const { upsertUserConceptStatus } = result?.data?.restricted || {};
201
201
  const { variables } = options || {};
202
202
  if (!variables || !upsertUserConceptStatus) {
@@ -206,17 +206,24 @@ export const updateCacheOnConceptLearningStatusUpdate = (topicId, prevStatus) =>
206
206
  conceptIds.forEach((id) => {
207
207
  cache.writeFragment({
208
208
  id: cache.identify({ id, __typename: 'Concept' }),
209
- data: {
210
- status,
211
- },
209
+ data: { status },
212
210
  fragment: STATUS_CONCEPT_FRAGMENT,
213
211
  });
214
212
  });
215
- const prevData = cache.readFragment({
216
- id: cache.identify({
217
- id: topicId,
218
- __typename: 'Topic',
213
+ const topicFragmentId = cache.identify({
214
+ id: topicId.toString(),
215
+ ...(entitlement && {
216
+ entitlement: {
217
+ __ref: cache.identify({
218
+ id: entitlement,
219
+ __typename: 'Entitlement',
220
+ }),
221
+ },
219
222
  }),
223
+ __typename: 'Topic',
224
+ });
225
+ const prevData = cache.readFragment({
226
+ id: topicFragmentId,
220
227
  fragment: TOPIC_CONCEPT_STATUS_STATS_FRAGMENT,
221
228
  });
222
229
  if (prevData) {
@@ -232,7 +239,7 @@ export const updateCacheOnConceptLearningStatusUpdate = (topicId, prevStatus) =>
232
239
  (prevData[prevStatName] || 0) - conceptIds.length;
233
240
  }
234
241
  cache.writeFragment({
235
- id: cache.identify({ id: topicId, __typename: 'Topic' }),
242
+ id: topicFragmentId,
236
243
  data: {
237
244
  ...newData,
238
245
  },
@@ -366,7 +373,7 @@ const getVideoUpdatedFieldNames = (newStatus, prevStatus) => [
366
373
  getVideoStatsFieldName(prevStatus),
367
374
  getVideoStatsFieldName(newStatus),
368
375
  ];
369
- export const updateCacheOnVideoLearningStatusUpdate = (prevStatus) => (cache, result, options) => {
376
+ export const updateCacheOnVideoLearningStatusUpdate = (prevStatus, entitlement) => (cache, result, options) => {
370
377
  const { upsertUserVideoStatus } = result?.data?.restricted || {};
371
378
  const { variables } = options || {};
372
379
  if (!variables || !upsertUserVideoStatus) {
@@ -376,9 +383,7 @@ export const updateCacheOnVideoLearningStatusUpdate = (prevStatus) => (cache, re
376
383
  videoIds.forEach((id) => {
377
384
  cache.writeFragment({
378
385
  id: cache.identify({ id, __typename: 'Video' }),
379
- data: {
380
- status,
381
- },
386
+ data: { status },
382
387
  fragment: VIDEO_STATUS_FRAGMENT,
383
388
  });
384
389
  });
@@ -395,11 +400,20 @@ export const updateCacheOnVideoLearningStatusUpdate = (prevStatus) => (cache, re
395
400
  return;
396
401
  }
397
402
  [...topicIds].forEach((topicId) => {
398
- const prevData = cache.readFragment({
399
- id: cache.identify({
400
- id: topicId,
401
- __typename: 'Topic',
403
+ const topicFragmentId = cache.identify({
404
+ id: topicId.toString(),
405
+ ...(entitlement && {
406
+ entitlement: {
407
+ __ref: cache.identify({
408
+ id: entitlement,
409
+ __typename: 'Entitlement',
410
+ }),
411
+ },
402
412
  }),
413
+ __typename: 'Topic',
414
+ });
415
+ const prevData = cache.readFragment({
416
+ id: topicFragmentId,
403
417
  fragment: TOPIC_VIDEO_STATUS_STATS_FRAGMENT,
404
418
  });
405
419
  if (prevData) {
@@ -415,7 +429,7 @@ export const updateCacheOnVideoLearningStatusUpdate = (prevStatus) => (cache, re
415
429
  (prevData[prevStatName] || 0) - videoIds.length;
416
430
  }
417
431
  cache.writeFragment({
418
- id: cache.identify({ id: topicId, __typename: 'Topic' }),
432
+ id: topicFragmentId,
419
433
  data: {
420
434
  ...newData,
421
435
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quesmed/types",
3
- "version": "2.6.200",
3
+ "version": "2.6.201",
4
4
  "description": "Typescript types for Quesmed",
5
5
  "keywords": [
6
6
  "quesmed",