@jphil/bookwhen-client 0.5.1 → 0.6.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/README.md CHANGED
@@ -109,7 +109,7 @@ Project docs are intentionally lightweight and living:
109
109
 
110
110
  ## Roadmap
111
111
 
112
- - Expand coverage to remaining Bookwhen v2 content models.
112
+ - Improve and consolidate shared JSON:API typing across model services.
113
113
  - Continue improving test depth across browser and Node environments.
114
114
  - Iterate toward a stable 1.0 release with community feedback.
115
115
 
package/dist/index.d.ts CHANGED
@@ -229,12 +229,24 @@ declare class EventService implements IEventService {
229
229
  */
230
230
  getById(params: z.infer<typeof GetEventByIdParamsSchema>): Promise<EventResponse>;
231
231
  /**
232
- * Retrieves multiple events based on filtering and pagination parameters.
232
+ * Retrieves a single page of events based on filtering and pagination parameters.
233
+ * The Bookwhen API returns up to 20 events per page by default.
233
234
  *
234
235
  * @param {GetMultipleEventsParams} params - Optional parameters for filtering and pagination.
235
236
  * @return {Promise<EventsResponse>} A Promise that resolves to the full JSON:API response object.
236
237
  */
237
238
  getMultiple(params?: GetMultipleEventsParams): Promise<EventsResponse>;
239
+ /**
240
+ * Retrieves all events matching the given filters, automatically following
241
+ * pagination links to fetch every page of results.
242
+ *
243
+ * The returned response contains the combined `data` and deduplicated
244
+ * `included` arrays from all pages.
245
+ *
246
+ * @param {GetMultipleEventsParams} params - Optional parameters for filtering.
247
+ * @return {Promise<EventsResponse>} A Promise that resolves to the combined JSON:API response.
248
+ */
249
+ getAll(params?: GetMultipleEventsParams): Promise<EventsResponse>;
238
250
  }
239
251
 
240
252
  declare interface EventsResponse extends JsonApiResponse<BookwhenEvent[]> {
@@ -371,11 +383,18 @@ export declare interface IEventService {
371
383
  */
372
384
  getById(params: GetEventByIdParams): Promise<EventResponse>;
373
385
  /**
374
- * Retrieves multiple events based on specified parameters.
386
+ * Retrieves a single page of events based on specified parameters.
375
387
  * @param params Optional parameters to filter and control the list of returned events, according to what the Bookwhen API supports.
376
388
  * @returns A Promise that resolves to the full JSON:API response object.
377
389
  */
378
390
  getMultiple?(params?: GetMultipleEventsParams): Promise<EventsResponse>;
391
+ /**
392
+ * Retrieves all events matching the given filters, automatically following
393
+ * pagination links to fetch every page of results.
394
+ * @param params Optional parameters to filter the returned events.
395
+ * @returns A Promise that resolves to the combined JSON:API response with all pages merged.
396
+ */
397
+ getAll?(params?: GetMultipleEventsParams): Promise<EventsResponse>;
379
398
  }
380
399
 
381
400
  export declare interface ILocationService {
package/dist/index.js CHANGED
@@ -6481,7 +6481,8 @@ class EventService {
6481
6481
  }
6482
6482
  }
6483
6483
  /**
6484
- * Retrieves multiple events based on filtering and pagination parameters.
6484
+ * Retrieves a single page of events based on filtering and pagination parameters.
6485
+ * The Bookwhen API returns up to 20 events per page by default.
6485
6486
  *
6486
6487
  * @param {GetMultipleEventsParams} params - Optional parameters for filtering and pagination.
6487
6488
  * @return {Promise<EventsResponse>} A Promise that resolves to the full JSON:API response object.
@@ -6497,6 +6498,50 @@ class EventService {
6497
6498
  handleServiceHTTPErrors(error, SERVICE_HTTP_STATUS_CODES);
6498
6499
  }
6499
6500
  }
6501
+ /**
6502
+ * Retrieves all events matching the given filters, automatically following
6503
+ * pagination links to fetch every page of results.
6504
+ *
6505
+ * The returned response contains the combined `data` and deduplicated
6506
+ * `included` arrays from all pages.
6507
+ *
6508
+ * @param {GetMultipleEventsParams} params - Optional parameters for filtering.
6509
+ * @return {Promise<EventsResponse>} A Promise that resolves to the combined JSON:API response.
6510
+ */
6511
+ async getAll(params = {}) {
6512
+ const firstPage = await this.getMultiple(params);
6513
+ if (!firstPage?.data || !firstPage.links?.next) {
6514
+ return firstPage;
6515
+ }
6516
+ const allData = [...firstPage.data];
6517
+ const includedById = /* @__PURE__ */ new Map();
6518
+ if (firstPage.included) {
6519
+ for (const item of firstPage.included) {
6520
+ includedById.set(`${item.type}:${item.id}`, item);
6521
+ }
6522
+ }
6523
+ let nextUrl = firstPage.links.next;
6524
+ while (nextUrl) {
6525
+ try {
6526
+ const page = (await this.axiosInstance.get(nextUrl)).data;
6527
+ if (page.data) {
6528
+ allData.push(...page.data);
6529
+ }
6530
+ if (page.included) {
6531
+ for (const item of page.included) {
6532
+ includedById.set(`${item.type}:${item.id}`, item);
6533
+ }
6534
+ }
6535
+ nextUrl = page.links?.next;
6536
+ } catch (error) {
6537
+ handleServiceHTTPErrors(error, SERVICE_HTTP_STATUS_CODES);
6538
+ }
6539
+ }
6540
+ return {
6541
+ data: allData,
6542
+ included: includedById.size > 0 ? Array.from(includedById.values()) : void 0
6543
+ };
6544
+ }
6500
6545
  }
6501
6546
  const TicketResourceSchema = z.enum([
6502
6547
  "class_passes",