@ipetsadmin/api-client 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -19,6 +19,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
19
19
 
20
20
  ### Security
21
21
 
22
+ ## [1.4.0] - 2026-06-12
23
+
24
+ ### Added
25
+
26
+ - **Pets / appointments** ([`src/endpoints/pet.ts`](./src/endpoints/pet.ts)), mounted under `/api/v1/pets/...`:
27
+ - **`getPetAppointments`** — `GET /api/v1/pets/:petId/appointments`.
28
+ - **`createPetAppointment`** — `POST /api/v1/pets/:petId/appointments` — body **`PostPetAppointmentRequestBody`** (no `petId` in body; `status` optional).
29
+ - **`getPetAppointment`** — `GET /api/v1/pets/:petId/appointments/:appointmentId`.
30
+ - **`patchPetAppointment`** — `PATCH /api/v1/pets/:petId/appointments/:appointmentId` — body **`PatchPetAppointmentRequestBody`**.
31
+ - **`patchPetAppointmentStatus`** — `PATCH .../appointments/:appointmentId/status` — body **`PatchPetAppointmentStatusBody`**.
32
+ - **`deletePetAppointment`** — `DELETE /api/v1/pets/:petId/appointments/:appointmentId`.
33
+ - **`HttpDelete`** and **`HttpClient.delete`** for appointment removal (Axios-compatible).
34
+ - **`createApiClient`** **`pets`** namespace: **`getAppointments`**, **`createAppointment`**, **`getAppointment`**, **`patchAppointment`**, **`patchAppointmentStatus`**, **`deleteAppointment`**.
35
+ - Type aliases **`PostPetAppointmentRequestBody`**, **`PatchPetAppointmentRequestBody`**, **`PatchPetAppointmentStatusBody`**; re-exports from [`src/index.ts`](./src/index.ts).
36
+
37
+ ### Changed
38
+
39
+ - **Peer dependency** on **`@ipetsadmin/contracts`** is now **≥ 1.4.0** (`AppointmentResponse`, `CreateAppointmentInput`, `AppointmentStatus`, `AppointmentType`).
40
+
41
+ ### Breaking
42
+
43
+ - Custom **`HttpClient`** implementations must implement **`delete`** (in addition to **`get`**, **`post`**, **`patch`**, **`put`**).
44
+
22
45
  ## [1.3.0] - 2026-05-15
23
46
 
24
47
  ### Added
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, AppointmentResponse, CreateAppointmentInput, AppointmentStatus, UserProfileResponse, PatchUserProfileInput, HealthCheck } from '@ipetsadmin/contracts';
2
2
 
