@minipim/sdk 0.5.0 → 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/dist/index.cjs CHANGED
@@ -80,9 +80,7 @@ async function* paginate(client, path, opts = {}) {
80
80
  params: { query: { ...opts.query ?? {}, limit: pageSize, offset } }
81
81
  });
82
82
  if (error || !data) {
83
- throw new Error(
84
- `paginate ${path} failed at offset ${offset} (HTTP ${response?.status})`
85
- );
83
+ throw new Error(`paginate ${path} failed at offset ${offset} (HTTP ${response?.status})`);
86
84
  }
87
85
  if (Array.isArray(data)) {
88
86
  for (const item of data) yield item;
package/dist/index.d.cts CHANGED
@@ -77,9 +77,13 @@ type MinipimClient = Client<paths>;
77
77
  declare function createMinipimClient(opts: CreateMinipimClientOptions): MinipimClient;
78
78
 
79
79
  /**
80
- * Generic pagination helper. Every MiniPim list endpoint returns
81
- * `{ data, limit, offset, hasMore }`; this walks the pages so consumers
82
- * don't hand-roll the `hasMore` loop. Yields one item at a time.
80
+ * Generic pagination helper. MiniPim list endpoints return
81
+ * `{ data, limit, offset }`, and **only `/v1/products` also returns
82
+ * `hasMore`** so this walks the pages by trusting `hasMore` when it is
83
+ * present and falling back to a short-page check when it isn't. That is the
84
+ * whole reason to use this instead of a hand-rolled `while (hasMore)` loop,
85
+ * which reads exactly one page from every other endpoint and stops. Yields
86
+ * one item at a time.
83
87
  *
84
88
  * Typed loosely on purpose — openapi-fetch's per-path generics don't
85
89
  * compose into a single reusable signature without a lot of conditional-
package/dist/index.d.ts CHANGED
@@ -77,9 +77,13 @@ type MinipimClient = Client<paths>;
77
77
  declare function createMinipimClient(opts: CreateMinipimClientOptions): MinipimClient;
78
78
 
79
79
  /**
80
- * Generic pagination helper. Every MiniPim list endpoint returns
81
- * `{ data, limit, offset, hasMore }`; this walks the pages so consumers
82
- * don't hand-roll the `hasMore` loop. Yields one item at a time.
80
+ * Generic pagination helper. MiniPim list endpoints return
81
+ * `{ data, limit, offset }`, and **only `/v1/products` also returns
82
+ * `hasMore`** so this walks the pages by trusting `hasMore` when it is
83
+ * present and falling back to a short-page check when it isn't. That is the
84
+ * whole reason to use this instead of a hand-rolled `while (hasMore)` loop,
85
+ * which reads exactly one page from every other endpoint and stops. Yields
86
+ * one item at a time.
83
87
  *
84
88
  * Typed loosely on purpose — openapi-fetch's per-path generics don't
85
89
  * compose into a single reusable signature without a lot of conditional-
package/dist/index.js CHANGED
@@ -28,9 +28,7 @@ async function* paginate(client, path, opts = {}) {
28
28
  params: { query: { ...opts.query ?? {}, limit: pageSize, offset } }
29
29
  });
30
30
  if (error || !data) {
31
- throw new Error(
32
- `paginate ${path} failed at offset ${offset} (HTTP ${response?.status})`
33
- );
31
+ throw new Error(`paginate ${path} failed at offset ${offset} (HTTP ${response?.status})`);
34
32
  }
35
33
  if (Array.isArray(data)) {
36
34
  for (const item of data) yield item;