@jphil/bookwhen-client 0.3.1 → 0.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/dist/index.d.ts CHANGED
@@ -105,6 +105,9 @@ declare interface EventImage {
105
105
 
106
106
  export declare type EventResource = 'location' | 'attachments' | 'tickets' | 'tickets.events' | 'tickets.class_passes';
107
107
 
108
+ declare interface EventResponse extends JsonApiResponse<BookwhenEvent> {
109
+ }
110
+
108
111
  /**
109
112
  * Service class for managing events in the Bookwhen API.
110
113
  */
@@ -123,14 +126,17 @@ declare class EventService implements IEventService {
123
126
  * @param {string} [param.include] - Optional parameter to include additional data.
124
127
  * @returns {Promise<BookwhenEvent>} A Promise that resolves to the BookwhenEvent object.
125
128
  */
126
- getById(params: z.infer<typeof GetEventByIdParamsSchema>): Promise<BookwhenEvent>;
129
+ getById(params: z.infer<typeof GetEventByIdParamsSchema>): Promise<EventResponse>;
127
130
  /**
128
131
  * Retrieves multiple events based on filtering and pagination parameters.
129
132
  *
130
133
  * @param {GetMultipleEventsParams} params - Optional parameters for filtering and pagination.
131
- * @return {Promise<BookwhenEvent[]>} A Promise that resolves to an array of BookwhenEvent objects.
134
+ * @return {Promise<EventsResponse>} A Promise that resolves to the full JSON:API response object.
132
135
  */
133
- getMultiple(params?: GetMultipleEventsParams): Promise<BookwhenEvent[]>;
136
+ getMultiple(params?: GetMultipleEventsParams): Promise<EventsResponse>;
137
+ }
138
+
139
+ declare interface EventsResponse extends JsonApiResponse<BookwhenEvent[]> {
134
140
  }
135
141
 
136
142
  export declare interface Filters {
@@ -181,15 +187,34 @@ export declare interface IEventService {
181
187
  * Retrieves a single event by its ID.
182
188
  * @param eventId The unique identifier of the event.
183
189
  * @param include Optional parameter to include additional data.
184
- * @returns A Promise that resolves to an Event object, as defined by the Bookwhen API data structure.
190
+ * @returns A Promise that resolves to the full JSON:API response object.
185
191
  */
186
- getById(params: GetEventByIdParams): Promise<BookwhenEvent>;
192
+ getById(params: GetEventByIdParams): Promise<EventResponse>;
187
193
  /**
188
194
  * Retrieves multiple events based on specified parameters.
189
195
  * @param params Optional parameters to filter and control the list of returned events, according to what the Bookwhen API supports.
190
- * @returns A Promise that resolves to an array of Event objects.
196
+ * @returns A Promise that resolves to the full JSON:API response object.
191
197
  */
192
- getMultiple?(params?: GetMultipleEventsParams): Promise<BookwhenEvent[]>;
198
+ getMultiple?(params?: GetMultipleEventsParams): Promise<EventsResponse>;
199
+ }
200
+
201
+ declare interface JsonApiResponse<T> {
202
+ data: T;
203
+ included?: any[];
204
+ links?: {
205
+ self?: string;
206
+ first?: string;
207
+ last?: string;
208
+ prev?: string;
209
+ next?: string;
210
+ };
211
+ meta?: {
212
+ page?: {
213
+ current?: number;
214
+ total?: number;
215
+ size?: number;
216
+ };
217
+ };
193
218
  }
194
219
 
195
220
  export declare type Resource = string;
package/dist/index.js CHANGED
@@ -6463,7 +6463,7 @@ class EventService {
6463
6463
  query.addIncludes(validParams.includes);
6464
6464
  }
6465
6465
  const response = await this.axiosInstance.get(`${query}`);
6466
- return response.data?.data;
6466
+ return response.data;
6467
6467
  } catch (error) {
6468
6468
  if (error instanceof z.ZodError) {
6469
6469
  const errorMessages = error.errors.map((e) => e.message).join(", ");
@@ -6484,7 +6484,7 @@ class EventService {
6484
6484
  * Retrieves multiple events based on filtering and pagination parameters.
6485
6485
  *
6486
6486
  * @param {GetMultipleEventsParams} params - Optional parameters for filtering and pagination.
6487
- * @return {Promise<BookwhenEvent[]>} A Promise that resolves to an array of BookwhenEvent objects.
6487
+ * @return {Promise<EventsResponse>} A Promise that resolves to the full JSON:API response object.
6488
6488
  */
6489
6489
  async getMultiple(params = {}) {
6490
6490
  try {
@@ -6492,7 +6492,7 @@ class EventService {
6492
6492
  if (params.includes) query.addIncludes(params.includes);
6493
6493
  if (params.filters) query.addFilters(params.filters);
6494
6494
  const response = await this.axiosInstance.get(`${query}`);
6495
- return response.data.data;
6495
+ return response.data;
6496
6496
  } catch (error) {
6497
6497
  handleServiceHTTPErrors(error, SERVICE_HTTP_STATUS_CODES);
6498
6498
  }