@athos-sdk/api-types 1.0.0 → 2.0.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.
package/dist/index.d.mts CHANGED
@@ -416,4 +416,427 @@ interface Activity {
416
416
  createdAt: string;
417
417
  }
418
418
 
419
- export { type Activity, type AddExpertDto, type AddMemberDto, type AddStaffDto, type AdminSummaryResponse, type AuthResponse, type AvailabilitySlotDto, type Booking, BookingStatus, type Challenge, type ChallengeOccurrence, type ChallengeOccurrenceWithDetails, type ChallengeParticipation, ChallengeVerificationType, type CheckIn, type CompleteChallengeDto, type CreateBookingDto, type CreateChallengeDto, type CreateCheckInDto, type CreateLeaderboardDto, type CreateOccurrenceDto, type CreateRewardDto, type Expert, type ExpertAvailability, type ExpertAvailabilityException, type ExpertAvailabilityResponse, ExpertRole, type ExpertWithUser, type GetMeResponse, type Gym, type JoinChallengeDto, type JoinGymDto, type Leaderboard, type LeaderboardEntry, LeaderboardEntryStatus, type LeaderboardWithEntries, type Level, type LoginDto, type Media, type Member, type MemberReward, type MemberStatsResponse, type MemberWithGym, type MemberWithUser, type Notification, type RegisterDto, type RegisterResponse, type ReviewEntryDto, type Reward, type SetAvailabilityDto, type SetAvailabilityExceptionDto, type Staff, type StaffWithUser, type SubmitEntryDto, type SuccessResponse, type UpdateBookingStatusDto, type UpdateGymDto, type UpdateMemberProfileDto, type UpdateRewardDto, type User, type UserWithRoles };
419
+ /**
420
+ * API path constants. Use with your base URL: baseUrl + ROUTES.auth.login
421
+ * Paths with :param are templates; replace :id, :userId etc. when calling.
422
+ */
423
+ declare const ROUTES: {
424
+ readonly health: "/";
425
+ readonly auth: {
426
+ readonly register: "/auth/register";
427
+ readonly login: "/auth/login";
428
+ readonly deleteMe: "/auth/me";
429
+ };
430
+ readonly members: {
431
+ readonly join: "/members/join";
432
+ readonly me: "/members/me";
433
+ readonly meStats: "/members/me/stats";
434
+ };
435
+ readonly checkIns: {
436
+ readonly create: "/check-ins";
437
+ };
438
+ readonly leaderboards: {
439
+ readonly list: "/leaderboards";
440
+ readonly create: "/leaderboards";
441
+ readonly submitEntry: "/leaderboards/entries";
442
+ readonly reviewEntry: "/leaderboards/entries/review";
443
+ };
444
+ readonly challenges: {
445
+ readonly create: "/challenges";
446
+ readonly createOccurrence: "/challenges/occurrences";
447
+ readonly meActive: "/challenges/me/active";
448
+ readonly join: "/challenges/join";
449
+ readonly complete: "/challenges/complete";
450
+ };
451
+ readonly bookings: {
452
+ readonly create: "/bookings";
453
+ readonly updateStatus: "/bookings/status";
454
+ readonly meMember: "/bookings/me/member";
455
+ readonly meExpert: "/bookings/me/expert";
456
+ };
457
+ readonly rewards: {
458
+ readonly list: "/rewards";
459
+ readonly me: "/rewards/me";
460
+ };
461
+ readonly experts: {
462
+ readonly list: "/experts";
463
+ readonly me: "/experts/me";
464
+ readonly availability: (id: string) => string;
465
+ readonly meAvailability: "/experts/me/availability";
466
+ readonly meAvailabilityExceptions: "/experts/me/availability-exceptions";
467
+ };
468
+ readonly notifications: {
469
+ readonly me: "/notifications/me";
470
+ readonly meReadAll: "/notifications/me/read-all";
471
+ };
472
+ readonly activities: {
473
+ readonly me: "/activities/me";
474
+ };
475
+ readonly media: {
476
+ readonly upload: "/media";
477
+ readonly delete: (id: string) => string;
478
+ };
479
+ readonly admin: {
480
+ readonly summary: "/admin/summary";
481
+ readonly gym: "/admin/gym";
482
+ readonly members: "/admin/members";
483
+ readonly createMember: "/admin/members";
484
+ readonly rewards: "/admin/rewards";
485
+ readonly createReward: "/admin/rewards";
486
+ readonly rewardById: (id: string) => string;
487
+ readonly staff: "/admin/staff";
488
+ readonly createStaff: "/admin/staff";
489
+ readonly staffByUserId: (userId: string) => string;
490
+ readonly staffDisable: (userId: string) => string;
491
+ readonly staffEnable: (userId: string) => string;
492
+ readonly experts: "/admin/experts";
493
+ readonly createExpert: "/admin/experts";
494
+ readonly expertByUserId: (userId: string) => string;
495
+ readonly expertDisable: (userId: string) => string;
496
+ readonly expertEnable: (userId: string) => string;
497
+ };
498
+ };
499
+ type Routes = typeof ROUTES;
500
+
501
+ /**
502
+ * Typed API routes: path + method + request/response types in one place.
503
+ * Use with a generic fetch helper to get full type safety.
504
+ *
505
+ * @example
506
+ * // In your frontend API client:
507
+ * import { apiRoutes, type RequestBody, type ResponseBody } from '@athos-sdk/api-types';
508
+ *
509
+ * const data = await fetchJson(apiRoutes.auth.login, { email, password });
510
+ * // data is typed as AuthResponse
511
+ *
512
+ * type LoginBody = RequestBody<typeof apiRoutes.auth.login>;
513
+ * type LoginResponse = ResponseBody<typeof apiRoutes.auth.login>;
514
+ */
515
+
516
+ /** HTTP method for a route */
517
+ type HttpMethod = 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE';
518
+ /**
519
+ * Typed route definition. Request body is void for GET/DELETE with no body.
520
+ * Use RequestBody<R> and ResponseBody<R> to infer types from a route constant.
521
+ */
522
+ interface RouteDef<M extends HttpMethod, Req = void, Res = unknown> {
523
+ method: M;
524
+ path: string;
525
+ /** @internal Used for type inference only */
526
+ _req?: Req;
527
+ /** @internal Used for type inference only */
528
+ _res?: Res;
529
+ }
530
+ /** Extract request body type from a RouteDef (void if no body). */
531
+ type RequestBody<R> = R extends RouteDef<HttpMethod, infer Req, unknown> ? Req : never;
532
+ /** Extract response type from a RouteDef. */
533
+ type ResponseBody<R> = R extends RouteDef<HttpMethod, unknown, infer Res> ? Res : never;
534
+ /** Extract HTTP method from a RouteDef. */
535
+ type RouteMethod<R> = R extends RouteDef<infer M, unknown, unknown> ? M : never;
536
+ /** Extract path string from a RouteDef. */
537
+ type RoutePath<R> = R extends RouteDef<HttpMethod, unknown, unknown> ? R['path'] : never;
538
+ declare const apiRoutes: {
539
+ readonly auth: {
540
+ readonly register: {
541
+ method: "POST";
542
+ path: string;
543
+ _req: RegisterDto;
544
+ _res: RegisterResponse;
545
+ };
546
+ readonly login: {
547
+ method: "POST";
548
+ path: string;
549
+ _req: LoginDto;
550
+ _res: AuthResponse;
551
+ };
552
+ readonly deleteMe: {
553
+ method: "DELETE";
554
+ path: string;
555
+ };
556
+ };
557
+ readonly members: {
558
+ readonly join: {
559
+ method: "POST";
560
+ path: string;
561
+ _req: JoinGymDto;
562
+ _res: MemberWithGym;
563
+ };
564
+ readonly me: {
565
+ method: "GET";
566
+ path: string;
567
+ };
568
+ readonly updateMe: {
569
+ method: "PATCH";
570
+ path: string;
571
+ _req: UpdateMemberProfileDto;
572
+ _res: GetMeResponse;
573
+ };
574
+ readonly meStats: {
575
+ method: "GET";
576
+ path: string;
577
+ };
578
+ };
579
+ readonly checkIns: {
580
+ readonly create: {
581
+ method: "POST";
582
+ path: string;
583
+ _req: CreateCheckInDto;
584
+ _res: CheckIn;
585
+ };
586
+ };
587
+ readonly leaderboards: {
588
+ readonly list: {
589
+ method: "GET";
590
+ path: string;
591
+ };
592
+ readonly create: {
593
+ method: "POST";
594
+ path: string;
595
+ _req: CreateLeaderboardDto;
596
+ _res: Leaderboard;
597
+ };
598
+ readonly submitEntry: {
599
+ method: "POST";
600
+ path: string;
601
+ _req: SubmitEntryDto;
602
+ _res: unknown;
603
+ };
604
+ readonly reviewEntry: {
605
+ method: "POST";
606
+ path: string;
607
+ _req: ReviewEntryDto;
608
+ _res: SuccessResponse;
609
+ };
610
+ };
611
+ readonly challenges: {
612
+ readonly create: {
613
+ method: "POST";
614
+ path: string;
615
+ _req: CreateChallengeDto;
616
+ _res: Challenge;
617
+ };
618
+ readonly createOccurrence: {
619
+ method: "POST";
620
+ path: string;
621
+ _req: CreateOccurrenceDto;
622
+ _res: ChallengeOccurrence;
623
+ };
624
+ readonly meActive: {
625
+ method: "GET";
626
+ path: string;
627
+ };
628
+ readonly join: {
629
+ method: "POST";
630
+ path: string;
631
+ _req: JoinChallengeDto;
632
+ _res: unknown;
633
+ };
634
+ readonly complete: {
635
+ method: "POST";
636
+ path: string;
637
+ _req: CompleteChallengeDto;
638
+ _res: unknown;
639
+ };
640
+ };
641
+ readonly bookings: {
642
+ readonly create: {
643
+ method: "POST";
644
+ path: string;
645
+ _req: CreateBookingDto;
646
+ _res: Booking;
647
+ };
648
+ readonly updateStatus: {
649
+ method: "POST";
650
+ path: string;
651
+ _req: UpdateBookingStatusDto;
652
+ _res: Booking;
653
+ };
654
+ readonly meMember: {
655
+ method: "GET";
656
+ path: string;
657
+ };
658
+ readonly meExpert: {
659
+ method: "GET";
660
+ path: string;
661
+ };
662
+ };
663
+ readonly rewards: {
664
+ readonly list: {
665
+ method: "GET";
666
+ path: string;
667
+ };
668
+ readonly me: {
669
+ method: "GET";
670
+ path: string;
671
+ };
672
+ };
673
+ readonly experts: {
674
+ readonly list: {
675
+ method: "GET";
676
+ path: string;
677
+ };
678
+ readonly me: {
679
+ method: "GET";
680
+ path: string;
681
+ };
682
+ readonly availability: (id: string) => RouteDef<"GET", void, ExpertAvailabilityResponse>;
683
+ readonly meAvailability: {
684
+ method: "POST";
685
+ path: string;
686
+ _req: SetAvailabilityDto;
687
+ _res: ExpertAvailability[];
688
+ };
689
+ readonly meAvailabilityExceptions: {
690
+ method: "POST";
691
+ path: string;
692
+ _req: SetAvailabilityExceptionDto;
693
+ _res: unknown;
694
+ };
695
+ };
696
+ readonly notifications: {
697
+ readonly me: {
698
+ method: "GET";
699
+ path: string;
700
+ };
701
+ readonly meReadAll: {
702
+ method: "POST";
703
+ path: string;
704
+ };
705
+ };
706
+ readonly activities: {
707
+ readonly me: {
708
+ method: "GET";
709
+ path: string;
710
+ };
711
+ };
712
+ readonly media: {
713
+ readonly upload: {
714
+ method: "POST";
715
+ path: string;
716
+ _res: Media;
717
+ };
718
+ readonly delete: (id: string) => RouteDef<"DELETE", void, SuccessResponse>;
719
+ };
720
+ readonly admin: {
721
+ readonly summary: {
722
+ method: "GET";
723
+ path: string;
724
+ };
725
+ readonly gym: {
726
+ method: "GET";
727
+ path: string;
728
+ };
729
+ readonly updateGym: {
730
+ method: "PATCH";
731
+ path: string;
732
+ _req: UpdateGymDto;
733
+ _res: Gym;
734
+ };
735
+ readonly members: {
736
+ method: "GET";
737
+ path: string;
738
+ };
739
+ readonly createMember: {
740
+ method: "POST";
741
+ path: string;
742
+ _req: AddMemberDto;
743
+ _res: MemberWithUser;
744
+ };
745
+ readonly rewards: {
746
+ method: "GET";
747
+ path: string;
748
+ };
749
+ readonly createReward: {
750
+ method: "POST";
751
+ path: string;
752
+ _req: CreateRewardDto;
753
+ _res: Reward;
754
+ };
755
+ readonly updateReward: (id: string) => RouteDef<"PATCH", UpdateRewardDto, Reward>;
756
+ readonly deleteReward: (id: string) => RouteDef<"DELETE", void, SuccessResponse>;
757
+ readonly staff: {
758
+ method: "GET";
759
+ path: string;
760
+ };
761
+ readonly createStaff: {
762
+ method: "POST";
763
+ path: string;
764
+ _req: AddStaffDto;
765
+ _res: StaffWithUser;
766
+ };
767
+ readonly deleteStaff: (userId: string) => RouteDef<"DELETE", void, SuccessResponse>;
768
+ readonly disableStaff: (userId: string) => RouteDef<"PATCH", void, SuccessResponse>;
769
+ readonly enableStaff: (userId: string) => RouteDef<"PATCH", void, SuccessResponse>;
770
+ readonly experts: {
771
+ method: "GET";
772
+ path: string;
773
+ };
774
+ readonly createExpert: {
775
+ method: "POST";
776
+ path: string;
777
+ _req: AddExpertDto;
778
+ _res: ExpertWithUser;
779
+ };
780
+ readonly deleteExpert: (userId: string) => RouteDef<"DELETE", void, SuccessResponse>;
781
+ readonly disableExpert: (userId: string) => RouteDef<"PATCH", void, SuccessResponse>;
782
+ readonly enableExpert: (userId: string) => RouteDef<"PATCH", void, SuccessResponse>;
783
+ };
784
+ };
785
+
786
+ /**
787
+ * Axios-compatible API client. Use with your axios instance for typed requests.
788
+ * No axios dependency: pass any client that matches AthosHttpClient.
789
+ */
790
+
791
+ /**
792
+ * Minimal axios-like interface so you can pass an axios instance without adding axios as a dependency.
793
+ * Axios instances satisfy this (request returns { data }).
794
+ */
795
+ interface AthosHttpClient {
796
+ request<T = unknown>(config: {
797
+ method: string;
798
+ url: string;
799
+ data?: unknown;
800
+ params?: Record<string, string>;
801
+ headers?: Record<string, string>;
802
+ }): Promise<{
803
+ data: T;
804
+ }>;
805
+ }
806
+ /**
807
+ * Perform a typed request. Route carries the path, method, and (via types) request/response types.
808
+ *
809
+ * @example
810
+ * const api = createApi(axios.create({ baseURL: 'https://api.example.com' }));
811
+ * const auth = await api.request(apiRoutes.auth.login, { email: 'a@b.com', password: 'x' });
812
+ * // auth is AuthResponse
813
+ */
814
+ declare function request<R extends RouteDef<HttpMethod, unknown, unknown>>(client: AthosHttpClient, baseUrl: string, route: R, body?: RequestBody<R>): Promise<ResponseBody<R>>;
815
+ /**
816
+ * Create an API helper that uses your axios (or compatible) instance.
817
+ * Use .request(route, body?) for full type inference: route gives you the path, and TypeScript
818
+ * enforces the body type and infers the response type.
819
+ *
820
+ * @example
821
+ * import axios from 'axios';
822
+ * import { createApi, apiRoutes } from '@athos-sdk/api-types';
823
+ *
824
+ * const api = createApi(axios.create({ baseURL: 'https://api.example.com' }));
825
+ *
826
+ * // POST with body – body and response are typed from the route
827
+ * const auth = await api.request(apiRoutes.auth.login, { email: 'u@x.com', password: 'p' });
828
+ *
829
+ * // GET – no body
830
+ * const me = await api.request(apiRoutes.members.me);
831
+ *
832
+ * // Dynamic path
833
+ * const availability = await api.request(apiRoutes.experts.availability(expertId));
834
+ */
835
+ declare function createApi(client: AthosHttpClient, baseUrl?: string): {
836
+ /**
837
+ * Execute a typed request. The route defines method + path; body and response types are inferred.
838
+ */
839
+ request<R extends RouteDef<HttpMethod, unknown, unknown>>(route: R, body?: RequestBody<R>): Promise<ResponseBody<R>>;
840
+ };
841
+
842
+ export { type Activity, type AddExpertDto, type AddMemberDto, type AddStaffDto, type AdminSummaryResponse, type AthosHttpClient, type AuthResponse, type AvailabilitySlotDto, type Booking, BookingStatus, type Challenge, type ChallengeOccurrence, type ChallengeOccurrenceWithDetails, type ChallengeParticipation, ChallengeVerificationType, type CheckIn, type CompleteChallengeDto, type CreateBookingDto, type CreateChallengeDto, type CreateCheckInDto, type CreateLeaderboardDto, type CreateOccurrenceDto, type CreateRewardDto, type Expert, type ExpertAvailability, type ExpertAvailabilityException, type ExpertAvailabilityResponse, ExpertRole, type ExpertWithUser, type GetMeResponse, type Gym, type HttpMethod, type JoinChallengeDto, type JoinGymDto, type Leaderboard, type LeaderboardEntry, LeaderboardEntryStatus, type LeaderboardWithEntries, type Level, type LoginDto, type Media, type Member, type MemberReward, type MemberStatsResponse, type MemberWithGym, type MemberWithUser, type Notification, ROUTES, type RegisterDto, type RegisterResponse, type RequestBody, type ResponseBody, type ReviewEntryDto, type Reward, type RouteDef, type RouteMethod, type RoutePath, type Routes, type SetAvailabilityDto, type SetAvailabilityExceptionDto, type Staff, type StaffWithUser, type SubmitEntryDto, type SuccessResponse, type UpdateBookingStatusDto, type UpdateGymDto, type UpdateMemberProfileDto, type UpdateRewardDto, type User, type UserWithRoles, apiRoutes, createApi, request };