@ipetsadmin/api-client 1.3.0 → 1.3.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 CHANGED
@@ -1,4 +1,4 @@
1
- import { RegisterRequest, IApiResponse, AuthSessionResponse, LoginRequest, OAuthGoogleStartResponse, OAuthGoogleCallbackRequest, RefreshRequest, LogoutRequest, VerifyEmailRequest, AuthUserResponse, PetResponse, CreatePetInput, TreatmentResponse, CreateTreatmentInput, UserProfileResponse, PatchUserProfileInput, HealthCheck } from '@ipetsadmin/contracts';
1
+ import { RegisterRequest, IApiResponse, AuthSessionResponse, LoginRequest, OAuthGoogleStartResponse, OAuthGoogleCallbackRequest, RefreshRequest, LogoutRequest, VerifyEmailRequest, AuthUserResponse, PetResponse, CreatePetInput, TreatmentResponse, CreateTreatmentInput, DoseResponse, CreateDoseInput, UserProfileResponse, PatchUserProfileInput, HealthCheck } from '@ipetsadmin/contracts';
2
2
 
3
3
  type HttpGet = <TResponse>(url: string, config?: unknown) => Promise<{
4
4
  data: TResponse;
@@ -30,11 +30,14 @@ declare function patchVerifyEmail(http: HttpClient, body: VerifyEmailRequest): P
30
30
 
31
31
  type PutPetDetailsBody = Partial<Omit<CreatePetInput, 'ownerId' | 'createdAt' | 'updatedAt'>>;
32
32
  type PostPetTreatmentRequestBody = Omit<CreateTreatmentInput, 'petId'> & Partial<Pick<CreateTreatmentInput, 'status'>>;
33
+ type PostPetTreatmentDoseBody = Omit<CreateDoseInput, 'treatmentId' | 'petId' | 'ownerId'> & Partial<Pick<CreateDoseInput, 'status'>>;
33
34
  declare function getPetDetails(http: HttpClient, accessToken: string, petId: string): Promise<IApiResponse<PetResponse>>;
34
35
  declare function putPetDetails(http: HttpClient, accessToken: string, petId: string, body: PutPetDetailsBody): Promise<IApiResponse<PetResponse>>;
35
36
  declare function getPetTreatments(http: HttpClient, accessToken: string, petId: string): Promise<IApiResponse<TreatmentResponse[]>>;
36
37
  declare function createPetTreatment(http: HttpClient, accessToken: string, petId: string, body: PostPetTreatmentRequestBody): Promise<IApiResponse<TreatmentResponse>>;
37
38
  declare function getPetTreatment(http: HttpClient, accessToken: string, petId: string, treatmentId: string): Promise<IApiResponse<TreatmentResponse>>;
39
+ declare function getPetTreatmentDoses(http: HttpClient, accessToken: string, petId: string, treatmentId: string): Promise<IApiResponse<DoseResponse[]>>;
40
+ declare function createPetTreatmentDose(http: HttpClient, accessToken: string, petId: string, treatmentId: string, body: PostPetTreatmentDoseBody): Promise<IApiResponse<DoseResponse>>;
38
41
 
39
42
  type PostUserPetRequestBody = Omit<CreatePetInput, 'ownerId' | 'createdAt' | 'updatedAt'>;
40
43
  declare function getUserProfile(http: HttpClient, accessToken: string): Promise<IApiResponse<UserProfileResponse>>;
@@ -71,8 +74,10 @@ interface ApiClient {
71
74
  readonly getTreatments: (accessToken: string, petId: string) => ReturnType<typeof getPetTreatments>;
72
75
  readonly createTreatment: (accessToken: string, petId: string, body: Parameters<typeof createPetTreatment>[3]) => ReturnType<typeof createPetTreatment>;
73
76
  readonly getTreatment: (accessToken: string, petId: string, treatmentId: string) => ReturnType<typeof getPetTreatment>;
77
+ readonly getTreatmentDoses: (accessToken: string, petId: string, treatmentId: string) => ReturnType<typeof getPetTreatmentDoses>;
78
+ readonly createTreatmentDose: (accessToken: string, petId: string, treatmentId: string, body: Parameters<typeof createPetTreatmentDose>[4]) => ReturnType<typeof createPetTreatmentDose>;
74
79
  };
75
80
  }
76
81
  declare function createApiClient(options: CreateApiClientOptions): ApiClient;
77
82
 
78
- export { type ApiClient, type CreateApiClientOptions, type HttpClient, type HttpGet, type HttpPatch, type HttpPost, type HttpPut, type PostPetTreatmentRequestBody, type PostUserPetRequestBody, type PutPetDetailsBody, createApiClient, createPetTreatment, createUserPet, fetchHealthCheck, getGoogleOAuthStart, getMe, getPetDetails, getPetTreatment, getPetTreatments, getUserPets, getUserProfile, patchUserProfile, patchVerifyEmail, postGoogleOAuthCallback, postLogin, postLogout, postRefresh, postRegister, putPetDetails };
83
+ export { type ApiClient, type CreateApiClientOptions, type HttpClient, type HttpGet, type HttpPatch, type HttpPost, type HttpPut, type PostPetTreatmentDoseBody, type PostPetTreatmentRequestBody, type PostUserPetRequestBody, type PutPetDetailsBody, createApiClient, createPetTreatment, createPetTreatmentDose, createUserPet, fetchHealthCheck, getGoogleOAuthStart, getMe, getPetDetails, getPetTreatment, getPetTreatmentDoses, getPetTreatments, getUserPets, getUserProfile, patchUserProfile, patchVerifyEmail, postGoogleOAuthCallback, postLogin, postLogout, postRefresh, postRegister, putPetDetails };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { RegisterRequest, IApiResponse, AuthSessionResponse, LoginRequest, OAuthGoogleStartResponse, OAuthGoogleCallbackRequest, RefreshRequest, LogoutRequest, VerifyEmailRequest, AuthUserResponse, PetResponse, CreatePetInput, TreatmentResponse, CreateTreatmentInput, UserProfileResponse, PatchUserProfileInput, HealthCheck } from '@ipetsadmin/contracts';
1
+ import { RegisterRequest, IApiResponse, AuthSessionResponse, LoginRequest, OAuthGoogleStartResponse, OAuthGoogleCallbackRequest, RefreshRequest, LogoutRequest, VerifyEmailRequest, AuthUserResponse, PetResponse, CreatePetInput, TreatmentResponse, CreateTreatmentInput, DoseResponse, CreateDoseInput, UserProfileResponse, PatchUserProfileInput, HealthCheck } from '@ipetsadmin/contracts';
2
2
 
3
3
  type HttpGet = <TResponse>(url: string, config?: unknown) => Promise<{
4
4
  data: TResponse;
@@ -30,11 +30,14 @@ declare function patchVerifyEmail(http: HttpClient, body: VerifyEmailRequest): P
30
30
 
31
31
  type PutPetDetailsBody = Partial<Omit<CreatePetInput, 'ownerId' | 'createdAt' | 'updatedAt'>>;
32
32
  type PostPetTreatmentRequestBody = Omit<CreateTreatmentInput, 'petId'> & Partial<Pick<CreateTreatmentInput, 'status'>>;
33
+ type PostPetTreatmentDoseBody = Omit<CreateDoseInput, 'treatmentId' | 'petId' | 'ownerId'> & Partial<Pick<CreateDoseInput, 'status'>>;
33
34
  declare function getPetDetails(http: HttpClient, accessToken: string, petId: string): Promise<IApiResponse<PetResponse>>;
34
35
  declare function putPetDetails(http: HttpClient, accessToken: string, petId: string, body: PutPetDetailsBody): Promise<IApiResponse<PetResponse>>;
35
36
  declare function getPetTreatments(http: HttpClient, accessToken: string, petId: string): Promise<IApiResponse<TreatmentResponse[]>>;
36
37
  declare function createPetTreatment(http: HttpClient, accessToken: string, petId: string, body: PostPetTreatmentRequestBody): Promise<IApiResponse<TreatmentResponse>>;
37
38
  declare function getPetTreatment(http: HttpClient, accessToken: string, petId: string, treatmentId: string): Promise<IApiResponse<TreatmentResponse>>;
39
+ declare function getPetTreatmentDoses(http: HttpClient, accessToken: string, petId: string, treatmentId: string): Promise<IApiResponse<DoseResponse[]>>;
40
+ declare function createPetTreatmentDose(http: HttpClient, accessToken: string, petId: string, treatmentId: string, body: PostPetTreatmentDoseBody): Promise<IApiResponse<DoseResponse>>;
38
41
 
39
42
  type PostUserPetRequestBody = Omit<CreatePetInput, 'ownerId' | 'createdAt' | 'updatedAt'>;
40
43
  declare function getUserProfile(http: HttpClient, accessToken: string): Promise<IApiResponse<UserProfileResponse>>;
@@ -71,8 +74,10 @@ interface ApiClient {
71
74
  readonly getTreatments: (accessToken: string, petId: string) => ReturnType<typeof getPetTreatments>;
72
75
  readonly createTreatment: (accessToken: string, petId: string, body: Parameters<typeof createPetTreatment>[3]) => ReturnType<typeof createPetTreatment>;
73
76
  readonly getTreatment: (accessToken: string, petId: string, treatmentId: string) => ReturnType<typeof getPetTreatment>;
77
+ readonly getTreatmentDoses: (accessToken: string, petId: string, treatmentId: string) => ReturnType<typeof getPetTreatmentDoses>;
78
+ readonly createTreatmentDose: (accessToken: string, petId: string, treatmentId: string, body: Parameters<typeof createPetTreatmentDose>[4]) => ReturnType<typeof createPetTreatmentDose>;
74
79
  };
75
80
  }
76
81
  declare function createApiClient(options: CreateApiClientOptions): ApiClient;
77
82
 
78
- export { type ApiClient, type CreateApiClientOptions, type HttpClient, type HttpGet, type HttpPatch, type HttpPost, type HttpPut, type PostPetTreatmentRequestBody, type PostUserPetRequestBody, type PutPetDetailsBody, createApiClient, createPetTreatment, createUserPet, fetchHealthCheck, getGoogleOAuthStart, getMe, getPetDetails, getPetTreatment, getPetTreatments, getUserPets, getUserProfile, patchUserProfile, patchVerifyEmail, postGoogleOAuthCallback, postLogin, postLogout, postRefresh, postRegister, putPetDetails };
83
+ export { type ApiClient, type CreateApiClientOptions, type HttpClient, type HttpGet, type HttpPatch, type HttpPost, type HttpPut, type PostPetTreatmentDoseBody, type PostPetTreatmentRequestBody, type PostUserPetRequestBody, type PutPetDetailsBody, createApiClient, createPetTreatment, createPetTreatmentDose, createUserPet, fetchHealthCheck, getGoogleOAuthStart, getMe, getPetDetails, getPetTreatment, getPetTreatmentDoses, getPetTreatments, getUserPets, getUserProfile, patchUserProfile, patchVerifyEmail, postGoogleOAuthCallback, postLogin, postLogout, postRefresh, postRegister, putPetDetails };
package/dist/index.js CHANGED
@@ -100,6 +100,25 @@ async function getPetTreatment(http, accessToken, petId, treatmentId) {
100
100
  );
101
101
  return data;
102
102
  }