3
3
  type HttpGet = <TResponse>(url: string, config?: unknown) => Promise<{
4
4
  data: TResponse;
@@ -12,11 +12,15 @@ type HttpPatch = <TResponse, TBody = unknown>(url: string, body?: TBody, config?
12
12
  type HttpPut = <TResponse, TBody = unknown>(url: string, body?: TBody, config?: unknown) => Promise<{
13
13
  data: TResponse;
14
14
  }>;
15
+ type HttpDelete = <TResponse>(url: string, config?: unknown) => Promise<{
16
+ data: TResponse;
17
+ }>;
15
18
  interface HttpClient {
16
19
  readonly get: HttpGet;
17
20
  readonly post: HttpPost;
18
21
  readonly patch: HttpPatch;
19
22
  readonly put: HttpPut;
23
+ readonly delete: HttpDelete;
20
24
  }
21
25
 
22
26
  declare function postRegister(http: HttpClient, body: RegisterRequest): Promise<IApiResponse<AuthSessionResponse>>;
@@ -30,11 +34,25 @@ declare function patchVerifyEmail(http: HttpClient, body: VerifyEmailRequest): P
30
34
 
31
35
  type PutPetDetailsBody = Partial<Omit<CreatePetInput, 'ownerId' | 'createdAt' | 'updatedAt'>>;
32
36
  type PostPetTreatmentRequestBody = Omit<CreateTreatmentInput, 'petId'> & Partial<Pick<CreateTreatmentInput, 'status'>>;
37
+ type PostPetTreatmentDoseBody = Omit<CreateDoseInput, 'treatmentId' | 'petId' | 'ownerId'> & Partial<Pick<CreateDoseInput, 'status'>>;
38
+ type PostPetAppointmentRequestBody = Omit<CreateAppointmentInput, 'petId'> & Partial<Pick<CreateAppointmentInput, 'status'>>;
39
+ type PatchPetAppointmentRequestBody = Partial<Omit<CreateAppointmentInput, 'petId' | 'ownerId' | 'status'>>;
40
+ type PatchPetAppointmentStatusBody = {
41
+ status: AppointmentStatus;
42
+ };
33
43
  declare function getPetDetails(http: HttpClient, accessToken: string, petId: string): Promise<IApiResponse<PetResponse>>;
34
44
  declare function putPetDetails(http: HttpClient, accessToken: string, petId: string, body: PutPetDetailsBody): Promise<IApiResponse<PetResponse>>;
35
45
  declare function getPetTreatments(http: HttpClient, accessToken: string, petId: string): Promise<IApiResponse<TreatmentResponse[]>>;
36
46
  declare function createPetTreatment(http: HttpClient, accessToken: string, petId: string, body: PostPetTreatmentRequestBody): Promise<IApiResponse<TreatmentResponse>>;
37
47
  declare function getPetTreatment(http: HttpClient, accessToken: string, petId: string, treatmentId: string): Promise<IApiResponse<TreatmentResponse>>;
48
+ declare function getPetTreatmentDoses(http: HttpClient, accessToken: string, petId: string, treatmentId: string): Promise<IApiResponse<DoseResponse[]>>;
49
+ declare function createPetTreatmentDose(http: HttpClient, accessToken: string, petId: string, treatmentId: string, body: PostPetTreatmentDoseBody): Promise<IApiResponse<DoseResponse>>;
50
+ declare function getPetAppointments(http: HttpClient, accessToken: string, petId: string): Promise<IApiResponse<AppointmentResponse[]>>;
51
+ declare function createPetAppointment(http: HttpClient, accessToken: string, petId: string, body: PostPetAppointmentRequestBody): Promise<IApiResponse<AppointmentResponse>>;
52
+ declare function getPetAppointment(http: HttpClient, accessToken: string, petId: string, appointmentId: string): Promise<IApiResponse<AppointmentResponse>>;
53
+ declare function patchPetAppointment(http: HttpClient, accessToken: string, petId: string, appointmentId: string, body: PatchPetAppointmentRequestBody): Promise<IApiResponse<AppointmentResponse>>;
54
+ declare function patchPetAppointmentStatus(http: HttpClient, accessToken: string, petId: string, appointmentId: string, body: PatchPetAppointmentStatusBody): Promise<IApiResponse<AppointmentResponse>>;
55
+ declare function deletePetAppointment(http: HttpClient, accessToken: string, petId: string, appointmentId: string): Promise<IApiResponse<null>>;
38
56
 
39
57
  type PostUserPetRequestBody = Omit<CreatePetInput, 'ownerId' | 'createdAt' | 'updatedAt'>;
40
58
  declare function getUserProfile(http: HttpClient, accessToken: string): Promise<IApiResponse<UserProfileResponse>>;
@@ -71,8 +89,16 @@ interface ApiClient {
71
89
  readonly getTreatments: (accessToken: string, petId: string) => ReturnType<typeof getPetTreatments>;
72
90
  readonly createTreatment: (accessToken: string, petId: string, body: Parameters<typeof createPetTreatment>[3]) => ReturnType<typeof createPetTreatment>;
73
91
  readonly getTreatment: (accessToken: string, petId: string, treatmentId: string) => ReturnType<typeof getPetTreatment>;
92
+ readonly getTreatmentDoses: (accessToken: string, petId: string, treatmentId: string) => ReturnType<typeof getPetTreatmentDoses>;
93
+ readonly createTreatmentDose: (accessToken: string, petId: string, treatmentId: string, body: Parameters<typeof createPetTreatmentDose>[4]) => ReturnType<typeof createPetTreatmentDose>;
94
+ readonly getAppointments: (accessToken: string, petId: string) => ReturnType<typeof getPetAppointments>;
95
+ readonly createAppointment: (accessToken: string, petId: string, body: Parameters<typeof createPetAppointment>[3]) => ReturnType<typeof createPetAppointment>;
96
+ readonly getAppointment: (accessToken: string, petId: string, appointmentId: string) => ReturnType<typeof getPetAppointment>;
97
+ readonly patchAppointment: (accessToken: string, petId: string, appointmentId: string, body: Parameters<typeof patchPetAppointment>[4]) => ReturnType<typeof patchPetAppointment>;
98
+ readonly patchAppointmentStatus: (accessToken: string, petId: string, appointmentId: string, body: Parameters<typeof patchPetAppointmentStatus>[4]) => ReturnType<typeof patchPetAppointmentStatus>;
99
+ readonly deleteAppointment: (accessToken: string, petId: string, appointmentId: string) => ReturnType<typeof deletePetAppointment>;
74
100
  };
75
101
  }
76
102
  declare function createApiClient(options: CreateApiClientOptions): ApiClient;
77
103
 
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 };
104
+ export { type ApiClient, type CreateApiClientOptions, type HttpClient, type HttpDelete, type HttpGet, type HttpPatch, type HttpPost, type HttpPut, type PatchPetAppointmentRequestBody, type PatchPetAppointmentStatusBody, type PostPetAppointmentRequestBody, type PostPetTreatmentDoseBody, type PostPetTreatmentRequestBody, type PostUserPetRequestBody, type PutPetDetailsBody, createApiClient, createPetAppointment, createPetTreatment, createPetTreatmentDose, createUserPet, deletePetAppointment, fetchHealthCheck, getGoogleOAuthStart, getMe, getPetAppointment, getPetAppointments, getPetDetails, getPetTreatment, getPetTreatmentDoses, getPetTreatments, getUserPets, getUserProfile, patchPetAppointment, patchPetAppointmentStatus, 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, AppointmentResponse, CreateAppointmentInput, AppointmentStatus, UserProfileResponse, PatchUserProfileInput, HealthCheck } from '@ipetsadmin/contracts';
2
2
 
