@athos-sdk/api-types 1.0.0 → 2.0.1
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 +255 -1
- package/dist/index.d.ts +255 -1
- package/dist/index.js +381 -2
- package/dist/index.mjs +376 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -416,4 +416,258 @@ interface Activity {
|
|
|
416
416
|
createdAt: string;
|
|
417
417
|
}
|
|
418
418
|
|
|
419
|
-
|
|
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: RouteDef<"POST", RegisterDto, RegisterResponse>;
|
|
541
|
+
readonly login: RouteDef<"POST", LoginDto, AuthResponse>;
|
|
542
|
+
readonly deleteMe: RouteDef<"DELETE", void, SuccessResponse>;
|
|
543
|
+
};
|
|
544
|
+
readonly members: {
|
|
545
|
+
readonly join: RouteDef<"POST", JoinGymDto, MemberWithGym>;
|
|
546
|
+
readonly me: RouteDef<"GET", void, GetMeResponse>;
|
|
547
|
+
readonly updateMe: RouteDef<"PATCH", UpdateMemberProfileDto, GetMeResponse>;
|
|
548
|
+
readonly meStats: RouteDef<"GET", void, MemberStatsResponse>;
|
|
549
|
+
};
|
|
550
|
+
readonly checkIns: {
|
|
551
|
+
readonly create: RouteDef<"POST", CreateCheckInDto, CheckIn>;
|
|
552
|
+
};
|
|
553
|
+
readonly leaderboards: {
|
|
554
|
+
readonly list: RouteDef<"GET", void, LeaderboardWithEntries[]>;
|
|
555
|
+
readonly create: RouteDef<"POST", CreateLeaderboardDto, Leaderboard>;
|
|
556
|
+
readonly submitEntry: RouteDef<"POST", SubmitEntryDto, unknown>;
|
|
557
|
+
readonly reviewEntry: RouteDef<"POST", ReviewEntryDto, SuccessResponse>;
|
|
558
|
+
};
|
|
559
|
+
readonly challenges: {
|
|
560
|
+
readonly create: RouteDef<"POST", CreateChallengeDto, Challenge>;
|
|
561
|
+
readonly createOccurrence: RouteDef<"POST", CreateOccurrenceDto, ChallengeOccurrence>;
|
|
562
|
+
readonly meActive: RouteDef<"GET", void, ChallengeOccurrenceWithDetails[]>;
|
|
563
|
+
readonly join: RouteDef<"POST", JoinChallengeDto, unknown>;
|
|
564
|
+
readonly complete: RouteDef<"POST", CompleteChallengeDto, unknown>;
|
|
565
|
+
};
|
|
566
|
+
readonly bookings: {
|
|
567
|
+
readonly create: RouteDef<"POST", CreateBookingDto, Booking>;
|
|
568
|
+
readonly updateStatus: RouteDef<"POST", UpdateBookingStatusDto, Booking>;
|
|
569
|
+
readonly meMember: RouteDef<"GET", void, Booking[]>;
|
|
570
|
+
readonly meExpert: RouteDef<"GET", void, Booking[]>;
|
|
571
|
+
};
|
|
572
|
+
readonly rewards: {
|
|
573
|
+
readonly list: RouteDef<"GET", void, Reward[]>;
|
|
574
|
+
readonly me: RouteDef<"GET", void, MemberReward[]>;
|
|
575
|
+
};
|
|
576
|
+
readonly experts: {
|
|
577
|
+
readonly list: RouteDef<"GET", void, Expert[]>;
|
|
578
|
+
readonly me: RouteDef<"GET", void, Expert>;
|
|
579
|
+
readonly availability: (id: string) => RouteDef<"GET", void, ExpertAvailabilityResponse>;
|
|
580
|
+
readonly meAvailability: RouteDef<"POST", SetAvailabilityDto, ExpertAvailability[]>;
|
|
581
|
+
readonly meAvailabilityExceptions: RouteDef<"POST", SetAvailabilityExceptionDto, unknown>;
|
|
582
|
+
};
|
|
583
|
+
readonly notifications: {
|
|
584
|
+
readonly me: RouteDef<"GET", void, Notification[]>;
|
|
585
|
+
readonly meReadAll: RouteDef<"POST", void, SuccessResponse>;
|
|
586
|
+
};
|
|
587
|
+
readonly activities: {
|
|
588
|
+
readonly me: RouteDef<"GET", void, Activity[]>;
|
|
589
|
+
};
|
|
590
|
+
readonly media: {
|
|
591
|
+
readonly upload: RouteDef<"POST", unknown, Media>;
|
|
592
|
+
readonly delete: (id: string) => RouteDef<"DELETE", void, SuccessResponse>;
|
|
593
|
+
};
|
|
594
|
+
readonly admin: {
|
|
595
|
+
readonly summary: RouteDef<"GET", void, AdminSummaryResponse>;
|
|
596
|
+
readonly gym: RouteDef<"GET", void, Gym>;
|
|
597
|
+
readonly updateGym: RouteDef<"PATCH", UpdateGymDto, Gym>;
|
|
598
|
+
readonly members: RouteDef<"GET", void, MemberWithUser[]>;
|
|
599
|
+
readonly createMember: RouteDef<"POST", AddMemberDto, MemberWithUser>;
|
|
600
|
+
readonly rewards: RouteDef<"GET", void, Reward[]>;
|
|
601
|
+
readonly createReward: RouteDef<"POST", CreateRewardDto, Reward>;
|
|
602
|
+
readonly updateReward: (id: string) => RouteDef<"PATCH", UpdateRewardDto, Reward>;
|
|
603
|
+
readonly deleteReward: (id: string) => RouteDef<"DELETE", void, SuccessResponse>;
|
|
604
|
+
readonly staff: RouteDef<"GET", void, StaffWithUser[]>;
|
|
605
|
+
readonly createStaff: RouteDef<"POST", AddStaffDto, StaffWithUser>;
|
|
606
|
+
readonly deleteStaff: (userId: string) => RouteDef<"DELETE", void, SuccessResponse>;
|
|
607
|
+
readonly disableStaff: (userId: string) => RouteDef<"PATCH", void, SuccessResponse>;
|
|
608
|
+
readonly enableStaff: (userId: string) => RouteDef<"PATCH", void, SuccessResponse>;
|
|
609
|
+
readonly experts: RouteDef<"GET", void, ExpertWithUser[]>;
|
|
610
|
+
readonly createExpert: RouteDef<"POST", AddExpertDto, ExpertWithUser>;
|
|
611
|
+
readonly deleteExpert: (userId: string) => RouteDef<"DELETE", void, SuccessResponse>;
|
|
612
|
+
readonly disableExpert: (userId: string) => RouteDef<"PATCH", void, SuccessResponse>;
|
|
613
|
+
readonly enableExpert: (userId: string) => RouteDef<"PATCH", void, SuccessResponse>;
|
|
614
|
+
};
|
|
615
|
+
};
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
* Axios-compatible API client. Use with your axios instance for typed requests.
|
|
619
|
+
* No axios dependency: pass any client that matches AthosHttpClient.
|
|
620
|
+
*/
|
|
621
|
+
|
|
622
|
+
/**
|
|
623
|
+
* Minimal axios-like interface so you can pass an axios instance without adding axios as a dependency.
|
|
624
|
+
* Axios instances satisfy this (request returns { data }).
|
|
625
|
+
*/
|
|
626
|
+
interface AthosHttpClient {
|
|
627
|
+
request<T = unknown>(config: {
|
|
628
|
+
method: string;
|
|
629
|
+
url: string;
|
|
630
|
+
data?: unknown;
|
|
631
|
+
params?: Record<string, string>;
|
|
632
|
+
headers?: Record<string, string>;
|
|
633
|
+
}): Promise<{
|
|
634
|
+
data: T;
|
|
635
|
+
}>;
|
|
636
|
+
}
|
|
637
|
+
/**
|
|
638
|
+
* Perform a typed request. Route carries the path, method, and (via types) request/response types.
|
|
639
|
+
*
|
|
640
|
+
* @example
|
|
641
|
+
* const api = createApi(axios.create({ baseURL: 'https://api.example.com' }));
|
|
642
|
+
* const auth = await api.request(apiRoutes.auth.login, { email: 'a@b.com', password: 'x' });
|
|
643
|
+
* // auth is AuthResponse
|
|
644
|
+
*/
|
|
645
|
+
declare function request<R extends RouteDef<HttpMethod, unknown, unknown>>(client: AthosHttpClient, baseUrl: string, route: R, body?: RequestBody<R>): Promise<ResponseBody<R>>;
|
|
646
|
+
/**
|
|
647
|
+
* Create an API helper that uses your axios (or compatible) instance.
|
|
648
|
+
* Use .request(route, body?) for full type inference: route gives you the path, and TypeScript
|
|
649
|
+
* enforces the body type and infers the response type.
|
|
650
|
+
*
|
|
651
|
+
* @example
|
|
652
|
+
* import axios from 'axios';
|
|
653
|
+
* import { createApi, apiRoutes } from '@athos-sdk/api-types';
|
|
654
|
+
*
|
|
655
|
+
* const api = createApi(axios.create({ baseURL: 'https://api.example.com' }));
|
|
656
|
+
*
|
|
657
|
+
* // POST with body – body and response are typed from the route
|
|
658
|
+
* const auth = await api.request(apiRoutes.auth.login, { email: 'u@x.com', password: 'p' });
|
|
659
|
+
*
|
|
660
|
+
* // GET – no body
|
|
661
|
+
* const me = await api.request(apiRoutes.members.me);
|
|
662
|
+
*
|
|
663
|
+
* // Dynamic path
|
|
664
|
+
* const availability = await api.request(apiRoutes.experts.availability(expertId));
|
|
665
|
+
*/
|
|
666
|
+
declare function createApi(client: AthosHttpClient, baseUrl?: string): {
|
|
667
|
+
/**
|
|
668
|
+
* Execute a typed request. The route defines method + path; body and response types are inferred.
|
|
669
|
+
*/
|
|
670
|
+
request<R extends RouteDef<HttpMethod, unknown, unknown>>(route: R, body?: RequestBody<R>): Promise<ResponseBody<R>>;
|
|
671
|
+
};
|
|
672
|
+
|
|
673
|
+
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -416,4 +416,258 @@ interface Activity {
|
|
|
416
416
|
createdAt: string;
|
|
417
417
|
}
|
|
418
418
|
|
|
419
|
-
|
|
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: RouteDef<"POST", RegisterDto, RegisterResponse>;
|
|
541
|
+
readonly login: RouteDef<"POST", LoginDto, AuthResponse>;
|
|
542
|
+
readonly deleteMe: RouteDef<"DELETE", void, SuccessResponse>;
|
|
543
|
+
};
|
|
544
|
+
readonly members: {
|
|
545
|
+
readonly join: RouteDef<"POST", JoinGymDto, MemberWithGym>;
|
|
546
|
+
readonly me: RouteDef<"GET", void, GetMeResponse>;
|
|
547
|
+
readonly updateMe: RouteDef<"PATCH", UpdateMemberProfileDto, GetMeResponse>;
|
|
548
|
+
readonly meStats: RouteDef<"GET", void, MemberStatsResponse>;
|
|
549
|
+
};
|
|
550
|
+
readonly checkIns: {
|
|
551
|
+
readonly create: RouteDef<"POST", CreateCheckInDto, CheckIn>;
|
|
552
|
+
};
|
|
553
|
+
readonly leaderboards: {
|
|
554
|
+
readonly list: RouteDef<"GET", void, LeaderboardWithEntries[]>;
|
|
555
|
+
readonly create: RouteDef<"POST", CreateLeaderboardDto, Leaderboard>;
|
|
556
|
+
readonly submitEntry: RouteDef<"POST", SubmitEntryDto, unknown>;
|
|
557
|
+
readonly reviewEntry: RouteDef<"POST", ReviewEntryDto, SuccessResponse>;
|
|
558
|
+
};
|
|
559
|
+
readonly challenges: {
|
|
560
|
+
readonly create: RouteDef<"POST", CreateChallengeDto, Challenge>;
|
|
561
|
+
readonly createOccurrence: RouteDef<"POST", CreateOccurrenceDto, ChallengeOccurrence>;
|
|
562
|
+
readonly meActive: RouteDef<"GET", void, ChallengeOccurrenceWithDetails[]>;
|
|
563
|
+
readonly join: RouteDef<"POST", JoinChallengeDto, unknown>;
|
|
564
|
+
readonly complete: RouteDef<"POST", CompleteChallengeDto, unknown>;
|
|
565
|
+
};
|
|
566
|
+
readonly bookings: {
|
|
567
|
+
readonly create: RouteDef<"POST", CreateBookingDto, Booking>;
|
|
568
|
+
readonly updateStatus: RouteDef<"POST", UpdateBookingStatusDto, Booking>;
|
|
569
|
+
readonly meMember: RouteDef<"GET", void, Booking[]>;
|
|
570
|
+
readonly meExpert: RouteDef<"GET", void, Booking[]>;
|
|
571
|
+
};
|
|
572
|
+
readonly rewards: {
|
|
573
|
+
readonly list: RouteDef<"GET", void, Reward[]>;
|
|
574
|
+
readonly me: RouteDef<"GET", void, MemberReward[]>;
|
|
575
|
+
};
|
|
576
|
+
readonly experts: {
|
|
577
|
+
readonly list: RouteDef<"GET", void, Expert[]>;
|
|
578
|
+
readonly me: RouteDef<"GET", void, Expert>;
|
|
579
|
+
readonly availability: (id: string) => RouteDef<"GET", void, ExpertAvailabilityResponse>;
|
|
580
|
+
readonly meAvailability: RouteDef<"POST", SetAvailabilityDto, ExpertAvailability[]>;
|
|
581
|
+
readonly meAvailabilityExceptions: RouteDef<"POST", SetAvailabilityExceptionDto, unknown>;
|
|
582
|
+
};
|
|
583
|
+
readonly notifications: {
|
|
584
|
+
readonly me: RouteDef<"GET", void, Notification[]>;
|
|
585
|
+
readonly meReadAll: RouteDef<"POST", void, SuccessResponse>;
|
|
586
|
+
};
|
|
587
|
+
readonly activities: {
|
|
588
|
+
readonly me: RouteDef<"GET", void, Activity[]>;
|
|
589
|
+
};
|
|
590
|
+
readonly media: {
|
|
591
|
+
readonly upload: RouteDef<"POST", unknown, Media>;
|
|
592
|
+
readonly delete: (id: string) => RouteDef<"DELETE", void, SuccessResponse>;
|
|
593
|
+
};
|
|
594
|
+
readonly admin: {
|
|
595
|
+
readonly summary: RouteDef<"GET", void, AdminSummaryResponse>;
|
|
596
|
+
readonly gym: RouteDef<"GET", void, Gym>;
|
|
597
|
+
readonly updateGym: RouteDef<"PATCH", UpdateGymDto, Gym>;
|
|
598
|
+
readonly members: RouteDef<"GET", void, MemberWithUser[]>;
|
|
599
|
+
readonly createMember: RouteDef<"POST", AddMemberDto, MemberWithUser>;
|
|
600
|
+
readonly rewards: RouteDef<"GET", void, Reward[]>;
|
|
601
|
+
readonly createReward: RouteDef<"POST", CreateRewardDto, Reward>;
|
|
602
|
+
readonly updateReward: (id: string) => RouteDef<"PATCH", UpdateRewardDto, Reward>;
|
|
603
|
+
readonly deleteReward: (id: string) => RouteDef<"DELETE", void, SuccessResponse>;
|
|
604
|
+
readonly staff: RouteDef<"GET", void, StaffWithUser[]>;
|
|
605
|
+
readonly createStaff: RouteDef<"POST", AddStaffDto, StaffWithUser>;
|
|
606
|
+
readonly deleteStaff: (userId: string) => RouteDef<"DELETE", void, SuccessResponse>;
|
|
607
|
+
readonly disableStaff: (userId: string) => RouteDef<"PATCH", void, SuccessResponse>;
|
|
608
|
+
readonly enableStaff: (userId: string) => RouteDef<"PATCH", void, SuccessResponse>;
|
|
609
|
+
readonly experts: RouteDef<"GET", void, ExpertWithUser[]>;
|
|
610
|
+
readonly createExpert: RouteDef<"POST", AddExpertDto, ExpertWithUser>;
|
|
611
|
+
readonly deleteExpert: (userId: string) => RouteDef<"DELETE", void, SuccessResponse>;
|
|
612
|
+
readonly disableExpert: (userId: string) => RouteDef<"PATCH", void, SuccessResponse>;
|
|
613
|
+
readonly enableExpert: (userId: string) => RouteDef<"PATCH", void, SuccessResponse>;
|
|
614
|
+
};
|
|
615
|
+
};
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
* Axios-compatible API client. Use with your axios instance for typed requests.
|
|
619
|
+
* No axios dependency: pass any client that matches AthosHttpClient.
|
|
620
|
+
*/
|
|
621
|
+
|
|
622
|
+
/**
|
|
623
|
+
* Minimal axios-like interface so you can pass an axios instance without adding axios as a dependency.
|
|
624
|
+
* Axios instances satisfy this (request returns { data }).
|
|
625
|
+
*/
|
|
626
|
+
interface AthosHttpClient {
|
|
627
|
+
request<T = unknown>(config: {
|
|
628
|
+
method: string;
|
|
629
|
+
url: string;
|
|
630
|
+
data?: unknown;
|
|
631
|
+
params?: Record<string, string>;
|
|
632
|
+
headers?: Record<string, string>;
|
|
633
|
+
}): Promise<{
|
|
634
|
+
data: T;
|
|
635
|
+
}>;
|
|
636
|
+
}
|
|
637
|
+
/**
|
|
638
|
+
* Perform a typed request. Route carries the path, method, and (via types) request/response types.
|
|
639
|
+
*
|
|
640
|
+
* @example
|
|
641
|
+
* const api = createApi(axios.create({ baseURL: 'https://api.example.com' }));
|
|
642
|
+
* const auth = await api.request(apiRoutes.auth.login, { email: 'a@b.com', password: 'x' });
|
|
643
|
+
* // auth is AuthResponse
|
|
644
|
+
*/
|
|
645
|
+
declare function request<R extends RouteDef<HttpMethod, unknown, unknown>>(client: AthosHttpClient, baseUrl: string, route: R, body?: RequestBody<R>): Promise<ResponseBody<R>>;
|
|
646
|
+
/**
|
|
647
|
+
* Create an API helper that uses your axios (or compatible) instance.
|
|
648
|
+
* Use .request(route, body?) for full type inference: route gives you the path, and TypeScript
|
|
649
|
+
* enforces the body type and infers the response type.
|
|
650
|
+
*
|
|
651
|
+
* @example
|
|
652
|
+
* import axios from 'axios';
|
|
653
|
+
* import { createApi, apiRoutes } from '@athos-sdk/api-types';
|
|
654
|
+
*
|
|
655
|
+
* const api = createApi(axios.create({ baseURL: 'https://api.example.com' }));
|
|
656
|
+
*
|
|
657
|
+
* // POST with body – body and response are typed from the route
|
|
658
|
+
* const auth = await api.request(apiRoutes.auth.login, { email: 'u@x.com', password: 'p' });
|
|
659
|
+
*
|
|
660
|
+
* // GET – no body
|
|
661
|
+
* const me = await api.request(apiRoutes.members.me);
|
|
662
|
+
*
|
|
663
|
+
* // Dynamic path
|
|
664
|
+
* const availability = await api.request(apiRoutes.experts.availability(expertId));
|
|
665
|
+
*/
|
|
666
|
+
declare function createApi(client: AthosHttpClient, baseUrl?: string): {
|
|
667
|
+
/**
|
|
668
|
+
* Execute a typed request. The route defines method + path; body and response types are inferred.
|
|
669
|
+
*/
|
|
670
|
+
request<R extends RouteDef<HttpMethod, unknown, unknown>>(route: R, body?: RequestBody<R>): Promise<ResponseBody<R>>;
|
|
671
|
+
};
|
|
672
|
+
|
|
673
|
+
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 };
|
package/dist/index.js
CHANGED
|
@@ -23,7 +23,11 @@ __export(index_exports, {
|
|
|
23
23
|
BookingStatus: () => BookingStatus,
|
|
24
24
|
ChallengeVerificationType: () => ChallengeVerificationType,
|
|
25
25
|
ExpertRole: () => ExpertRole,
|
|
26
|
-
LeaderboardEntryStatus: () => LeaderboardEntryStatus
|
|
26
|
+
LeaderboardEntryStatus: () => LeaderboardEntryStatus,
|
|
27
|
+
ROUTES: () => ROUTES,
|
|
28
|
+
apiRoutes: () => apiRoutes,
|
|
29
|
+
createApi: () => createApi,
|
|
30
|
+
request: () => request
|
|
27
31
|
});
|
|
28
32
|
module.exports = __toCommonJS(index_exports);
|
|
29
33
|
|
|
@@ -53,10 +57,385 @@ var ExpertRole = /* @__PURE__ */ ((ExpertRole2) => {
|
|
|
53
57
|
ExpertRole2["DIETITIAN"] = "DIETITIAN";
|
|
54
58
|
return ExpertRole2;
|
|
55
59
|
})(ExpertRole || {});
|
|
60
|
+
|
|
61
|
+
// src/routes.ts
|
|
62
|
+
var ROUTES = {
|
|
63
|
+
// App
|
|
64
|
+
health: "/",
|
|
65
|
+
// Auth
|
|
66
|
+
auth: {
|
|
67
|
+
register: "/auth/register",
|
|
68
|
+
login: "/auth/login",
|
|
69
|
+
deleteMe: "/auth/me"
|
|
70
|
+
},
|
|
71
|
+
// Members
|
|
72
|
+
members: {
|
|
73
|
+
join: "/members/join",
|
|
74
|
+
me: "/members/me",
|
|
75
|
+
meStats: "/members/me/stats"
|
|
76
|
+
},
|
|
77
|
+
// Check-ins
|
|
78
|
+
checkIns: {
|
|
79
|
+
create: "/check-ins"
|
|
80
|
+
},
|
|
81
|
+
// Leaderboards
|
|
82
|
+
leaderboards: {
|
|
83
|
+
list: "/leaderboards",
|
|
84
|
+
create: "/leaderboards",
|
|
85
|
+
submitEntry: "/leaderboards/entries",
|
|
86
|
+
reviewEntry: "/leaderboards/entries/review"
|
|
87
|
+
},
|
|
88
|
+
// Challenges
|
|
89
|
+
challenges: {
|
|
90
|
+
create: "/challenges",
|
|
91
|
+
createOccurrence: "/challenges/occurrences",
|
|
92
|
+
meActive: "/challenges/me/active",
|
|
93
|
+
join: "/challenges/join",
|
|
94
|
+
complete: "/challenges/complete"
|
|
95
|
+
},
|
|
96
|
+
// Bookings
|
|
97
|
+
bookings: {
|
|
98
|
+
create: "/bookings",
|
|
99
|
+
updateStatus: "/bookings/status",
|
|
100
|
+
meMember: "/bookings/me/member",
|
|
101
|
+
meExpert: "/bookings/me/expert"
|
|
102
|
+
},
|
|
103
|
+
// Rewards
|
|
104
|
+
rewards: {
|
|
105
|
+
list: "/rewards",
|
|
106
|
+
me: "/rewards/me"
|
|
107
|
+
},
|
|
108
|
+
// Experts
|
|
109
|
+
experts: {
|
|
110
|
+
list: "/experts",
|
|
111
|
+
me: "/experts/me",
|
|
112
|
+
availability: (id) => `/experts/${id}/availability`,
|
|
113
|
+
meAvailability: "/experts/me/availability",
|
|
114
|
+
meAvailabilityExceptions: "/experts/me/availability-exceptions"
|
|
115
|
+
},
|
|
116
|
+
// Notifications
|
|
117
|
+
notifications: {
|
|
118
|
+
me: "/notifications/me",
|
|
119
|
+
meReadAll: "/notifications/me/read-all"
|
|
120
|
+
},
|
|
121
|
+
// Activities
|
|
122
|
+
activities: {
|
|
123
|
+
me: "/activities/me"
|
|
124
|
+
},
|
|
125
|
+
// Media
|
|
126
|
+
media: {
|
|
127
|
+
upload: "/media",
|
|
128
|
+
delete: (id) => `/media/${id}`
|
|
129
|
+
},
|
|
130
|
+
// Admin
|
|
131
|
+
admin: {
|
|
132
|
+
summary: "/admin/summary",
|
|
133
|
+
gym: "/admin/gym",
|
|
134
|
+
members: "/admin/members",
|
|
135
|
+
createMember: "/admin/members",
|
|
136
|
+
rewards: "/admin/rewards",
|
|
137
|
+
createReward: "/admin/rewards",
|
|
138
|
+
rewardById: (id) => `/admin/rewards/${id}`,
|
|
139
|
+
staff: "/admin/staff",
|
|
140
|
+
createStaff: "/admin/staff",
|
|
141
|
+
staffByUserId: (userId) => `/admin/staff/${userId}`,
|
|
142
|
+
staffDisable: (userId) => `/admin/staff/${userId}/disable`,
|
|
143
|
+
staffEnable: (userId) => `/admin/staff/${userId}/enable`,
|
|
144
|
+
experts: "/admin/experts",
|
|
145
|
+
createExpert: "/admin/experts",
|
|
146
|
+
expertByUserId: (userId) => `/admin/experts/${userId}`,
|
|
147
|
+
expertDisable: (userId) => `/admin/experts/${userId}/disable`,
|
|
148
|
+
expertEnable: (userId) => `/admin/experts/${userId}/enable`
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
// src/api-routes.ts
|
|
153
|
+
function defineRoute(def) {
|
|
154
|
+
return def;
|
|
155
|
+
}
|
|
156
|
+
var auth = {
|
|
157
|
+
register: defineRoute({
|
|
158
|
+
method: "POST",
|
|
159
|
+
path: "/auth/register"
|
|
160
|
+
}),
|
|
161
|
+
login: defineRoute({
|
|
162
|
+
method: "POST",
|
|
163
|
+
path: "/auth/login"
|
|
164
|
+
}),
|
|
165
|
+
deleteMe: defineRoute({
|
|
166
|
+
method: "DELETE",
|
|
167
|
+
path: "/auth/me"
|
|
168
|
+
})
|
|
169
|
+
};
|
|
170
|
+
var members = {
|
|
171
|
+
join: defineRoute({
|
|
172
|
+
method: "POST",
|
|
173
|
+
path: "/members/join"
|
|
174
|
+
}),
|
|
175
|
+
me: defineRoute({
|
|
176
|
+
method: "GET",
|
|
177
|
+
path: "/members/me"
|
|
178
|
+
}),
|
|
179
|
+
updateMe: defineRoute({
|
|
180
|
+
method: "PATCH",
|
|
181
|
+
path: "/members/me"
|
|
182
|
+
}),
|
|
183
|
+
meStats: defineRoute({
|
|
184
|
+
method: "GET",
|
|
185
|
+
path: "/members/me/stats"
|
|
186
|
+
})
|
|
187
|
+
};
|
|
188
|
+
var checkIns = {
|
|
189
|
+
create: defineRoute({
|
|
190
|
+
method: "POST",
|
|
191
|
+
path: "/check-ins"
|
|
192
|
+
})
|
|
193
|
+
};
|
|
194
|
+
var leaderboards = {
|
|
195
|
+
list: defineRoute({
|
|
196
|
+
method: "GET",
|
|
197
|
+
path: "/leaderboards"
|
|
198
|
+
}),
|
|
199
|
+
create: defineRoute({
|
|
200
|
+
method: "POST",
|
|
201
|
+
path: "/leaderboards"
|
|
202
|
+
}),
|
|
203
|
+
submitEntry: defineRoute({
|
|
204
|
+
method: "POST",
|
|
205
|
+
path: "/leaderboards/entries"
|
|
206
|
+
}),
|
|
207
|
+
reviewEntry: defineRoute({
|
|
208
|
+
method: "POST",
|
|
209
|
+
path: "/leaderboards/entries/review"
|
|
210
|
+
})
|
|
211
|
+
};
|
|
212
|
+
var challenges = {
|
|
213
|
+
create: defineRoute({
|
|
214
|
+
method: "POST",
|
|
215
|
+
path: "/challenges"
|
|
216
|
+
}),
|
|
217
|
+
createOccurrence: defineRoute({
|
|
218
|
+
method: "POST",
|
|
219
|
+
path: "/challenges/occurrences"
|
|
220
|
+
}),
|
|
221
|
+
meActive: defineRoute({
|
|
222
|
+
method: "GET",
|
|
223
|
+
path: "/challenges/me/active"
|
|
224
|
+
}),
|
|
225
|
+
join: defineRoute({
|
|
226
|
+
method: "POST",
|
|
227
|
+
path: "/challenges/join"
|
|
228
|
+
}),
|
|
229
|
+
complete: defineRoute({
|
|
230
|
+
method: "POST",
|
|
231
|
+
path: "/challenges/complete"
|
|
232
|
+
})
|
|
233
|
+
};
|
|
234
|
+
var bookings = {
|
|
235
|
+
create: defineRoute({
|
|
236
|
+
method: "POST",
|
|
237
|
+
path: "/bookings"
|
|
238
|
+
}),
|
|
239
|
+
updateStatus: defineRoute({
|
|
240
|
+
method: "POST",
|
|
241
|
+
path: "/bookings/status"
|
|
242
|
+
}),
|
|
243
|
+
meMember: defineRoute({
|
|
244
|
+
method: "GET",
|
|
245
|
+
path: "/bookings/me/member"
|
|
246
|
+
}),
|
|
247
|
+
meExpert: defineRoute({
|
|
248
|
+
method: "GET",
|
|
249
|
+
path: "/bookings/me/expert"
|
|
250
|
+
})
|
|
251
|
+
};
|
|
252
|
+
var rewards = {
|
|
253
|
+
list: defineRoute({
|
|
254
|
+
method: "GET",
|
|
255
|
+
path: "/rewards"
|
|
256
|
+
}),
|
|
257
|
+
me: defineRoute({
|
|
258
|
+
method: "GET",
|
|
259
|
+
path: "/rewards/me"
|
|
260
|
+
})
|
|
261
|
+
};
|
|
262
|
+
var experts = {
|
|
263
|
+
list: defineRoute({
|
|
264
|
+
method: "GET",
|
|
265
|
+
path: "/experts"
|
|
266
|
+
}),
|
|
267
|
+
me: defineRoute({
|
|
268
|
+
method: "GET",
|
|
269
|
+
path: "/experts/me"
|
|
270
|
+
}),
|
|
271
|
+
availability: (id) => defineRoute({
|
|
272
|
+
method: "GET",
|
|
273
|
+
path: `/experts/${id}/availability`
|
|
274
|
+
}),
|
|
275
|
+
meAvailability: defineRoute({
|
|
276
|
+
method: "POST",
|
|
277
|
+
path: "/experts/me/availability"
|
|
278
|
+
}),
|
|
279
|
+
meAvailabilityExceptions: defineRoute({
|
|
280
|
+
method: "POST",
|
|
281
|
+
path: "/experts/me/availability-exceptions"
|
|
282
|
+
})
|
|
283
|
+
};
|
|
284
|
+
var notifications = {
|
|
285
|
+
me: defineRoute({
|
|
286
|
+
method: "GET",
|
|
287
|
+
path: "/notifications/me"
|
|
288
|
+
}),
|
|
289
|
+
meReadAll: defineRoute({
|
|
290
|
+
method: "POST",
|
|
291
|
+
path: "/notifications/me/read-all"
|
|
292
|
+
})
|
|
293
|
+
};
|
|
294
|
+
var activities = {
|
|
295
|
+
me: defineRoute({
|
|
296
|
+
method: "GET",
|
|
297
|
+
path: "/activities/me"
|
|
298
|
+
})
|
|
299
|
+
};
|
|
300
|
+
var media = {
|
|
301
|
+
upload: defineRoute({
|
|
302
|
+
method: "POST",
|
|
303
|
+
path: "/media"
|
|
304
|
+
}),
|
|
305
|
+
delete: (id) => defineRoute({
|
|
306
|
+
method: "DELETE",
|
|
307
|
+
path: `/media/${id}`
|
|
308
|
+
})
|
|
309
|
+
};
|
|
310
|
+
var admin = {
|
|
311
|
+
summary: defineRoute({
|
|
312
|
+
method: "GET",
|
|
313
|
+
path: "/admin/summary"
|
|
314
|
+
}),
|
|
315
|
+
gym: defineRoute({
|
|
316
|
+
method: "GET",
|
|
317
|
+
path: "/admin/gym"
|
|
318
|
+
}),
|
|
319
|
+
updateGym: defineRoute({
|
|
320
|
+
method: "PATCH",
|
|
321
|
+
path: "/admin/gym"
|
|
322
|
+
}),
|
|
323
|
+
members: defineRoute({
|
|
324
|
+
method: "GET",
|
|
325
|
+
path: "/admin/members"
|
|
326
|
+
}),
|
|
327
|
+
createMember: defineRoute({
|
|
328
|
+
method: "POST",
|
|
329
|
+
path: "/admin/members"
|
|
330
|
+
}),
|
|
331
|
+
rewards: defineRoute({
|
|
332
|
+
method: "GET",
|
|
333
|
+
path: "/admin/rewards"
|
|
334
|
+
}),
|
|
335
|
+
createReward: defineRoute({
|
|
336
|
+
method: "POST",
|
|
337
|
+
path: "/admin/rewards"
|
|
338
|
+
}),
|
|
339
|
+
updateReward: (id) => defineRoute({
|
|
340
|
+
method: "PATCH",
|
|
341
|
+
path: `/admin/rewards/${id}`
|
|
342
|
+
}),
|
|
343
|
+
deleteReward: (id) => defineRoute({
|
|
344
|
+
method: "DELETE",
|
|
345
|
+
path: `/admin/rewards/${id}`
|
|
346
|
+
}),
|
|
347
|
+
staff: defineRoute({
|
|
348
|
+
method: "GET",
|
|
349
|
+
path: "/admin/staff"
|
|
350
|
+
}),
|
|
351
|
+
createStaff: defineRoute({
|
|
352
|
+
method: "POST",
|
|
353
|
+
path: "/admin/staff"
|
|
354
|
+
}),
|
|
355
|
+
deleteStaff: (userId) => defineRoute({
|
|
356
|
+
method: "DELETE",
|
|
357
|
+
path: `/admin/staff/${userId}`
|
|
358
|
+
}),
|
|
359
|
+
disableStaff: (userId) => defineRoute({
|
|
360
|
+
method: "PATCH",
|
|
361
|
+
path: `/admin/staff/${userId}/disable`
|
|
362
|
+
}),
|
|
363
|
+
enableStaff: (userId) => defineRoute({
|
|
364
|
+
method: "PATCH",
|
|
365
|
+
path: `/admin/staff/${userId}/enable`
|
|
366
|
+
}),
|
|
367
|
+
experts: defineRoute({
|
|
368
|
+
method: "GET",
|
|
369
|
+
path: "/admin/experts"
|
|
370
|
+
}),
|
|
371
|
+
createExpert: defineRoute({
|
|
372
|
+
method: "POST",
|
|
373
|
+
path: "/admin/experts"
|
|
374
|
+
}),
|
|
375
|
+
deleteExpert: (userId) => defineRoute({
|
|
376
|
+
method: "DELETE",
|
|
377
|
+
path: `/admin/experts/${userId}`
|
|
378
|
+
}),
|
|
379
|
+
disableExpert: (userId) => defineRoute({
|
|
380
|
+
method: "PATCH",
|
|
381
|
+
path: `/admin/experts/${userId}/disable`
|
|
382
|
+
}),
|
|
383
|
+
enableExpert: (userId) => defineRoute({
|
|
384
|
+
method: "PATCH",
|
|
385
|
+
path: `/admin/experts/${userId}/enable`
|
|
386
|
+
})
|
|
387
|
+
};
|
|
388
|
+
var apiRoutes = {
|
|
389
|
+
auth,
|
|
390
|
+
members,
|
|
391
|
+
checkIns,
|
|
392
|
+
leaderboards,
|
|
393
|
+
challenges,
|
|
394
|
+
bookings,
|
|
395
|
+
rewards,
|
|
396
|
+
experts,
|
|
397
|
+
notifications,
|
|
398
|
+
activities,
|
|
399
|
+
media,
|
|
400
|
+
admin
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
// src/api-client.ts
|
|
404
|
+
function buildUrl(baseUrl, path) {
|
|
405
|
+
const base = baseUrl.replace(/\/$/, "");
|
|
406
|
+
const p = path.startsWith("/") ? path : `/${path}`;
|
|
407
|
+
return base ? `${base}${p}` : p;
|
|
408
|
+
}
|
|
409
|
+
function request(client, baseUrl, route, body) {
|
|
410
|
+
const url = buildUrl(baseUrl, route.path);
|
|
411
|
+
const config = {
|
|
412
|
+
method: route.method,
|
|
413
|
+
url,
|
|
414
|
+
headers: { "Content-Type": "application/json" }
|
|
415
|
+
};
|
|
416
|
+
if (body !== void 0 && body !== null && ["POST", "PUT", "PATCH"].includes(route.method)) {
|
|
417
|
+
config.data = body;
|
|
418
|
+
}
|
|
419
|
+
return client.request(config).then((res) => res.data);
|
|
420
|
+
}
|
|
421
|
+
function createApi(client, baseUrl = "") {
|
|
422
|
+
return {
|
|
423
|
+
/**
|
|
424
|
+
* Execute a typed request. The route defines method + path; body and response types are inferred.
|
|
425
|
+
*/
|
|
426
|
+
request(route, body) {
|
|
427
|
+
return request(client, baseUrl, route, body);
|
|
428
|
+
}
|
|
429
|
+
};
|
|
430
|
+
}
|
|
56
431
|
// Annotate the CommonJS export names for ESM import in node:
|
|
57
432
|
0 && (module.exports = {
|
|
58
433
|
BookingStatus,
|
|
59
434
|
ChallengeVerificationType,
|
|
60
435
|
ExpertRole,
|
|
61
|
-
LeaderboardEntryStatus
|
|
436
|
+
LeaderboardEntryStatus,
|
|
437
|
+
ROUTES,
|
|
438
|
+
apiRoutes,
|
|
439
|
+
createApi,
|
|
440
|
+
request
|
|
62
441
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -24,9 +24,384 @@ var ExpertRole = /* @__PURE__ */ ((ExpertRole2) => {
|
|
|
24
24
|
ExpertRole2["DIETITIAN"] = "DIETITIAN";
|
|
25
25
|
return ExpertRole2;
|
|
26
26
|
})(ExpertRole || {});
|
|
27
|
+
|
|
28
|
+
// src/routes.ts
|
|
29
|
+
var ROUTES = {
|
|
30
|
+
// App
|
|
31
|
+
health: "/",
|
|
32
|
+
// Auth
|
|
33
|
+
auth: {
|
|
34
|
+
register: "/auth/register",
|
|
35
|
+
login: "/auth/login",
|
|
36
|
+
deleteMe: "/auth/me"
|
|
37
|
+
},
|
|
38
|
+
// Members
|
|
39
|
+
members: {
|
|
40
|
+
join: "/members/join",
|
|
41
|
+
me: "/members/me",
|
|
42
|
+
meStats: "/members/me/stats"
|
|
43
|
+
},
|
|
44
|
+
// Check-ins
|
|
45
|
+
checkIns: {
|
|
46
|
+
create: "/check-ins"
|
|
47
|
+
},
|
|
48
|
+
// Leaderboards
|
|
49
|
+
leaderboards: {
|
|
50
|
+
list: "/leaderboards",
|
|
51
|
+
create: "/leaderboards",
|
|
52
|
+
submitEntry: "/leaderboards/entries",
|
|
53
|
+
reviewEntry: "/leaderboards/entries/review"
|
|
54
|
+
},
|
|
55
|
+
// Challenges
|
|
56
|
+
challenges: {
|
|
57
|
+
create: "/challenges",
|
|
58
|
+
createOccurrence: "/challenges/occurrences",
|
|
59
|
+
meActive: "/challenges/me/active",
|
|
60
|
+
join: "/challenges/join",
|
|
61
|
+
complete: "/challenges/complete"
|
|
62
|
+
},
|
|
63
|
+
// Bookings
|
|
64
|
+
bookings: {
|
|
65
|
+
create: "/bookings",
|
|
66
|
+
updateStatus: "/bookings/status",
|
|
67
|
+
meMember: "/bookings/me/member",
|
|
68
|
+
meExpert: "/bookings/me/expert"
|
|
69
|
+
},
|
|
70
|
+
// Rewards
|
|
71
|
+
rewards: {
|
|
72
|
+
list: "/rewards",
|
|
73
|
+
me: "/rewards/me"
|
|
74
|
+
},
|
|
75
|
+
// Experts
|
|
76
|
+
experts: {
|
|
77
|
+
list: "/experts",
|
|
78
|
+
me: "/experts/me",
|
|
79
|
+
availability: (id) => `/experts/${id}/availability`,
|
|
80
|
+
meAvailability: "/experts/me/availability",
|
|
81
|
+
meAvailabilityExceptions: "/experts/me/availability-exceptions"
|
|
82
|
+
},
|
|
83
|
+
// Notifications
|
|
84
|
+
notifications: {
|
|
85
|
+
me: "/notifications/me",
|
|
86
|
+
meReadAll: "/notifications/me/read-all"
|
|
87
|
+
},
|
|
88
|
+
// Activities
|
|
89
|
+
activities: {
|
|
90
|
+
me: "/activities/me"
|
|
91
|
+
},
|
|
92
|
+
// Media
|
|
93
|
+
media: {
|
|
94
|
+
upload: "/media",
|
|
95
|
+
delete: (id) => `/media/${id}`
|
|
96
|
+
},
|
|
97
|
+
// Admin
|
|
98
|
+
admin: {
|
|
99
|
+
summary: "/admin/summary",
|
|
100
|
+
gym: "/admin/gym",
|
|
101
|
+
members: "/admin/members",
|
|
102
|
+
createMember: "/admin/members",
|
|
103
|
+
rewards: "/admin/rewards",
|
|
104
|
+
createReward: "/admin/rewards",
|
|
105
|
+
rewardById: (id) => `/admin/rewards/${id}`,
|
|
106
|
+
staff: "/admin/staff",
|
|
107
|
+
createStaff: "/admin/staff",
|
|
108
|
+
staffByUserId: (userId) => `/admin/staff/${userId}`,
|
|
109
|
+
staffDisable: (userId) => `/admin/staff/${userId}/disable`,
|
|
110
|
+
staffEnable: (userId) => `/admin/staff/${userId}/enable`,
|
|
111
|
+
experts: "/admin/experts",
|
|
112
|
+
createExpert: "/admin/experts",
|
|
113
|
+
expertByUserId: (userId) => `/admin/experts/${userId}`,
|
|
114
|
+
expertDisable: (userId) => `/admin/experts/${userId}/disable`,
|
|
115
|
+
expertEnable: (userId) => `/admin/experts/${userId}/enable`
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
// src/api-routes.ts
|
|
120
|
+
function defineRoute(def) {
|
|
121
|
+
return def;
|
|
122
|
+
}
|
|
123
|
+
var auth = {
|
|
124
|
+
register: defineRoute({
|
|
125
|
+
method: "POST",
|
|
126
|
+
path: "/auth/register"
|
|
127
|
+
}),
|
|
128
|
+
login: defineRoute({
|
|
129
|
+
method: "POST",
|
|
130
|
+
path: "/auth/login"
|
|
131
|
+
}),
|
|
132
|
+
deleteMe: defineRoute({
|
|
133
|
+
method: "DELETE",
|
|
134
|
+
path: "/auth/me"
|
|
135
|
+
})
|
|
136
|
+
};
|
|
137
|
+
var members = {
|
|
138
|
+
join: defineRoute({
|
|
139
|
+
method: "POST",
|
|
140
|
+
path: "/members/join"
|
|
141
|
+
}),
|
|
142
|
+
me: defineRoute({
|
|
143
|
+
method: "GET",
|
|
144
|
+
path: "/members/me"
|
|
145
|
+
}),
|
|
146
|
+
updateMe: defineRoute({
|
|
147
|
+
method: "PATCH",
|
|
148
|
+
path: "/members/me"
|
|
149
|
+
}),
|
|
150
|
+
meStats: defineRoute({
|
|
151
|
+
method: "GET",
|
|
152
|
+
path: "/members/me/stats"
|
|
153
|
+
})
|
|
154
|
+
};
|
|
155
|
+
var checkIns = {
|
|
156
|
+
create: defineRoute({
|
|
157
|
+
method: "POST",
|
|
158
|
+
path: "/check-ins"
|
|
159
|
+
})
|
|
160
|
+
};
|
|
161
|
+
var leaderboards = {
|
|
162
|
+
list: defineRoute({
|
|
163
|
+
method: "GET",
|
|
164
|
+
path: "/leaderboards"
|
|
165
|
+
}),
|
|
166
|
+
create: defineRoute({
|
|
167
|
+
method: "POST",
|
|
168
|
+
path: "/leaderboards"
|
|
169
|
+
}),
|
|
170
|
+
submitEntry: defineRoute({
|
|
171
|
+
method: "POST",
|
|
172
|
+
path: "/leaderboards/entries"
|
|
173
|
+
}),
|
|
174
|
+
reviewEntry: defineRoute({
|
|
175
|
+
method: "POST",
|
|
176
|
+
path: "/leaderboards/entries/review"
|
|
177
|
+
})
|
|
178
|
+
};
|
|
179
|
+
var challenges = {
|
|
180
|
+
create: defineRoute({
|
|
181
|
+
method: "POST",
|
|
182
|
+
path: "/challenges"
|
|
183
|
+
}),
|
|
184
|
+
createOccurrence: defineRoute({
|
|
185
|
+
method: "POST",
|
|
186
|
+
path: "/challenges/occurrences"
|
|
187
|
+
}),
|
|
188
|
+
meActive: defineRoute({
|
|
189
|
+
method: "GET",
|
|
190
|
+
path: "/challenges/me/active"
|
|
191
|
+
}),
|
|
192
|
+
join: defineRoute({
|
|
193
|
+
method: "POST",
|
|
194
|
+
path: "/challenges/join"
|
|
195
|
+
}),
|
|
196
|
+
complete: defineRoute({
|
|
197
|
+
method: "POST",
|
|
198
|
+
path: "/challenges/complete"
|
|
199
|
+
})
|
|
200
|
+
};
|
|
201
|
+
var bookings = {
|
|
202
|
+
create: defineRoute({
|
|
203
|
+
method: "POST",
|
|
204
|
+
path: "/bookings"
|
|
205
|
+
}),
|
|
206
|
+
updateStatus: defineRoute({
|
|
207
|
+
method: "POST",
|
|
208
|
+
path: "/bookings/status"
|
|
209
|
+
}),
|
|
210
|
+
meMember: defineRoute({
|
|
211
|
+
method: "GET",
|
|
212
|
+
path: "/bookings/me/member"
|
|
213
|
+
}),
|
|
214
|
+
meExpert: defineRoute({
|
|
215
|
+
method: "GET",
|
|
216
|
+
path: "/bookings/me/expert"
|
|
217
|
+
})
|
|
218
|
+
};
|
|
219
|
+
var rewards = {
|
|
220
|
+
list: defineRoute({
|
|
221
|
+
method: "GET",
|
|
222
|
+
path: "/rewards"
|
|
223
|
+
}),
|
|
224
|
+
me: defineRoute({
|
|
225
|
+
method: "GET",
|
|
226
|
+
path: "/rewards/me"
|
|
227
|
+
})
|
|
228
|
+
};
|
|
229
|
+
var experts = {
|
|
230
|
+
list: defineRoute({
|
|
231
|
+
method: "GET",
|
|
232
|
+
path: "/experts"
|
|
233
|
+
}),
|
|
234
|
+
me: defineRoute({
|
|
235
|
+
method: "GET",
|
|
236
|
+
path: "/experts/me"
|
|
237
|
+
}),
|
|
238
|
+
availability: (id) => defineRoute({
|
|
239
|
+
method: "GET",
|
|
240
|
+
path: `/experts/${id}/availability`
|
|
241
|
+
}),
|
|
242
|
+
meAvailability: defineRoute({
|
|
243
|
+
method: "POST",
|
|
244
|
+
path: "/experts/me/availability"
|
|
245
|
+
}),
|
|
246
|
+
meAvailabilityExceptions: defineRoute({
|
|
247
|
+
method: "POST",
|
|
248
|
+
path: "/experts/me/availability-exceptions"
|
|
249
|
+
})
|
|
250
|
+
};
|
|
251
|
+
var notifications = {
|
|
252
|
+
me: defineRoute({
|
|
253
|
+
method: "GET",
|
|
254
|
+
path: "/notifications/me"
|
|
255
|
+
}),
|
|
256
|
+
meReadAll: defineRoute({
|
|
257
|
+
method: "POST",
|
|
258
|
+
path: "/notifications/me/read-all"
|
|
259
|
+
})
|
|
260
|
+
};
|
|
261
|
+
var activities = {
|
|
262
|
+
me: defineRoute({
|
|
263
|
+
method: "GET",
|
|
264
|
+
path: "/activities/me"
|
|
265
|
+
})
|
|
266
|
+
};
|
|
267
|
+
var media = {
|
|
268
|
+
upload: defineRoute({
|
|
269
|
+
method: "POST",
|
|
270
|
+
path: "/media"
|
|
271
|
+
}),
|
|
272
|
+
delete: (id) => defineRoute({
|
|
273
|
+
method: "DELETE",
|
|
274
|
+
path: `/media/${id}`
|
|
275
|
+
})
|
|
276
|
+
};
|
|
277
|
+
var admin = {
|
|
278
|
+
summary: defineRoute({
|
|
279
|
+
method: "GET",
|
|
280
|
+
path: "/admin/summary"
|
|
281
|
+
}),
|
|
282
|
+
gym: defineRoute({
|
|
283
|
+
method: "GET",
|
|
284
|
+
path: "/admin/gym"
|
|
285
|
+
}),
|
|
286
|
+
updateGym: defineRoute({
|
|
287
|
+
method: "PATCH",
|
|
288
|
+
path: "/admin/gym"
|
|
289
|
+
}),
|
|
290
|
+
members: defineRoute({
|
|
291
|
+
method: "GET",
|
|
292
|
+
path: "/admin/members"
|
|
293
|
+
}),
|
|
294
|
+
createMember: defineRoute({
|
|
295
|
+
method: "POST",
|
|
296
|
+
path: "/admin/members"
|
|
297
|
+
}),
|
|
298
|
+
rewards: defineRoute({
|
|
299
|
+
method: "GET",
|
|
300
|
+
path: "/admin/rewards"
|
|
301
|
+
}),
|
|
302
|
+
createReward: defineRoute({
|
|
303
|
+
method: "POST",
|
|
304
|
+
path: "/admin/rewards"
|
|
305
|
+
}),
|
|
306
|
+
updateReward: (id) => defineRoute({
|
|
307
|
+
method: "PATCH",
|
|
308
|
+
path: `/admin/rewards/${id}`
|
|
309
|
+
}),
|
|
310
|
+
deleteReward: (id) => defineRoute({
|
|
311
|
+
method: "DELETE",
|
|
312
|
+
path: `/admin/rewards/${id}`
|
|
313
|
+
}),
|
|
314
|
+
staff: defineRoute({
|
|
315
|
+
method: "GET",
|
|
316
|
+
path: "/admin/staff"
|
|
317
|
+
}),
|
|
318
|
+
createStaff: defineRoute({
|
|
319
|
+
method: "POST",
|
|
320
|
+
path: "/admin/staff"
|
|
321
|
+
}),
|
|
322
|
+
deleteStaff: (userId) => defineRoute({
|
|
323
|
+
method: "DELETE",
|
|
324
|
+
path: `/admin/staff/${userId}`
|
|
325
|
+
}),
|
|
326
|
+
disableStaff: (userId) => defineRoute({
|
|
327
|
+
method: "PATCH",
|
|
328
|
+
path: `/admin/staff/${userId}/disable`
|
|
329
|
+
}),
|
|
330
|
+
enableStaff: (userId) => defineRoute({
|
|
331
|
+
method: "PATCH",
|
|
332
|
+
path: `/admin/staff/${userId}/enable`
|
|
333
|
+
}),
|
|
334
|
+
experts: defineRoute({
|
|
335
|
+
method: "GET",
|
|
336
|
+
path: "/admin/experts"
|
|
337
|
+
}),
|
|
338
|
+
createExpert: defineRoute({
|
|
339
|
+
method: "POST",
|
|
340
|
+
path: "/admin/experts"
|
|
341
|
+
}),
|
|
342
|
+
deleteExpert: (userId) => defineRoute({
|
|
343
|
+
method: "DELETE",
|
|
344
|
+
path: `/admin/experts/${userId}`
|
|
345
|
+
}),
|
|
346
|
+
disableExpert: (userId) => defineRoute({
|
|
347
|
+
method: "PATCH",
|
|
348
|
+
path: `/admin/experts/${userId}/disable`
|
|
349
|
+
}),
|
|
350
|
+
enableExpert: (userId) => defineRoute({
|
|
351
|
+
method: "PATCH",
|
|
352
|
+
path: `/admin/experts/${userId}/enable`
|
|
353
|
+
})
|
|
354
|
+
};
|
|
355
|
+
var apiRoutes = {
|
|
356
|
+
auth,
|
|
357
|
+
members,
|
|
358
|
+
checkIns,
|
|
359
|
+
leaderboards,
|
|
360
|
+
challenges,
|
|
361
|
+
bookings,
|
|
362
|
+
rewards,
|
|
363
|
+
experts,
|
|
364
|
+
notifications,
|
|
365
|
+
activities,
|
|
366
|
+
media,
|
|
367
|
+
admin
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
// src/api-client.ts
|
|
371
|
+
function buildUrl(baseUrl, path) {
|
|
372
|
+
const base = baseUrl.replace(/\/$/, "");
|
|
373
|
+
const p = path.startsWith("/") ? path : `/${path}`;
|
|
374
|
+
return base ? `${base}${p}` : p;
|
|
375
|
+
}
|
|
376
|
+
function request(client, baseUrl, route, body) {
|
|
377
|
+
const url = buildUrl(baseUrl, route.path);
|
|
378
|
+
const config = {
|
|
379
|
+
method: route.method,
|
|
380
|
+
url,
|
|
381
|
+
headers: { "Content-Type": "application/json" }
|
|
382
|
+
};
|
|
383
|
+
if (body !== void 0 && body !== null && ["POST", "PUT", "PATCH"].includes(route.method)) {
|
|
384
|
+
config.data = body;
|
|
385
|
+
}
|
|
386
|
+
return client.request(config).then((res) => res.data);
|
|
387
|
+
}
|
|
388
|
+
function createApi(client, baseUrl = "") {
|
|
389
|
+
return {
|
|
390
|
+
/**
|
|
391
|
+
* Execute a typed request. The route defines method + path; body and response types are inferred.
|
|
392
|
+
*/
|
|
393
|
+
request(route, body) {
|
|
394
|
+
return request(client, baseUrl, route, body);
|
|
395
|
+
}
|
|
396
|
+
};
|
|
397
|
+
}
|
|
27
398
|
export {
|
|
28
399
|
BookingStatus,
|
|
29
400
|
ChallengeVerificationType,
|
|
30
401
|
ExpertRole,
|
|
31
|
-
LeaderboardEntryStatus
|
|
402
|
+
LeaderboardEntryStatus,
|
|
403
|
+
ROUTES,
|
|
404
|
+
apiRoutes,
|
|
405
|
+
createApi,
|
|
406
|
+
request
|
|
32
407
|
};
|