@orjok/commons 1.1.0 → 1.2.0

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.
@@ -1,4 +1,4 @@
1
- import { N as NetworkProvider, S as StorageProvider, A as AuthProvider } from './storage-DLqdJgQt.cjs';
1
+ import { N as NetworkProvider, S as StorageProvider, A as AuthProvider } from './storage-9pK8KwIM.cjs';
2
2
 
3
3
  interface CreateQuestionInput {
4
4
  question: string;
@@ -6,6 +6,7 @@ interface CreateQuestionInput {
6
6
  options: string;
7
7
  language: string;
8
8
  level: string;
9
+ publicExam?: string;
9
10
  difficulty: string;
10
11
  type?: string;
11
12
  explanation?: string;
@@ -24,6 +25,7 @@ interface CreateQuestionInput {
24
25
  interface CreatePackInput {
25
26
  name: string;
26
27
  level: string;
28
+ publicExam?: string;
27
29
  language: string;
28
30
  difficulty: string;
29
31
  automaticNumbering?: boolean;
@@ -141,6 +143,17 @@ interface ListByCurriculumInput {
141
143
  sortDirection?: "ASC" | "DESC";
142
144
  language?: string;
143
145
  difficulty?: string;
146
+ publicExam?: string;
147
+ questionType?: string;
148
+ }
149
+ interface ListByPublicExamInput {
150
+ publicExam: string;
151
+ limit?: number;
152
+ nextToken?: string | null;
153
+ sortDirection?: "ASC" | "DESC";
154
+ language?: string;
155
+ difficulty?: string;
156
+ questionType?: string;
144
157
  }
145
158
  interface ListByRandomHashInput {
146
159
  id: string;
@@ -155,11 +168,126 @@ interface ListByRandomHashInput {
155
168
  }
156
169
  interface UpdateUserAvatarInput {
157
170
  userId: string;
158
- avatarUrl: string;
159
- avatarConfig: string;
171
+ avatarUrl?: string | null;
172
+ avatarConfig?: string | null;
173
+ }
174
+ interface CreateAnnouncementInput {
175
+ title: string;
176
+ message: string;
177
+ senderType?: "ORJOK" | "ADMIN" | string;
178
+ senderName?: string | null;
179
+ senderAvatar?: string | null;
180
+ category?: string | null;
181
+ actionUrl?: string | null;
182
+ priority?: "NORMAL" | "HIGH" | string | null;
183
+ }
184
+ interface CreateUserNotificationInput {
185
+ userId: string;
186
+ title: string;
187
+ message: string;
188
+ type?: "LEVEL_UP" | "DIRECT" | "SYSTEM" | "ACHIEVEMENT" | string | null;
189
+ senderType?: "SYSTEM" | "ORJOK" | "ADMIN" | string | null;
190
+ senderName?: string | null;
191
+ senderAvatar?: string | null;
192
+ actionUrl?: string | null;
193
+ metadata?: string | null;
194
+ }
195
+ interface UpdateUserNotificationInput {
196
+ id: string;
197
+ isRead?: boolean | null;
198
+ readAt?: string | null;
199
+ }
200
+ interface ListByLevelInput {
201
+ level: string;
202
+ limit?: number;
203
+ nextToken?: string | null;
204
+ sortDirection?: "ASC" | "DESC";
205
+ language?: string;
206
+ difficulty?: string;
207
+ publicExam?: string;
208
+ questionType?: string;
209
+ }
210
+ interface CreatePackGroupInput {
211
+ name: string;
212
+ description?: string;
213
+ imageUrl?: string;
214
+ type?: string;
215
+ level?: string;
216
+ order?: number;
217
+ packIds?: string[];
218
+ }
219
+ interface ListPackGroupsInput {
220
+ type?: string;
221
+ level?: string;
222
+ limit?: number;
223
+ nextToken?: string | null;
224
+ sortDirection?: "ASC" | "DESC";
225
+ }
226
+ interface UpdateUserProfileInput {
227
+ id: string;
228
+ fullName?: string;
229
+ phoneNumber?: string | null;
230
+ tier?: string | null;
231
+ subscriptionExpiresAt?: string | null;
232
+ aiEvaluationRemaining?: number | null;
233
+ aiQuestionGenRemaining?: number | null;
234
+ xp?: number | null;
235
+ userLevel?: number | null;
236
+ avatarUrl?: string | null;
237
+ avatarConfig?: string | null;
238
+ }
239
+ interface ListUsersInput {
240
+ filter?: Record<string, unknown>;
241
+ limit?: number;
242
+ nextToken?: string | null;
243
+ }
244
+ interface CreateSubscriptionRequestInput {
245
+ userId: string;
246
+ userFullName?: string;
247
+ userEmail?: string;
248
+ itemType: string;
249
+ itemId: string;
250
+ itemTitle: string;
251
+ amount: number;
252
+ billingCycle?: string;
253
+ paymentMethod: string;
254
+ senderPhone: string;
255
+ contactPhone: string;
256
+ trxId: string;
257
+ status?: string;
258
+ aiEvals?: number;
259
+ aiQuestions?: number;
260
+ adminNotes?: string;
261
+ }
262
+ interface UpdateSubscriptionRequestInput {
263
+ id: string;
264
+ status?: string;
265
+ adminNotes?: string;
266
+ processedAt?: string;
267
+ processedBy?: string;
268
+ aiEvals?: number;
269
+ aiQuestions?: number;
270
+ }
271
+ interface ListSubscriptionRequestsInput {
272
+ status?: string;
273
+ userId?: string;
274
+ limit?: number;
275
+ nextToken?: string | null;
276
+ sortDirection?: "ASC" | "DESC";
277
+ filter?: Record<string, unknown>;
278
+ }
279
+ interface UploadCourseItemInput {
280
+ courseId: string;
281
+ fileName: string;
282
+ fileType: string;
283
+ fileData?: ArrayBuffer | Blob | Uint8Array | string;
284
+ parentId?: string | null;
285
+ itemOrder: number;
286
+ itemName?: string;
160
287
  }
161
288
 
162
- type Tier = "FREE" | "PREMIUM";
289
+ type Tier = "FREE" | "PRO" | "PRO_AI";
290
+ type PaymentMethod = "BKASH" | "ROCKET" | "NAGAD" | "CARD" | "OTHER";
163
291
  type QuestionType = "MCQ" | "WRITTEN";
164
292
  type Difficulty = "Easy" | "Medium" | "Hard";
165
293
  type Level = "One" | "Two" | "Three" | "Four" | "Five" | "Six" | "Seven" | "Eight" | "SSC" | "HSC" | "Admission" | "HSC+Admission" | "BCS";
@@ -184,6 +312,7 @@ interface User {
184
312
  tier?: Tier | null;
185
313
  subscriptionExpiresAt?: string | null;
186
314
  aiEvaluationRemaining?: number | null;
315
+ aiQuestionGenRemaining?: number | null;
187
316
  questionCount?: number | null;
188
317
  packCount?: number | null;
189
318
  contestCount?: number | null;
@@ -202,6 +331,11 @@ interface User {
202
331
  hscMathRating?: number | null;
203
332
  hscBiologyRating?: number | null;
204
333
  bcsOverallRating?: number | null;
334
+ xp?: number | null;
335
+ userLevel?: number | null;
336
+ lastReadAnnouncementAt?: string | null;
337
+ fcmToken?: string | null;
338
+ apnsToken?: string | null;
205
339
  }
206
340
  interface Option {
207
341
  id: string;
@@ -220,6 +354,7 @@ interface QuestionObject {
220
354
  imageUrl?: string | null;
221
355
  language: string;
222
356
  level: string;
357
+ publicExam?: string | null;
223
358
  difficulty?: string | null;
224
359
  type?: QuestionType | null;
225
360
  markingInstructions?: string | null;
@@ -246,6 +381,7 @@ interface Pack {
246
381
  name?: string | null;
247
382
  language: string;
248
383
  level: string;
384
+ publicExam?: string | null;
249
385
  difficulty?: string | null;
250
386
  questionCount?: number | null;
251
387
  automaticNumbering: boolean;
@@ -458,6 +594,29 @@ interface PackGroup {
458
594
  order: number;
459
595
  packs?: PaginatedList<Pack> | null;
460
596
  }
597
+ interface SubscriptionRequest {
598
+ id: string;
599
+ userId: string;
600
+ userFullName?: string | null;
601
+ userEmail?: string | null;
602
+ itemType: string;
603
+ itemId: string;
604
+ itemTitle: string;
605
+ amount: number;
606
+ billingCycle?: string | null;
607
+ paymentMethod: string;
608
+ senderPhone: string;
609
+ contactPhone: string;
610
+ trxId: string;
611
+ status?: string | null;
612
+ aiEvals?: number | null;
613
+ aiQuestions?: number | null;
614
+ adminNotes?: string | null;
615
+ processedAt?: string | null;
616
+ processedBy?: string | null;
617
+ createdAt?: string | null;
618
+ updatedAt?: string | null;
619
+ }
461
620
  interface PaymentTransaction {
462
621
  id: string;
463
622
  userId: string;
@@ -467,6 +626,7 @@ interface PaymentTransaction {
467
626
  trxId: string;
468
627
  status?: PaymentStatus | null;
469
628
  tierSelected: string;
629
+ senderPhone?: string | null;
470
630
  }
471
631
  interface AIUsageLog {
472
632
  id: string;
@@ -529,6 +689,35 @@ interface NewsArticle {
529
689
  createdAt?: string | null;
530
690
  updatedAt?: string | null;
531
691
  }
692
+ interface Announcement {
693
+ id: string;
694
+ title: string;
695
+ message: string;
696
+ senderType: "ORJOK" | "ADMIN" | string;
697
+ senderName?: string | null;
698
+ senderAvatar?: string | null;
699
+ category?: string | null;
700
+ actionUrl?: string | null;
701
+ priority?: "NORMAL" | "HIGH" | string | null;
702
+ createdAt?: string | null;
703
+ updatedAt?: string | null;
704
+ }
705
+ interface UserNotification {
706
+ id: string;
707
+ userId: string;
708
+ title: string;
709
+ message: string;
710
+ type?: "LEVEL_UP" | "DIRECT" | "SYSTEM" | "ACHIEVEMENT" | string | null;
711
+ senderType?: "SYSTEM" | "ORJOK" | "ADMIN" | string | null;
712
+ senderName?: string | null;
713
+ senderAvatar?: string | null;
714
+ actionUrl?: string | null;
715
+ isRead?: boolean | null;
716
+ readAt?: string | null;
717
+ metadata?: string | null;
718
+ createdAt?: string | null;
719
+ updatedAt?: string | null;
720
+ }
532
721
 
533
722
  declare class UserService {
534
723
  private network;
@@ -539,6 +728,8 @@ declare class UserService {
539
728
  getPacks(userId: string, nextToken?: string, limit?: number): Promise<PaginatedList<Pack>>;
540
729
  getCourses(userId: string): Promise<Course[]>;
541
730
  getEnrolledCourses(userId: string): Promise<CourseEnrolled[]>;
731
+ updateProfile(input: UpdateUserProfileInput): Promise<User | null>;
732
+ list(input?: ListUsersInput): Promise<PaginatedList<User>>;
542
733
  }
543
734
 
544
735
  interface StatusResponse {
@@ -636,7 +827,9 @@ declare class QuestionService {
636
827
  listBySubject(input: ListByCurriculumInput): Promise<PaginatedList<QuestionObject>>;
637
828
  listByChapter(input: ListByCurriculumInput): Promise<PaginatedList<QuestionObject>>;
638
829
  listByTopic(input: ListByCurriculumInput): Promise<PaginatedList<QuestionObject>>;
830
+ listByPublicExam(input: ListByPublicExamInput): Promise<PaginatedList<QuestionObject>>;
639
831
  listByRandomHash(input: ListByRandomHashInput): Promise<PaginatedList<QuestionObject>>;
832
+ listByLevel(input: ListByLevelInput): Promise<PaginatedList<QuestionObject>>;
640
833
  }
641
834
 
642
835
  declare class PackService {
@@ -651,14 +844,28 @@ declare class PackService {
651
844
  report(id: string, reason: string): Promise<{
652
845
  id: string;
653
846
  }>;
654
- submitExam(packId: string, selectedOptions: (string | null)[]): Promise<StatusIdResponse>;
847
+ submitExam(packId: string, selectedOptions: (string | null)[], options?: {
848
+ functionUrl?: string;
849
+ authToken?: string;
850
+ }): Promise<StatusIdResponse>;
655
851
  getExams(userId: string, nextToken?: string): Promise<PaginatedList<PackExamResults>>;
656
852
  getExamResult(resultId: string): Promise<PackExamResults | null>;
657
853
  listBySubject(input: ListByCurriculumInput): Promise<PaginatedList<Pack>>;
658
854
  listByChapter(input: ListByCurriculumInput): Promise<PaginatedList<Pack>>;
659
855
  listByTopic(input: ListByCurriculumInput): Promise<PaginatedList<Pack>>;
856
+ listByPublicExam(input: ListByPublicExamInput): Promise<PaginatedList<Pack>>;
857
+ listByLevel(input: ListByLevelInput): Promise<PaginatedList<Pack>>;
858
+ createGroup(input: CreatePackGroupInput): Promise<PackGroup>;
859
+ deleteGroup(id: string): Promise<{
860
+ id: string;
861
+ }>;
660
862
  listGroups(type: string, level?: string): Promise<PackGroup[]>;
863
+ listGroups(input: ListPackGroupsInput): Promise<PaginatedList<PackGroup>>;
661
864
  getGroup(id: string): Promise<PackGroup | null>;
865
+ list(input?: {
866
+ limit?: number;
867
+ nextToken?: string | null;
868
+ }): Promise<PaginatedList<Pack>>;
662
869
  }
663
870
 
664
871
  declare class ContestService {
@@ -705,6 +912,7 @@ declare class CourseService {
705
912
  selectLiveExamOption(examId: string, optionId: string, order: number): Promise<StatusResponse>;
706
913
  getLiveExamLeaderboard(examId: string, nextToken?: string | null): Promise<LeaderboardResponse>;
707
914
  publishLiveExamResults(examId: string): Promise<StatusResponse>;
915
+ uploadCourseItem(input: UploadCourseItemInput): Promise<StatusIdResponse>;
708
916
  }
709
917
 
710
918
  declare class CurriculumService {
@@ -716,6 +924,8 @@ declare class CurriculumService {
716
924
  getSubjects(level: string): Promise<Subject[]>;
717
925
  getChapters(subjectId: string): Promise<Chapter[]>;
718
926
  getTopics(chapterId: string): Promise<Topic[]>;
927
+ recalculateQuestionCounts(): Promise<void>;
928
+ recalculateCreatorStats(): Promise<void>;
719
929
  }
720
930
 
721
931
  declare class MediaService {
@@ -750,13 +960,18 @@ declare class ProgressService {
750
960
  getChapterProgress(userId: string): Promise<UserChapterProgress[]>;
751
961
  getTopicProgress(userId: string): Promise<UserTopicProgress[]>;
752
962
  getTopicMetrics(userId: string): Promise<UserTopicMetric[]>;
753
- getMistakenQuestions(userId: string): Promise<QuestionTracking[]>;
963
+ getMistakenQuestions(userId: string, status?: QuestionTrackingStatus): Promise<QuestionTracking[]>;
964
+ getCorrectedQuestions(userId: string): Promise<QuestionTracking[]>;
754
965
  }
755
966
 
967
+ interface FunctionUrlOptions {
968
+ functionUrl?: string;
969
+ authToken?: string;
970
+ }
756
971
  declare class AIService {
757
972
  private network;
758
973
  constructor(network: NetworkProvider);
759
- evaluateWrittenAnswer(input: EvaluateWrittenAnswerInput): Promise<EvaluateWrittenAnswerResponse>;
974
+ evaluateWrittenAnswer(input: EvaluateWrittenAnswerInput, options?: FunctionUrlOptions): Promise<EvaluateWrittenAnswerResponse>;
760
975
  }
761
976
 
762
977
  declare class NewsService {
@@ -767,6 +982,56 @@ declare class NewsService {
767
982
  get(id: string): Promise<NewsArticle | null>;
768
983
  }
769
984
 
985
+ declare class NotificationService {
986
+ private network;
987
+ constructor(network: NetworkProvider);
988
+ /**
989
+ * List broadcast announcements (ordered by category and createdAt).
990
+ */
991
+ listAnnouncements(limit?: number, nextToken?: string | null): Promise<PaginatedList<Announcement>>;
992
+ /**
993
+ * List announcements by category.
994
+ */
995
+ listAnnouncementsByCategory(category?: string, limit?: number, nextToken?: string | null): Promise<PaginatedList<Announcement>>;
996
+ /**
997
+ * Create an announcement (Admins only).
998
+ */
999
+ createAnnouncement(input: CreateAnnouncementInput): Promise<Announcement | null>;
1000
+ /**
1001
+ * Delete an announcement (Admins only).
1002
+ */
1003
+ deleteAnnouncement(id: string): Promise<boolean>;
1004
+ /**
1005
+ * List user notifications for a specific user ID.
1006
+ */
1007
+ listUserNotifications(userId: string, limit?: number, nextToken?: string | null): Promise<PaginatedList<UserNotification>>;
1008
+ /**
1009
+ * Create a user notification (Level up, direct message, system alert).
1010
+ */
1011
+ createUserNotification(input: CreateUserNotificationInput): Promise<UserNotification | null>;
1012
+ /**
1013
+ * Mark a personal notification as read.
1014
+ */
1015
+ markNotificationAsRead(id: string): Promise<UserNotification | null>;
1016
+ /**
1017
+ * Delete a personal user notification.
1018
+ */
1019
+ deleteUserNotification(id: string): Promise<boolean>;
1020
+ /**
1021
+ * Update the user's lastReadAnnouncementAt timestamp in DynamoDB.
1022
+ */
1023
+ updateLastReadAnnouncement(userId: string, timestamp?: string): Promise<boolean>;
1024
+ }
1025
+
1026
+ declare class SubscriptionService {
1027
+ private network;
1028
+ constructor(network: NetworkProvider);
1029
+ createRequest(input: CreateSubscriptionRequestInput): Promise<SubscriptionRequest>;
1030
+ getRequest(id: string): Promise<SubscriptionRequest | null>;
1031
+ listRequests(input?: ListSubscriptionRequestsInput): Promise<PaginatedList<SubscriptionRequest>>;
1032
+ updateRequest(input: UpdateSubscriptionRequestInput): Promise<SubscriptionRequest>;
1033
+ }
1034
+
770
1035
  interface OrjokClientConfig {
771
1036
  authProvider: AuthProvider;
772
1037
  networkProvider: NetworkProvider;
@@ -774,6 +1039,7 @@ interface OrjokClientConfig {
774
1039
  }
775
1040
  declare class OrjokClient {
776
1041
  readonly auth: AuthProvider;
1042
+ readonly network: NetworkProvider;
777
1043
  readonly users: UserService;
778
1044
  readonly questions: QuestionService;
779
1045
  readonly packs: PackService;
@@ -784,6 +1050,8 @@ declare class OrjokClient {
784
1050
  readonly progress: ProgressService;
785
1051
  readonly ai: AIService;
786
1052
  readonly news: NewsService;
1053
+ readonly notifications: NotificationService;
1054
+ readonly subscriptions: SubscriptionService;
787
1055
  readonly storage?: StorageProvider;
788
1056
  constructor(config: OrjokClientConfig);
789
1057
  }
@@ -803,4 +1071,85 @@ declare function isLanguageMatch(qLang?: string | null, targetLang?: string): bo
803
1071
  declare function isDifficultyMatch(qDiff?: string | null, targetDiff?: string): boolean;
804
1072
  declare function isValidMCQ(q: unknown): boolean;
805
1073
 
806
- export { type ListByRandomHashInput as $, AIService as A, type CreateCourseItemInput as B, type Chapter as C, type Difficulty as D, type CreateCourseLiveExamInput as E, type CreateCourseResponse as F, type CreateCourseVideoInput as G, type CreateCourseVideoResponse as H, type CreatePackInput as I, type CreateQuestionInput as J, type CreateQuestionResponse as K, type Language as L, CurriculumService as M, type DeleteCourseItemInput as N, OrjokClient as O, type Pack as P, type QuestionObject as Q, type EnrollStudentInput as R, type Subject as S, type Topic as T, type UserSubjectProgress as U, type EvaluateWrittenAnswerInput as V, type EvaluateWrittenAnswerResponse as W, type GetSignedFileURLInput as X, type GetSignedURLInput as Y, type LeaderboardResponse as Z, type ListByCurriculumInput as _, type Contest as a, MediaService as a0, type ModelType as a1, type NewsArticle as a2, NewsService as a3, type Option as a4, type OrjokClientConfig as a5, type PackExamResults as a6, type PackGroup as a7, type PackReport as a8, PackService as a9, type Verification as aA, type VerificationType as aB, type VoteInput as aC, type VoteType as aD, aggregateChapterMetrics as aE, aggregateSubjectMetrics as aF, aggregateTopicMetrics as aG, calculateAccuracy as aH, createOrjokClient as aI, isDifficultyMatch as aJ, isLanguageMatch as aK, isValidMCQ as aL, type PackTag as aa, type PaginatedList as ab, type PaymentStatus as ac, type PaymentTransaction as ad, ProgressService as ae, type QuestionReport as af, QuestionService as ag, type QuestionTag as ah, type QuestionTracking as ai, type QuestionTrackingStatus as aj, type QuestionVote as ak, type SendEnrollmentRequestInput as al, type SignedURLResponse as am, type SortDirection as an, type StatusIdResponse as ao, type StatusResponse as ap, type SubmitPackExamInput as aq, type Tag as ar, type Tier as as, type TrackPracticeProgressInput as at, type UpdateUserAvatarInput as au, type UploadImageResponse as av, type UploadVideoToBunnyInput as aw, type User as ax, UserService as ay, type UserTopicMetric as az, type CheckParticipationResponse as b, type Course as c, type CourseItem as d, type CourseLiveExam as e, type UserChapterProgress as f, type UserTopicProgress as g, type PracticeMetrics as h, type Level as i, type QuestionType as j, type AIUsageLog as k, type AddQuestionTagInput as l, type ContestAnswersResponse as m, type ContestOption as n, type ContestParticipant as o, type ContestQuestion as p, type ContestQuestionsResponse as q, ContestService as r, type CourseEnrolled as s, type CourseEnrollmentRequest as t, type CourseItemType as u, type CourseLiveExamParticipant as v, type CourseLiveExamQuestionsResponse as w, CourseService as x, type CreateContestInput as y, type CreateCourseInput as z };
1074
+ interface SelectOption<T = string> {
1075
+ value: T;
1076
+ label: string;
1077
+ }
1078
+ declare const levelOptions: SelectOption<Level>[];
1079
+ declare const languageOptions: SelectOption<Language>[];
1080
+ declare const difficultyOptions: SelectOption<Difficulty>[];
1081
+ interface PublicExamOption extends SelectOption<string> {
1082
+ level: Level | Level[] | string | string[];
1083
+ }
1084
+ declare const publicExamOptions: PublicExamOption[];
1085
+ /**
1086
+ * Returns public exams relevant to the given level.
1087
+ * Handles normalized level matching (e.g. "Admission" maps to "HSC+Admission").
1088
+ */
1089
+ declare function getPublicExamsByLevel(level?: string | null): PublicExamOption[];
1090
+
1091
+ /**
1092
+ * @file notification.ts
1093
+ * @description Logic for notification formatting, level up messaging, and feed management.
1094
+ */
1095
+
1096
+ interface LevelUpNotificationResult {
1097
+ type: "LEVEL_UP";
1098
+ newLevel: number;
1099
+ oldLevel: number;
1100
+ tierId: string;
1101
+ tierNameEn: string;
1102
+ tierNameBn: string;
1103
+ isTierPromotion: boolean;
1104
+ titleEn: string;
1105
+ titleBn: string;
1106
+ messageEn: string;
1107
+ messageBn: string;
1108
+ metadata: {
1109
+ newLevel: number;
1110
+ oldLevel: number;
1111
+ tierId: string;
1112
+ isTierPromotion: boolean;
1113
+ };
1114
+ }
1115
+ interface FormatLevelUpParams {
1116
+ newLevel: number;
1117
+ oldLevel?: number;
1118
+ userName?: string;
1119
+ }
1120
+ /**
1121
+ * Format level-up notifications with bilingual support and tier promotion detection.
1122
+ */
1123
+ declare function formatLevelUpNotification({ newLevel, oldLevel, userName, }: FormatLevelUpParams): LevelUpNotificationResult;
1124
+ interface NotificationTimelineItem {
1125
+ id: string;
1126
+ itemType: "ANNOUNCEMENT" | "USER_NOTIFICATION";
1127
+ title: string;
1128
+ message: string;
1129
+ senderType: string;
1130
+ senderName?: string | null;
1131
+ senderAvatar?: string | null;
1132
+ category?: string | null;
1133
+ actionUrl?: string | null;
1134
+ priority?: string | null;
1135
+ isUnread: boolean;
1136
+ createdAt: string;
1137
+ metadata?: string | null;
1138
+ rawAnnouncement?: Announcement;
1139
+ rawUserNotification?: UserNotification;
1140
+ }
1141
+ interface MergeTimelineParams {
1142
+ announcements?: Announcement[] | null;
1143
+ userNotifications?: UserNotification[] | null;
1144
+ lastReadAnnouncementAt?: string | null;
1145
+ }
1146
+ /**
1147
+ * Merges announcements and user-specific notifications into a single chronological stream.
1148
+ */
1149
+ declare function mergeNotificationTimeline({ announcements, userNotifications, lastReadAnnouncementAt, }: MergeTimelineParams): NotificationTimelineItem[];
1150
+ /**
1151
+ * Calculate total unread count for badge display.
1152
+ */
1153
+ declare function calculateUnreadCount({ announcements, userNotifications, lastReadAnnouncementAt, }: MergeTimelineParams): number;
1154
+
1155
+ export { CurriculumService as $, type Announcement as A, type CourseLiveExamQuestionsResponse as B, type Chapter as C, type Difficulty as D, CourseService as E, type CreateAnnouncementInput as F, type CreateContestInput as G, type CreateCourseInput as H, type CreateCourseItemInput as I, type CreateCourseLiveExamInput as J, type CreateCourseResponse as K, type Language as L, type CreateCourseVideoInput as M, type NotificationTimelineItem as N, OrjokClient as O, type Pack as P, type QuestionObject as Q, type CreateCourseVideoResponse as R, type Subject as S, type Topic as T, type UserSubjectProgress as U, type CreatePackGroupInput as V, type CreatePackInput as W, type CreateQuestionInput as X, type CreateQuestionResponse as Y, type CreateSubscriptionRequestInput as Z, type CreateUserNotificationInput as _, type Contest as a, type VoteInput as a$, type DeleteCourseItemInput as a0, type EnrollStudentInput as a1, type EvaluateWrittenAnswerInput as a2, type EvaluateWrittenAnswerResponse as a3, type FormatLevelUpParams as a4, type GetSignedFileURLInput as a5, type GetSignedURLInput as a6, type LeaderboardResponse as a7, type LevelUpNotificationResult as a8, type ListByCurriculumInput as a9, type QuestionTracking as aA, type QuestionTrackingStatus as aB, type QuestionVote as aC, type SelectOption as aD, type SendEnrollmentRequestInput as aE, type SignedURLResponse as aF, type SortDirection as aG, type StatusIdResponse as aH, type StatusResponse as aI, type SubmitPackExamInput as aJ, type SubscriptionRequest as aK, SubscriptionService as aL, type Tag as aM, type Tier as aN, type TrackPracticeProgressInput as aO, type UpdateSubscriptionRequestInput as aP, type UpdateUserAvatarInput as aQ, type UpdateUserNotificationInput as aR, type UpdateUserProfileInput as aS, type UploadCourseItemInput as aT, type UploadImageResponse as aU, type UploadVideoToBunnyInput as aV, type User as aW, UserService as aX, type UserTopicMetric as aY, type Verification as aZ, type VerificationType as a_, type ListByLevelInput as aa, type ListByPublicExamInput as ab, type ListByRandomHashInput as ac, type ListPackGroupsInput as ad, type ListSubscriptionRequestsInput as ae, type ListUsersInput as af, MediaService as ag, type MergeTimelineParams as ah, type ModelType as ai, type NewsArticle as aj, NewsService as ak, NotificationService as al, type Option as am, type OrjokClientConfig as an, type PackExamResults as ao, type PackGroup as ap, type PackReport as aq, PackService as ar, type PackTag as as, type PaymentMethod as at, type PaymentStatus as au, type PaymentTransaction as av, ProgressService as aw, type QuestionReport as ax, QuestionService as ay, type QuestionTag as az, type CheckParticipationResponse as b, type VoteType as b0, aggregateChapterMetrics as b1, aggregateSubjectMetrics as b2, aggregateTopicMetrics as b3, calculateAccuracy as b4, calculateUnreadCount as b5, createOrjokClient as b6, difficultyOptions as b7, formatLevelUpNotification as b8, getPublicExamsByLevel as b9, isDifficultyMatch as ba, isLanguageMatch as bb, isValidMCQ as bc, languageOptions as bd, levelOptions as be, mergeNotificationTimeline as bf, publicExamOptions as bg, type Course as c, type CourseItem as d, type CourseLiveExam as e, type UserChapterProgress as f, type UserTopicProgress as g, type PracticeMetrics as h, type PublicExamOption as i, type UserNotification as j, type QuestionType as k, type Level as l, type PaginatedList as m, AIService as n, type AIUsageLog as o, type AddQuestionTagInput as p, type ContestAnswersResponse as q, type ContestOption as r, type ContestParticipant as s, type ContestQuestion as t, type ContestQuestionsResponse as u, ContestService as v, type CourseEnrolled as w, type CourseEnrollmentRequest as x, type CourseItemType as y, type CourseLiveExamParticipant as z };
@@ -29,7 +29,7 @@ interface AuthProvider {
29
29
  userId?: string;
30
30
  }>;
31
31
  signOut(): Promise<void>;
32
- signInWithRedirect(provider: string): Promise<void>;
32
+ signInWithRedirect(provider?: string): Promise<void>;
33
33
  fetchUserAttributes(): Promise<UserAttributes>;
34
34
  updateUserAttributes(attributes: Record<string, string>): Promise<void>;
35
35
  fetchAuthSession(): Promise<AuthSession>;
@@ -40,7 +40,9 @@ interface AuthProvider {
40
40
  resetPassword(username: string): Promise<void>;
41
41
  confirmResetPassword(username: string, code: string, newPassword: string): Promise<void>;
42
42
  getCurrentUserId(): Promise<string | null>;
43
+ onAuthEvent?(listener: AuthEventListener): () => void;
43
44
  }
45
+ type AuthEventListener = (event: "signedIn" | "signedOut" | "signInWithRedirect" | "tokenRefresh" | string, data?: unknown) => void;
44
46
 
45
47
  interface GraphQLResult<T = Record<string, unknown>> {
46
48
  data: T;
@@ -69,4 +71,4 @@ interface StorageProvider {
69
71
  }>;
70
72
  }
71
73
 
72
- export type { AuthProvider as A, GraphQLResult as G, NetworkProvider as N, StorageProvider as S, UserAttributes as U, AuthSession as a, UploadOptions as b };
74
+ export type { AuthProvider as A, GraphQLResult as G, NetworkProvider as N, StorageProvider as S, UserAttributes as U, AuthSession as a, AuthEventListener as b, UploadOptions as c };
@@ -29,7 +29,7 @@ interface AuthProvider {
29
29
  userId?: string;
30
30
  }>;
31
31
  signOut(): Promise<void>;
32
- signInWithRedirect(provider: string): Promise<void>;
32
+ signInWithRedirect(provider?: string): Promise<void>;
33
33
  fetchUserAttributes(): Promise<UserAttributes>;
34
34
  updateUserAttributes(attributes: Record<string, string>): Promise<void>;
35
35
  fetchAuthSession(): Promise<AuthSession>;
@@ -40,7 +40,9 @@ interface AuthProvider {
40
40
  resetPassword(username: string): Promise<void>;
41
41
  confirmResetPassword(username: string, code: string, newPassword: string): Promise<void>;
42
42
  getCurrentUserId(): Promise<string | null>;
43
+ onAuthEvent?(listener: AuthEventListener): () => void;
43
44
  }
45
+ type AuthEventListener = (event: "signedIn" | "signedOut" | "signInWithRedirect" | "tokenRefresh" | string, data?: unknown) => void;
44
46
 
45
47
  interface GraphQLResult<T = Record<string, unknown>> {
46
48
  data: T;
@@ -69,4 +71,4 @@ interface StorageProvider {
69
71
  }>;
70
72
  }
71
73
 
72
- export type { AuthProvider as A, GraphQLResult as G, NetworkProvider as N, StorageProvider as S, UserAttributes as U, AuthSession as a, UploadOptions as b };
74
+ export type { AuthProvider as A, GraphQLResult as G, NetworkProvider as N, StorageProvider as S, UserAttributes as U, AuthSession as a, AuthEventListener as b, UploadOptions as c };
package/dist/testing.cjs CHANGED
@@ -2,6 +2,7 @@
2
2
  var MockAuthProvider = class {
3
3
  constructor() {
4
4
  this.currentUserId = "test-user-id";
5
+ this.eventListeners = [];
5
6
  }
6
7
  setCurrentUserId(userId) {
7
8
  this.currentUserId = userId;
@@ -41,38 +42,58 @@ var MockAuthProvider = class {
41
42
  async getCurrentUserId() {
42
43
  return this.currentUserId;
43
44
  }
45
+ onAuthEvent(listener) {
46
+ this.eventListeners.push(listener);
47
+ return () => {
48
+ this.eventListeners = this.eventListeners.filter((l) => l !== listener);
49
+ };
50
+ }
51
+ emitAuthEvent(event, data) {
52
+ this.eventListeners.forEach((l) => l(event, data));
53
+ }
44
54
  };
45
55
  var MockNetworkProvider = class {
46
56
  constructor() {
47
57
  this.responses = /* @__PURE__ */ new Map();
58
+ this.handlers = /* @__PURE__ */ new Map();
48
59
  this.errors = /* @__PURE__ */ new Map();
49
60
  this.calls = [];
50
61
  }
51
62
  setResponse(operationKey, data) {
52
63
  this.responses.set(operationKey, data);
53
64
  }
65
+ setHandler(operationKey, handler) {
66
+ this.handlers.set(operationKey, handler);
67
+ }
54
68
  setError(operationKey, error) {
55
69
  this.errors.set(operationKey, error);
56
70
  }
57
71
  reset() {
58
72
  this.responses.clear();
73
+ this.handlers.clear();
59
74
  this.errors.clear();
60
75
  this.calls.length = 0;
61
76
  }
62
77
  async query(query, variables) {
63
78
  this.calls.push({ type: "query", query, variables });
64
- return this.findResponse(query);
79
+ return this.findResponse(query, variables);
65
80
  }
66
81
  async mutate(mutation, variables) {
67
82
  this.calls.push({ type: "mutation", query: mutation, variables });
68
- return this.findResponse(mutation);
83
+ return this.findResponse(mutation, variables);
69
84
  }
70
- findResponse(queryString) {
85
+ findResponse(queryString, variables) {
71
86
  for (const [key, error] of this.errors.entries()) {
72
87
  if (queryString.includes(key)) {
73
88
  throw error;
74
89
  }
75
90
  }
91
+ for (const [key, handler] of this.handlers.entries()) {
92
+ if (queryString.includes(key)) {
93
+ const data = handler(variables);
94
+ return { data };
95
+ }
96
+ }
76
97
  for (const [key, value] of this.responses.entries()) {
77
98
  if (queryString.includes(key)) {
78
99
  return { data: value };