3
3
  type HttpGet = <TResponse>(url: string, config?: unknown) => Promise<{
4
4
  data: TResponse;
@@ -12,11 +12,15 @@ type HttpPatch = <TResponse, TBody = unknown>(url: string, body?: TBody, config?
12
12
  type HttpPut = <TResponse, TBody = unknown>(url: string, body?: TBody, config?: unknown) => Promise<{
13
13
  data: TResponse;
14
14
  }>;
15
+ type HttpDelete = <TResponse>(url: string, config?: unknown) => Promise<{
16
+ data: TResponse;
17
+ }>;
15
18
  interface HttpClient {
16
19
  readonly get: HttpGet;
17
20
  readonly post: HttpPost;
18
21
  readonly patch: HttpPatch;
19
22
  readonly put: HttpPut;
23
+ readonly delete: HttpDelete;
20
24
  }
21
25
 
22
26
  declare function postRegister(http: HttpClient, body: RegisterRequest): Promise<IApiResponse<AuthSessionResponse>>;
@@ -30,11 +34,25 @@ declare function patchVerifyEmail(http: HttpClient, body: VerifyEmailRequest): P
30
34
 
31
35
  type PutPetDetailsBody = Partial<Omit<CreatePetInput, 'ownerId' | 'createdAt' | 'updatedAt'>>;
32
36
  type PostPetTreatmentRequestBody = Omit<CreateTreatmentInput, 'petId'> & Partial<Pick<CreateTreatmentInput, 'status'>>;
37
+ type PostPetTreatmentDoseBody = Omit<CreateDoseInput, 'treatmentId' | 'petId' | 'ownerId'> & Partial<Pick<CreateDoseInput, 'status'>>;
38
+ type PostPetAppointmentRequestBody = Omit<CreateAppointmentInput, 'petId'> & Partial<Pick<CreateAppointmentInput, 'status'>>;
39
+ type PatchPetAppointmentRequestBody = Partial<Omit<CreateAppointmentInput, 'petId' | 'ownerId' | 'status'>>;
40
+ type PatchPetAppointmentStatusBody = {
41
+ status: AppointmentStatus;
42
+ };
33
43
  declare function getPetDetails(http: HttpClient, accessToken: string, petId: string): Promise<IApiResponse<PetResponse>>;
34
44
  declare function putPetDetails(http: HttpClient, accessToken: string, petId: string, body: PutPetDetailsBody): Promise<IApiResponse<PetResponse>>;
35
45
  declare function getPetTreatments(http: HttpClient, accessToken: string, petId: string): Promise<IApiResponse<TreatmentResponse[]>>;
36
46
  declare function createPetTreatment(http: HttpClient, accessToken: string, petId: string, body: PostPetTreatmentRequestBody): Promise<IApiResponse<TreatmentResponse>>;
37
47
  declare function getPetTreatment(http: HttpClient, accessToken: string, petId: string, treatmentId: string): Promise<IApiResponse<TreatmentResponse>>;
48
+ declare function getPetTreatmentDoses(http: HttpClient, accessToken: string, petId: string, treatmentId: string): Promise<IApiResponse<DoseResponse[]>>;
49
+ declare function createPetTreatmentDose(http: HttpClient, accessToken: string, petId: string, treatmentId: string, body: PostPetTreatmentDoseBody): Promise<IApiResponse<DoseResponse>>;
50
+ declare function getPetAppointments(http: HttpClient, accessToken: string, petId: string): Promise<IApiResponse<AppointmentResponse[]>>;
51
+ declare function createPetAppointment(http: HttpClient, accessToken: string, petId: string, body: PostPetAppointmentRequestBody): Promise<IApiResponse<AppointmentResponse>>;
52
+ declare function getPetAppointment(http: HttpClient, accessToken: string, petId: string, appointmentId: string): Promise<IApiResponse<AppointmentResponse>>;
53
+ declare function patchPetAppointment(http: HttpClient, accessToken: string, petId: string, appointmentId: string, body: PatchPetAppointmentRequestBody): Promise<IApiResponse<AppointmentResponse>>;
54
+ declare function patchPetAppointmentStatus(http: HttpClient, accessToken: string, petId: string, appointmentId: string, body: PatchPetAppointmentStatusBody): Promise<IApiResponse<AppointmentResponse>>;
55
+ declare function deletePetAppointment(http: HttpClient, accessToken: string, petId: string, appointmentId: string): Promise<IApiResponse<null>>;
38
56
 
39
57
  type PostUserPetRequestBody = Omit<CreatePetInput, 'ownerId' | 'createdAt' | 'updatedAt'>;
40
58
  declare function getUserProfile(http: HttpClient, accessToken: string): Promise<IApiResponse<UserProfileResponse>>;
@@ -71,8 +89,16 @@ interface ApiClient {
71
89
  readonly getTreatments: (accessToken: string, petId: string) => ReturnType<typeof getPetTreatments>;
72
90
  readonly createTreatment: (accessToken: string, petId: string, body: Parameters<typeof createPetTreatment>[3]) => ReturnType<typeof createPetTreatment>;
73
91
  readonly getTreatment: (accessToken: string, petId: string, treatmentId: string) => ReturnType<typeof getPetTreatment>;
92
+ readonly getTreatmentDoses: (accessToken: string, petId: string, treatmentId: string) => ReturnType<typeof getPetTreatmentDoses>;
93
+ readonly createTreatmentDose: (accessToken: string, petId: string, treatmentId: string, body: Parameters<typeof createPetTreatmentDose>[4]) => ReturnType<typeof createPetTreatmentDose>;
94
+ readonly getAppointments: (accessToken: string, petId: string) => ReturnType<typeof getPetAppointments>;
95
+ readonly createAppointment: (accessToken: string, petId: string, body: Parameters<typeof createPetAppointment>[3]) => ReturnType<typeof createPetAppointment>;
96
+ readonly getAppointment: (accessToken: string, petId: string, appointmentId: string) => ReturnType<typeof getPetAppointment>;
97
+ readonly patchAppointment: (accessToken: string, petId: string, appointmentId: string, body: Parameters<typeof patchPetAppointment>[4]) => ReturnType<typeof patchPetAppointment>;
98
+ readonly patchAppointmentStatus: (accessToken: string, petId: string, appointmentId: string, body: Parameters<typeof patchPetAppointmentStatus>[4]) => ReturnType<typeof patchPetAppointmentStatus>;
99
+ readonly deleteAppointment: (accessToken: string, petId: string, appointmentId: string) => ReturnType<typeof deletePetAppointment>;
74
100
  };
75
101
  }
76
102
  declare function createApiClient(options: CreateApiClientOptions): ApiClient;
77
103
 
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 };
104
+ export { type ApiClient, type CreateApiClientOptions, type HttpClient, type HttpDelete, type HttpGet, type HttpPatch, type HttpPost, type HttpPut, type PatchPetAppointmentRequestBody, type PatchPetAppointmentStatusBody, type PostPetAppointmentRequestBody, type PostPetTreatmentDoseBody, type PostPetTreatmentRequestBody, type PostUserPetRequestBody, type PutPetDetailsBody, createApiClient, createPetAppointment, createPetTreatment, createPetTreatmentDose, createUserPet, deletePetAppointment, fetchHealthCheck, getGoogleOAuthStart, getMe, getPetAppointment, getPetAppointments, getPetDetails, getPetTreatment, getPetTreatmentDoses, getPetTreatments, getUserPets, getUserProfile, patchPetAppointment, patchPetAppointmentStatus, patchUserProfile, patchVerifyEmail, postGoogleOAuthCallback, postLogin, postLogout, postRefresh, postRegister, putPetDetails };
package/dist/index.js CHANGED
@@ -100,6 +100,70 @@ 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
+ }
122
+ async function getPetAppointments(http, accessToken, petId) {
123
+ const { data } = await http.get(
124
+ `${PETS_BASE}/${petId}/appointments`,
125
+ {
126
+ headers: { Authorization: `Bearer ${accessToken}` }
127
+ }
128
+ );
129
+ return data;
130
+ }
131
+ async function createPetAppointment(http, accessToken, petId, body) {
132
+ const { data } = await http.post(`${PETS_BASE}/${petId}/appointments`, body, {
133
+ headers: { Authorization: `Bearer ${accessToken}` }
134
+ });
135
+ return data;
136
+ }
137
+ async function getPetAppointment(http, accessToken, petId, appointmentId) {
138
+ const { data } = await http.get(
139
+ `${PETS_BASE}/${petId}/appointments/${appointmentId}`,
140
+ {
141
+ headers: { Authorization: `Bearer ${accessToken}` }
142
+ }
143
+ );
144
+ return data;
145
+ }
146
+ async function patchPetAppointment(http, accessToken, petId, appointmentId, body) {
147
+ const { data } = await http.patch(`${PETS_BASE}/${petId}/appointments/${appointmentId}`, body, {
148
+ headers: { Authorization: `Bearer ${accessToken}` }
149
+ });
150
+ return data;
151
+ }
152
+ async function patchPetAppointmentStatus(http, accessToken, petId, appointmentId, body) {
153
+ const { data } = await http.patch(`${PETS_BASE}/${petId}/appointments/${appointmentId}/status`, body, {
154
+ headers: { Authorization: `Bearer ${accessToken}` }
155
+ });
156
+ return data;
157
+ }
158
+ async function deletePetAppointment(http, accessToken, petId, appointmentId) {
159
+ const { data } = await http.delete(
160
+ `${PETS_BASE}/${petId}/appointments/${appointmentId}`,
161
+ {
162
+ headers: { Authorization: `Bearer ${accessToken}` }
163
+ }
164
+ );
165
+ return data;
166
+ }
103
167
 
