@koine/api 2.0.0-beta.15 → 2.0.0-beta.16

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/cjs/createApi.js CHANGED
@@ -2,9 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createApi = void 0;
4
4
  var tslib_1 = require("tslib");
5
- var buildUrlQueryString_1 = require("@koine/utils/buildUrlQueryString");
6
- var errorToString_1 = require("@koine/utils/errorToString");
7
- var isFullObject_1 = require("@koine/utils/isFullObject");
5
+ var utils_1 = require("@koine/utils");
8
6
  var createApi = function (apiName, baseUrl, options) {
9
7
  var _a = options || {}, _b = _a.headers, headersBase = _b === void 0 ? {} : _b, _c = _a.request, requestBase = _c === void 0 ? {} : _c, throwErrBase = _a.throwErr, _d = _a.timeout, timeoutBase = _d === void 0 ? 10000 : _d, processReqBase = _a.processReq, processResBase = _a.processRes, processErrBase = _a.processErr;
10
8
  return ["get", "post", "put", "patch", "delete"].reduce(function (api, method) {
@@ -33,7 +31,7 @@ var createApi = function (apiName, baseUrl, options) {
33
31
  params = transformed[3];
34
32
  requestInit = transformed[4];
35
33
  }
36
- if ((0, isFullObject_1.default)(params)) {
34
+ if ((0, utils_1.isFullObject)(params)) {
37
35
  for (key in params) {
38
36
  url = url.replace("{".concat(key, "}"), params[key].toString());
39
37
  }
@@ -48,7 +46,7 @@ var createApi = function (apiName, baseUrl, options) {
48
46
  requestInit.signal = controller.signal;
49
47
  }
50
48
  if (query) {
51
- url += (0, buildUrlQueryString_1.default)(query);
49
+ url += (0, utils_1.buildUrlQueryString)(query);
52
50
  }
53
51
  response = null;
54
52
  result = null;
@@ -62,7 +60,7 @@ var createApi = function (apiName, baseUrl, options) {
62
60
  return [3, 4];
63
61
  case 3:
64
62
  e_1 = _j.sent();
65
- msg = (0, errorToString_1.default)(e_1);
63
+ msg = (0, utils_1.errorToString)(e_1);
66
64
  return [3, 4];
67
65
  case 4:
68
66
  if (timeoutId) {
@@ -84,7 +82,7 @@ var createApi = function (apiName, baseUrl, options) {
84
82
  case 9: return [3, 11];
85
83
  case 10:
86
84
  e_2 = _j.sent();
87
- msg = (0, errorToString_1.default)(e_2);
85
+ msg = (0, utils_1.errorToString)(e_2);
88
86
  return [3, 11];
89
87
  case 11:
90
88
  if (!(result === null)) return [3, 14];
@@ -5,7 +5,7 @@ exports.createSwrApi = void 0;
5
5
  var tslib_1 = require("tslib");
6
6
  var swr_1 = require("swr");
7
7
  var mutation_1 = require("swr/mutation");
8
- var isFunction_1 = require("@koine/utils/isFunction");
8
+ var utils_1 = require("@koine/utils");
9
9
  var createApi_1 = require("./createApi");
10
10
  function createUseApi(api, method) {
11
11
  return function useApi(endpoint, options, _config) {
@@ -24,7 +24,7 @@ function createUseApi(api, method) {
24
24
  }); };
25
25
  var config_1 = _config;
26
26
  var shouldNotFetch = (config_1 === null || config_1 === void 0 ? void 0 : config_1.when) === false ||
27
- ((0, isFunction_1.default)(config_1 === null || config_1 === void 0 ? void 0 : config_1.when) && (config_1 === null || config_1 === void 0 ? void 0 : config_1.when()) === false);
27
+ ((0, utils_1.isFunction)(config_1 === null || config_1 === void 0 ? void 0 : config_1.when) && (config_1 === null || config_1 === void 0 ? void 0 : config_1.when()) === false);
28
28
  return (0, swr_1.default)(shouldNotFetch ? null : options ? [endpoint, options] : [endpoint], fetcher, config_1);
29
29
  }
30
30
  var config = _config;
package/createApi.js CHANGED
@@ -1,7 +1,5 @@
1
1
  import { __assign, __awaiter, __generator } from "tslib";
2
- import buildUrlQueryString from "@koine/utils/buildUrlQueryString";
3
- import errorToString from "@koine/utils/errorToString";
4
- import isFullObject from "@koine/utils/isFullObject";
2
+ import { buildUrlQueryString, errorToString, isFullObject, } from "@koine/utils";
5
3
  export var createApi = function (apiName, baseUrl, options) {
6
4
  var _a = options || {}, _b = _a.headers, headersBase = _b === void 0 ? {} : _b, _c = _a.request, requestBase = _c === void 0 ? {} : _c, throwErrBase = _a.throwErr, _d = _a.timeout, timeoutBase = _d === void 0 ? 10000 : _d, processReqBase = _a.processReq, processResBase = _a.processRes, processErrBase = _a.processErr;
7
5
  return ["get", "post", "put", "patch", "delete"].reduce(function (api, method) {
package/createSwrApi.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { __assign, __awaiter, __generator } from "tslib";
3
3
  import useSWR from "swr";
4
4
  import useSWRMutation from "swr/mutation";
5
- import isFunction from "@koine/utils/isFunction";
5
+ import { isFunction } from "@koine/utils";
6
6
  import createApi from "./createApi.js";
7
7
  function createUseApi(api, method) {
8
8
  return function useApi(endpoint, options, _config) {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@koine/api",
3
3
  "sideEffects": false,
4
4
  "dependencies": {
5
- "@koine/utils": "2.0.0-beta.15"
5
+ "@koine/utils": "2.0.0-beta.16"
6
6
  },
7
7
  "peerDependenciesMeta": {
8
8
  "next": {
@@ -51,5 +51,5 @@
51
51
  }
52
52
  },
53
53
  "peerDependencies": {},
54
- "version": "2.0.0-beta.15"
54
+ "version": "2.0.0-beta.16"
55
55
  }