@milobedini/shared-types 1.0.39 → 1.0.41

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/index.d.ts CHANGED
@@ -1,3 +1 @@
1
- export * from './program';
2
- export * from './auth';
3
- export * from './general';
1
+ export * from './types';
@@ -0,0 +1,292 @@
1
+ export type ApiError = {
2
+ data: {
3
+ message: string;
4
+ };
5
+ };
6
+ export type User = {
7
+ _id: string;
8
+ username: string;
9
+ email: string;
10
+ name?: string;
11
+ };
12
+ export type UserRole = 'therapist' | 'admin' | 'patient';
13
+ export type AuthUser = User & {
14
+ roles: UserRole[];
15
+ isVerifiedTherapist?: boolean;
16
+ patients?: string[];
17
+ therapist?: string;
18
+ };
19
+ export type AuthResponse = {
20
+ success: boolean;
21
+ message: string;
22
+ user: AuthUser;
23
+ };
24
+ export type RegisterInput = {
25
+ username: string;
26
+ email: string;
27
+ password: string;
28
+ roles: UserRole[];
29
+ };
30
+ export type LoginInput = {
31
+ identifier: string;
32
+ password: string;
33
+ };
34
+ export type VerifyInput = {
35
+ verificationCode: string;
36
+ };
37
+ export type PatientsResponse = AuthUser[];
38
+ export type AddRemoveTherapistInput = {
39
+ therapistId: string;
40
+ patientId: string;
41
+ };
42
+ export type AddRemoveTherapistResponse = {
43
+ message: string;
44
+ patient: AuthUser;
45
+ therapistPatients: string[];
46
+ };
47
+ export type ProfileResponse = {
48
+ _id: string;
49
+ username: string;
50
+ email: string;
51
+ roles: UserRole[];
52
+ isVerifiedTherapist: boolean;
53
+ patients: string[];
54
+ therapist: User | null;
55
+ };
56
+ export type ProgramBase = {
57
+ _id: string;
58
+ title: string;
59
+ description: string;
60
+ createdAt: string;
61
+ updatedAt: string;
62
+ };
63
+ export type Program = ProgramBase & {
64
+ modules: string[];
65
+ };
66
+ export type ProgramWithModules = ProgramBase & {
67
+ modules: Module[];
68
+ };
69
+ export type ModuleType = 'questionnaire' | 'psychoeducation' | 'exercise';
70
+ export type Module = {
71
+ _id: string;
72
+ title: string;
73
+ description: string;
74
+ program: Program;
75
+ type: ModuleType;
76
+ disclaimer?: string;
77
+ imageUrl?: string;
78
+ createdAt: string;
79
+ updatedAt: string;
80
+ enrolled?: string[];
81
+ };
82
+ export type Choice = {
83
+ text: string;
84
+ score: number;
85
+ };
86
+ export type Question = {
87
+ _id: string;
88
+ module: string;
89
+ order: number;
90
+ text: string;
91
+ choices: Choice[];
92
+ };
93
+ export type ScoreBand = {
94
+ _id: string;
95
+ module: string;
96
+ min: number;
97
+ max: number;
98
+ label: string;
99
+ interpretation: string;
100
+ };
101
+ export type ScoreBandSummary = {
102
+ _id: string;
103
+ label: string;
104
+ interpretation: string;
105
+ min: number;
106
+ max: number;
107
+ };
108
+ export type AttemptStatus = 'started' | 'submitted' | 'abandoned';
109
+ export type AttemptAnswer = {
110
+ question: string;
111
+ chosenScore: number;
112
+ };
113
+ export type ModuleSnapshotQuestion = {
114
+ _id: string;
115
+ text: string;
116
+ choices: Choice[];
117
+ };
118
+ export type ModuleSnapshot = {
119
+ title: string;
120
+ disclaimer?: string;
121
+ questions?: ModuleSnapshotQuestion[];
122
+ };
123
+ export type ModuleAttempt = {
124
+ _id: string;
125
+ user: string;
126
+ therapist?: string;
127
+ program: string;
128
+ module: string;
129
+ moduleType: ModuleType;
130
+ status: AttemptStatus;
131
+ startedAt: string;
132
+ completedAt?: string;
133
+ lastInteractionAt: string;
134
+ durationSecs?: number;
135
+ iteration?: number;
136
+ dueAt?: string;
137
+ answers?: AttemptAnswer[];
138
+ totalScore?: number;
139
+ scoreBandLabel?: string;
140
+ band?: ScoreBandSummary;
141
+ weekStart?: string;
142
+ contentVersion?: number;
143
+ moduleSnapshot?: ModuleSnapshot;
144
+ userNote?: string;
145
+ therapistNote?: string;
146
+ createdAt: string;
147
+ updatedAt: string;
148
+ };
149
+ export type AttemptListItem = Pick<ModuleAttempt, '_id' | 'module' | 'program' | 'moduleType' | 'totalScore' | 'scoreBandLabel' | 'band' | 'weekStart' | 'completedAt' | 'iteration'>;
150
+ export type AssignmentStatus = 'assigned' | 'in_progress' | 'completed' | 'cancelled';
151
+ export type AssignmentRecurrence = {
152
+ freq: 'weekly' | 'monthly' | 'none';
153
+ interval?: number;
154
+ };
155
+ export type ModuleAssignment = {
156
+ _id: string;
157
+ user: string;
158
+ therapist: string;
159
+ program: string;
160
+ module: string;
161
+ moduleType: ModuleType;
162
+ status: AssignmentStatus;
163
+ dueAt?: string;
164
+ recurrence?: AssignmentRecurrence;
165
+ latestAttempt?: string;
166
+ notes?: string;
167
+ createdAt: string;
168
+ updatedAt: string;
169
+ };
170
+ export type ProgramResponse = {
171
+ program: ProgramWithModules;
172
+ };
173
+ export type ProgramsResponse = {
174
+ programs: Program[];
175
+ };
176
+ export type ModulesResponse = {
177
+ success: boolean;
178
+ modules: Module[];
179
+ };
180
+ export type ModuleResponse = {
181
+ success: boolean;
182
+ module: Module;
183
+ };
184
+ export type ModuleDetailResponse = {
185
+ success: boolean;
186
+ module: Module;
187
+ questions: Question[];
188
+ scoreBands: ScoreBand[];
189
+ };
190
+ export type StartAttemptResponse = {
191
+ success: boolean;
192
+ attempt: ModuleAttempt;
193
+ };
194
+ export type SaveProgressInput = {
195
+ answers?: AttemptAnswer[];
196
+ userNote?: string;
197
+ };
198
+ export type SaveProgressResponse = {
199
+ success: boolean;
200
+ attempt: ModuleAttempt;
201
+ };
202
+ export type SubmitAttemptInput = {
203
+ assignmentId?: string;
204
+ };
205
+ export type SubmitAttemptResponse = {
206
+ success: boolean;
207
+ attempt: ModuleAttempt;
208
+ };
209
+ export type Cursor = string | {
210
+ completedAt: string;
211
+ id: string;
212
+ };
213
+ export type MyAttemptsQuery = {
214
+ moduleId?: string;
215
+ limit?: number;
216
+ cursor?: Cursor;
217
+ };
218
+ export type MyAttemptsResponse = {
219
+ success: boolean;
220
+ attempts: AttemptListItem[];
221
+ nextCursor: string | null;
222
+ };
223
+ export type TherapistUserPreview = Pick<AuthUser, '_id' | 'username' | 'email'>;
224
+ export type TherapistModulePreview = Pick<Module, '_id' | 'title'>;
225
+ export type TherapistLatestRow = {
226
+ user: TherapistUserPreview;
227
+ module: TherapistModulePreview;
228
+ lastAttempt: AttemptListItem & {
229
+ band?: ScoreBandSummary;
230
+ };
231
+ };
232
+ export type TherapistLatestResponse = {
233
+ success: boolean;
234
+ rows: TherapistLatestRow[];
235
+ };
236
+ export type PatientModuleTimelineResponse = {
237
+ success: boolean;
238
+ attempts: (AttemptListItem & {
239
+ band?: ScoreBandSummary;
240
+ })[];
241
+ };
242
+ export type CreateAssignmentInput = {
243
+ userId: string;
244
+ moduleId: string;
245
+ dueAt?: string;
246
+ notes?: string;
247
+ recurrence?: AssignmentRecurrence;
248
+ };
249
+ export type CreateAssignmentResponse = {
250
+ success: boolean;
251
+ assignment: ModuleAssignment;
252
+ };
253
+ export type ListAssignmentsResponse = {
254
+ success: boolean;
255
+ assignments: ModuleAssignment[];
256
+ };
257
+ export type UpdateAssignmentStatusInput = {
258
+ status: AssignmentStatus;
259
+ };
260
+ export type UpdateAssignmentStatusResponse = {
261
+ success: boolean;
262
+ assignment: ModuleAssignment;
263
+ };
264
+ export type CreateModuleInput = {
265
+ title: string;
266
+ description: string;
267
+ type: ModuleType;
268
+ program: string;
269
+ disclaimer?: string;
270
+ imageUrl?: string;
271
+ };
272
+ export type CreateQuestionInput = {
273
+ moduleId: string;
274
+ text: string;
275
+ order: number;
276
+ choices: Choice[];
277
+ };
278
+ export type CreateScoreBandInput = {
279
+ moduleId: string;
280
+ min: number;
281
+ max: number;
282
+ label: string;
283
+ interpretation: string;
284
+ };
285
+ export type EnrolInput = {
286
+ patientId: string;
287
+ moduleId: string;
288
+ };
289
+ export type EnrolResponse = {
290
+ success: boolean;
291
+ message: string;
292
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@milobedini/shared-types",
3
- "version": "1.0.39",
3
+ "version": "1.0.41",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "files": [