103
+ async function getPetTreatmentDoses(http, accessToken, petId, treatmentId) {
104
+ const { data } = await http.get(
105
+ `${PETS_BASE}/${petId}/treatments/${treatmentId}/doses`,
106
+ {
107
+ headers: { Authorization: `Bearer ${accessToken}` }
108
+ }
109
+ );
110
+ return data;
111
+ }
112
+ async function createPetTreatmentDose(http, accessToken, petId, treatmentId, body) {
113
+ const { data } = await http.post(
114
+ `${PETS_BASE}/${petId}/treatments/${treatmentId}/doses`,
115
+ body,
116
+ {
117
+ headers: { Authorization: `Bearer ${accessToken}` }
118
+ }
119
+ );
120
+ return data;
121
+ }
103
122
 
104
123
  // src/endpoints/user.ts
105
124
  var USERS_BASE = "/api/v1/users";
@@ -169,19 +188,23 @@ function createApiClient(options) {
169
188
  update: (accessToken, petId, body) => putPetDetails(http, accessToken, petId, body),
170
189
  getTreatments: (accessToken, petId) => getPetTreatments(http, accessToken, petId),
171
190
  createTreatment: (accessToken, petId, body) => createPetTreatment(http, accessToken, petId, body),
172
- getTreatment: (accessToken, petId, treatmentId) => getPetTreatment(http, accessToken, petId, treatmentId)
191
+ getTreatment: (accessToken, petId, treatmentId) => getPetTreatment(http, accessToken, petId, treatmentId),
192
+ getTreatmentDoses: (accessToken, petId, treatmentId) => getPetTreatmentDoses(http, accessToken, petId, treatmentId),
193
+ createTreatmentDose: (accessToken, petId, treatmentId, body) => createPetTreatmentDose(http, accessToken, petId, treatmentId, body)
173
194
  }
174
195
  };
175
196
  }
176
197
 
177
198
  exports.createApiClient = createApiClient;
178
199
  exports.createPetTreatment = createPetTreatment;
200
+ exports.createPetTreatmentDose = createPetTreatmentDose;
179
201
  exports.createUserPet = createUserPet;
180
202
  exports.fetchHealthCheck = fetchHealthCheck;
181
203
  exports.getGoogleOAuthStart = getGoogleOAuthStart;
182
204
  exports.getMe = getMe;
183
205
  exports.getPetDetails = getPetDetails;
184
206
  exports.getPetTreatment = getPetTreatment;
207
+ exports.getPetTreatmentDoses = getPetTreatmentDoses;
185
208
  exports.getPetTreatments = getPetTreatments;
186
209
  exports.getUserPets = getUserPets;
187
210
  exports.getUserProfile = getUserProfile;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/endpoints/auth.ts","../src/endpoints/pet.ts","../src/endpoints/user.ts","../src/endpoints/health-check.ts","../src/create-api-client.ts"],"names":[],"mappings":";;;AAeA,IAAM,SAAA,GAAY,cAAA;AAKlB,eAAsB,YAAA,CACpB,MACA,IAAA,EAC4C;AAC5C,EAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,IAAA,CAAK,IAAA;AAAA,IAC1B,GAAG,SAAS,CAAA,SAAA,CAAA;AAAA,IACZ;AAAA,GACF;AACA,EAAA,OAAO,IAAA;AACT;AAKA,eAAsB,SAAA,CACpB,MACA,IAAA,EAC4C;AAC5C,EAAA,MAAM,EAAE,I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IAAA,EAAM,aAAa,KAAK,CAAA;AAAA,MAChF,eAAA,EAAiB,CAAC,WAAA,EAAa,KAAA,EAAO,SACpC,kBAAA,CAAmB,IAAA,EAAM,WAAA,EAAa,KAAA,EAAO,IAAI,CAAA;AAAA,MACnD,YAAA,EAAc,CAAC,WAAA,EAAa,KAAA,EAAO,gBACjC,eAAA,CAAgB,IAAA,EAAM,WAAA,EAAa,KAAA,EAAO,WAAW;AAAA;AACzD,GACF;AACF","file":"index.js","sourcesContent":["import type {\n AuthSessionResponse,\n AuthUserResponse,\n IApiResponse,\n LoginRequest,\n LogoutRequest,\n OAuthGoogleCallbackRequest,\n OAuthGoogleStartResponse,\n RefreshRequest,\n RegisterRequest,\n VerifyEmailRequest,\n} from '@ipetsadmin/contracts';\n\nimport type { HttpClient } from '../http-client';\n\nconst AUTH_BASE = '/api/v1/auth' as const;\n\n/**\n * POST /api/v1/auth/register\n */\nexport async function postRegister(\n http: HttpClient,\n body: RegisterRequest,\n): Promise<IApiResponse<AuthSessionResponse>> {\n const { data } = await http.post<IApiResponse<AuthSessionResponse>, RegisterRequest>(\n `${AUTH_BASE}/register`,\n body,\n );\n return data;\n}\n\n/**\n * POST /api/v1/auth/login\n */\nexport async function postLogin(\n http: HttpClient,\n body: LoginRequest,\n): Promise<IApiResponse<AuthSessionResponse>> {\n const { data } = await http.post<IApiResponse<AuthSessionResponse>, LoginRequest>(\n `${AUTH_BASE}/login`,\n body,\n );\n return data;\n}\n\n/**\n * GET /api/v1/auth/oauth/google/start?redirectUri=...\n */\nexport async function getGoogleOAuthStart(\n http: HttpClient,\n redirectUri: string,\n): Promise<IApiResponse<OAuthGoogleStartResponse>> {\n const q = new URLSearchParams({ redirectUri });\n const { data } = await http.get<IApiResponse<OAuthGoogleStartResponse>>(\n `${AUTH_BASE}/oauth/google/start?${q.toString()}`,\n );\n return data;\n}\n\n/**\n * POST /api/v1/auth/oauth/google/callback\n */\nexport async function postGoogleOAuthCallback(\n http: HttpClient,\n body: OAuthGoogleCallbackRequest,\n): Promise<IApiResponse<AuthSessionResponse>> {\n const { data } = await http.post<IApiResponse<AuthSessionResponse>, OAuthGoogleCallbackRequest>(\n `${AUTH_BASE}/oauth/google/callback`,\n body,\n );\n return data;\n}\n\n/**\n * POST /api/v1/auth/refresh\n */\nexport async function postRefresh(\n http: HttpClient,\n body: RefreshRequest,\n): Promise<IApiResponse<AuthSessionResponse>> {\n const { data } = await http.post<IApiResponse<AuthSessionResponse>, RefreshRequest>(\n `${AUTH_BASE}/refresh`,\n body,\n );\n return data;\n}\n\n/**\n * POST /api/v1/auth/logout — 204 No Content (no JSON body).\n */\nexport async function postLogout(http: HttpClient, body: LogoutRequest): Promise<void> {\n await http.post<undefined, LogoutRequest>(`${AUTH_BASE}/logout`, body);\n}\n\n/**\n * GET /api/v1/auth/me — requires `Authorization: Bearer <accessToken>`.\n */\nexport async function getMe(\n http: HttpClient,\n accessToken: string,\n): Promise<IApiResponse<AuthUserResponse>> {\n const { data } = await http.get<IApiResponse<AuthUserResponse>>(`${AUTH_BASE}/me`, {\n headers: { Authorization: `Bearer ${accessToken}` },\n });\n return data;\n}\n\n/**\n * PATCH /api/v1/auth/verify-email\n */\nexport async function patchVerifyEmail(\n http: HttpClient,\n body: VerifyEmailRequest,\n): Promise<IApiResponse<void>> {\n const { data } = await http.patch<IApiResponse<void>, VerifyEmailRequest>(\n `${AUTH_BASE}/verify-email`,\n body,\n );\n return data;\n}\n","import type {\n CreateTreatmentInput,\n IApiResponse,\n PetResponse,\n TreatmentResponse,\n CreatePetInput,\n} from '@ipetsadmin/contracts';\n\nimport type { HttpClient } from '../http-client';\n\nconst PETS_BASE = '/api/v1/pets' as const;\n\n/** Body for PUT /api/v1/pets/:petId (partial update; excludes server-owned fields). */\nexport type PutPetDetailsBody = Partial<\n Omit<CreatePetInput, 'ownerId' | 'createdAt' | 'updatedAt'>\n>;\n\n/**\n * Same fields as creating a treatment without `petId` (provided in the URL). `status` may be omitted\n * (defaults on the server).\n */\nexport type PostPetTreatmentRequestBody = Omit<CreateTreatmentInput, 'petId'> &\n Partial<Pick<CreateTreatmentInput, 'status'>>;\n\n/**\n * GET /api/v1/pets/:petId — Bearer access token required.\n */\nexport async function getPetDetails(\n http: HttpClient,\n accessToken: string,\n petId: string,\n): Promise<IApiResponse<PetResponse>> {\n const { data } = await http.get<IApiResponse<PetResponse>>(`${PETS_BASE}/${petId}`, {\n headers: { Authorization: `Bearer ${accessToken}` },\n });\n return data;\n}\n\n/**\n * PUT /api/v1/pets/:petId — partial update; owner must match JWT user.\n */\nexport async function putPetDetails(\n http: HttpClient,\n accessToken: string,\n petId: string,\n body: PutPetDetailsBody,\n): Promise<IApiResponse<PetResponse>> {\n const { data } = await http.put<IApiResponse<PetResponse>, PutPetDetailsBody>(\n `${PETS_BASE}/${petId}`,\n body,\n {\n headers: { Authorization: `Bearer ${accessToken}` },\n },\n );\n return data;\n}\n\n/**\n * GET /api/v1/pets/:petId/treatments\n */\nexport async function getPetTreatments(\n http: HttpClient,\n accessToken: string,\n petId: string,\n): Promise<IApiResponse<TreatmentResponse[]>> {\n const { data } = await http.get<IApiResponse<TreatmentResponse[]>>(\n `${PETS_BASE}/${petId}/treatments`,\n {\n headers: { Authorization: `Bearer ${accessToken}` },\n },\n );\n return data;\n}\n\n/**\n * POST /api/v1/pets/:petId/treatments — 201 Created (`IApiResponse<TreatmentResponse>` body).\n */\nexport async function createPetTreatment(\n http: HttpClient,\n accessToken: string,\n petId: string,\n body: PostPetTreatmentRequestBody,\n): Promise<IApiResponse<TreatmentResponse>> {\n const { data } = await http.post<IApiResponse<TreatmentResponse>, PostPetTreatmentRequestBody>(\n `${PETS_BASE}/${petId}/treatments`,\n body,\n {\n headers: { Authorization: `Bearer ${accessToken}` },\n },\n );\n return data;\n}\n\n/**\n * GET /api/v1/pets/:petId/treatments/:treatmentId\n */\nexport async function getPetTreatment(\n http: HttpClient,\n accessToken: string,\n petId: string,\n treatmentId: string,\n): Promise<IApiResponse<TreatmentResponse>> {\n const { data } = await http.get<IApiResponse<TreatmentResponse>>(\n `${PETS_BASE}/${petId}/treatments/${treatmentId}`,\n {\n headers: { Authorization: `Bearer ${accessToken}` },\n },\n );\n return data;\n}\n","import type {\n CreatePetInput,\n IApiResponse,\n PatchUserProfileInput,\n PetResponse,\n UserProfileResponse,\n} from '@ipetsadmin/contracts';\n\nimport type { HttpClient } from '../http-client';\n\nconst USERS_BASE = '/api/v1/users' as const;\n\n/** Body for POST /users/:userId/pets (`ownerId` / timestamps come from the server). */\nexport type PostUserPetRequestBody = Omit<CreatePetInput, 'ownerId' | 'createdAt' | 'updatedAt'>;\n\n/**\n * GET /api/v1/users/me/profile — requires `Authorization: Bearer <accessToken>`.\n */\nexport async function getUserProfile(\n http: HttpClient,\n accessToken: string,\n): Promise<IApiResponse<UserProfileResponse>> {\n const { data } = await http.get<IApiResponse<UserProfileResponse>>(`${USERS_BASE}/me/profile`, {\n headers: { Authorization: `Bearer ${accessToken}` },\n });\n return data;\n}\n\n/**\n * GET /api/v1/users/:userId/pets — requires `Authorization: Bearer <accessToken>`.\n */\nexport async function getUserPets(\n http: HttpClient,\n accessToken: string,\n userId: string,\n): Promise<IApiResponse<PetResponse[]>> {\n const { data } = await http.get<IApiResponse<PetResponse[]>>(`${USERS_BASE}/${userId}/pets`, {\n headers: { Authorization: `Bearer ${accessToken}` },\n });\n return data;\n}\n\n/**\n * POST /api/v1/users/:userId/pets — requires `Authorization: Bearer <accessToken>`.\n */\nexport async function createUserPet(\n http: HttpClient,\n accessToken: string,\n userId: string,\n body: PostUserPetRequestBody,\n): Promise<IApiResponse<PetResponse>> {\n const { data } = await http.post<IApiResponse<PetResponse>, PostUserPetRequestBody>(\n `${USERS_BASE}/${userId}/pets`,\n body,\n {\n headers: { Authorization: `Bearer ${accessToken}` },\n },\n );\n return data;\n}\n\n/**\n * PATCH /api/v1/users/me/profile — requires `Authorization: Bearer <accessToken>`.\n * Body must not include `avatar` (API rejects unknown keys in strict mode).\n */\nexport async function patchUserProfile(\n http: HttpClient,\n accessToken: string,\n body: PatchUserProfileInput,\n): Promise<IApiResponse<UserProfileResponse>> {\n const { data } = await http.patch<IApiResponse<UserProfileResponse>, PatchUserProfileInput>(\n `${USERS_BASE}/me/profile`,\n body,\n {\n headers: { Authorization: `Bearer ${accessToken}` },\n },\n );\n return data;\n}\n","import type { IApiResponse, HealthCheck } from '@ipetsadmin/contracts';\nimport type { HttpClient } from '../http-client';\n\n/** Same path as `/api/${v1}/health-check` on the server when `v1` is the string `'v1'`. */\nconst HEALTH_CHECK_PATH = '/api/v1/health-check' as const;\n\n/**\n * GET /api/v1/health-check — server liveness.\n *\n * Returns the full JSON the server sends (`IApiResponse<HealthCheck>`).\n *\n * **Why not `data.data` here?** Adapters like Axios wrap the HTTP body in a property also\n * called `data`. That outer `data` is the entire `res.json(...)` object. The inner\n * `IApiResponse.data` is the `HealthCheck` payload — use `.data` on the **returned** value,\n * e.g. `(await fetchHealthCheck(http)).data`.\n */\nexport async function fetchHealthCheck(http: HttpClient): Promise<IApiResponse<HealthCheck>> {\n const { data: body } = await http.get<IApiResponse<HealthCheck>>(HEALTH_CHECK_PATH);\n\n return body;\n}\n","import {\n getGoogleOAuthStart,\n getMe,\n patchVerifyEmail,\n postGoogleOAuthCallback,\n postLogin,\n postLogout,\n postRefresh,\n postRegister,\n} from './endpoints/auth';\nimport {\n createPetTreatment,\n getPetDetails,\n getPetTreatment,\n getPetTreatments,\n putPetDetails,\n} from './endpoints/pet';\nimport { createUserPet, getUserPets, getUserProfile, patchUserProfile } from './endpoints/user';\nimport { fetchHealthCheck } from './endpoints/health-check';\nimport type { HttpClient } from './http-client';\n\nexport interface CreateApiClientOptions {\n /**\n * Preconfigured HTTP client (e.g. Axios instance with `baseURL` set).\n * Paths in this library are relative to that base (e.g. `/api/v1/...`).\n * `get`, `post`, `patch`, and `put` are required for all implemented routes.\n */\n readonly http: HttpClient;\n}\n\nexport interface ApiClient {\n readonly healthCheck: () => ReturnType<typeof fetchHealthCheck>;\n readonly auth: {\n readonly register: (\n body: Parameters<typeof postRegister>[1],\n ) => ReturnType<typeof postRegister>;\n readonly login: (body: Parameters<typeof postLogin>[1]) => ReturnType<typeof postLogin>;\n readonly getGoogleOAuthStart: (redirectUri: string) => ReturnType<typeof getGoogleOAuthStart>;\n readonly postGoogleOAuthCallback: (\n body: Parameters<typeof postGoogleOAuthCallback>[1],\n ) => ReturnType<typeof postGoogleOAuthCallback>;\n readonly refresh: (body: Parameters<typeof postRefresh>[1]) => ReturnType<typeof postRefresh>;\n readonly logout: (body: Parameters<typeof postLogout>[1]) => ReturnType<typeof postLogout>;\n readonly verifyEmail: (\n body: Parameters<typeof patchVerifyEmail>[1],\n ) => ReturnType<typeof patchVerifyEmail>;\n readonly me: (accessToken: string) => ReturnType<typeof getMe>;\n };\n readonly users: {\n readonly getProfile: (accessToken: string) => ReturnType<typeof getUserProfile>;\n readonly patchProfile: (\n accessToken: string,\n body: Parameters<typeof patchUserProfile>[2],\n ) => ReturnType<typeof patchUserProfile>;\n readonly getPets: (accessToken: string, userId: string) => ReturnType<typeof getUserPets>;\n readonly createPet: (\n accessToken: string,\n userId: string,\n body: Parameters<typeof createUserPet>[3],\n ) => ReturnType<typeof createUserPet>;\n };\n readonly pets: {\n readonly getById: (accessToken: string, petId: string) => ReturnType<typeof getPetDetails>;\n readonly update: (\n accessToken: string,\n petId: string,\n body: Parameters<typeof putPetDetails>[3],\n ) => ReturnType<typeof putPetDetails>;\n readonly getTreatments: (\n accessToken: string,\n petId: string,\n ) => ReturnType<typeof getPetTreatments>;\n readonly createTreatment: (\n accessToken: string,\n petId: string,\n body: Parameters<typeof createPetTreatment>[3],\n ) => ReturnType<typeof createPetTreatment>;\n readonly getTreatment: (\n accessToken: string,\n petId: string,\n treatmentId: string,\n ) => ReturnType<typeof getPetTreatment>;\n };\n}\n\n/**\n * Creates a typed API client backed by the provided HTTP implementation.\n */\nexport function createApiClient(options: CreateApiClientOptions): ApiClient {\n const { http } = options;\n\n return {\n healthCheck: () => fetchHealthCheck(http),\n auth: {\n register: (body) => postRegister(http, body),\n login: (body) => postLogin(http, body),\n getGoogleOAuthStart: (redirectUri) => getGoogleOAuthStart(http, redirectUri),\n postGoogleOAuthCallback: (body) => postGoogleOAuthCallback(http, body),\n refresh: (body) => postRefresh(http, body),\n logout: (body) => postLogout(http, body),\n verifyEmail: (body) => patchVerifyEmail(http, body),\n me: (accessToken) => getMe(http, accessToken),\n },\n users: {\n getProfile: (accessToken) => getUserProfile(http, accessToken),\n patchProfile: (accessToken, body) => patchUserProfile(http, accessToken, body),\n getPets: (accessToken, userId) => getUserPets(http, accessToken, userId),\n createPet: (accessToken, userId, body) => createUserPet(http, accessToken, userId, body),\n },\n pets: {\n getById: (accessToken, petId) => getPetDetails(http, accessToken, petId),\n update: (accessToken, petId, body) => putPetDetails(http, accessToken, petId, body),\n getTreatments: (accessToken, petId) => getPetTreatments(http, accessToken, petId),\n createTreatment: (accessToken, petId, body) =>\n createPetTreatment(http, accessToken, petId, body),\n getTreatment: (accessToken, petId, treatmentId) =>\n getPetTreatment(http, accessToken, petId, treatmentId),\n },\n };\n}\n"]}