104
168
  // src/endpoints/user.ts
105
169
  var USERS_BASE = "/api/v1/users";
@@ -169,22 +233,38 @@ function createApiClient(options) {
169
233
  update: (accessToken, petId, body) => putPetDetails(http, accessToken, petId, body),
170
234
  getTreatments: (accessToken, petId) => getPetTreatments(http, accessToken, petId),
171
235
  createTreatment: (accessToken, petId, body) => createPetTreatment(http, accessToken, petId, body),
172
- getTreatment: (accessToken, petId, treatmentId) => getPetTreatment(http, accessToken, petId, treatmentId)
236
+ getTreatment: (accessToken, petId, treatmentId) => getPetTreatment(http, accessToken, petId, treatmentId),
237
+ getTreatmentDoses: (accessToken, petId, treatmentId) => getPetTreatmentDoses(http, accessToken, petId, treatmentId),
238
+ createTreatmentDose: (accessToken, petId, treatmentId, body) => createPetTreatmentDose(http, accessToken, petId, treatmentId, body),
239
+ getAppointments: (accessToken, petId) => getPetAppointments(http, accessToken, petId),
240
+ createAppointment: (accessToken, petId, body) => createPetAppointment(http, accessToken, petId, body),
241
+ getAppointment: (accessToken, petId, appointmentId) => getPetAppointment(http, accessToken, petId, appointmentId),
242
+ patchAppointment: (accessToken, petId, appointmentId, body) => patchPetAppointment(http, accessToken, petId, appointmentId, body),
243
+ patchAppointmentStatus: (accessToken, petId, appointmentId, body) => patchPetAppointmentStatus(http, accessToken, petId, appointmentId, body),
244
+ deleteAppointment: (accessToken, petId, appointmentId) => deletePetAppointment(http, accessToken, petId, appointmentId)
173
245
  }
