@quesmed/types 2.4.6 → 2.4.8
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/dist/cjs/models/User.js +11 -12
- package/dist/cjs/resolvers/mutation/restricted/todo.d.ts +8 -2
- package/dist/cjs/resolvers/mutation/restricted/todo.js +47 -31
- package/dist/mjs/models/User.js +11 -12
- package/dist/mjs/resolvers/mutation/restricted/todo.d.ts +8 -2
- package/dist/mjs/resolvers/mutation/restricted/todo.js +47 -31
- package/package.json +2 -2
package/dist/cjs/models/User.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.currentClassGroup = exports.currentClassYear = exports.EPracticeIntensity = exports.classYearGroup = exports.EClassYearGroup = exports.classYears = void 0;
|
|
4
|
+
const luxon_1 = require("luxon");
|
|
4
5
|
exports.classYears = [
|
|
5
6
|
'Year 1',
|
|
6
7
|
'Year 2',
|
|
@@ -33,7 +34,7 @@ var EPracticeIntensity;
|
|
|
33
34
|
EPracticeIntensity[EPracticeIntensity["MED"] = 2] = "MED";
|
|
34
35
|
EPracticeIntensity[EPracticeIntensity["HIGH"] = 3] = "HIGH";
|
|
35
36
|
})(EPracticeIntensity = exports.EPracticeIntensity || (exports.EPracticeIntensity = {}));
|
|
36
|
-
function currentClassYear(createdAtUnix, classYear, compareUnix =
|
|
37
|
+
function currentClassYear(createdAtUnix, classYear, compareUnix = luxon_1.DateTime.now().toUnixInteger()) {
|
|
37
38
|
if (createdAtUnix === 0) {
|
|
38
39
|
throw new Error('createdAt not given in Unix');
|
|
39
40
|
}
|
|
@@ -45,20 +46,18 @@ function currentClassYear(createdAtUnix, classYear, compareUnix = new Date().get
|
|
|
45
46
|
if (classYearsIdx === -1) {
|
|
46
47
|
return exports.classYears[lastClassYearIdx];
|
|
47
48
|
}
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
if (createdAt.getFullYear() > compareDate.getFullYear()) {
|
|
49
|
+
const compareDT = luxon_1.DateTime.fromSeconds(compareUnix);
|
|
50
|
+
const createdAtDT = luxon_1.DateTime.fromSeconds(createdAtUnix);
|
|
51
|
+
if (createdAtDT.year > compareDT.year) {
|
|
52
52
|
throw new Error('createdAt not given in Unix');
|
|
53
53
|
}
|
|
54
|
-
|
|
55
|
-
let
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (createdAt > createdAcademicYear) {
|
|
59
|
-
yearsAdded--;
|
|
54
|
+
let yearsAdded = compareDT.year - createdAtDT.year;
|
|
55
|
+
let createdAtAcademicDT = luxon_1.DateTime.local(createdAtDT.year, 8, 1);
|
|
56
|
+
if (createdAtDT < createdAtAcademicDT) {
|
|
57
|
+
createdAtAcademicDT = createdAtAcademicDT.minus({ year: 1 });
|
|
60
58
|
}
|
|
61
|
-
|
|
59
|
+
const compareAcademicDT = luxon_1.DateTime.local(compareDT.year, 8, 1);
|
|
60
|
+
if (compareDT > compareAcademicDT) {
|
|
62
61
|
yearsAdded++;
|
|
63
62
|
}
|
|
64
63
|
const newClassYearIdx = classYearsIdx + yearsAdded;
|
|
@@ -31,14 +31,20 @@ export declare const ADD_TO_DAILY_STACK: import("@apollo/client").DocumentNode;
|
|
|
31
31
|
export interface IAddToDailyStackVar {
|
|
32
32
|
conceptIds: Id[];
|
|
33
33
|
}
|
|
34
|
-
export declare type IAddToDailyStackData = RestrictedData<
|
|
34
|
+
export declare type IAddToDailyStackData = RestrictedData<graphqlNormalize & {
|
|
35
|
+
addedUserCompletedCards: (graphqlNormalize & IUserCompletedCard)[];
|
|
36
|
+
dailyFeed: graphqlNormalize & ITodo;
|
|
37
|
+
}, 'addToDailyStack'>;
|
|
35
38
|
export declare const REMOVE_FROM_DAILY_STACK: import("@apollo/client").DocumentNode;
|
|
36
39
|
export interface IRemoveFromDailyStackVar {
|
|
37
40
|
cardId?: Id;
|
|
38
41
|
todoId?: Id;
|
|
39
42
|
conceptId?: Id;
|
|
40
43
|
}
|
|
41
|
-
export declare type IRemoveFromDailyStackData = RestrictedData<
|
|
44
|
+
export declare type IRemoveFromDailyStackData = RestrictedData<graphqlNormalize & {
|
|
45
|
+
removedUserCompletedCards: (graphqlNormalize & IUserCompletedCard)[];
|
|
46
|
+
dailyFeed: graphqlNormalize & ITodo;
|
|
47
|
+
}, 'removeFromDailyStack'>;
|
|
42
48
|
export declare const updateCacheOnRemoveFromDailyStack: (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IRemoveFromDailyStackData>, options: ApolloUpdateOptions) => void;
|
|
43
49
|
export declare const updateCacheOnAddToDailyStack: (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IAddToDailyStackData>) => void;
|
|
44
50
|
export declare const REFRESH_DAILY_TASK: import("@apollo/client").DocumentNode;
|
|
@@ -118,34 +118,42 @@ exports.ADD_TO_DAILY_STACK = (0, client_1.gql) `
|
|
|
118
118
|
mutation AddToDailyStack($conceptIds: [Int!]!) {
|
|
119
119
|
restricted {
|
|
120
120
|
addToDailyStack(conceptIds: $conceptIds) {
|
|
121
|
-
|
|
122
|
-
createdAt
|
|
123
|
-
updatedAt
|
|
124
|
-
concept {
|
|
125
|
-
id
|
|
126
|
-
name
|
|
127
|
-
}
|
|
128
|
-
lastSeen
|
|
129
|
-
reviewDate
|
|
130
|
-
score
|
|
131
|
-
iteration
|
|
132
|
-
optimalFactor
|
|
133
|
-
cardId
|
|
134
|
-
card {
|
|
121
|
+
addedUserCompletedCards {
|
|
135
122
|
id
|
|
136
|
-
|
|
123
|
+
createdAt
|
|
124
|
+
updatedAt
|
|
137
125
|
concept {
|
|
138
126
|
id
|
|
139
127
|
name
|
|
140
128
|
}
|
|
141
|
-
|
|
129
|
+
lastSeen
|
|
130
|
+
reviewDate
|
|
131
|
+
score
|
|
132
|
+
iteration
|
|
133
|
+
optimalFactor
|
|
134
|
+
cardId
|
|
135
|
+
card {
|
|
142
136
|
id
|
|
143
|
-
|
|
137
|
+
conceptId
|
|
138
|
+
concept {
|
|
139
|
+
id
|
|
140
|
+
name
|
|
141
|
+
}
|
|
142
|
+
topic {
|
|
143
|
+
id
|
|
144
|
+
name
|
|
145
|
+
}
|
|
146
|
+
question
|
|
147
|
+
explanation
|
|
148
|
+
pictures {
|
|
149
|
+
...PictureFields
|
|
150
|
+
}
|
|
144
151
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
152
|
+
}
|
|
153
|
+
dailyFeed {
|
|
154
|
+
id
|
|
155
|
+
marks {
|
|
156
|
+
id
|
|
149
157
|
}
|
|
150
158
|
}
|
|
151
159
|
}
|
|
@@ -160,24 +168,32 @@ exports.REMOVE_FROM_DAILY_STACK = (0, client_1.gql) `
|
|
|
160
168
|
todoId: $todoId
|
|
161
169
|
conceptId: $conceptId
|
|
162
170
|
) {
|
|
163
|
-
|
|
164
|
-
cardId
|
|
165
|
-
concept {
|
|
171
|
+
removedUserCompletedCards {
|
|
166
172
|
id
|
|
167
|
-
|
|
173
|
+
cardId
|
|
174
|
+
concept {
|
|
175
|
+
id
|
|
176
|
+
name
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
dailyFeed {
|
|
180
|
+
id
|
|
181
|
+
marks {
|
|
182
|
+
id
|
|
183
|
+
}
|
|
168
184
|
}
|
|
169
185
|
}
|
|
170
186
|
}
|
|
171
187
|
}
|
|
172
188
|
`;
|
|
173
189
|
const updateCacheOnRemoveFromDailyStack = (cache, result, options) => {
|
|
174
|
-
const { removeFromDailyStack } = result.data?.restricted || {};
|
|
190
|
+
const { removeFromDailyStack: data } = result.data?.restricted || {};
|
|
175
191
|
const { variables } = options || {};
|
|
176
192
|
const { todoId } = variables || {};
|
|
177
|
-
if (!
|
|
193
|
+
if (!data || !data.removedUserCompletedCards.length) {
|
|
178
194
|
return;
|
|
179
195
|
}
|
|
180
|
-
const toRemove = new Set(
|
|
196
|
+
const toRemove = new Set(data.removedUserCompletedCards.map(({ cardId }) => cardId));
|
|
181
197
|
const prevData = cache.readQuery({
|
|
182
198
|
query: restricted_1.USER_COMPLETED_DATA,
|
|
183
199
|
});
|
|
@@ -223,14 +239,14 @@ const updateCacheOnRemoveFromDailyStack = (cache, result, options) => {
|
|
|
223
239
|
};
|
|
224
240
|
exports.updateCacheOnRemoveFromDailyStack = updateCacheOnRemoveFromDailyStack;
|
|
225
241
|
const updateCacheOnAddToDailyStack = (cache, result) => {
|
|
226
|
-
const { addToDailyStack } = result.data?.restricted || {};
|
|
242
|
+
const { addToDailyStack: data } = result.data?.restricted || {};
|
|
227
243
|
const prevData = cache.readQuery({
|
|
228
244
|
query: restricted_1.USER_COMPLETED_DATA,
|
|
229
245
|
});
|
|
230
|
-
if (prevData &&
|
|
246
|
+
if (prevData && data) {
|
|
231
247
|
const newCompletedCards = [
|
|
232
248
|
...prevData.restricted.user.completedCards,
|
|
233
|
-
...
|
|
249
|
+
...data.addedUserCompletedCards,
|
|
234
250
|
];
|
|
235
251
|
cache.writeQuery({
|
|
236
252
|
query: restricted_1.USER_COMPLETED_DATA,
|
package/dist/mjs/models/User.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DateTime } from 'luxon';
|
|
1
2
|
export const classYears = [
|
|
2
3
|
'Year 1',
|
|
3
4
|
'Year 2',
|
|
@@ -30,7 +31,7 @@ export var EPracticeIntensity;
|
|
|
30
31
|
EPracticeIntensity[EPracticeIntensity["MED"] = 2] = "MED";
|
|
31
32
|
EPracticeIntensity[EPracticeIntensity["HIGH"] = 3] = "HIGH";
|
|
32
33
|
})(EPracticeIntensity || (EPracticeIntensity = {}));
|
|
33
|
-
export function currentClassYear(createdAtUnix, classYear, compareUnix =
|
|
34
|
+
export function currentClassYear(createdAtUnix, classYear, compareUnix = DateTime.now().toUnixInteger()) {
|
|
34
35
|
if (createdAtUnix === 0) {
|
|
35
36
|
throw new Error('createdAt not given in Unix');
|
|
36
37
|
}
|
|
@@ -42,20 +43,18 @@ export function currentClassYear(createdAtUnix, classYear, compareUnix = new Dat
|
|
|
42
43
|
if (classYearsIdx === -1) {
|
|
43
44
|
return classYears[lastClassYearIdx];
|
|
44
45
|
}
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
if (createdAt.getFullYear() > compareDate.getFullYear()) {
|
|
46
|
+
const compareDT = DateTime.fromSeconds(compareUnix);
|
|
47
|
+
const createdAtDT = DateTime.fromSeconds(createdAtUnix);
|
|
48
|
+
if (createdAtDT.year > compareDT.year) {
|
|
49
49
|
throw new Error('createdAt not given in Unix');
|
|
50
50
|
}
|
|
51
|
-
|
|
52
|
-
let
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (createdAt > createdAcademicYear) {
|
|
56
|
-
yearsAdded--;
|
|
51
|
+
let yearsAdded = compareDT.year - createdAtDT.year;
|
|
52
|
+
let createdAtAcademicDT = DateTime.local(createdAtDT.year, 8, 1);
|
|
53
|
+
if (createdAtDT < createdAtAcademicDT) {
|
|
54
|
+
createdAtAcademicDT = createdAtAcademicDT.minus({ year: 1 });
|
|
57
55
|
}
|
|
58
|
-
|
|
56
|
+
const compareAcademicDT = DateTime.local(compareDT.year, 8, 1);
|
|
57
|
+
if (compareDT > compareAcademicDT) {
|
|
59
58
|
yearsAdded++;
|
|
60
59
|
}
|
|
61
60
|
const newClassYearIdx = classYearsIdx + yearsAdded;
|
|
@@ -31,14 +31,20 @@ export declare const ADD_TO_DAILY_STACK: import("@apollo/client").DocumentNode;
|
|
|
31
31
|
export interface IAddToDailyStackVar {
|
|
32
32
|
conceptIds: Id[];
|
|
33
33
|
}
|
|
34
|
-
export declare type IAddToDailyStackData = RestrictedData<
|
|
34
|
+
export declare type IAddToDailyStackData = RestrictedData<graphqlNormalize & {
|
|
35
|
+
addedUserCompletedCards: (graphqlNormalize & IUserCompletedCard)[];
|
|
36
|
+
dailyFeed: graphqlNormalize & ITodo;
|
|
37
|
+
}, 'addToDailyStack'>;
|
|
35
38
|
export declare const REMOVE_FROM_DAILY_STACK: import("@apollo/client").DocumentNode;
|
|
36
39
|
export interface IRemoveFromDailyStackVar {
|
|
37
40
|
cardId?: Id;
|
|
38
41
|
todoId?: Id;
|
|
39
42
|
conceptId?: Id;
|
|
40
43
|
}
|
|
41
|
-
export declare type IRemoveFromDailyStackData = RestrictedData<
|
|
44
|
+
export declare type IRemoveFromDailyStackData = RestrictedData<graphqlNormalize & {
|
|
45
|
+
removedUserCompletedCards: (graphqlNormalize & IUserCompletedCard)[];
|
|
46
|
+
dailyFeed: graphqlNormalize & ITodo;
|
|
47
|
+
}, 'removeFromDailyStack'>;
|
|
42
48
|
export declare const updateCacheOnRemoveFromDailyStack: (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IRemoveFromDailyStackData>, options: ApolloUpdateOptions) => void;
|
|
43
49
|
export declare const updateCacheOnAddToDailyStack: (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IAddToDailyStackData>) => void;
|
|
44
50
|
export declare const REFRESH_DAILY_TASK: import("@apollo/client").DocumentNode;
|
|
@@ -112,34 +112,42 @@ export const ADD_TO_DAILY_STACK = gql `
|
|
|
112
112
|
mutation AddToDailyStack($conceptIds: [Int!]!) {
|
|
113
113
|
restricted {
|
|
114
114
|
addToDailyStack(conceptIds: $conceptIds) {
|
|
115
|
-
|
|
116
|
-
createdAt
|
|
117
|
-
updatedAt
|
|
118
|
-
concept {
|
|
119
|
-
id
|
|
120
|
-
name
|
|
121
|
-
}
|
|
122
|
-
lastSeen
|
|
123
|
-
reviewDate
|
|
124
|
-
score
|
|
125
|
-
iteration
|
|
126
|
-
optimalFactor
|
|
127
|
-
cardId
|
|
128
|
-
card {
|
|
115
|
+
addedUserCompletedCards {
|
|
129
116
|
id
|
|
130
|
-
|
|
117
|
+
createdAt
|
|
118
|
+
updatedAt
|
|
131
119
|
concept {
|
|
132
120
|
id
|
|
133
121
|
name
|
|
134
122
|
}
|
|
135
|
-
|
|
123
|
+
lastSeen
|
|
124
|
+
reviewDate
|
|
125
|
+
score
|
|
126
|
+
iteration
|
|
127
|
+
optimalFactor
|
|
128
|
+
cardId
|
|
129
|
+
card {
|
|
136
130
|
id
|
|
137
|
-
|
|
131
|
+
conceptId
|
|
132
|
+
concept {
|
|
133
|
+
id
|
|
134
|
+
name
|
|
135
|
+
}
|
|
136
|
+
topic {
|
|
137
|
+
id
|
|
138
|
+
name
|
|
139
|
+
}
|
|
140
|
+
question
|
|
141
|
+
explanation
|
|
142
|
+
pictures {
|
|
143
|
+
...PictureFields
|
|
144
|
+
}
|
|
138
145
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
146
|
+
}
|
|
147
|
+
dailyFeed {
|
|
148
|
+
id
|
|
149
|
+
marks {
|
|
150
|
+
id
|
|
143
151
|
}
|
|
144
152
|
}
|
|
145
153
|
}
|
|
@@ -154,24 +162,32 @@ export const REMOVE_FROM_DAILY_STACK = gql `
|
|
|
154
162
|
todoId: $todoId
|
|
155
163
|
conceptId: $conceptId
|
|
156
164
|
) {
|
|
157
|
-
|
|
158
|
-
cardId
|
|
159
|
-
concept {
|
|
165
|
+
removedUserCompletedCards {
|
|
160
166
|
id
|
|
161
|
-
|
|
167
|
+
cardId
|
|
168
|
+
concept {
|
|
169
|
+
id
|
|
170
|
+
name
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
dailyFeed {
|
|
174
|
+
id
|
|
175
|
+
marks {
|
|
176
|
+
id
|
|
177
|
+
}
|
|
162
178
|
}
|
|
163
179
|
}
|
|
164
180
|
}
|
|
165
181
|
}
|
|
166
182
|
`;
|
|
167
183
|
export const updateCacheOnRemoveFromDailyStack = (cache, result, options) => {
|
|
168
|
-
const { removeFromDailyStack } = result.data?.restricted || {};
|
|
184
|
+
const { removeFromDailyStack: data } = result.data?.restricted || {};
|
|
169
185
|
const { variables } = options || {};
|
|
170
186
|
const { todoId } = variables || {};
|
|
171
|
-
if (!
|
|
187
|
+
if (!data || !data.removedUserCompletedCards.length) {
|
|
172
188
|
return;
|
|
173
189
|
}
|
|
174
|
-
const toRemove = new Set(
|
|
190
|
+
const toRemove = new Set(data.removedUserCompletedCards.map(({ cardId }) => cardId));
|
|
175
191
|
const prevData = cache.readQuery({
|
|
176
192
|
query: USER_COMPLETED_DATA,
|
|
177
193
|
});
|
|
@@ -216,14 +232,14 @@ export const updateCacheOnRemoveFromDailyStack = (cache, result, options) => {
|
|
|
216
232
|
}
|
|
217
233
|
};
|
|
218
234
|
export const updateCacheOnAddToDailyStack = (cache, result) => {
|
|
219
|
-
const { addToDailyStack } = result.data?.restricted || {};
|
|
235
|
+
const { addToDailyStack: data } = result.data?.restricted || {};
|
|
220
236
|
const prevData = cache.readQuery({
|
|
221
237
|
query: USER_COMPLETED_DATA,
|
|
222
238
|
});
|
|
223
|
-
if (prevData &&
|
|
239
|
+
if (prevData && data) {
|
|
224
240
|
const newCompletedCards = [
|
|
225
241
|
...prevData.restricted.user.completedCards,
|
|
226
|
-
...
|
|
242
|
+
...data.addedUserCompletedCards,
|
|
227
243
|
];
|
|
228
244
|
cache.writeQuery({
|
|
229
245
|
query: USER_COMPLETED_DATA,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quesmed/types",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.8",
|
|
4
4
|
"description": "Typescript types for Quesmed",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"quesmed",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"author": "stefan@quesmed.com",
|
|
76
76
|
"license": "ISC",
|
|
77
77
|
"scripts": {
|
|
78
|
-
"test": "jest",
|
|
78
|
+
"test": "yarn jest",
|
|
79
79
|
"clean": "rimraf dist && rimraf build",
|
|
80
80
|
"tsc:watch:mjs": "yarn pnpify tsc -w -p tsconfig.json",
|
|
81
81
|
"tsc:watch:cjs": "yarn pnpify tsc -w -p tsconfig-cjs.json",
|