1
+ {"version":3,"sources":["../src/endpoints/auth.ts","../src/endpoints/pet.ts","../src/endpoints/user.ts","../src/endpoints/health-check.ts","../src/create-api-client.ts"],"names":[],"mappings":";;;AAeA,IAAM,SAAA,GAAY,cAAA;AAKlB,eAAsB,YAAA,CACpB,MACA,IAAA,EAC4C;AAC5C,EAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,IAAA,CAAK,IAAA;AAAA,IAC1B,GAAG,SAAS,CAAA,SAAA,CAAA;AAAA,IACZ;AAAA,GACF;AACA,EAAA,OAAO,IAAA;AACT;AAKA,eAAsB,SAAA,CACpB,MACA,IAAA,EAC4C;AAC5C,EAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,IAAA,CAAK,IAAA;AAAA,IAC1B,GAAG,SAAS,CAAA,MAAA,CAAA;AAAA,IACZ;AAAA,GACF;AACA,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ponse,\n AuthUserResponse,\n IApiResponse,\n LoginRequest,\n LogoutRequest,\n OAuthGoogleCallbackRequest,\n OAuthGoogleStartResponse,\n RefreshRequest,\n RegisterRequest,\n VerifyEmailRequest,\n} from '@ipetsadmin/contracts';\n\nimport type { HttpClient } from '../http-client';\n\nconst AUTH_BASE = '/api/v1/auth' as const;\n\n/**\n * POST /api/v1/auth/register\n */\nexport async function postRegister(\n http: HttpClient,\n body: RegisterRequest,\n): Promise<IApiResponse<AuthSessionResponse>> {\n const { data } = await http.post<IApiResponse<AuthSessionResponse>, RegisterRequest>(\n `${AUTH_BASE}/register`,\n body,\n );\n return data;\n}\n\n/**\n * POST /api/v1/auth/login\n */\nexport async function postLogin(\n http: HttpClient,\n body: LoginRequest,\n): Promise<IApiResponse<AuthSessionResponse>> {\n const { data } = await http.post<IApiResponse<AuthSessionResponse>, LoginRequest>(\n `${AUTH_BASE}/login`,\n body,\n );\n return data;\n}\n\n/**\n * GET /api/v1/auth/oauth/google/start?redirectUri=...\n */\nexport async function getGoogleOAuthStart(\n http: HttpClient,\n redirectUri: string,\n): Promise<IApiResponse<OAuthGoogleStartResponse>> {\n const q = new URLSearchParams({ redirectUri });\n const { data } = await http.get<IApiResponse<OAuthGoogleStartResponse>>(\n `${AUTH_BASE}/oauth/google/start?${q.toString()}`,\n );\n return data;\n}\n\n/**\n * POST /api/v1/auth/oauth/google/callback\n */\nexport async function postGoogleOAuthCallback(\n http: HttpClient,\n body: OAuthGoogleCallbackRequest,\n): Promise<IApiResponse<AuthSessionResponse>> {\n const { data } = await http.post<IApiResponse<AuthSessionResponse>, OAuthGoogleCallbackRequest>(\n `${AUTH_BASE}/oauth/google/callback`,\n body,\n );\n return data;\n}\n\n/**\n * POST /api/v1/auth/refresh\n */\nexport async function postRefresh(\n http: HttpClient,\n body: RefreshRequest,\n): Promise<IApiResponse<AuthSessionResponse>> {\n const { data } = await http.post<IApiResponse<AuthSessionResponse>, RefreshRequest>(\n `${AUTH_BASE}/refresh`,\n body,\n );\n return data;\n}\n\n/**\n * POST /api/v1/auth/logout — 204 No Content (no JSON body).\n */\nexport async function postLogout(http: HttpClient, body: LogoutRequest): Promise<void> {\n await http.post<undefined, LogoutRequest>(`${AUTH_BASE}/logout`, body);\n}\n\n/**\n * GET /api/v1/auth/me — requires `Authorization: Bearer <accessToken>`.\n */\nexport async function getMe(\n http: HttpClient,\n accessToken: string,\n): Promise<IApiResponse<AuthUserResponse>> {\n const { data } = await http.get<IApiResponse<AuthUserResponse>>(`${AUTH_BASE}/me`, {\n headers: { Authorization: `Bearer ${accessToken}` },\n });\n return data;\n}\n\n/**\n * PATCH /api/v1/auth/verify-email\n */\nexport async function patchVerifyEmail(\n http: HttpClient,\n body: VerifyEmailRequest,\n): Promise<IApiResponse<void>> {\n const { data } = await http.patch<IApiResponse<void>, VerifyEmailRequest>(\n `${AUTH_BASE}/verify-email`,\n body,\n );\n return data;\n}\n","import type {\n CreateDoseInput,\n CreatePetInput,\n CreateTreatmentInput,\n DoseResponse,\n IApiResponse,\n PetResponse,\n TreatmentResponse,\n} from '@ipetsadmin/contracts';\n\nimport type { HttpClient } from '../http-client';\n\nconst PETS_BASE = '/api/v1/pets' as const;\n\n/** Body for PUT /api/v1/pets/:petId (partial update; excludes server-owned fields). */\nexport type PutPetDetailsBody = Partial<\n Omit<CreatePetInput, 'ownerId' | 'createdAt' | 'updatedAt'>\n>;\n\n/**\n * Same fields as creating a treatment without `petId` (provided in the URL). `status` may be omitted\n * (defaults on the server).\n */\nexport type PostPetTreatmentRequestBody = Omit<CreateTreatmentInput, 'petId'> &\n Partial<Pick<CreateTreatmentInput, 'status'>>;\n\n/**\n * POST .../treatments/:treatmentId/doses — `treatmentId`, `petId`, and `ownerId` are not sent in JSON.\n */\nexport type PostPetTreatmentDoseBody = Omit<CreateDoseInput, 'treatmentId' | 'petId' | 'ownerId'> &\n Partial<Pick<CreateDoseInput, 'status'>>;\n\n/**\n * GET /api/v1/pets/:petId — Bearer access token required.\n */\nexport async function getPetDetails(\n http: HttpClient,\n accessToken: string,\n petId: string,\n): Promise<IApiResponse<PetResponse>> {\n const { data } = await http.get<IApiResponse<PetResponse>>(`${PETS_BASE}/${petId}`, {\n headers: { Authorization: `Bearer ${accessToken}` },\n });\n return data;\n}\n\n/**\n * PUT /api/v1/pets/:petId — partial update; owner must match JWT user.\n */\nexport async function putPetDetails(\n http: HttpClient,\n accessToken: string,\n petId: string,\n body: PutPetDetailsBody,\n): Promise<IApiResponse<PetResponse>> {\n const { data } = await http.put<IApiResponse<PetResponse>, PutPetDetailsBody>(\n `${PETS_BASE}/${petId}`,\n body,\n {\n headers: { Authorization: `Bearer ${accessToken}` },\n },\n );\n return data;\n}\n\n/**\n * GET /api/v1/pets/:petId/treatments\n */\nexport async function getPetTreatments(\n http: HttpClient,\n accessToken: string,\n petId: string,\n): Promise<IApiResponse<TreatmentResponse[]>> {\n const { data } = await http.get<IApiResponse<TreatmentResponse[]>>(\n `${PETS_BASE}/${petId}/treatments`,\n {\n headers: { Authorization: `Bearer ${accessToken}` },\n },\n );\n return data;\n}\n\n/**\n * POST /api/v1/pets/:petId/treatments — 201 Created (`IApiResponse<TreatmentResponse>` body).\n */\nexport async function createPetTreatment(\n http: HttpClient,\n accessToken: string,\n petId: string,\n body: PostPetTreatmentRequestBody,\n): Promise<IApiResponse<TreatmentResponse>> {\n const { data } = await http.post<IApiResponse<TreatmentResponse>, PostPetTreatmentRequestBody>(\n `${PETS_BASE}/${petId}/treatments`,\n body,\n {\n headers: { Authorization: `Bearer ${accessToken}` },\n },\n );\n return data;\n}\n\n/**\n * GET /api/v1/pets/:petId/treatments/:treatmentId\n */\nexport async function getPetTreatment(\n http: HttpClient,\n accessToken: string,\n petId: string,\n treatmentId: string,\n): Promise<IApiResponse<TreatmentResponse>> {\n const { data } = await http.get<IApiResponse<TreatmentResponse>>(\n `${PETS_BASE}/${petId}/treatments/${treatmentId}`,\n {\n headers: { Authorization: `Bearer ${accessToken}` },\n },\n );\n return data;\n}\n\n/**\n * GET /api/v1/pets/:petId/treatments/:treatmentId/doses\n */\nexport async function getPetTreatmentDoses(\n http: HttpClient,\n accessToken: string,\n petId: string,\n treatmentId: string,\n): Promise<IApiResponse<DoseResponse[]>> {\n const { data } = await http.get<IApiResponse<DoseResponse[]>>(\n `${PETS_BASE}/${petId}/treatments/${treatmentId}/doses`,\n {\n headers: { Authorization: `Bearer ${accessToken}` },\n },\n );\n return data;\n}\n\n/**\n * POST /api/v1/pets/:petId/treatments/:treatmentId/doses — 201 Created.\n */\nexport async function createPetTreatmentDose(\n http: HttpClient,\n accessToken: string,\n petId: string,\n treatmentId: string,\n body: PostPetTreatmentDoseBody,\n): Promise<IApiResponse<DoseResponse>> {\n const { data } = await http.post<IApiResponse<DoseResponse>, PostPetTreatmentDoseBody>(\n `${PETS_BASE}/${petId}/treatments/${treatmentId}/doses`,\n body,\n {\n headers: { Authorization: `Bearer ${accessToken}` },\n },\n );\n return data;\n}\n","import type {\n CreatePetInput,\n IApiResponse,\n PatchUserProfileInput,\n PetResponse,\n UserProfileResponse,\n} from '@ipetsadmin/contracts';\n\nimport type { HttpClient } from '../http-client';\n\nconst USERS_BASE = '/api/v1/users' as const;\n\n/** Body for POST /users/:userId/pets (`ownerId` / timestamps come from the server). */\nexport type PostUserPetRequestBody = Omit<CreatePetInput, 'ownerId' | 'createdAt' | 'updatedAt'>;\n\n/**\n * GET /api/v1/users/me/profile — requires `Authorization: Bearer <accessToken>`.\n */\nexport async function getUserProfile(\n http: HttpClient,\n accessToken: string,\n): Promise<IApiResponse<UserProfileResponse>> {\n const { data } = await http.get<IApiResponse<UserProfileResponse>>(`${USERS_BASE}/me/profile`, {\n headers: { Authorization: `Bearer ${accessToken}` },\n });\n return data;\n}\n\n/**\n * GET /api/v1/users/:userId/pets — requires `Authorization: Bearer <accessToken>`.\n */\nexport async function getUserPets(\n http: HttpClient,\n accessToken: string,\n userId: string,\n): Promise<IApiResponse<PetResponse[]>> {\n const { data } = await http.get<IApiResponse<PetResponse[]>>(`${USERS_BASE}/${userId}/pets`, {\n headers: { Authorization: `Bearer ${accessToken}` },\n });\n return data;\n}\n\n/**\n * POST /api/v1/users/:userId/pets — requires `Authorization: Bearer <accessToken>`.\n */\nexport async function createUserPet(\n http: HttpClient,\n accessToken: string,\n userId: string,\n body: PostUserPetRequestBody,\n): Promise<IApiResponse<PetResponse>> {\n const { data } = await http.post<IApiResponse<PetResponse>, PostUserPetRequestBody>(\n `${USERS_BASE}/${userId}/pets`,\n body,\n {\n headers: { Authorization: `Bearer ${accessToken}` },\n },\n );\n return data;\n}\n\n/**\n * PATCH /api/v1/users/me/profile — requires `Authorization: Bearer <accessToken>`.\n * Body must not include `avatar` (API rejects unknown keys in strict mode).\n */\nexport async function patchUserProfile(\n http: HttpClient,\n accessToken: string,\n body: PatchUserProfileInput,\n): Promise<IApiResponse<UserProfileResponse>> {\n const { data } = await http.patch<IApiResponse<UserProfileResponse>, PatchUserProfileInput>(\n `${USERS_BASE}/me/profile`,\n body,\n {\n headers: { Authorization: `Bearer ${accessToken}` },\n },\n );\n return data;\n}\n","import type { IApiResponse, HealthCheck } from '@ipetsadmin/contracts';\nimport type { HttpClient } from '../http-client';\n\n/** Same path as `/api/${v1}/health-check` on the server when `v1` is the string `'v1'`. */\nconst HEALTH_CHECK_PATH = '/api/v1/health-check' as const;\n\n/**\n * GET /api/v1/health-check — server liveness.\n *\n * Returns the full JSON the server sends (`IApiResponse<HealthCheck>`).\n *\n * **Why not `data.data` here?** Adapters like Axios wrap the HTTP body in a property also\n * called `data`. That outer `data` is the entire `res.json(...)` object. The inner\n * `IApiResponse.data` is the `HealthCheck` payload — use `.data` on the **returned** value,\n * e.g. `(await fetchHealthCheck(http)).data`.\n */\nexport async function fetchHealthCheck(http: HttpClient): Promise<IApiResponse<HealthCheck>> {\n const { data: body } = await http.get<IApiResponse<HealthCheck>>(HEALTH_CHECK_PATH);\n\n return body;\n}\n","import {\n getGoogleOAuthStart,\n getMe,\n patchVerifyEmail,\n postGoogleOAuthCallback,\n postLogin,\n postLogout,\n postRefresh,\n postRegister,\n} from './endpoints/auth';\nimport {\n createPetTreatment,\n createPetTreatmentDose,\n getPetDetails,\n getPetTreatment,\n getPetTreatmentDoses,\n getPetTreatments,\n putPetDetails,\n} from './endpoints/pet';\nimport { createUserPet, getUserPets, getUserProfile, patchUserProfile } from './endpoints/user';\nimport { fetchHealthCheck } from './endpoints/health-check';\nimport type { HttpClient } from './http-client';\n\nexport interface CreateApiClientOptions {\n /**\n * Preconfigured HTTP client (e.g. Axios instance with `baseURL` set).\n * Paths in this library are relative to that base (e.g. `/api/v1/...`).\n * `get`, `post`, `patch`, and `put` are required for all implemented routes.\n */\n readonly http: HttpClient;\n}\n\nexport interface ApiClient {\n readonly healthCheck: () => ReturnType<typeof fetchHealthCheck>;\n readonly auth: {\n readonly register: (\n body: Parameters<typeof postRegister>[1],\n ) => ReturnType<typeof postRegister>;\n readonly login: (body: Parameters<typeof postLogin>[1]) => ReturnType<typeof postLogin>;\n readonly getGoogleOAuthStart: (redirectUri: string) => ReturnType<typeof getGoogleOAuthStart>;\n readonly postGoogleOAuthCallback: (\n body: Parameters<typeof postGoogleOAuthCallback>[1],\n ) => ReturnType<typeof postGoogleOAuthCallback>;\n readonly refresh: (body: Parameters<typeof postRefresh>[1]) => ReturnType<typeof postRefresh>;\n readonly logout: (body: Parameters<typeof postLogout>[1]) => ReturnType<typeof postLogout>;\n readonly verifyEmail: (\n body: Parameters<typeof patchVerifyEmail>[1],\n ) => ReturnType<typeof patchVerifyEmail>;\n readonly me: (accessToken: string) => ReturnType<typeof getMe>;\n };\n readonly users: {\n readonly getProfile: (accessToken: string) => ReturnType<typeof getUserProfile>;\n readonly patchProfile: (\n accessToken: string,\n body: Parameters<typeof patchUserProfile>[2],\n ) => ReturnType<typeof patchUserProfile>;\n readonly getPets: (accessToken: string, userId: string) => ReturnType<typeof getUserPets>;\n readonly createPet: (\n accessToken: string,\n userId: string,\n body: Parameters<typeof createUserPet>[3],\n ) => ReturnType<typeof createUserPet>;\n };\n readonly pets: {\n readonly getById: (accessToken: string, petId: string) => ReturnType<typeof getPetDetails>;\n readonly update: (\n accessToken: string,\n petId: string,\n body: Parameters<typeof putPetDetails>[3],\n ) => ReturnType<typeof putPetDetails>;\n readonly getTreatments: (\n accessToken: string,\n petId: string,\n ) => ReturnType<typeof getPetTreatments>;\n readonly createTreatment: (\n accessToken: string,\n petId: string,\n body: Parameters<typeof createPetTreatment>[3],\n ) => ReturnType<typeof createPetTreatment>;\n readonly getTreatment: (\n accessToken: string,\n petId: string,\n treatmentId: string,\n ) => ReturnType<typeof getPetTreatment>;\n readonly getTreatmentDoses: (\n accessToken: string,\n petId: string,\n treatmentId: string,\n ) => ReturnType<typeof getPetTreatmentDoses>;\n readonly createTreatmentDose: (\n accessToken: string,\n petId: string,\n treatmentId: string,\n body: Parameters<typeof createPetTreatmentDose>[4],\n ) => ReturnType<typeof createPetTreatmentDose>;\n };\n}\n\n/**\n * Creates a typed API client backed by the provided HTTP implementation.\n */\nexport function createApiClient(options: CreateApiClientOptions): ApiClient {\n const { http } = options;\n\n return {\n healthCheck: () => fetchHealthCheck(http),\n auth: {\n register: (body) => postRegister(http, body),\n login: (body) => postLogin(http, body),\n getGoogleOAuthStart: (redirectUri) => getGoogleOAuthStart(http, redirectUri),\n postGoogleOAuthCallback: (body) => postGoogleOAuthCallback(http, body),\n refresh: (body) => postRefresh(http, body),\n logout: (body) => postLogout(http, body),\n verifyEmail: (body) => patchVerifyEmail(http, body),\n me: (accessToken) => getMe(http, accessToken),\n },\n users: {\n getProfile: (accessToken) => getUserProfile(http, accessToken),\n patchProfile: (accessToken, body) => patchUserProfile(http, accessToken, body),\n getPets: (accessToken, userId) => getUserPets(http, accessToken, userId),\n createPet: (accessToken, userId, body) => createUserPet(http, accessToken, userId, body),\n },\n pets: {\n getById: (accessToken, petId) => getPetDetails(http, accessToken, petId),\n update: (accessToken, petId, body) => putPetDetails(http, accessToken, petId, body),\n getTreatments: (accessToken, petId) => getPetTreatments(http, accessToken, petId),\n createTreatment: (accessToken, petId, body) =>\n createPetTreatment(http, accessToken, petId, body),\n getTreatment: (accessToken, petId, treatmentId) =>\n getPetTreatment(http, accessToken, petId, treatmentId),\n getTreatmentDoses: (accessToken, petId, treatmentId) =>\n getPetTreatmentDoses(http, accessToken, petId, treatmentId),\n createTreatmentDose: (accessToken, petId, treatmentId, body) =>\n createPetTreatmentDose(http, accessToken, petId, treatmentId, body),\n },\n };\n}\n"]}
package/dist/index.mjs CHANGED
@@ -98,6 +98,25 @@ async function getPetTreatment(http, accessToken, petId, treatmentId) {
98
98
  );