174
246
  };
175
247
  }
176
248
 
177
249
  exports.createApiClient = createApiClient;
250
+ exports.createPetAppointment = createPetAppointment;
178
251
  exports.createPetTreatment = createPetTreatment;
252
+ exports.createPetTreatmentDose = createPetTreatmentDose;
179
253
  exports.createUserPet = createUserPet;
254
+ exports.deletePetAppointment = deletePetAppointment;
180
255
  exports.fetchHealthCheck = fetchHealthCheck;
181
256
  exports.getGoogleOAuthStart = getGoogleOAuthStart;
182
257
  exports.getMe = getMe;
258
+ exports.getPetAppointment = getPetAppointment;
259
+ exports.getPetAppointments = getPetAppointments;
183
260
  exports.getPetDetails = getPetDetails;
184
261
  exports.getPetTreatment = getPetTreatment;
262
+ exports.getPetTreatmentDoses = getPetTreatmentDoses;
185
263
  exports.getPetTreatments = getPetTreatments;
186
264
  exports.getUserPets = getUserPets;
187
265
  exports.getUserProfile = getUserProfile;
266
+ exports.patchPetAppointment = patchPetAppointment;
267
+ exports.patchPetAppointmentStatus = patchPetAppointmentStatus;
188
268
  exports.patchUserProfile = patchUserProfile;
189
269
  exports.patchVerifyEmail = patchVerifyEmail;
