@orjok/commons 1.0.2 → 1.1.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.
@@ -162,8 +162,8 @@ interface UpdateUserAvatarInput {
162
162
  type Tier = "FREE" | "PREMIUM";
163
163
  type QuestionType = "MCQ" | "WRITTEN";
164
164
  type Difficulty = "Easy" | "Medium" | "Hard";
165
- type Level = "SSC" | "HSC" | "ENGINEERING" | "MEDICAL" | "VARSITY" | "BCS";
166
- type Language = "Bangla" | "English";
165
+ type Level = "One" | "Two" | "Three" | "Four" | "Five" | "Six" | "Seven" | "Eight" | "SSC" | "HSC" | "Admission" | "HSC+Admission" | "BCS";
166
+ type Language = "Bangla" | "English" | "Any";
167
167
  type VoteType = "upvote" | "downvote";
168
168
  type ModelType = "question" | "pack";
169
169
  type VerificationType = "question" | "pack";
@@ -535,8 +535,8 @@ declare class UserService {
535
535
  constructor(network: NetworkProvider);
536
536
  get(id: string): Promise<User | null>;
537
537
  updateAvatar(input: UpdateUserAvatarInput): Promise<User | null>;
538
- getQuestions(userId: string, nextToken?: string): Promise<PaginatedList<QuestionObject>>;
539
- getPacks(userId: string, nextToken?: string): Promise<PaginatedList<Pack>>;
538
+ getQuestions(userId: string, nextToken?: string, limit?: number): Promise<PaginatedList<QuestionObject>>;
539
+ getPacks(userId: string, nextToken?: string, limit?: number): Promise<PaginatedList<Pack>>;
540
540
  getCourses(userId: string): Promise<Course[]>;
541
541
  getEnrolledCourses(userId: string): Promise<CourseEnrolled[]>;
542
542
  }
@@ -607,7 +607,23 @@ declare class QuestionService {
607
607
  getFull(id: string): Promise<QuestionObject | null>;
608
608
  getAnswer(id: string): Promise<Option | null>;
609
609
  getQuestionId(packId: string, order: number): Promise<string | null>;
610
+ listByPack(packId: string, limit?: number, sortDirection?: "ASC" | "DESC", nextToken?: string | null): Promise<PaginatedList<QuestionObject>>;
610
611
  update(id: string, fields: Record<string, unknown>): Promise<QuestionObject | null>;
612
+ updateOption(id: string, content: string): Promise<{
613
+ id: string;
614
+ content: string;
615
+ } | null>;
616
+ createOption(input: {
617
+ id?: string;
618
+ content: string;
619
+ questionId: string;
620
+ }): Promise<{
621
+ id: string;
622
+ content: string;
623
+ } | null>;
624
+ deleteOption(id: string): Promise<{
625
+ id: string;
626
+ } | null>;
611
627
  delete(id: string): Promise<QuestionObject | null>;
612
628
  vote(input: VoteInput): Promise<StatusIdResponse>;
613
629
  upVote(questionId: string): Promise<StatusIdResponse>;
@@ -768,8 +784,23 @@ declare class OrjokClient {
768
784
  readonly progress: ProgressService;
769
785
  readonly ai: AIService;
770
786
  readonly news: NewsService;
787
+ readonly storage?: StorageProvider;
771
788
  constructor(config: OrjokClientConfig);
772
789
  }
773
790
  declare function createOrjokClient(config: OrjokClientConfig): OrjokClient;
774
791
 
775
- export { NewsService as $, AIService as A, type CreateCourseResponse as B, type Chapter as C, type Difficulty as D, type CreateCourseVideoInput as E, type CreateCourseVideoResponse as F, type CreatePackInput as G, type CreateQuestionInput as H, type CreateQuestionResponse as I, CurriculumService as J, type DeleteCourseItemInput as K, type EnrollStudentInput as L, type EvaluateWrittenAnswerInput as M, type EvaluateWrittenAnswerResponse as N, OrjokClient as O, type GetSignedFileURLInput as P, type QuestionType as Q, type GetSignedURLInput as R, type Language as S, type LeaderboardResponse as T, type UserChapterProgress as U, type Level as V, type ListByCurriculumInput as W, type ListByRandomHashInput as X, MediaService as Y, type ModelType as Z, type NewsArticle as _, type QuestionObject as a, type Option as a0, type OrjokClientConfig as a1, type Pack as a2, type PackExamResults as a3, type PackGroup as a4, type PackReport as a5, PackService as a6, type PackTag as a7, type PaginatedList as a8, type PaymentStatus as a9, type VerificationType as aA, type VoteInput as aB, type VoteType as aC, createOrjokClient as aD, type PaymentTransaction as aa, ProgressService as ab, type QuestionReport as ac, QuestionService as ad, type QuestionTag as ae, type QuestionTracking as af, type QuestionTrackingStatus as ag, type QuestionVote as ah, type SendEnrollmentRequestInput as ai, type SignedURLResponse as aj, type SortDirection as ak, type StatusIdResponse as al, type StatusResponse as am, type Subject as an, type SubmitPackExamInput as ao, type Tag as ap, type Tier as aq, type Topic as ar, type TrackPracticeProgressInput as as, type UpdateUserAvatarInput 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 UserSubjectProgress as b, type UserTopicProgress as c, type AIUsageLog as d, type AddQuestionTagInput as e, type CheckParticipationResponse as f, type Contest as g, type ContestAnswersResponse as h, type ContestOption as i, type ContestParticipant as j, type ContestQuestion as k, type ContestQuestionsResponse as l, ContestService as m, type Course as n, type CourseEnrolled as o, type CourseEnrollmentRequest as p, type CourseItem as q, type CourseItemType as r, type CourseLiveExam as s, type CourseLiveExamParticipant as t, type CourseLiveExamQuestionsResponse as u, CourseService as v, type CreateContestInput as w, type CreateCourseInput as x, type CreateCourseItemInput as y, type CreateCourseLiveExamInput as z };
792
+ interface PracticeMetrics {
793
+ totalPracticed: number;
794
+ totalMistakes: number;
795
+ totalCorrected: number;
796
+ accuracy: number;
797
+ }
798
+ declare function aggregateSubjectMetrics(progress: UserSubjectProgress[]): PracticeMetrics;
799
+ declare function aggregateChapterMetrics(progress: UserChapterProgress[]): PracticeMetrics;
800
+ declare function aggregateTopicMetrics(progress: UserTopicProgress[]): PracticeMetrics;
801
+ declare function calculateAccuracy(practiced: number, mistakes: number): number;
802
+ declare function isLanguageMatch(qLang?: string | null, targetLang?: string): boolean;
803
+ declare function isDifficultyMatch(qDiff?: string | null, targetDiff?: string): boolean;
804
+ declare function isValidMCQ(q: unknown): boolean;
805
+
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 };
@@ -162,8 +162,8 @@ interface UpdateUserAvatarInput {
162
162
  type Tier = "FREE" | "PREMIUM";
163
163
  type QuestionType = "MCQ" | "WRITTEN";
164
164
  type Difficulty = "Easy" | "Medium" | "Hard";
165
- type Level = "SSC" | "HSC" | "ENGINEERING" | "MEDICAL" | "VARSITY" | "BCS";
166
- type Language = "Bangla" | "English";
165
+ type Level = "One" | "Two" | "Three" | "Four" | "Five" | "Six" | "Seven" | "Eight" | "SSC" | "HSC" | "Admission" | "HSC+Admission" | "BCS";
166
+ type Language = "Bangla" | "English" | "Any";
167
167
  type VoteType = "upvote" | "downvote";
168
168
  type ModelType = "question" | "pack";
169
169
  type VerificationType = "question" | "pack";
@@ -535,8 +535,8 @@ declare class UserService {
535
535
  constructor(network: NetworkProvider);
536
536
  get(id: string): Promise<User | null>;
537
537
  updateAvatar(input: UpdateUserAvatarInput): Promise<User | null>;
538
- getQuestions(userId: string, nextToken?: string): Promise<PaginatedList<QuestionObject>>;
539
- getPacks(userId: string, nextToken?: string): Promise<PaginatedList<Pack>>;
538
+ getQuestions(userId: string, nextToken?: string, limit?: number): Promise<PaginatedList<QuestionObject>>;
539
+ getPacks(userId: string, nextToken?: string, limit?: number): Promise<PaginatedList<Pack>>;
540
540
  getCourses(userId: string): Promise<Course[]>;
541
541
  getEnrolledCourses(userId: string): Promise<CourseEnrolled[]>;
542
542
  }
@@ -607,7 +607,23 @@ declare class QuestionService {
607
607
  getFull(id: string): Promise<QuestionObject | null>;
608
608
  getAnswer(id: string): Promise<Option | null>;
609
609
  getQuestionId(packId: string, order: number): Promise<string | null>;
610
+ listByPack(packId: string, limit?: number, sortDirection?: "ASC" | "DESC", nextToken?: string | null): Promise<PaginatedList<QuestionObject>>;
610
611
  update(id: string, fields: Record<string, unknown>): Promise<QuestionObject | null>;
612
+ updateOption(id: string, content: string): Promise<{
613
+ id: string;
614
+ content: string;
615
+ } | null>;
616
+ createOption(input: {
617
+ id?: string;
618
+ content: string;
619
+ questionId: string;
620
+ }): Promise<{
621
+ id: string;
622
+ content: string;
623
+ } | null>;
624
+ deleteOption(id: string): Promise<{
625
+ id: string;
626
+ } | null>;
611
627
  delete(id: string): Promise<QuestionObject | null>;
612
628
  vote(input: VoteInput): Promise<StatusIdResponse>;
613
629
  upVote(questionId: string): Promise<StatusIdResponse>;
@@ -768,8 +784,23 @@ declare class OrjokClient {
768
784
  readonly progress: ProgressService;
769
785
  readonly ai: AIService;
770
786
  readonly news: NewsService;
787
+ readonly storage?: StorageProvider;
771
788
  constructor(config: OrjokClientConfig);
772
789
  }
773
790
  declare function createOrjokClient(config: OrjokClientConfig): OrjokClient;
774
791
 
775
- export { NewsService as $, AIService as A, type CreateCourseResponse as B, type Chapter as C, type Difficulty as D, type CreateCourseVideoInput as E, type CreateCourseVideoResponse as F, type CreatePackInput as G, type CreateQuestionInput as H, type CreateQuestionResponse as I, CurriculumService as J, type DeleteCourseItemInput as K, type EnrollStudentInput as L, type EvaluateWrittenAnswerInput as M, type EvaluateWrittenAnswerResponse as N, OrjokClient as O, type GetSignedFileURLInput as P, type QuestionType as Q, type GetSignedURLInput as R, type Language as S, type LeaderboardResponse as T, type UserChapterProgress as U, type Level as V, type ListByCurriculumInput as W, type ListByRandomHashInput as X, MediaService as Y, type ModelType as Z, type NewsArticle as _, type QuestionObject as a, type Option as a0, type OrjokClientConfig as a1, type Pack as a2, type PackExamResults as a3, type PackGroup as a4, type PackReport as a5, PackService as a6, type PackTag as a7, type PaginatedList as a8, type PaymentStatus as a9, type VerificationType as aA, type VoteInput as aB, type VoteType as aC, createOrjokClient as aD, type PaymentTransaction as aa, ProgressService as ab, type QuestionReport as ac, QuestionService as ad, type QuestionTag as ae, type QuestionTracking as af, type QuestionTrackingStatus as ag, type QuestionVote as ah, type SendEnrollmentRequestInput as ai, type SignedURLResponse as aj, type SortDirection as ak, type StatusIdResponse as al, type StatusResponse as am, type Subject as an, type SubmitPackExamInput as ao, type Tag as ap, type Tier as aq, type Topic as ar, type TrackPracticeProgressInput as as, type UpdateUserAvatarInput 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 UserSubjectProgress as b, type UserTopicProgress as c, type AIUsageLog as d, type AddQuestionTagInput as e, type CheckParticipationResponse as f, type Contest as g, type ContestAnswersResponse as h, type ContestOption as i, type ContestParticipant as j, type ContestQuestion as k, type ContestQuestionsResponse as l, ContestService as m, type Course as n, type CourseEnrolled as o, type CourseEnrollmentRequest as p, type CourseItem as q, type CourseItemType as r, type CourseLiveExam as s, type CourseLiveExamParticipant as t, type CourseLiveExamQuestionsResponse as u, CourseService as v, type CreateContestInput as w, type CreateCourseInput as x, type CreateCourseItemInput as y, type CreateCourseLiveExamInput as z };
792
+ interface PracticeMetrics {
793
+ totalPracticed: number;
794
+ totalMistakes: number;
795
+ totalCorrected: number;
796
+ accuracy: number;
797
+ }
798
+ declare function aggregateSubjectMetrics(progress: UserSubjectProgress[]): PracticeMetrics;
799
+ declare function aggregateChapterMetrics(progress: UserChapterProgress[]): PracticeMetrics;
800
+ declare function aggregateTopicMetrics(progress: UserTopicProgress[]): PracticeMetrics;
801
+ declare function calculateAccuracy(practiced: number, mistakes: number): number;
802
+ declare function isLanguageMatch(qLang?: string | null, targetLang?: string): boolean;
803
+ declare function isDifficultyMatch(qDiff?: string | null, targetDiff?: string): boolean;
804
+ declare function isValidMCQ(q: unknown): boolean;
805
+
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 };
package/dist/testing.cjs CHANGED
@@ -45,13 +45,18 @@ var MockAuthProvider = class {
45
45
  var MockNetworkProvider = class {
46
46
  constructor() {
47
47
  this.responses = /* @__PURE__ */ new Map();
48
+ this.errors = /* @__PURE__ */ new Map();
48
49
  this.calls = [];
49
50
  }
50
51
  setResponse(operationKey, data) {
51
52
  this.responses.set(operationKey, data);
52
53
  }
54
+ setError(operationKey, error) {
55
+ this.errors.set(operationKey, error);
56
+ }
53
57
  reset() {
54
58
  this.responses.clear();
59
+ this.errors.clear();
55
60
  this.calls.length = 0;
56
61
  }
57
62
  async query(query, variables) {
@@ -63,6 +68,11 @@ var MockNetworkProvider = class {
63
68
  return this.findResponse(mutation);
64
69
  }
65
70
  findResponse(queryString) {
71
+ for (const [key, error] of this.errors.entries()) {
72
+ if (queryString.includes(key)) {
73
+ throw error;
74
+ }
75
+ }
66
76
  for (const [key, value] of this.responses.entries()) {
67
77
  if (queryString.includes(key)) {
68
78
  return { data: value };
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/orjok/orjok/packages/commons/dist/testing.cjs","../src/testing/mock-providers.ts"],"names":[],"mappings":"AAAA;ACIO,IAAM,iBAAA,EAAN,MAA+C;AAAA,EAA/C,WAAA,CAAA,EAAA;AACL,IAAA,IAAA,CAAQ,cAAA,EAA+B,cAAA;AAAA,EAAA;AAAA,EAEvC,gBAAA,CAAiB,MAAA,EAA6B;AAC5C,IAAA,IAAA,CAAK,cAAA,EAAgB,MAAA;AAAA,EACvB;AAAA,EAEA,MAAM,MAAA,CAAO,SAAA,EAAmB,SAAA,EAAmB;AACjD,IAAA,OAAO,EAAE,UAAA,EAAY,KAAK,CAAA;AAAA,EAC5B;AAAA,EAEA,MAAM,MAAA,CAAO,SAAA,EAAmB,SAAA,EAAmB,WAAA,EAAqC;AACtF,IAAA,OAAO,EAAE,gBAAA,EAAkB,IAAA,EAAM,MAAA,mBAAQ,IAAA,CAAK,aAAA,UAAiB,KAAA,IAAU,CAAA;AAAA,EAC3E;AAAA,EAEA,MAAM,OAAA,CAAA,EAAU;AAAA,EAAC;AAAA,EAEjB,MAAM,kBAAA,CAAmB,SAAA,EAAmB;AAAA,EAAC;AAAA,EAE7C,MAAM,mBAAA,CAAA,EAA+C;AACnD,IAAA,OAAO,EAAE,KAAA,EAAO,eAAA,EAAiB,GAAA,mBAAK,IAAA,CA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AAE,CAAC,CAAA;AACtD,IAAA,OAAO,EAAE,GAAA,EAAK,CAAA,0BAAA,EAA6B,IAAI,CAAA,EAAA;AACjD,EAAA;AAM6B,EAAA;AACoB,IAAA;AACtB,IAAA;AACuB,MAAA;AAChD,IAAA;AACc,IAAA;AAChB,EAAA;AACF;ADhBoD;AACA;AACA;AACA;AACA","file":"/home/runner/work/orjok/orjok/packages/commons/dist/testing.cjs","sourcesContent":[null,"import type { AuthProvider, UserAttributes, AuthSession } from \"../providers/auth\";\nimport type { NetworkProvider, GraphQLResult } from \"../providers/network\";\nimport type { StorageProvider, UploadOptions } from \"../providers/storage\";\n\nexport class MockAuthProvider implements AuthProvider {\n private currentUserId: string | null = \"test-user-id\";\n\n setCurrentUserId(userId: string | null): void {\n this.currentUserId = userId;\n }\n\n async signIn(_username: string, _password: string) {\n return { isSignedIn: true };\n }\n\n async signUp(_username: string, _password: string, _attributes: Record<string, string>) {\n return { isSignUpComplete: true, userId: this.currentUserId ?? undefined };\n }\n\n async signOut() {}\n\n async signInWithRedirect(_provider: string) {}\n\n async fetchUserAttributes(): Promise<UserAttributes> {\n return { email: \"test@test.com\", sub: this.currentUserId ?? undefined };\n }\n\n async updateUserAttributes(_attributes: Record<string, string>) {}\n\n async fetchAuthSession(): Promise<AuthSession> {\n return {\n tokens: {\n accessToken: { toString: () => \"mock-access-token\" },\n idToken: { toString: () => \"mock-id-token\" },\n },\n };\n }\n\n async confirmSignUp(_username: string, _code: string) {\n return { isSignUpComplete: true };\n }\n\n async resendSignUpCode(_username: string) {}\n\n async resetPassword(_username: string) {}\n\n async confirmResetPassword(_username: string, _code: string, _newPassword: string) {}\n\n async getCurrentUserId(): Promise<string | null> {\n return this.currentUserId;\n }\n}\n\nexport class MockNetworkProvider implements NetworkProvider {\n private responses = new Map<string, unknown>();\n readonly calls: Array<{ type: \"query\" | \"mutation\"; query: string; variables?: Record<string, unknown> }> = [];\n\n setResponse<T>(operationKey: string, data: T): void {\n this.responses.set(operationKey, data);\n }\n\n reset(): void {\n this.responses.clear();\n this.calls.length = 0;\n }\n\n async query<T>(query: string, variables?: Record<string, unknown>): Promise<GraphQLResult<T>> {\n this.calls.push({ type: \"query\", query, variables });\n return this.findResponse<T>(query);\n }\n\n async mutate<T>(mutation: string, variables?: Record<string, unknown>): Promise<GraphQLResult<T>> {\n this.calls.push({ type: \"mutation\", query: mutation, variables });\n return this.findResponse<T>(mutation);\n }\n\n private findResponse<T>(queryString: string): GraphQLResult<T> {\n for (const [key, value] of this.responses.entries()) {\n if (queryString.includes(key)) {\n return { data: value as T };\n }\n }\n throw new Error(\n `No mock response registered for query containing operation. Query starts with: \"${queryString.slice(0, 80)}...\"`\n );\n }\n}\n\nexport class MockStorageProvider implements StorageProvider {\n readonly calls: Array<{ method: string; args: unknown[] }> = [];\n\n async getFileUrl(path: string): Promise<{ url: string }> {\n this.calls.push({ method: \"getFileUrl\", args: [path] });\n return { url: `https://mock-storage.test/${path}` };\n }\n\n async uploadFile(\n path: string,\n data: Blob | ArrayBuffer | string,\n options?: UploadOptions\n ): Promise<{ path: string }> {\n this.calls.push({ method: \"uploadFile\", args: [path, data, options] });\n if (options?.onProgress) {\n options.onProgress({ loaded: 100, total: 100 });\n }\n return { path };\n }\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/orjok/orjok/packages/commons/dist/testing.cjs","../src/testing/mock-providers.ts"],"names":[],"mappings":"AAAA;ACIO,IAAM,iBAAA,EAAN,MAA+C;AAAA,EAA/C,WAAA,CAAA,EAAA;AACL,IAAA,IAAA,CAAQ,cAAA,EAA+B,cAAA;AAAA,EAAA;AAAA,EAEvC,gBAAA,CAAiB,MAAA,EAA6B;AAC5C,IAAA,IAAA,CAAK,cAAA,EAAgB,MAAA;AAAA,EACvB;AAAA,EAEA,MAAM,MAAA,CAAO,SAAA,EAAmB,SAAA,EAAmB;AACjD,IAAA,OAAO,EAAE,UAAA,EAAY,KAAK,CAAA;AAAA,EAC5B;AAAA,EAEA,MAAM,MAAA,CAAO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AAA,GAAK,IAAA,CAAK,MAAA,CAAO,OAAA,CAAQ,CAAA,EAAG;AAChD,MAAA,GAAA,CAAI,WAAA,CAAY,QAAA,CAAS,GAAG,CAAA,EAAG;AAC7B,QAAA,MAAM,KAAA;AAAA,MACR;AAAA,IACF;AACA,IAAA,IAAA,CAAA,MAAW,CAAC,GAAA,EAAK,KAAK,EAAA,GAAK,IAAA,CAAK,SAAA,CAAU,OAAA,CAAQ,CAAA,EAAG;AACnD,MAAA,GAAA,CAAI,WAAA,CAAY,QAAA,CAAS,GAAG,CAAA,EAAG;AAC7B,QAAA,OAAO,EAAE,IAAA,EAAM,MAAW,CAAA;AAAA,MAC5B;AAAA,IACF;AACA,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,gFAAA,EAAmF,WAAA,CAAY,KAAA,CAAM,CAAA,EAAG,EAAE,CAAC,CAAA,IAAA;AAAA,IAC7G,CAAA;AAAA,EACF;AACF,CAAA;AAEO,IAAM,oBAAA,EAAN,MAAqD;AAAA,EAArD,WAAA,CAAA,EAAA;AACL,IAAA,IAAA,CAAS,MAAA,EAAoD,CAAC,CAAA;AAAA,EAAA;AAAA,EAE9D,MAAM,UAAA,CAAW,IAAA,EAAwC;AACvD,IAAA,IAAA,CAAK,KAAA,CAAM,IAAA,CAAK,EAAE,MAAA,EAAQ,YAAA,EAAc,IAAA,EAAM,CAAC,IAAI,EAAE,CAAC,CAAA;AACtD,IAAA,OAAO,EAAE,GAAA,EAAK,CAAA,0BAAA,EAA6B,IAAI,CAAA,EAAA;AACjD,EAAA;AAM6B,EAAA;AACoB,IAAA;AACtB,IAAA;AACuB,MAAA;AAChD,IAAA;AACc,IAAA;AAChB,EAAA;AACF;ADjBoD;AACA;AACA;AACA;AACA","file":"/home/runner/work/orjok/orjok/packages/commons/dist/testing.cjs","sourcesContent":[null,"import type { AuthProvider, UserAttributes, AuthSession } from \"../providers/auth\";\nimport type { NetworkProvider, GraphQLResult } from \"../providers/network\";\nimport type { StorageProvider, UploadOptions } from \"../providers/storage\";\n\nexport class MockAuthProvider implements AuthProvider {\n private currentUserId: string | null = \"test-user-id\";\n\n setCurrentUserId(userId: string | null): void {\n this.currentUserId = userId;\n }\n\n async signIn(_username: string, _password: string) {\n return { isSignedIn: true };\n }\n\n async signUp(_username: string, _password: string, _attributes: Record<string, string>) {\n return { isSignUpComplete: true, userId: this.currentUserId ?? undefined };\n }\n\n async signOut() {}\n\n async signInWithRedirect(_provider: string) {}\n\n async fetchUserAttributes(): Promise<UserAttributes> {\n return { email: \"test@test.com\", sub: this.currentUserId ?? undefined };\n }\n\n async updateUserAttributes(_attributes: Record<string, string>) {}\n\n async fetchAuthSession(): Promise<AuthSession> {\n return {\n tokens: {\n accessToken: { toString: () => \"mock-access-token\" },\n idToken: { toString: () => \"mock-id-token\" },\n },\n };\n }\n\n async confirmSignUp(_username: string, _code: string) {\n return { isSignUpComplete: true };\n }\n\n async resendSignUpCode(_username: string) {}\n\n async resetPassword(_username: string) {}\n\n async confirmResetPassword(_username: string, _code: string, _newPassword: string) {}\n\n async getCurrentUserId(): Promise<string | null> {\n return this.currentUserId;\n }\n}\n\nexport class MockNetworkProvider implements NetworkProvider {\n private responses = new Map<string, unknown>();\n private errors = new Map<string, Error>();\n readonly calls: Array<{ type: \"query\" | \"mutation\"; query: string; variables?: Record<string, unknown> }> = [];\n\n setResponse<T>(operationKey: string, data: T): void {\n this.responses.set(operationKey, data);\n }\n\n setError(operationKey: string, error: Error): void {\n this.errors.set(operationKey, error);\n }\n\n reset(): void {\n this.responses.clear();\n this.errors.clear();\n this.calls.length = 0;\n }\n\n async query<T>(query: string, variables?: Record<string, unknown>): Promise<GraphQLResult<T>> {\n this.calls.push({ type: \"query\", query, variables });\n return this.findResponse<T>(query);\n }\n\n async mutate<T>(mutation: string, variables?: Record<string, unknown>): Promise<GraphQLResult<T>> {\n this.calls.push({ type: \"mutation\", query: mutation, variables });\n return this.findResponse<T>(mutation);\n }\n\n private findResponse<T>(queryString: string): GraphQLResult<T> {\n for (const [key, error] of this.errors.entries()) {\n if (queryString.includes(key)) {\n throw error;\n }\n }\n for (const [key, value] of this.responses.entries()) {\n if (queryString.includes(key)) {\n return { data: value as T };\n }\n }\n throw new Error(\n `No mock response registered for query containing operation. Query starts with: \"${queryString.slice(0, 80)}...\"`\n );\n }\n}\n\nexport class MockStorageProvider implements StorageProvider {\n readonly calls: Array<{ method: string; args: unknown[] }> = [];\n\n async getFileUrl(path: string): Promise<{ url: string }> {\n this.calls.push({ method: \"getFileUrl\", args: [path] });\n return { url: `https://mock-storage.test/${path}` };\n }\n\n async uploadFile(\n path: string,\n data: Blob | ArrayBuffer | string,\n options?: UploadOptions\n ): Promise<{ path: string }> {\n this.calls.push({ method: \"uploadFile\", args: [path, data, options] });\n if (options?.onProgress) {\n options.onProgress({ loaded: 100, total: 100 });\n }\n return { path };\n }\n}\n"]}
@@ -25,12 +25,14 @@ declare class MockAuthProvider implements AuthProvider {
25
25
  }
26
26
  declare class MockNetworkProvider implements NetworkProvider {
27
27
  private responses;
28
+ private errors;
28
29
  readonly calls: Array<{
29
30
  type: "query" | "mutation";
30
31
  query: string;
31
32
  variables?: Record<string, unknown>;
32
33
  }>;
33
34
  setResponse<T>(operationKey: string, data: T): void;
35
+ setError(operationKey: string, error: Error): void;
34
36
  reset(): void;
35
37
  query<T>(query: string, variables?: Record<string, unknown>): Promise<GraphQLResult<T>>;
36
38
  mutate<T>(mutation: string, variables?: Record<string, unknown>): Promise<GraphQLResult<T>>;
package/dist/testing.d.ts CHANGED
@@ -25,12 +25,14 @@ declare class MockAuthProvider implements AuthProvider {
25
25
  }
26
26
  declare class MockNetworkProvider implements NetworkProvider {
27
27
  private responses;
28
+ private errors;
28
29
  readonly calls: Array<{
29
30
  type: "query" | "mutation";
30
31
  query: string;
31
32
  variables?: Record<string, unknown>;
32
33
  }>;
33
34
  setResponse<T>(operationKey: string, data: T): void;
35
+ setError(operationKey: string, error: Error): void;
34
36
  reset(): void;
35
37
  query<T>(query: string, variables?: Record<string, unknown>): Promise<GraphQLResult<T>>;
36
38
  mutate<T>(mutation: string, variables?: Record<string, unknown>): Promise<GraphQLResult<T>>;
package/dist/testing.js CHANGED
@@ -45,13 +45,18 @@ var MockAuthProvider = class {
45
45
  var MockNetworkProvider = class {
46
46
  constructor() {
47
47
  this.responses = /* @__PURE__ */ new Map();
48
+ this.errors = /* @__PURE__ */ new Map();
48
49
  this.calls = [];
49
50
  }
50
51
  setResponse(operationKey, data) {
51
52
  this.responses.set(operationKey, data);
52
53
  }
54
+ setError(operationKey, error) {
55
+ this.errors.set(operationKey, error);
56
+ }
53
57
  reset() {
54
58
  this.responses.clear();
59
+ this.errors.clear();
55
60
  this.calls.length = 0;
56
61
  }
57
62
  async query(query, variables) {
@@ -63,6 +68,11 @@ var MockNetworkProvider = class {
63
68
  return this.findResponse(mutation);
64
69
  }
65
70
  findResponse(queryString) {
71
+ for (const [key, error] of this.errors.entries()) {
72
+ if (queryString.includes(key)) {
73
+ throw error;
74
+ }
75
+ }
66
76
  for (const [key, value] of this.responses.entries()) {
67
77
  if (queryString.includes(key)) {
68
78
  return { data: value };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/testing/mock-providers.ts"],"sourcesContent":["import type { AuthProvider, UserAttributes, AuthSession } from \"../providers/auth\";\nimport type { NetworkProvider, GraphQLResult } from \"../providers/network\";\nimport type { StorageProvider, UploadOptions } from \"../providers/storage\";\n\nexport class MockAuthProvider implements AuthProvider {\n private currentUserId: string | null = \"test-user-id\";\n\n setCurrentUserId(userId: string | null): void {\n this.currentUserId = userId;\n }\n\n async signIn(_username: string, _password: string) {\n return { isSignedIn: true };\n }\n\n async signUp(_username: string, _password: string, _attributes: Record<string, string>) {\n return { isSignUpComplete: true, userId: this.currentUserId ?? undefined };\n }\n\n async signOut() {}\n\n async signInWithRedirect(_provider: string) {}\n\n async fetchUserAttributes(): Promise<UserAttributes> {\n return { email: \"test@test.com\", sub: this.currentUserId ?? undefined };\n }\n\n async updateUserAttributes(_attributes: Record<string, string>) {}\n\n async fetchAuthSession(): Promise<AuthSession> {\n return {\n tokens: {\n accessToken: { toString: () => \"mock-access-token\" },\n idToken: { toString: () => \"mock-id-token\" },\n },\n };\n }\n\n async confirmSignUp(_username: string, _code: string) {\n return { isSignUpComplete: true };\n }\n\n async resendSignUpCode(_username: string) {}\n\n async resetPassword(_username: string) {}\n\n async confirmResetPassword(_username: string, _code: string, _newPassword: string) {}\n\n async getCurrentUserId(): Promise<string | null> {\n return this.currentUserId;\n }\n}\n\nexport class MockNetworkProvider implements NetworkProvider {\n private responses = new Map<string, unknown>();\n readonly calls: Array<{ type: \"query\" | \"mutation\"; query: string; variables?: Record<string, unknown> }> = [];\n\n setResponse<T>(operationKey: string, data: T): void {\n this.responses.set(operationKey, data);\n }\n\n reset(): void {\n this.responses.clear();\n this.calls.length = 0;\n }\n\n async query<T>(query: string, variables?: Record<string, unknown>): Promise<GraphQLResult<T>> {\n this.calls.push({ type: \"query\", query, variables });\n return this.findResponse<T>(query);\n }\n\n async mutate<T>(mutation: string, variables?: Record<string, unknown>): Promise<GraphQLResult<T>> {\n this.calls.push({ type: \"mutation\", query: mutation, variables });\n return this.findResponse<T>(mutation);\n }\n\n private findResponse<T>(queryString: string): GraphQLResult<T> {\n for (const [key, value] of this.responses.entries()) {\n if (queryString.includes(key)) {\n return { data: value as T };\n }\n }\n throw new Error(\n `No mock response registered for query containing operation. Query starts with: \"${queryString.slice(0, 80)}...\"`\n );\n }\n}\n\nexport class MockStorageProvider implements StorageProvider {\n readonly calls: Array<{ method: string; args: unknown[] }> = [];\n\n async getFileUrl(path: string): Promise<{ url: string }> {\n this.calls.push({ method: \"getFileUrl\", args: [path] });\n return { url: `https://mock-storage.test/${path}` };\n }\n\n async uploadFile(\n path: string,\n data: Blob | ArrayBuffer | string,\n options?: UploadOptions\n ): Promise<{ path: string }> {\n this.calls.push({ method: \"uploadFile\", args: [path, data, options] });\n if (options?.onProgress) {\n options.onProgress({ loaded: 100, total: 100 });\n }\n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A,EACvC;AAAA,EAEA,QAAc;AACZ,SAAK,UAAU,MAAM;AACrB,SAAK,MAAM,SAAS;AAAA,EACtB;AAAA,EAEA,MAAM,MAAS,OAAe,WAAgE;AAC5F,SAAK,MAAM,KAAK,EAAE,MAAM,SAAS,OAAO,UAAU,CAAC;AACnD,WAAO,KAAK,aAAgB,KAAK;AAAA,EACnC;AAAA,EAEA,MAAM,OAAU,UAAkB,WAAgE;AAChG,SAAK,MAAM,KAAK,EAAE,MAAM,YAAY,OAAO,UAAU,UAAU,CAAC;AAChE,WAAO,KAAK,aAAgB,QAAQ;AAAA,EACtC;AAAA,EAEQ,aAAgB,aAAuC;AAC7D,eAAW,CAAC,KAAK,KAAK,KAAK,KAAK,UAAU,QAAQ,GAAG;AACnD,UAAI,YAAY,SAAS,GAAG,GAAG;AAC7B,eAAO,EAAE,MAAM,MAAW;AAAA,MAC5B;AAAA,IACF;AACA,UAAM,IAAI;AAAA,MACR,mFAAmF,YAAY,MAAM,GAAG,EAAE,CAAC;AAAA,IAC7G;AAAA,EACF;AACF;AAEO,IAAM,sBAAN,MAAqD;AAAA,EAArD;AACL,SAAS,QAAoD,CAAC;AAAA;AAAA,EAE9D,MAAM,WAAW,MAAwC;AACvD,SAAK,MAAM,KAAK,EAAE,QAAQ,cAAc,MAAM,CAAC,IAAI,EAAE,CAAC;AACtD,WAAO,EAAE,KAAK,6BAA6B,IAAI,GAAG;AAAA,EACpD;AAAA,EAEA,MAAM,WACJ,MACA,MACA,SAC2B;AAC3B,SAAK,MAAM,KAAK,EAAE,QAAQ,cAAc,MAAM,CAAC,MAAM,MAAM,OAAO,EAAE,CAAC;AACrE,QAAI,SAAS,YAAY;AACvB,cAAQ,WAAW,EAAE,QAAQ,KAAK,OAAO,IAAI,CAAC;AAAA,IAChD;AACA,WAAO,EAAE,KAAK;AAAA,EAChB;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/testing/mock-providers.ts"],"sourcesContent":["import type { AuthProvider, UserAttributes, AuthSession } from \"../providers/auth\";\nimport type { NetworkProvider, GraphQLResult } from \"../providers/network\";\nimport type { StorageProvider, UploadOptions } from \"../providers/storage\";\n\nexport class MockAuthProvider implements AuthProvider {\n private currentUserId: string | null = \"test-user-id\";\n\n setCurrentUserId(userId: string | null): void {\n this.currentUserId = userId;\n }\n\n async signIn(_username: string, _password: string) {\n return { isSignedIn: true };\n }\n\n async signUp(_username: string, _password: string, _attributes: Record<string, string>) {\n return { isSignUpComplete: true, userId: this.currentUserId ?? undefined };\n }\n\n async signOut() {}\n\n async signInWithRedirect(_provider: string) {}\n\n async fetchUserAttributes(): Promise<UserAttributes> {\n return { email: \"test@test.com\", sub: this.currentUserId ?? undefined };\n }\n\n async updateUserAttributes(_attributes: Record<string, string>) {}\n\n async fetchAuthSession(): Promise<AuthSession> {\n return {\n tokens: {\n accessToken: { toString: () => \"mock-access-token\" },\n idToken: { toString: () => \"mock-id-token\" },\n },\n };\n }\n\n async confirmSignUp(_username: string, _code: string) {\n return { isSignUpComplete: true };\n }\n\n async resendSignUpCode(_username: string) {}\n\n async resetPassword(_username: string) {}\n\n async confirmResetPassword(_username: string, _code: string, _newPassword: string) {}\n\n async getCurrentUserId(): Promise<string | null> {\n return this.currentUserId;\n }\n}\n\nexport class MockNetworkProvider implements NetworkProvider {\n private responses = new Map<string, unknown>();\n private errors = new Map<string, Error>();\n readonly calls: Array<{ type: \"query\" | \"mutation\"; query: string; variables?: Record<string, unknown> }> = [];\n\n setResponse<T>(operationKey: string, data: T): void {\n this.responses.set(operationKey, data);\n }\n\n setError(operationKey: string, error: Error): void {\n this.errors.set(operationKey, error);\n }\n\n reset(): void {\n this.responses.clear();\n this.errors.clear();\n this.calls.length = 0;\n }\n\n async query<T>(query: string, variables?: Record<string, unknown>): Promise<GraphQLResult<T>> {\n this.calls.push({ type: \"query\", query, variables });\n return this.findResponse<T>(query);\n }\n\n async mutate<T>(mutation: string, variables?: Record<string, unknown>): Promise<GraphQLResult<T>> {\n this.calls.push({ type: \"mutation\", query: mutation, variables });\n return this.findResponse<T>(mutation);\n }\n\n private findResponse<T>(queryString: string): GraphQLResult<T> {\n for (const [key, error] of this.errors.entries()) {\n if (queryString.includes(key)) {\n throw error;\n }\n }\n for (const [key, value] of this.responses.entries()) {\n if (queryString.includes(key)) {\n return { data: value as T };\n }\n }\n throw new Error(\n `No mock response registered for query containing operation. Query starts with: \"${queryString.slice(0, 80)}...\"`\n );\n }\n}\n\nexport class MockStorageProvider implements StorageProvider {\n readonly calls: Array<{ method: string; args: unknown[] }> = [];\n\n async getFileUrl(path: string): Promise<{ url: string }> {\n this.calls.push({ method: \"getFileUrl\", args: [path] });\n return { url: `https://mock-storage.test/${path}` };\n }\n\n async uploadFile(\n path: string,\n data: Blob | ArrayBuffer | string,\n options?: UploadOptions\n ): Promise<{ path: string }> {\n this.calls.push({ method: \"uploadFile\", args: [path, data, options] });\n if (options?.onProgress) {\n options.onProgress({ loaded: 100, total: 100 });\n }\n return { path };\n }\n}\n"],"mappings":";AAIO,IAAM,mBAAN,MAA+C;AAAA,EAA/C;AACL,SAAQ,gBAA+B;AAAA;AAAA,EAEvC,iBAAiB,QAA6B;AAC5C,SAAK,gBAAgB;AAAA,EACvB;AAAA,EAEA,MAAM,OAAO,WAAmB,WAAmB;AACjD,WAAO,EAAE,YAAY,KAAK;AAAA,EAC5B;AAAA,EAEA,MAAM,OAAO,WAAmB,WAAmB,aAAqC;AACtF,WAAO,EAAE,kBAAkB,MAAM,QAAQ,KAAK,iBAAiB,OAAU;AAAA,EAC3E;AAAA,EAEA,MAAM,UAAU;AAAA,EAAC;AAAA,EAEjB,MAAM,mBAAmB,WAAmB;AAAA,EAAC;AAAA,EAE7C,MAAM,sBAA+C;AACnD,WAAO,EAAE,OAAO,iBAAiB,KAAK,KAAK,iBAAiB,OAAU;AAAA,EACxE;AAAA,EAEA,MAAM,qBAAqB,aAAqC;AAAA,EAAC;AAAA,EAEjE,MAAM,mBAAyC;AAC7C,WAAO;AAAA,MACL,QAAQ;AAAA,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7B,cAAM;AAAA,MACR;AAAA,IACF;AACA,eAAW,CAAC,KAAK,KAAK,KAAK,KAAK,UAAU,QAAQ,GAAG;AACnD,UAAI,YAAY,SAAS,GAAG,GAAG;AAC7B,eAAO,EAAE,MAAM,MAAW;AAAA,MAC5B;AAAA,IACF;AACA,UAAM,IAAI;AAAA,MACR,mFAAmF,YAAY,MAAM,GAAG,EAAE,CAAC;AAAA,IAC7G;AAAA,EACF;AACF;AAEO,IAAM,sBAAN,MAAqD;AAAA,EAArD;AACL,SAAS,QAAoD,CAAC;AAAA;AAAA,EAE9D,MAAM,WAAW,MAAwC;AACvD,SAAK,MAAM,KAAK,EAAE,QAAQ,cAAc,MAAM,CAAC,IAAI,EAAE,CAAC;AACtD,WAAO,EAAE,KAAK,6BAA6B,IAAI,GAAG;AAAA,EACpD;AAAA,EAEA,MAAM,WACJ,MACA,MACA,SAC2B;AAC3B,SAAK,MAAM,KAAK,EAAE,QAAQ,cAAc,MAAM,CAAC,MAAM,MAAM,OAAO,EAAE,CAAC;AACrE,QAAI,SAAS,YAAY;AACvB,cAAQ,WAAW,EAAE,QAAQ,KAAK,OAAO,IAAI,CAAC;AAAA,IAChD;AACA,WAAO,EAAE,KAAK;AAAA,EAChB;AACF;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orjok/commons",
3
- "version": "1.0.2",
3
+ "version": "1.1.0",
4
4
  "description": "Orjok platform shared business logic for React and React Native",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -62,9 +62,9 @@
62
62
  "prepublishOnly": "npm run build"
63
63
  },
64
64
  "peerDependencies": {
65
- "react": ">=17.0.0",
66
65
  "@tanstack/react-query": ">=5.0.0",
67
- "papaparse": ">=5.0.0"
66
+ "papaparse": ">=5.0.0",
67
+ "react": ">=17.0.0"
68
68
  },
69
69
  "peerDependenciesMeta": {
70
70
  "react": {
@@ -79,9 +79,11 @@
79
79
  },
80
80
  "devDependencies": {
81
81
  "@tanstack/react-query": "^5.101.0",
82
+ "@testing-library/react": "^15.0.7",
82
83
  "@types/papaparse": "^5.3.14",
83
84
  "@types/react": "^18.2.0",
84
85
  "aws-amplify": "^6.2.0",
86
+ "happy-dom": "^20.11.6",
85
87
  "papaparse": "^5.4.1",
86
88
  "tsup": "^8.0.0",
87
89
  "tsx": "^4.7.2",