99
99
  return data;
100
100
  }
101
+ async function getPetTreatmentDoses(http, accessToken, petId, treatmentId) {
102
+ const { data } = await http.get(
103
+ `${PETS_BASE}/${petId}/treatments/${treatmentId}/doses`,
104
+ {
105
+ headers: { Authorization: `Bearer ${accessToken}` }
106
+ }
107
+ );
108
+ return data;
109
+ }
110
+ async function createPetTreatmentDose(http, accessToken, petId, treatmentId, body) {
111
+ const { data } = await http.post(
112
+ `${PETS_BASE}/${petId}/treatments/${treatmentId}/doses`,
113
+ body,
114
+ {
115
+ headers: { Authorization: `Bearer ${accessToken}` }
116
+ }
117
+ );
118
+ return data;
119
+ }
101
120
 
102
121
  // src/endpoints/user.ts
103
122
  var USERS_BASE = "/api/v1/users";
@@ -167,11 +186,13 @@ function createApiClient(options) {
167
186
  update: (accessToken, petId, body) => putPetDetails(http, accessToken, petId, body),
168
187
  getTreatments: (accessToken, petId) => getPetTreatments(http, accessToken, petId),
169
188
  createTreatment: (accessToken, petId, body) => createPetTreatment(http, accessToken, petId, body),
170
- getTreatment: (accessToken, petId, treatmentId) => getPetTreatment(http, accessToken, petId, treatmentId)
189
+ getTreatment: (accessToken, petId, treatmentId) => getPetTreatment(http, accessToken, petId, treatmentId),
190
+ getTreatmentDoses: (accessToken, petId, treatmentId) => getPetTreatmentDoses(http, accessToken, petId, treatmentId),
191
+ createTreatmentDose: (accessToken, petId, treatmentId, body) => createPetTreatmentDose(http, accessToken, petId, treatmentId, body)
171
192
  }
