@faable/sdk-base 1.0.10 → 1.0.11

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.
@@ -1 +1 @@
1
- {"version":3,"file":"fetcher_axios.d.ts","sourceRoot":"","sources":["../../src/fetcher/fetcher_axios.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAiB,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAY5C,eAAO,MAAM,aAAa,YAAY,SAAS,KAAQ,OAwDtD,CAAC"}
1
+ {"version":3,"file":"fetcher_axios.d.ts","sourceRoot":"","sources":["../../src/fetcher/fetcher_axios.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAiB,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAY5C,eAAO,MAAM,aAAa,YAAY,SAAS,KAAQ,OA6DtD,CAAC"}
@@ -21,7 +21,8 @@ export const fetcher_axios = (params = {}) => {
21
21
  // Add base interceptor
22
22
  instance.interceptors.response.use((res) => {
23
23
  if (params.debug) {
24
- console.log(`[${res.status} ${res.statusText}] ${res.config.url}`);
24
+ const queryparams = new URLSearchParams(res.config.params);
25
+ console.log(`[${res.status}] ${res.config.url}${queryparams.size > 0 ? `?${queryparams.toString()}` : ""}`);
25
26
  }
26
27
  return res;
27
28
  }, handleErrorInterceptor);
@@ -1 +1 @@
1
- {"version":3,"file":"paginator.d.ts","sourceRoot":"","sources":["../../src/helpers/paginator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAEtE,MAAM,WAAW,IAAI,CAAC,CAAC;IACrB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,OAAO,EAAE,CAAC,EAAE,CAAC;CACd;AACD,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAC1D,eAAO,MAAM,cAAc,YACf,OAAO,MAChB,CAAC,OAAO,oBAAoB;;;oBAiBJ;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE;CAU9D,CAAC"}
1
+ {"version":3,"file":"paginator.d.ts","sourceRoot":"","sources":["../../src/helpers/paginator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAGtE,MAAM,WAAW,IAAI,CAAC,CAAC;IACrB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,OAAO,EAAE,CAAC,EAAE,CAAC;CACd;AACD,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAC1D,eAAO,MAAM,cAAc,YACf,OAAO,MAChB,CAAC,OAAO,oBAAoB;;;oBA0BJ;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE;CAU9D,CAAC"}
@@ -1,13 +1,23 @@
1
+ import { FaableApiError } from "./FaableApiError.js";
1
2
  export const buildPaginator = (fetcher) => (req) => {
2
3
  return {
3
4
  all: async () => {
4
5
  const pages = [];
5
6
  let data;
7
+ let nextCurrent = null;
6
8
  do {
7
9
  data = await fetcher.request({
8
10
  ...req,
9
- params: { ...req.params, next: data && data?.next },
11
+ params: data?.next
12
+ ? { ...req.params, next: data.next }
13
+ : req.params,
10
14
  });
15
+ // Next cursor cannot be the same as previous received one. Sanity check the api.
16
+ if (nextCurrent == data?.next) {
17
+ throw new FaableApiError("Bad next cursor");
18
+ }
19
+ nextCurrent = data.next;
20
+ // Add to data array
11
21
  pages.push(data);
12
22
  } while (data.next);
13
23
  return pages.map((page) => page.results).flat();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faable/sdk-base",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
4
4
  "author": "Marc Pomar <marc@faable.com>",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -21,6 +21,7 @@
21
21
  "@types/ramda": "^0.30.2",
22
22
  "ava": "^6.1.3",
23
23
  "dotenv": "^16.4.5",
24
+ "nock": "^13.5.5",
24
25
  "openapi-typescript": "^7.4.0",
25
26
  "rimraf": "^6.0.1",
26
27
  "semantic-release": "^24.1.1",