@gopowerteam/request 0.1.9 → 0.1.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.
@@ -68,7 +68,10 @@ var _RequestService = class {
68
68
  leftcycleFn && leftcycleFn.bind(plugin)(response, options);
69
69
  });
70
70
  }
71
- parseRequestPath(path, paramsPath) {
71
+ parseRequestPath(path, paramsPath, service) {
72
+ if (service) {
73
+ path = `/${service}/${path}`.replace(/\/{2,3}/g, "/");
74
+ }
72
75
  if (paramsPath) {
73
76
  return Object.entries(paramsPath).reduce(
74
77
  (r, [key, value]) => r.replace(`{${key}}`, value.toString()),
@@ -81,7 +84,11 @@ var _RequestService = class {
81
84
  startRequest(adapter, options) {
82
85
  return adapter.request({
83
86
  baseURL: _RequestService.config.gateway,
84
- pathURL: this.parseRequestPath(options.path, options.paramsPath),
87
+ pathURL: this.parseRequestPath(
88
+ options.path,
89
+ options.paramsPath,
90
+ options.service
91
+ ),
85
92
  method: options.method,
86
93
  headers: options.headers || {},
87
94
  paramsQuery: options.paramsQuery,
@@ -138,10 +145,10 @@ var _AxiosAdapter = class {
138
145
  "Content-Type": "application/json"
139
146
  },
140
147
  paramsSerializer: {
141
- encode: (params) => qs.stringify(
148
+ serialize: (params) => qs.stringify(
142
149
  params,
143
150
  RequestService.config.qs || {
144
- arrayFormat: "indices",
151
+ arrayFormat: "repeat",
145
152
  skipNulls: true,
146
153
  allowDots: true,
147
154
  encodeValuesOnly: true,
@@ -1,4 +1,4 @@
1
- import { a as RequestAdapter, b as RequestAdapterOptions, A as AdapterResponse } from '../request-adapter.interface-bd32c0be.js';
1
+ import { a as RequestAdapter, b as RequestAdapterOptions, A as AdapterResponse } from '../request-adapter.interface-7c4e2e8c.js';
2
2
  import { AxiosResponse, AxiosError } from 'axios';
3
3
 
4
4
  declare class AxiosAdapter implements RequestAdapter {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  RequestService,
3
3
  __publicField
4
- } from "../chunk-WMRFSSUJ.js";
4
+ } from "../chunk-XBVHYDNM.js";
5
5
 
6
6
  // src/adapters/axios.adapter.ts
7
7
  import axios from "axios";
@@ -15,10 +15,10 @@ var _AxiosAdapter = class {
15
15
  "Content-Type": "application/json"
16
16
  },
17
17
  paramsSerializer: {
18
- encode: (params) => qs.stringify(
18
+ serialize: (params) => qs.stringify(
19
19
  params,
20
20
  RequestService.config.qs || {
21
- arrayFormat: "indices",
21
+ arrayFormat: "repeat",
22
22
  skipNulls: true,
23
23
  allowDots: true,
24
24
  encodeValuesOnly: true,
@@ -43,7 +43,10 @@ var _RequestService = class {
43
43
  leftcycleFn && leftcycleFn.bind(plugin)(response, options);
44
44
  });
45
45
  }
46
- parseRequestPath(path, paramsPath) {
46
+ parseRequestPath(path, paramsPath, service) {
47
+ if (service) {
48
+ path = `/${service}/${path}`.replace(/\/{2,3}/g, "/");
49
+ }
47
50
  if (paramsPath) {
48
51
  return Object.entries(paramsPath).reduce(
49
52
  (r, [key, value]) => r.replace(`{${key}}`, value.toString()),
@@ -56,7 +59,11 @@ var _RequestService = class {
56
59
  startRequest(adapter, options) {
57
60
  return adapter.request({
58
61
  baseURL: _RequestService.config.gateway,
59
- pathURL: this.parseRequestPath(options.path, options.paramsPath),
62
+ pathURL: this.parseRequestPath(
63
+ options.path,
64
+ options.paramsPath,
65
+ options.service
66
+ ),
60
67
  method: options.method,
61
68
  headers: options.headers || {},
62
69
  paramsQuery: options.paramsQuery,
package/dist/index.cjs CHANGED
@@ -70,7 +70,10 @@ var _RequestService = class {
70
70
  leftcycleFn && leftcycleFn.bind(plugin)(response, options);
71
71
  });
72
72
  }
73
- parseRequestPath(path, paramsPath) {
73
+ parseRequestPath(path, paramsPath, service) {
74
+ if (service) {
75
+ path = `/${service}/${path}`.replace(/\/{2,3}/g, "/");
76
+ }
74
77
  if (paramsPath) {
75
78
  return Object.entries(paramsPath).reduce(
76
79
  (r, [key, value]) => r.replace(`{${key}}`, value.toString()),
@@ -83,7 +86,11 @@ var _RequestService = class {
83
86
  startRequest(adapter, options) {
84
87
  return adapter.request({
85
88
  baseURL: _RequestService.config.gateway,
86
- pathURL: this.parseRequestPath(options.path, options.paramsPath),
89
+ pathURL: this.parseRequestPath(
90
+ options.path,
91
+ options.paramsPath,
92
+ options.service
93
+ ),
87
94
  method: options.method,
88
95
  headers: options.headers || {},
89
96
  paramsQuery: options.paramsQuery,
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { R as RequestSendOptions, A as AdapterResponse, a as RequestAdapter } from './request-adapter.interface-bd32c0be.js';
2
- export { A as AdapterResponse, a as RequestAdapter, b as RequestAdapterOptions, c as RequestMethod, R as RequestSendOptions } from './request-adapter.interface-bd32c0be.js';
1
+ import { R as RequestSendOptions, A as AdapterResponse, a as RequestAdapter } from './request-adapter.interface-7c4e2e8c.js';
2
+ export { A as AdapterResponse, a as RequestAdapter, b as RequestAdapterOptions, c as RequestMethod, R as RequestSendOptions } from './request-adapter.interface-7c4e2e8c.js';
3
3
  import { IStringifyOptions } from 'qs';
4
4
 
5
5
  /**
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  PluginLifecycle,
3
3
  RequestService
4
- } from "./chunk-WMRFSSUJ.js";
4
+ } from "./chunk-XBVHYDNM.js";
5
5
 
6
6
  // src/request-setup.ts
7
7
  function setup(config) {
@@ -11,6 +11,7 @@ declare enum RequestMethod {
11
11
  Patch = "PATCH"
12
12
  }
13
13
  interface RequestSendOptions {
14
+ service?: string;
14
15
  path: string;
15
16
  method: RequestMethod | string;
16
17
  headers?: Record<string, string>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gopowerteam/request",
3
3
  "private": false,
4
- "version": "0.1.9",
4
+ "version": "0.1.11",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist",
@@ -28,7 +28,6 @@
28
28
  }
29
29
  },
30
30
  "devDependencies": {
31
- "@types/axios": "^0.14.0",
32
31
  "@types/jest": "^29.1.2",
33
32
  "@types/node": "16",
34
33
  "@types/qs": "^6.9.7",
@@ -39,7 +38,7 @@
39
38
  "typescript": "^4.8.4"
40
39
  },
41
40
  "dependencies": {
42
- "axios": "^1.1.2",
41
+ "axios": "^1.1.3",
43
42
  "qs": "^6.11.0"
44
43
  },
45
44
  "scripts": {