172
193
  };
173
194
  }
174
195
 
175
- export { createApiClient, createPetTreatment, createUserPet, fetchHealthCheck, getGoogleOAuthStart, getMe, getPetDetails, getPetTreatment, getPetTreatments, getUserPets, getUserProfile, patchUserProfile, patchVerifyEmail, postGoogleOAuthCallback, postLogin, postLogout, postRefresh, postRegister, putPetDetails };
196
+ export { createApiClient, createPetTreatment, createPetTreatmentDose, createUserPet, fetchHealthCheck, getGoogleOAuthStart, getMe, getPetDetails, getPetTreatment, getPetTreatmentDoses, getPetTreatments, getUserPets, getUserProfile, patchUserProfile, patchVerifyEmail, postGoogleOAuthCallback, postLogin, postLogout, postRefresh, postRegister, putPetDetails };
176
197
  //# sourceMappingURL=index.mjs.map
177
198
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/endpoints/auth.ts","../src/endpoints/pet.ts","../src/endpoints/user.ts","../src/endpoints/health-check.ts","../src/create-api-client.ts"],"names":[],"mappings":";AAeA,IAAM,SAAA,GAAY,cAAA;AAKlB,eAAsB,YAAA,CACpB,MACA,IAAA,EAC4C;AAC5C,EAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,IAAA,CAAK,IAAA;AAAA,IAC1B,GAAG,SAAS,CAAA,SAAA,CAAA;AAAA,IACZ;AAAA,GACF;AACA,EAAA,OAAO,IAAA;AACT;AAKA,eAAsB,SAAA,CACpB,MACA,IAAA,EAC4C;AAC5C,EAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,IAAA,CAAK,IAAA;AAAA,IAC1B,GAAG,SAAS,CAAA,MAAA,CAAA;AAAA,IACZ;AAAA,GACF;AACA,EAAA,OAAO,IAAA;AACT;AAKA,eAAsB,mBAAA,CACpB,MACA,WAAA,EACiD;AACjD,EAAA,MAAM,CAAA,GAAI,IAAI,eAAA,CAAgB,EAAE,aAAa,CAAA;AAC7C,EAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MA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","file":"index.mjs","sourcesContent":["import type {\n AuthSessionResponse,\n AuthUserResponse,\n IApiResponse,\n LoginRequest,\n LogoutRequest,\n OAuthGoogleCallbackRequest,\n OAuthGoogleStartResponse,\n RefreshRequest,\n RegisterRequest,\n VerifyEmailRequest,\n} from '@ipetsadmin/contracts';\n\nimport type { HttpClient } from '../http-client';\n\nconst AUTH_BASE = '/api/v1/auth' as const;\n\n/**\n * POST /api/v1/auth/register\n */\nexport async function postRegister(\n http: HttpClient,\n body: RegisterRequest,\n): Promise<IApiResponse<AuthSessionResponse>> {\n const { data } = await http.post<IApiResponse<AuthSessionResponse>, RegisterRequest>(\n `${AUTH_BASE}/register`,\n body,\n );\n return data;\n}\n\n/**\n * POST /api/v1/auth/login\n */\nexport async function postLogin(\n http: HttpClient,\n body: LoginRequest,\n): Promise<IApiResponse<AuthSessionResponse>> {\n const { data } = await http.post<IApiResponse<AuthSessionResponse>, LoginRequest>(\n `${AUTH_BASE}/login`,\n body,\n );\n return data;\n}\n\n/**\n * GET /api/v1/auth/oauth/google/start?redirectUri=...\n */\nexport async function getGoogleOAuthStart(\n http: HttpClient,\n redirectUri: string,\n): Promise<IApiResponse<OAuthGoogleStartResponse>> {\n const q = new URLSearchParams({ redirectUri });\n const { data } = await http.get<IApiResponse<OAuthGoogleStartResponse>>(\n `${AUTH_BASE}/oauth/google/start?${q.toString()}`,\n );\n return data;\n}\n\n/**\n * POST /api/v1/auth/oauth/google/callback\n */\nexport async function postGoogleOAuthCallback(\n http: HttpClient,\n body: OAuthGoogleCallbackRequest,\n): Promise<IApiResponse<AuthSessionResponse>> {\n const { data } = await http.post<IApiResponse<AuthSessionResponse>, OAuthGoogleCallbackRequest>(\n `${AUTH_BASE}/oauth/google/callback`,\n body,\n );\n return data;\n}\n\n/**\n * POST /api/v1/auth/refresh\n */\nexport async function postRefresh(\n http: HttpClient,\n body: RefreshRequest,\n): Promise<IApiResponse<AuthSessionResponse>> {\n const { data } = await http.post<IApiResponse<AuthSessionResponse>, RefreshRequest>(\n `${AUTH_BASE}/refresh`,\n body,\n );\n return data;\n}\n\n/**\n * POST /api/v1/auth/logout — 204 No Content (no JSON body).\n */\nexport async function postLogout(http: HttpClient, body: LogoutRequest): Promise<void> {\n await http.post<undefined, LogoutRequest>(`${AUTH_BASE}/logout`, body);\n}\n\n/**\n * GET /api/v1/auth/me — requires `Authorization: Bearer <accessToken>`.\n */\nexport async function getMe(\n http: HttpClient,\n accessToken: string,\n): Promise<IApiResponse<AuthUserResponse>> {\n const { data } = await http.get<IApiResponse<AuthUserResponse>>(`${AUTH_BASE}/me`, {\n headers: { Authorization: `Bearer ${accessToken}` },\n });\n return data;\n}\n\n/**\n * PATCH /api/v1/auth/verify-email\n */\nexport async function patchVerifyEmail(\n http: HttpClient,\n body: VerifyEmailRequest,\n): Promise<IApiResponse<void>> {\n const { data } = await http.patch<IApiResponse<void>, VerifyEmailRequest>(\n `${AUTH_BASE}/verify-email`,\n body,\n );\n return data;\n}\n","import type {\n CreateTreatmentInput,\n IApiResponse,\n PetResponse,\n TreatmentResponse,\n CreatePetInput,\n} from '@ipetsadmin/contracts';\n\nimport type { HttpClient } from '../http-client';\n\nconst PETS_BASE = '/api/v1/pets' as const;\n\n/** Body for PUT /api/v1/pets/:petId (partial update; excludes server-owned fields). */\nexport type PutPetDetailsBody = Partial<\n Omit<CreatePetInput, 'ownerId' | 'createdAt' | 'updatedAt'>\n>;\n\n/**\n * Same fields as creating a treatment without `petId` (provided in the URL). `status` may be omitted\n * (defaults on the server).\n */\nexport type PostPetTreatmentRequestBody = Omit<CreateTreatmentInput, 'petId'> &\n Partial<Pick<CreateTreatmentInput, 'status'>>;\n\n/**\n * GET /api/v1/pets/:petId — Bearer access token required.\n */\nexport async function getPetDetails(\n http: HttpClient,\n accessToken: string,\n petId: string,\n): Promise<IApiResponse<PetResponse>> {\n const { data } = await http.get<IApiResponse<PetResponse>>(`${PETS_BASE}/${petId}`, {\n headers: { Authorization: `Bearer ${accessToken}` },\n });\n return data;\n}\n\n/**\n * PUT /api/v1/pets/:petId — partial update; owner must match JWT user.\n */\nexport async function putPetDetails(\n http: HttpClient,\n accessToken: string,\n petId: string,\n body: PutPetDetailsBody,\n): Promise<IApiResponse<PetResponse>> {\n const { data } = await http.put<IApiResponse<PetResponse>, PutPetDetailsBody>(\n `${PETS_BASE}/${petId}`,\n body,\n {\n headers: { Authorization: `Bearer ${accessToken}` },\n },\n );\n return data;\n}\n\n/**\n * GET /api/v1/pets/:petId/treatments\n */\nexport async function getPetTreatments(\n http: HttpClient,\n accessToken: string,\n petId: string,\n): Promise<IApiResponse<TreatmentResponse[]>> {\n const { data } = await http.get<IApiResponse<TreatmentResponse[]>>(\n `${PETS_BASE}/${petId}/treatments`,\n {\n headers: { Authorization: `Bearer ${accessToken}` },\n },\n );\n return data;\n}\n\n/**\n * POST /api/v1/pets/:petId/treatments — 201 Created (`IApiResponse<TreatmentResponse>` body).\n */\nexport async function createPetTreatment(\n http: HttpClient,\n accessToken: string,\n petId: string,\n body: PostPetTreatmentRequestBody,\n): Promise<IApiResponse<TreatmentResponse>> {\n const { data } = await http.post<IApiResponse<TreatmentResponse>, PostPetTreatmentRequestBody>(\n `${PETS_BASE}/${petId}/treatments`,\n body,\n {\n headers: { Authorization: `Bearer ${accessToken}` },\n },\n );\n return data;\n}\n\n/**\n * GET /api/v1/pets/:petId/treatments/:treatmentId\n */\nexport async function getPetTreatment(\n http: HttpClient,\n accessToken: string,\n petId: string,\n treatmentId: string,\n): Promise<IApiResponse<TreatmentResponse>> {\n const { data } = await http.get<IApiResponse<TreatmentResponse>>(\n `${PETS_BASE}/${petId}/treatments/${treatmentId}`,\n {\n headers: { Authorization: `Bearer ${accessToken}` },\n },\n );\n return data;\n}\n","import type {\n CreatePetInput,\n IApiResponse,\n PatchUserProfileInput,\n PetResponse,\n UserProfileResponse,\n} from '@ipetsadmin/contracts';\n\nimport type { HttpClient } from '../http-client';\n\nconst USERS_BASE = '/api/v1/users' as const;\n\n/** Body for POST /users/:userId/pets (`ownerId` / timestamps come from the server). */\nexport type PostUserPetRequestBody = Omit<CreatePetInput, 'ownerId' | 'createdAt' | 'updatedAt'>;\n\n/**\n * GET /api/v1/users/me/profile — requires `Authorization: Bearer <accessToken>`.\n */\nexport async function getUserProfile(\n http: HttpClient,\n accessToken: string,\n): Promise<IApiResponse<UserProfileResponse>> {\n const { data } = await http.get<IApiResponse<UserProfileResponse>>(`${USERS_BASE}/me/profile`, {\n headers: { Authorization: `Bearer ${accessToken}` },\n });\n return data;\n}\n\n/**\n * GET /api/v1/users/:userId/pets — requires `Authorization: Bearer <accessToken>`.\n */\nexport async function getUserPets(\n http: HttpClient,\n accessToken: string,\n userId: string,\n): Promise<IApiResponse<PetResponse[]>> {\n const { data } = await http.get<IApiResponse<PetResponse[]>>(`${USERS_BASE}/${userId}/pets`, {\n headers: { Authorization: `Bearer ${accessToken}` },\n });\n return data;\n}\n\n/**\n * POST /api/v1/users/:userId/pets — requires `Authorization: Bearer <accessToken>`.\n */\nexport async function createUserPet(\n http: HttpClient,\n accessToken: string,\n userId: string,\n body: PostUserPetRequestBody,\n): Promise<IApiResponse<PetResponse>> {\n const { data } = await http.post<IApiResponse<PetResponse>, PostUserPetRequestBody>(\n `${USERS_BASE}/${userId}/pets`,\n body,\n {\n headers: { Authorization: `Bearer ${accessToken}` },\n },\n );\n return data;\n}\n\n/**\n * PATCH /api/v1/users/me/profile — requires `Authorization: Bearer <accessToken>`.\n * Body must not include `avatar` (API rejects unknown keys in strict mode).\n */\nexport async function patchUserProfile(\n http: HttpClient,\n accessToken: string,\n body: PatchUserProfileInput,\n): Promise<IApiResponse<UserProfileResponse>> {\n const { data } = await http.patch<IApiResponse<UserProfileResponse>, PatchUserProfileInput>(\n `${USERS_BASE}/me/profile`,\n body,\n {\n headers: { Authorization: `Bearer ${accessToken}` },\n },\n );\n return data;\n}\n","import type { IApiResponse, HealthCheck } from '@ipetsadmin/contracts';\nimport type { HttpClient } from '../http-client';\n\n/** Same path as `/api/${v1}/health-check` on the server when `v1` is the string `'v1'`. */\nconst HEALTH_CHECK_PATH = '/api/v1/health-check' as const;\n\n/**\n * GET /api/v1/health-check — server liveness.\n *\n * Returns the full JSON the server sends (`IApiResponse<HealthCheck>`).\n *\n * **Why not `data.data` here?** Adapters like Axios wrap the HTTP body in a property also\n * called `data`. That outer `data` is the entire `res.json(...)` object. The inner\n * `IApiResponse.data` is the `HealthCheck` payload — use `.data` on the **returned** value,\n * e.g. `(await fetchHealthCheck(http)).data`.\n */\nexport async function fetchHealthCheck(http: HttpClient): Promise<IApiResponse<HealthCheck>> {\n const { data: body } = await http.get<IApiResponse<HealthCheck>>(HEALTH_CHECK_PATH);\n\n return body;\n}\n","import {\n getGoogleOAuthStart,\n getMe,\n patchVerifyEmail,\n postGoogleOAuthCallback,\n postLogin,\n postLogout,\n postRefresh,\n postRegister,\n} from './endpoints/auth';\nimport {\n createPetTreatment,\n getPetDetails,\n getPetTreatment,\n getPetTreatments,\n putPetDetails,\n} from './endpoints/pet';\nimport { createUserPet, getUserPets, getUserProfile, patchUserProfile } from './endpoints/user';\nimport { fetchHealthCheck } from './endpoints/health-check';\nimport type { HttpClient } from './http-client';\n\nexport interface CreateApiClientOptions {\n /**\n * Preconfigured HTTP client (e.g. Axios instance with `baseURL` set).\n * Paths in this library are relative to that base (e.g. `/api/v1/...`).\n * `get`, `post`, `patch`, and `put` are required for all implemented routes.\n */\n readonly http: HttpClient;\n}\n\nexport interface ApiClient {\n readonly healthCheck: () => ReturnType<typeof fetchHealthCheck>;\n readonly auth: {\n readonly register: (\n body: Parameters<typeof postRegister>[1],\n ) => ReturnType<typeof postRegister>;\n readonly login: (body: Parameters<typeof postLogin>[1]) => ReturnType<typeof postLogin>;\n readonly getGoogleOAuthStart: (redirectUri: string) => ReturnType<typeof getGoogleOAuthStart>;\n readonly postGoogleOAuthCallback: (\n body: Parameters<typeof postGoogleOAuthCallback>[1],\n ) => ReturnType<typeof postGoogleOAuthCallback>;\n readonly refresh: (body: Parameters<typeof postRefresh>[1]) => ReturnType<typeof postRefresh>;\n readonly logout: (body: Parameters<typeof postLogout>[1]) => ReturnType<typeof postLogout>;\n readonly verifyEmail: (\n body: Parameters<typeof patchVerifyEmail>[1],\n ) => ReturnType<typeof patchVerifyEmail>;\n readonly me: (accessToken: string) => ReturnType<typeof getMe>;\n };\n readonly users: {\n readonly getProfile: (accessToken: string) => ReturnType<typeof getUserProfile>;\n readonly patchProfile: (\n accessToken: string,\n body: Parameters<typeof patchUserProfile>[2],\n ) => ReturnType<typeof patchUserProfile>;\n readonly getPets: (accessToken: string, userId: string) => ReturnType<typeof getUserPets>;\n readonly createPet: (\n accessToken: string,\n userId: string,\n body: Parameters<typeof createUserPet>[3],\n ) => ReturnType<typeof createUserPet>;\n };\n readonly pets: {\n readonly getById: (accessToken: string, petId: string) => ReturnType<typeof getPetDetails>;\n readonly update: (\n accessToken: string,\n petId: string,\n body: Parameters<typeof putPetDetails>[3],\n ) => ReturnType<typeof putPetDetails>;\n readonly getTreatments: (\n accessToken: string,\n petId: string,\n ) => ReturnType<typeof getPetTreatments>;\n readonly createTreatment: (\n accessToken: string,\n petId: string,\n body: Parameters<typeof createPetTreatment>[3],\n ) => ReturnType<typeof createPetTreatment>;\n readonly getTreatment: (\n accessToken: string,\n petId: string,\n treatmentId: string,\n ) => ReturnType<typeof getPetTreatment>;\n };\n}\n\n/**\n * Creates a typed API client backed by the provided HTTP implementation.\n */\nexport function createApiClient(options: CreateApiClientOptions): ApiClient {\n const { http } = options;\n\n return {\n healthCheck: () => fetchHealthCheck(http),\n auth: {\n register: (body) => postRegister(http, body),\n login: (body) => postLogin(http, body),\n getGoogleOAuthStart: (redirectUri) => getGoogleOAuthStart(http, redirectUri),\n postGoogleOAuthCallback: (body) => postGoogleOAuthCallback(http, body),\n refresh: (body) => postRefresh(http, body),\n logout: (body) => postLogout(http, body),\n verifyEmail: (body) => patchVerifyEmail(http, body),\n me: (accessToken) => getMe(http, accessToken),\n },\n users: {\n getProfile: (accessToken) => getUserProfile(http, accessToken),\n patchProfile: (accessToken, body) => patchUserProfile(http, accessToken, body),\n getPets: (accessToken, userId) => getUserPets(http, accessToken, userId),\n createPet: (accessToken, userId, body) => createUserPet(http, accessToken, userId, body),\n },\n pets: {\n getById: (accessToken, petId) => getPetDetails(http, accessToken, petId),\n update: (accessToken, petId, body) => putPetDetails(http, accessToken, petId, body),\n getTreatments: (accessToken, petId) => getPetTreatments(http, accessToken, petId),\n createTreatment: (accessToken, petId, body) =>\n createPetTreatment(http, accessToken, petId, body),\n getTreatment: (accessToken, petId, treatmentId) =>\n getPetTreatment(http, accessToken, petId, treatmentId),\n },\n };\n}\n"]}
1
+ {"version":3,"sources":["../src/endpoints/auth.ts","../src/endpoints/pet.ts","../src/endpoints/user.ts","../src/endpoints/health-check.ts","../src/create-api-client.ts"],"names":[],"mappings":";AAeA,IAAM,SAAA,GAAY,cAAA;AAKlB,eAAsB,YAAA,CACpB,MACA,IAAA,EAC4C;AAC5C,EAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,IAAA,CAAK,IAAA;AAAA,IAC1B,GAAG,SAAS,CAAA,SAAA,CAAA;AAAA,IACZ;AAAA,GACF;AACA,EAAA,OAAO,IAAA;AACT;AAKA,eAAsB,SAAA,CACpB,MACA,IAAA,EAC4C;AAC5C,EAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,IAAA,CAAK,IAAA;AAAA,IAC1B,GAAG,SAAS,CAAA,MAAA,CAAA;AAAA,IACZ;AAAA,GACF;AACA,EAAA,OAAO,IAAA;AACT;AAKA,eAAsB,mBAAA,CACpB,MACA,WAAA,EACiD;AACjD,EAAA,MAAM,CAAA,GAAI,IAAI,eAAA,CAAgB,EAAE,aAAa,CAAA;AAC7C,EAAA,MAAM,EAAE,IAAA,EAAK,GAAI,MAAM,IAAA,CAAK,GAAA;AAAA,IAC1B,CAAA,EAAG,SAAS,CAAA,oBAAA,EAAuB,CAAA,CAAE,UAAU,CAAA;AAAA,GACjD;AAC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AAM,WAAA,EAAa,MAAA,EAAQ,IAAI;AAAA,KACzF;AAAA,IACA,IAAA,EAAM;AAAA,MACJ,SAAS,CAAC,WAAA,EAAa,UAAU,aAAA,CAAc,IAAA,EAAM,aAAa,KAAK,CAAA;AAAA,MACvE,MAAA,EAAQ,CAAC,WAAA,EAAa,KAAA,EAAO,SAAS,aAAA,CAAc,IAAA,EAAM,WAAA,EAAa,KAAA,EAAO,IAAI,CAAA;AAAA,MAClF,eAAe,CAAC,WAAA,EAAa,UAAU,gBAAA,CAAiB,IAAA,EAAM,aAAa,KAAK,CAAA;AAAA,MAChF,eAAA,EAAiB,CAAC,WAAA,EAAa,KAAA,EAAO,SACpC,kBAAA,CAAmB,IAAA,EAAM,WAAA,EAAa,KAAA,EAAO,IAAI,CAAA;AAAA,MACnD,YAAA,EAAc,CAAC,WAAA,EAAa,KAAA,EAAO,gBACjC,eAAA,CAAgB,IAAA,EAAM,WAAA,EAAa,KAAA,EAAO,WAAW,CAAA;AAAA,MACvD,iBAAA,EAAmB,CAAC,WAAA,EAAa,KAAA,EAAO,gBACtC,oBAAA,CAAqB,IAAA,EAAM,WAAA,EAAa,KAAA,EAAO,WAAW,CAAA;AAAA,MAC5D,mBAAA,EAAqB,CAAC,WAAA,EAAa,KAAA,EAAO,WAAA,EAAa,IAAA,KACrD,sBAAA,CAAuB,IAAA,EAAM,WAAA,EAAa,KAAA,EAAO,WAAA,EAAa,IAAI;AAAA;AACtE,GACF;AACF","file":"index.mjs","sourcesContent":["import type {\n AuthSessionResponse,\n AuthUserResponse,\n IApiResponse,\n LoginRequest,\n LogoutRequest,\n OAuthGoogleCallbackRequest,\n OAuthGoogleStartResponse,\n RefreshRequest,\n RegisterRequest,\n VerifyEmailRequest,\n} from '@ipetsadmin/contracts';\n\nimport type { HttpClient } from '../http-client';\n\nconst AUTH_BASE = '/api/v1/auth' as const;\n\n/**\n * POST /api/v1/auth/register\n */\nexport async function postRegister(\n http: HttpClient,\n body: RegisterRequest,\n): Promise<IApiResponse<AuthSessionResponse>> {\n const { data } = await http.post<IApiResponse<AuthSessionResponse>, RegisterRequest>(\n `${AUTH_BASE}/register`,\n body,\n );\n return data;\n}\n\n/**\n * POST /api/v1/auth/login\n */\nexport async function postLogin(\n http: HttpClient,\n body: LoginRequest,\n): Promise<IApiResponse<AuthSessionResponse>> {\n const { data } = await http.post<IApiResponse<AuthSessionResponse>, LoginRequest>(\n `${AUTH_BASE}/login`,\n body,\n );\n return data;\n}\n\n/**\n * GET /api/v1/auth/oauth/google/start?redirectUri=...\n */\nexport async function getGoogleOAuthStart(\n http: HttpClient,\n redirectUri: string,\n): Promise<IApiResponse<OAuthGoogleStartResponse>> {\n const q = new URLSearchParams({ redirectUri });\n const { data } = await http.get<IApiResponse<OAuthGoogleStartResponse>>(\n `${AUTH_BASE}/oauth/google/start?${q.toString()}`,\n );\n return data;\n}\n\n/**\n * POST /api/v1/auth/oauth/google/callback\n */\nexport async function postGoogleOAuthCallback(\n http: HttpClient,\n body: OAuthGoogleCallbackRequest,\n): Promise<IApiResponse<AuthSessionResponse>> {\n const { data } = await http.post<IApiResponse<AuthSessionResponse>, OAuthGoogleCallbackRequest>(\n `${AUTH_BASE}/oauth/google/callback`,\n body,\n );\n return data;\n}\n\n/**\n * POST /api/v1/auth/refresh\n */\nexport async function postRefresh(\n http: HttpClient,\n body: RefreshRequest,\n): Promise<IApiResponse<AuthSessionResponse>> {\n const { data } = await http.post<IApiResponse<AuthSessionResponse>, RefreshRequest>(\n `${AUTH_BASE}/refresh`,\n body,\n );\n return data;\n}\n\n/**\n * POST /api/v1/auth/logout — 204 No Content (no JSON body).\n */\nexport async function postLogout(http: HttpClient, body: LogoutRequest): Promise<void> {\n await http.post<undefined, LogoutRequest>(`${AUTH_BASE}/logout`, body);\n}\n\n/**\n * GET /api/v1/auth/me — requires `Authorization: Bearer <accessToken>`.\n */\nexport async function getMe(\n http: HttpClient,\n accessToken: string,\n): Promise<IApiResponse<AuthUserResponse>> {\n const { data } = await http.get<IApiResponse<AuthUserResponse>>(`${AUTH_BASE}/me`, {\n headers: { Authorization: `Bearer ${accessToken}` },\n });\n return data;\n}\n\n/**\n * PATCH /api/v1/auth/verify-email\n */\nexport async function patchVerifyEmail(\n http: HttpClient,\n body: VerifyEmailRequest,\n): Promise<IApiResponse<void>> {\n const { data } = await http.patch<IApiResponse<void>, VerifyEmailRequest>(\n `${AUTH_BASE}/verify-email`,\n body,\n );\n return data;\n}\n","import type {\n CreateDoseInput,\n CreatePetInput,\n CreateTreatmentInput,\n DoseResponse,\n IApiResponse,\n PetResponse,\n TreatmentResponse,\n} from '@ipetsadmin/contracts';\n\nimport type { HttpClient } from '../http-client';\n\nconst PETS_BASE = '/api/v1/pets' as const;\n\n/** Body for PUT /api/v1/pets/:petId (partial update; excludes server-owned fields). */\nexport type PutPetDetailsBody = Partial<\n Omit<CreatePetInput, 'ownerId' | 'createdAt' | 'updatedAt'>\n>;\n\n/**\n * Same fields as creating a treatment without `petId` (provided in the URL). `status` may be omitted\n * (defaults on the server).\n */\nexport type PostPetTreatmentRequestBody = Omit<CreateTreatmentInput, 'petId'> &\n Partial<Pick<CreateTreatmentInput, 'status'>>;\n\n/**\n * POST .../treatments/:treatmentId/doses — `treatmentId`, `petId`, and `ownerId` are not sent in JSON.\n */\nexport type PostPetTreatmentDoseBody = Omit<CreateDoseInput, 'treatmentId' | 'petId' | 'ownerId'> &\n Partial<Pick<CreateDoseInput, 'status'>>;\n\n/**\n * GET /api/v1/pets/:petId — Bearer access token required.\n */\nexport async function getPetDetails(\n http: HttpClient,\n accessToken: string,\n petId: string,\n): Promise<IApiResponse<PetResponse>> {\n const { data } = await http.get<IApiResponse<PetResponse>>(`${PETS_BASE}/${petId}`, {\n headers: { Authorization: `Bearer ${accessToken}` },\n });\n return data;\n}\n\n/**\n * PUT /api/v1/pets/:petId — partial update; owner must match JWT user.\n */\nexport async function putPetDetails(\n http: HttpClient,\n accessToken: string,\n petId: string,\n body: PutPetDetailsBody,\n): Promise<IApiResponse<PetResponse>> {\n const { data } = await http.put<IApiResponse<PetResponse>, PutPetDetailsBody>(\n `${PETS_BASE}/${petId}`,\n body,\n {\n headers: { Authorization: `Bearer ${accessToken}` },\n },\n );\n return data;\n}\n\n/**\n * GET /api/v1/pets/:petId/treatments\n */\nexport async function getPetTreatments(\n http: HttpClient,\n accessToken: string,\n petId: string,\n): Promise<IApiResponse<TreatmentResponse[]>> {\n const { data } = await http.get<IApiResponse<TreatmentResponse[]>>(\n `${PETS_BASE}/${petId}/treatments`,\n {\n headers: { Authorization: `Bearer ${accessToken}` },\n },\n );\n return data;\n}\n\n/**\n * POST /api/v1/pets/:petId/treatments — 201 Created (`IApiResponse<TreatmentResponse>` body).\n */\nexport async function createPetTreatment(\n http: HttpClient,\n accessToken: string,\n petId: string,\n body: PostPetTreatmentRequestBody,\n): Promise<IApiResponse<TreatmentResponse>> {\n const { data } = await http.post<IApiResponse<TreatmentResponse>, PostPetTreatmentRequestBody>(\n `${PETS_BASE}/${petId}/treatments`,\n body,\n {\n headers: { Authorization: `Bearer ${accessToken}` },\n },\n );\n return data;\n}\n\n/**\n * GET /api/v1/pets/:petId/treatments/:treatmentId\n */\nexport async function getPetTreatment(\n http: HttpClient,\n accessToken: string,\n petId: string,\n treatmentId: string,\n): Promise<IApiResponse<TreatmentResponse>> {\n const { data } = await http.get<IApiResponse<TreatmentResponse>>(\n `${PETS_BASE}/${petId}/treatments/${treatmentId}`,\n {\n headers: { Authorization: `Bearer ${accessToken}` },\n },\n );\n return data;\n}\n\n/**\n * GET /api/v1/pets/:petId/treatments/:treatmentId/doses\n */\nexport async function getPetTreatmentDoses(\n http: HttpClient,\n accessToken: string,\n petId: string,\n treatmentId: string,\n): Promise<IApiResponse<DoseResponse[]>> {\n const { data } = await http.get<IApiResponse<DoseResponse[]>>(\n `${PETS_BASE}/${petId}/treatments/${treatmentId}/doses`,\n {\n headers: { Authorization: `Bearer ${accessToken}` },\n },\n );\n return data;\n}\n\n/**\n * POST /api/v1/pets/:petId/treatments/:treatmentId/doses — 201 Created.\n */\nexport async function createPetTreatmentDose(\n http: HttpClient,\n accessToken: string,\n petId: string,\n treatmentId: string,\n body: PostPetTreatmentDoseBody,\n): Promise<IApiResponse<DoseResponse>> {\n const { data } = await http.post<IApiResponse<DoseResponse>, PostPetTreatmentDoseBody>(\n `${PETS_BASE}/${petId}/treatments/${treatmentId}/doses`,\n body,\n {\n headers: { Authorization: `Bearer ${accessToken}` },\n },\n );\n return data;\n}\n","import type {\n CreatePetInput,\n IApiResponse,\n PatchUserProfileInput,\n PetResponse,\n UserProfileResponse,\n} from '@ipetsadmin/contracts';\n\nimport type { HttpClient } from '../http-client';\n\nconst USERS_BASE = '/api/v1/users' as const;\n\n/** Body for POST /users/:userId/pets (`ownerId` / timestamps come from the server). */\nexport type PostUserPetRequestBody = Omit<CreatePetInput, 'ownerId' | 'createdAt' | 'updatedAt'>;\n\n/**\n * GET /api/v1/users/me/profile — requires `Authorization: Bearer <accessToken>`.\n */\nexport async function getUserProfile(\n http: HttpClient,\n accessToken: string,\n): Promise<IApiResponse<UserProfileResponse>> {\n const { data } = await http.get<IApiResponse<UserProfileResponse>>(`${USERS_BASE}/me/profile`, {\n headers: { Authorization: `Bearer ${accessToken}` },\n });\n return data;\n}\n\n/**\n * GET /api/v1/users/:userId/pets — requires `Authorization: Bearer <accessToken>`.\n */\nexport async function getUserPets(\n http: HttpClient,\n accessToken: string,\n userId: string,\n): Promise<IApiResponse<PetResponse[]>> {\n const { data } = await http.get<IApiResponse<PetResponse[]>>(`${USERS_BASE}/${userId}/pets`, {\n headers: { Authorization: `Bearer ${accessToken}` },\n });\n return data;\n}\n\n/**\n * POST /api/v1/users/:userId/pets — requires `Authorization: Bearer <accessToken>`.\n */\nexport async function createUserPet(\n http: HttpClient,\n accessToken: string,\n userId: string,\n body: PostUserPetRequestBody,\n): Promise<IApiResponse<PetResponse>> {\n const { data } = await http.post<IApiResponse<PetResponse>, PostUserPetRequestBody>(\n `${USERS_BASE}/${userId}/pets`,\n body,\n {\n headers: { Authorization: `Bearer ${accessToken}` },\n },\n );\n return data;\n}\n\n/**\n * PATCH /api/v1/users/me/profile — requires `Authorization: Bearer <accessToken>`.\n * Body must not include `avatar` (API rejects unknown keys in strict mode).\n */\nexport async function patchUserProfile(\n http: HttpClient,\n accessToken: string,\n body: PatchUserProfileInput,\n): Promise<IApiResponse<UserProfileResponse>> {\n const { data } = await http.patch<IApiResponse<UserProfileResponse>, PatchUserProfileInput>(\n `${USERS_BASE}/me/profile`,\n body,\n {\n headers: { Authorization: `Bearer ${accessToken}` },\n },\n );\n return data;\n}\n","import type { IApiResponse, HealthCheck } from '@ipetsadmin/contracts';\nimport type { HttpClient } from '../http-client';\n\n/** Same path as `/api/${v1}/health-check` on the server when `v1` is the string `'v1'`. */\nconst HEALTH_CHECK_PATH = '/api/v1/health-check' as const;\n\n/**\n * GET /api/v1/health-check — server liveness.\n *\n * Returns the full JSON the server sends (`IApiResponse<HealthCheck>`).\n *\n * **Why not `data.data` here?** Adapters like Axios wrap the HTTP body in a property also\n * called `data`. That outer `data` is the entire `res.json(...)` object. The inner\n * `IApiResponse.data` is the `HealthCheck` payload — use `.data` on the **returned** value,\n * e.g. `(await fetchHealthCheck(http)).data`.\n */\nexport async function fetchHealthCheck(http: HttpClient): Promise<IApiResponse<HealthCheck>> {\n const { data: body } = await http.get<IApiResponse<HealthCheck>>(HEALTH_CHECK_PATH);\n\n return body;\n}\n","import {\n getGoogleOAuthStart,\n getMe,\n patchVerifyEmail,\n postGoogleOAuthCallback,\n postLogin,\n postLogout,\n postRefresh,\n postRegister,\n} from './endpoints/auth';\nimport {\n createPetTreatment,\n createPetTreatmentDose,\n getPetDetails,\n getPetTreatment,\n getPetTreatmentDoses,\n getPetTreatments,\n putPetDetails,\n} from './endpoints/pet';\nimport { createUserPet, getUserPets, getUserProfile, patchUserProfile } from './endpoints/user';\nimport { fetchHealthCheck } from './endpoints/health-check';\nimport type { HttpClient } from './http-client';\n\nexport interface CreateApiClientOptions {\n /**\n * Preconfigured HTTP client (e.g. Axios instance with `baseURL` set).\n * Paths in this library are relative to that base (e.g. `/api/v1/...`).\n * `get`, `post`, `patch`, and `put` are required for all implemented routes.\n */\n readonly http: HttpClient;\n}\n\nexport interface ApiClient {\n readonly healthCheck: () => ReturnType<typeof fetchHealthCheck>;\n readonly auth: {\n readonly register: (\n body: Parameters<typeof postRegister>[1],\n ) => ReturnType<typeof postRegister>;\n readonly login: (body: Parameters<typeof postLogin>[1]) => ReturnType<typeof postLogin>;\n readonly getGoogleOAuthStart: (redirectUri: string) => ReturnType<typeof getGoogleOAuthStart>;\n readonly postGoogleOAuthCallback: (\n body: Parameters<typeof postGoogleOAuthCallback>[1],\n ) => ReturnType<typeof postGoogleOAuthCallback>;\n readonly refresh: (body: Parameters<typeof postRefresh>[1]) => ReturnType<typeof postRefresh>;\n readonly logout: (body: Parameters<typeof postLogout>[1]) => ReturnType<typeof postLogout>;\n readonly verifyEmail: (\n body: Parameters<typeof patchVerifyEmail>[1],\n ) => ReturnType<typeof patchVerifyEmail>;\n readonly me: (accessToken: string) => ReturnType<typeof getMe>;\n };\n readonly users: {\n readonly getProfile: (accessToken: string) => ReturnType<typeof getUserProfile>;\n readonly patchProfile: (\n accessToken: string,\n body: Parameters<typeof patchUserProfile>[2],\n ) => ReturnType<typeof patchUserProfile>;\n readonly getPets: (accessToken: string, userId: string) => ReturnType<typeof getUserPets>;\n readonly createPet: (\n accessToken: string,\n userId: string,\n body: Parameters<typeof createUserPet>[3],\n ) => ReturnType<typeof createUserPet>;\n };\n readonly pets: {\n readonly getById: (accessToken: string, petId: string) => ReturnType<typeof getPetDetails>;\n readonly update: (\n accessToken: string,\n petId: string,\n body: Parameters<typeof putPetDetails>[3],\n ) => ReturnType<typeof putPetDetails>;\n readonly getTreatments: (\n accessToken: string,\n petId: string,\n ) => ReturnType<typeof getPetTreatments>;\n readonly createTreatment: (\n accessToken: string,\n petId: string,\n body: Parameters<typeof createPetTreatment>[3],\n ) => ReturnType<typeof createPetTreatment>;\n readonly getTreatment: (\n accessToken: string,\n petId: string,\n treatmentId: string,\n ) => ReturnType<typeof getPetTreatment>;\n readonly getTreatmentDoses: (\n accessToken: string,\n petId: string,\n treatmentId: string,\n ) => ReturnType<typeof getPetTreatmentDoses>;\n readonly createTreatmentDose: (\n accessToken: string,\n petId: string,\n treatmentId: string,\n body: Parameters<typeof createPetTreatmentDose>[4],\n ) => ReturnType<typeof createPetTreatmentDose>;\n };\n}\n\n/**\n * Creates a typed API client backed by the provided HTTP implementation.\n */\nexport function createApiClient(options: CreateApiClientOptions): ApiClient {\n const { http } = options;\n\n return {\n healthCheck: () => fetchHealthCheck(http),\n auth: {\n register: (body) => postRegister(http, body),\n login: (body) => postLogin(http, body),\n getGoogleOAuthStart: (redirectUri) => getGoogleOAuthStart(http, redirectUri),\n postGoogleOAuthCallback: (body) => postGoogleOAuthCallback(http, body),\n refresh: (body) => postRefresh(http, body),\n logout: (body) => postLogout(http, body),\n verifyEmail: (body) => patchVerifyEmail(http, body),\n me: (accessToken) => getMe(http, accessToken),\n },\n users: {\n getProfile: (accessToken) => getUserProfile(http, accessToken),\n patchProfile: (accessToken, body) => patchUserProfile(http, accessToken, body),\n getPets: (accessToken, userId) => getUserPets(http, accessToken, userId),\n createPet: (accessToken, userId, body) => createUserPet(http, accessToken, userId, body),\n },\n pets: {\n getById: (accessToken, petId) => getPetDetails(http, accessToken, petId),\n update: (accessToken, petId, body) => putPetDetails(http, accessToken, petId, body),\n getTreatments: (accessToken, petId) => getPetTreatments(http, accessToken, petId),\n createTreatment: (accessToken, petId, body) =>\n createPetTreatment(http, accessToken, petId, body),\n getTreatment: (accessToken, petId, treatmentId) =>\n getPetTreatment(http, accessToken, petId, treatmentId),\n getTreatmentDoses: (accessToken, petId, treatmentId) =>\n getPetTreatmentDoses(http, accessToken, petId, treatmentId),\n createTreatmentDose: (accessToken, petId, treatmentId, body) =>\n createPetTreatmentDose(http, accessToken, petId, treatmentId, body),\n },\n };\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ipetsadmin/api-client",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "Client used to interact with Truffa project API",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -38,7 +38,7 @@
38
38
  "author": "",
39
39
  "license": "MIT",
40
40
  "devDependencies": {
41
- "@ipetsadmin/contracts": "1.3.0",
41
+ "@ipetsadmin/contracts": "1.3.1",
42
42
  "@eslint/js": "^10.0.1",
43
43
  "@types/express": "^5.0.5",
44
44
  "@types/node": "^24.10.0",
@@ -52,7 +52,7 @@
52
52
  "typescript-eslint": "^8.58.0"
53
53
  },
54
54
  "peerDependencies": {
55
- "@ipetsadmin/contracts": ">=1.3.0"
55
+ "@ipetsadmin/contracts": ">=1.3.1"
56
56
  },
57
57
  "publishConfig": {
58
58
  "access": "public"