@techzunction/sdk 0.6.6 → 0.7.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.cjs CHANGED
@@ -71,7 +71,7 @@ var TZPaginatedQuery = class extends TZQuery {
71
71
  /** Check if there's a next page (must await first) */
72
72
  async hasNext() {
73
73
  const result = await this.data();
74
- return this._page < result.totalPages;
74
+ return result.pagination.hasNextPage;
75
75
  }
76
76
  /** Check if there's a previous page */
77
77
  hasPrev() {
@@ -373,12 +373,18 @@ var ScopedClient = class {
373
373
  const merged = { ...params, page: p, limit: l };
374
374
  const qs = toQs(merged);
375
375
  const fp = this.fullPath(`${path}${qs}`);
376
- return new TZPaginatedQuery(
377
- (signal) => this.root.rawRequest("GET", fp, { scope, signal, sendOrgKey: this.sendOrgKey }),
378
- p,
379
- l,
380
- factory
381
- );
376
+ const executor = async (signal) => {
377
+ const rawRes = await this.root.rawRequest("GET", fp, { scope, signal, sendOrgKey: this.sendOrgKey });
378
+ const envelope = rawRes.raw;
379
+ const pagination = envelope.pagination ?? { page: p, limit: l, total: 0, totalPages: 0, hasNextPage: false, hasPrevPage: false };
380
+ return {
381
+ data: { data: rawRes.data, pagination },
382
+ raw: rawRes.raw,
383
+ status: rawRes.status,
384
+ headers: rawRes.headers
385
+ };
386
+ };
387
+ return new TZPaginatedQuery(executor, p, l, factory);
382
388
  };
383
389
  return factory(page, limit);
384
390
  }