190
270
  exports.postGoogleOAuthCallback = postGoogleOAuthCallback;
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;AA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AAA,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;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;AA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WAAA,EAAa,KAAA,EAAO,SACtC,oBAAA,CAAqB,IAAA,EAAM,WAAA,EAAa,KAAA,EAAO,IAAI,CAAA;AAAA,MACrD,cAAA,EAAgB,CAAC,WAAA,EAAa,KAAA,EAAO,kBACnC,iBAAA,CAAkB,IAAA,EAAM,WAAA,EAAa,KAAA,EAAO,aAAa,CAAA;AAAA,MAC3D,gBAAA,EAAkB,CAAC,WAAA,EAAa,KAAA,EAAO,aAAA,EAAe,IAAA,KACpD,mBAAA,CAAoB,IAAA,EAAM,WAAA,EAAa,KAAA,EAAO,aAAA,EAAe,IAAI,CAAA;AAAA,MACnE,sBAAA,EAAwB,CAAC,WAAA,EAAa,KAAA,EAAO,aAAA,EAAe,IAAA,KAC1D,yBAAA,CAA0B,IAAA,EAAM,WAAA,EAAa,KAAA,EAAO,aAAA,EAAe,IAAI,CAAA;AAAA,MACzE,iBAAA,EAAmB,CAAC,WAAA,EAAa,KAAA,EAAO,kBACtC,oBAAA,CAAqB,IAAA,EAAM,WAAA,EAAa,KAAA,EAAO,aAAa;AAAA;AAChE,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 AppointmentResponse,\n AppointmentStatus,\n CreateAppointmentInput,\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 * Same fields as creating an appointment without `petId` (provided in the URL). `status` may be omitted\n * (defaults to pending on the server).\n */\nexport type PostPetAppointmentRequestBody = Omit<CreateAppointmentInput, 'petId'> &\n Partial<Pick<CreateAppointmentInput, 'status'>>;\n\n/** Partial update for PATCH /api/v1/pets/:petId/appointments/:appointmentId (excludes status). */\nexport type PatchPetAppointmentRequestBody = Partial<\n Omit<CreateAppointmentInput, 'petId' | 'ownerId' | 'status'>\n>;\n\n/** Body for PATCH .../appointments/:appointmentId/status. */\nexport type PatchPetAppointmentStatusBody = {\n status: AppointmentStatus;\n};\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\n/**\n * GET /api/v1/pets/:petId/appointments\n */\nexport async function getPetAppointments(\n http: HttpClient,\n accessToken: string,\n petId: string,\n): Promise<IApiResponse<AppointmentResponse[]>> {\n const { data } = await http.get<IApiResponse<AppointmentResponse[]>>(\n `${PETS_BASE}/${petId}/appointments`,\n {\n headers: { Authorization: `Bearer ${accessToken}` },\n },\n );\n return data;\n}\n\n/**\n * POST /api/v1/pets/:petId/appointments — 201 Created.\n */\nexport async function createPetAppointment(\n http: HttpClient,\n accessToken: string,\n petId: string,\n body: PostPetAppointmentRequestBody,\n): Promise<IApiResponse<AppointmentResponse>> {\n const { data } = await http.post<\n IApiResponse<AppointmentResponse>,\n PostPetAppointmentRequestBody\n >(`${PETS_BASE}/${petId}/appointments`, body, {\n headers: { Authorization: `Bearer ${accessToken}` },\n });\n return data;\n}\n\n/**\n * GET /api/v1/pets/:petId/appointments/:appointmentId\n */\nexport async function getPetAppointment(\n http: HttpClient,\n accessToken: string,\n petId: string,\n appointmentId: string,\n): Promise<IApiResponse<AppointmentResponse>> {\n const { data } = await http.get<IApiResponse<AppointmentResponse>>(\n `${PETS_BASE}/${petId}/appointments/${appointmentId}`,\n {\n headers: { Authorization: `Bearer ${accessToken}` },\n },\n );\n return data;\n}\n\n/**\n * PATCH /api/v1/pets/:petId/appointments/:appointmentId — partial update (not status).\n */\nexport async function patchPetAppointment(\n http: HttpClient,\n accessToken: string,\n petId: string,\n appointmentId: string,\n body: PatchPetAppointmentRequestBody,\n): Promise<IApiResponse<AppointmentResponse>> {\n const { data } = await http.patch<\n IApiResponse<AppointmentResponse>,\n PatchPetAppointmentRequestBody\n >(`${PETS_BASE}/${petId}/appointments/${appointmentId}`, body, {\n headers: { Authorization: `Bearer ${accessToken}` },\n });\n return data;\n}\n\n/**\n * PATCH /api/v1/pets/:petId/appointments/:appointmentId/status\n */\nexport async function patchPetAppointmentStatus(\n http: HttpClient,\n accessToken: string,\n petId: string,\n appointmentId: string,\n body: PatchPetAppointmentStatusBody,\n): Promise<IApiResponse<AppointmentResponse>> {\n const { data } = await http.patch<\n IApiResponse<AppointmentResponse>,\n PatchPetAppointmentStatusBody\n >(`${PETS_BASE}/${petId}/appointments/${appointmentId}/status`, body, {\n headers: { Authorization: `Bearer ${accessToken}` },\n });\n return data;\n}\n\n/**\n * DELETE /api/v1/pets/:petId/appointments/:appointmentId\n */\nexport async function deletePetAppointment(\n http: HttpClient,\n accessToken: string,\n petId: string,\n appointmentId: string,\n): Promise<IApiResponse<null>> {\n const { data } = await http.delete<IApiResponse<null>>(\n `${PETS_BASE}/${petId}/appointments/${appointmentId}`,\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 createPetAppointment,\n createPetTreatment,\n createPetTreatmentDose,\n deletePetAppointment,\n getPetAppointment,\n getPetAppointments,\n getPetDetails,\n getPetTreatment,\n getPetTreatmentDoses,\n getPetTreatments,\n patchPetAppointment,\n patchPetAppointmentStatus,\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`, `put`, and `delete` 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 readonly getAppointments: (\n accessToken: string,\n petId: string,\n ) => ReturnType<typeof getPetAppointments>;\n readonly createAppointment: (\n accessToken: string,\n petId: string,\n body: Parameters<typeof createPetAppointment>[3],\n ) => ReturnType<typeof createPetAppointment>;\n readonly getAppointment: (\n accessToken: string,\n petId: string,\n appointmentId: string,\n ) => ReturnType<typeof getPetAppointment>;\n readonly patchAppointment: (\n accessToken: string,\n petId: string,\n appointmentId: string,\n body: Parameters<typeof patchPetAppointment>[4],\n ) => ReturnType<typeof patchPetAppointment>;\n readonly patchAppointmentStatus: (\n accessToken: string,\n petId: string,\n appointmentId: string,\n body: Parameters<typeof patchPetAppointmentStatus>[4],\n ) => ReturnType<typeof patchPetAppointmentStatus>;\n readonly deleteAppointment: (\n accessToken: string,\n petId: string,\n appointmentId: string,\n ) => ReturnType<typeof deletePetAppointment>;\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 getAppointments: (accessToken, petId) => getPetAppointments(http, accessToken, petId),\n createAppointment: (accessToken, petId, body) =>\n createPetAppointment(http, accessToken, petId, body),\n getAppointment: (accessToken, petId, appointmentId) =>\n getPetAppointment(http, accessToken, petId, appointmentId),\n patchAppointment: (accessToken, petId, appointmentId, body) =>\n patchPetAppointment(http, accessToken, petId, appointmentId, body),\n patchAppointmentStatus: (accessToken, petId, appointmentId, body) =>\n patchPetAppointmentStatus(http, accessToken, petId, appointmentId, body),\n deleteAppointment: (accessToken, petId, appointmentId) =>\n deletePetAppointment(http, accessToken, petId, appointmentId),\n },\n };\n}\n"]}
package/dist/index.mjs CHANGED
@@ -98,6 +98,70 @@ 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
+ }
120
+ async function getPetAppointments(http, accessToken, petId) {
121
+ const { data } = await http.get(
122
+ `${PETS_BASE}/${petId}/appointments`,
123
+ {
124
+ headers: { Authorization: `Bearer ${accessToken}` }
125
+ }
126
+ );
127
+ return data;
128
+ }
129
+ async function createPetAppointment(http, accessToken, petId, body) {
130
+ const { data } = await http.post(`${PETS_BASE}/${petId}/appointments`, body, {
131
+ headers: { Authorization: `Bearer ${accessToken}` }
132
+ });
133
+ return data;
134
+ }
135
+ async function getPetAppointment(http, accessToken, petId, appointmentId) {
136
+ const { data } = await http.get(
137
+ `${PETS_BASE}/${petId}/appointments/${appointmentId}`,
138
+ {
139
+ headers: { Authorization: `Bearer ${accessToken}` }
140
+ }
141
+ );
142
+ return data;
143
+ }
144
+ async function patchPetAppointment(http, accessToken, petId, appointmentId, body) {
145
+ const { data } = await http.patch(`${PETS_BASE}/${petId}/appointments/${appointmentId}`, body, {
146
+ headers: { Authorization: `Bearer ${accessToken}` }
147
+ });
148
+ return data;
149
+ }
150
+ async function patchPetAppointmentStatus(http, accessToken, petId, appointmentId, body) {
151
+ const { data } = await http.patch(`${PETS_BASE}/${petId}/appointments/${appointmentId}/status`, body, {
152
+ headers: { Authorization: `Bearer ${accessToken}` }
153
+ });
154
+ return data;
155
+ }
156
+ async function deletePetAppointment(http, accessToken, petId, appointmentId) {
157
+ const { data } = await http.delete(
158
+ `${PETS_BASE}/${petId}/appointments/${appointmentId}`,
159
+ {
160
+ headers: { Authorization: `Bearer ${accessToken}` }
161
+ }
162
+ );
163
+ return data;
164
+ }
101
165
 
102
166
  // src/endpoints/user.ts
103
167
  var USERS_BASE = "/api/v1/users";
@@ -167,11 +231,19 @@ function createApiClient(options) {
167
231
  update: (accessToken, petId, body) => putPetDetails(http, accessToken, petId, body),
168
232
  getTreatments: (accessToken, petId) => getPetTreatments(http, accessToken, petId),
169
233
  createTreatment: (accessToken, petId, body) => createPetTreatment(http, accessToken, petId, body),
170
- getTreatment: (accessToken, petId, treatmentId) => getPetTreatment(http, accessToken, petId, treatmentId)
234
+ getTreatment: (accessToken, petId, treatmentId) => getPetTreatment(http, accessToken, petId, treatmentId),
235
+ getTreatmentDoses: (accessToken, petId, treatmentId) => getPetTreatmentDoses(http, accessToken, petId, treatmentId),
236
+ createTreatmentDose: (accessToken, petId, treatmentId, body) => createPetTreatmentDose(http, accessToken, petId, treatmentId, body),
237
+ getAppointments: (accessToken, petId) => getPetAppointments(http, accessToken, petId),
238
+ createAppointment: (accessToken, petId, body) => createPetAppointment(http, accessToken, petId, body),
239
+ getAppointment: (accessToken, petId, appointmentId) => getPetAppointment(http, accessToken, petId, appointmentId),
240
+ patchAppointment: (accessToken, petId, appointmentId, body) => patchPetAppointment(http, accessToken, petId, appointmentId, body),
241
+ patchAppointmentStatus: (accessToken, petId, appointmentId, body) => patchPetAppointmentStatus(http, accessToken, petId, appointmentId, body),
242
+ deleteAppointment: (accessToken, petId, appointmentId) => deletePetAppointment(http, accessToken, petId, appointmentId)
171
243
  }
172
244
  };
173
245
  }
174
246
 
175
- export { createApiClient, createPetTreatment, createUserPet, fetchHealthCheck, getGoogleOAuthStart, getMe, getPetDetails, getPetTreatment, getPetTreatments, getUserPets, getUserProfile, patchUserProfile, patchVerifyEmail, postGoogleOAuthCallback, postLogin, postLogout, postRefresh, postRegister, putPetDetails };
247
+ export { createApiClient, createPetAppointment, createPetTreatment, createPetTreatmentDose, createUserPet, deletePetAppointment, fetchHealthCheck, getGoogleOAuthStart, getMe, getPetAppointment, getPetAppointments, getPetDetails, getPetTreatment, getPetTreatmentDoses, getPetTreatments, getUserPets, getUserProfile, patchPetAppointment, patchPetAppointmentStatus, patchUserProfile, patchVerifyEmail, postGoogleOAuthCallback, postLogin, postLogout, postRefresh, postRegister, putPetDetails };
176
248
  //# sourceMappingURL=index.mjs.map
177
249
  //# 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,C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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.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,M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AA,EAAe,IAAI,CAAA;AAAA,MACnE,sBAAA,EAAwB,CAAC,WAAA,EAAa,KAAA,EAAO,aAAA,EAAe,IAAA,KAC1D,yBAAA,CAA0B,IAAA,EAAM,WAAA,EAAa,KAAA,EAAO,aAAA,EAAe,IAAI,CAAA;AAAA,MACzE,iBAAA,EAAmB,CAAC,WAAA,EAAa,KAAA,EAAO,kBACtC,oBAAA,CAAqB,IAAA,EAAM,WAAA,EAAa,KAAA,EAAO,aAAa;AAAA;AAChE,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 AppointmentResponse,\n AppointmentStatus,\n CreateAppointmentInput,\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 * Same fields as creating an appointment without `petId` (provided in the URL). `status` may be omitted\n * (defaults to pending on the server).\n */\nexport type PostPetAppointmentRequestBody = Omit<CreateAppointmentInput, 'petId'> &\n Partial<Pick<CreateAppointmentInput, 'status'>>;\n\n/** Partial update for PATCH /api/v1/pets/:petId/appointments/:appointmentId (excludes status). */\nexport type PatchPetAppointmentRequestBody = Partial<\n Omit<CreateAppointmentInput, 'petId' | 'ownerId' | 'status'>\n>;\n\n/** Body for PATCH .../appointments/:appointmentId/status. */\nexport type PatchPetAppointmentStatusBody = {\n status: AppointmentStatus;\n};\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\n/**\n * GET /api/v1/pets/:petId/appointments\n */\nexport async function getPetAppointments(\n http: HttpClient,\n accessToken: string,\n petId: string,\n): Promise<IApiResponse<AppointmentResponse[]>> {\n const { data } = await http.get<IApiResponse<AppointmentResponse[]>>(\n `${PETS_BASE}/${petId}/appointments`,\n {\n headers: { Authorization: `Bearer ${accessToken}` },\n },\n );\n return data;\n}\n\n/**\n * POST /api/v1/pets/:petId/appointments — 201 Created.\n */\nexport async function createPetAppointment(\n http: HttpClient,\n accessToken: string,\n petId: string,\n body: PostPetAppointmentRequestBody,\n): Promise<IApiResponse<AppointmentResponse>> {\n const { data } = await http.post<\n IApiResponse<AppointmentResponse>,\n PostPetAppointmentRequestBody\n >(`${PETS_BASE}/${petId}/appointments`, body, {\n headers: { Authorization: `Bearer ${accessToken}` },\n });\n return data;\n}\n\n/**\n * GET /api/v1/pets/:petId/appointments/:appointmentId\n */\nexport async function getPetAppointment(\n http: HttpClient,\n accessToken: string,\n petId: string,\n appointmentId: string,\n): Promise<IApiResponse<AppointmentResponse>> {\n const { data } = await http.get<IApiResponse<AppointmentResponse>>(\n `${PETS_BASE}/${petId}/appointments/${appointmentId}`,\n {\n headers: { Authorization: `Bearer ${accessToken}` },\n },\n );\n return data;\n}\n\n/**\n * PATCH /api/v1/pets/:petId/appointments/:appointmentId — partial update (not status).\n */\nexport async function patchPetAppointment(\n http: HttpClient,\n accessToken: string,\n petId: string,\n appointmentId: string,\n body: PatchPetAppointmentRequestBody,\n): Promise<IApiResponse<AppointmentResponse>> {\n const { data } = await http.patch<\n IApiResponse<AppointmentResponse>,\n PatchPetAppointmentRequestBody\n >(`${PETS_BASE}/${petId}/appointments/${appointmentId}`, body, {\n headers: { Authorization: `Bearer ${accessToken}` },\n });\n return data;\n}\n\n/**\n * PATCH /api/v1/pets/:petId/appointments/:appointmentId/status\n */\nexport async function patchPetAppointmentStatus(\n http: HttpClient,\n accessToken: string,\n petId: string,\n appointmentId: string,\n body: PatchPetAppointmentStatusBody,\n): Promise<IApiResponse<AppointmentResponse>> {\n const { data } = await http.patch<\n IApiResponse<AppointmentResponse>,\n PatchPetAppointmentStatusBody\n >(`${PETS_BASE}/${petId}/appointments/${appointmentId}/status`, body, {\n headers: { Authorization: `Bearer ${accessToken}` },\n });\n return data;\n}\n\n/**\n * DELETE /api/v1/pets/:petId/appointments/:appointmentId\n */\nexport async function deletePetAppointment(\n http: HttpClient,\n accessToken: string,\n petId: string,\n appointmentId: string,\n): Promise<IApiResponse<null>> {\n const { data } = await http.delete<IApiResponse<null>>(\n `${PETS_BASE}/${petId}/appointments/${appointmentId}`,\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 createPetAppointment,\n createPetTreatment,\n createPetTreatmentDose,\n deletePetAppointment,\n getPetAppointment,\n getPetAppointments,\n getPetDetails,\n getPetTreatment,\n getPetTreatmentDoses,\n getPetTreatments,\n patchPetAppointment,\n patchPetAppointmentStatus,\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`, `put`, and `delete` 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 readonly getAppointments: (\n accessToken: string,\n petId: string,\n ) => ReturnType<typeof getPetAppointments>;\n readonly createAppointment: (\n accessToken: string,\n petId: string,\n body: Parameters<typeof createPetAppointment>[3],\n ) => ReturnType<typeof createPetAppointment>;\n readonly getAppointment: (\n accessToken: string,\n petId: string,\n appointmentId: string,\n ) => ReturnType<typeof getPetAppointment>;\n readonly patchAppointment: (\n accessToken: string,\n petId: string,\n appointmentId: string,\n body: Parameters<typeof patchPetAppointment>[4],\n ) => ReturnType<typeof patchPetAppointment>;\n readonly patchAppointmentStatus: (\n accessToken: string,\n petId: string,\n appointmentId: string,\n body: Parameters<typeof patchPetAppointmentStatus>[4],\n ) => ReturnType<typeof patchPetAppointmentStatus>;\n readonly deleteAppointment: (\n accessToken: string,\n petId: string,\n appointmentId: string,\n ) => ReturnType<typeof deletePetAppointment>;\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 getAppointments: (accessToken, petId) => getPetAppointments(http, accessToken, petId),\n createAppointment: (accessToken, petId, body) =>\n createPetAppointment(http, accessToken, petId, body),\n getAppointment: (accessToken, petId, appointmentId) =>\n getPetAppointment(http, accessToken, petId, appointmentId),\n patchAppointment: (accessToken, petId, appointmentId, body) =>\n patchPetAppointment(http, accessToken, petId, appointmentId, body),\n patchAppointmentStatus: (accessToken, petId, appointmentId, body) =>\n patchPetAppointmentStatus(http, accessToken, petId, appointmentId, body),\n deleteAppointment: (accessToken, petId, appointmentId) =>\n deletePetAppointment(http, accessToken, petId, appointmentId),\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.4.0",
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.4.0",
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.4.0"
56
56
  },
57
57
  "publishConfig": {
58
58
  "access": "public"