@internxt/sdk 1.5.25 → 1.6.4
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/auth/index.d.ts +127 -122
- package/dist/auth/index.js +378 -310
- package/dist/auth/types.d.ts +65 -54
- package/dist/auth/types.js +26 -26
- package/dist/drive/backups/index.d.ts +18 -18
- package/dist/drive/backups/index.js +40 -40
- package/dist/drive/backups/types.d.ts +27 -27
- package/dist/drive/backups/types.js +2 -2
- package/dist/drive/index.d.ts +7 -7
- package/dist/drive/index.js +23 -19
- package/dist/drive/payments/index.d.ts +66 -71
- package/dist/drive/payments/index.js +206 -208
- package/dist/drive/payments/types.d.ts +180 -176
- package/dist/drive/payments/types.js +37 -37
- package/dist/drive/referrals/index.d.ts +19 -19
- package/dist/drive/referrals/index.js +54 -50
- package/dist/drive/referrals/types.d.ts +21 -21
- package/dist/drive/referrals/types.js +18 -18
- package/dist/drive/share/index.d.ts +319 -319
- package/dist/drive/share/index.js +544 -540
- package/dist/drive/share/types.d.ts +360 -360
- package/dist/drive/share/types.js +2 -2
- package/dist/drive/storage/index.d.ts +315 -315
- package/dist/drive/storage/index.js +634 -630
- package/dist/drive/storage/types.d.ts +480 -473
- package/dist/drive/storage/types.js +13 -13
- package/dist/drive/trash/index.d.ts +75 -75
- package/dist/drive/trash/index.js +184 -180
- package/dist/drive/trash/types.d.ts +29 -29
- package/dist/drive/trash/types.js +2 -2
- package/dist/drive/users/index.d.ts +135 -135
- package/dist/drive/users/index.js +208 -204
- package/dist/drive/users/types.d.ts +53 -51
- package/dist/drive/users/types.js +2 -2
- package/dist/index.d.ts +6 -6
- package/dist/index.js +35 -31
- package/dist/network/download.d.ts +8 -8
- package/dist/network/download.js +123 -123
- package/dist/network/errors/codes.d.ts +24 -24
- package/dist/network/errors/codes.js +48 -48
- package/dist/network/errors/context.d.ts +35 -35
- package/dist/network/errors/context.js +39 -39
- package/dist/network/errors/download.d.ts +4 -4
- package/dist/network/errors/download.js +52 -48
- package/dist/network/errors/index.d.ts +3 -3
- package/dist/network/errors/index.js +19 -15
- package/dist/network/errors/upload.d.ts +13 -13
- package/dist/network/errors/upload.js +82 -78
- package/dist/network/index.d.ts +70 -70
- package/dist/network/index.js +315 -311
- package/dist/network/types.d.ts +102 -102
- package/dist/network/types.js +18 -18
- package/dist/network/upload.d.ts +4 -4
- package/dist/network/upload.js +158 -159
- package/dist/photos/devices/index.d.ts +10 -10
- package/dist/photos/devices/index.js +79 -79
- package/dist/photos/index.d.ts +17 -17
- package/dist/photos/index.js +56 -52
- package/dist/photos/photos/index.d.ts +60 -60
- package/dist/photos/photos/index.js +225 -225
- package/dist/photos/shares/index.d.ts +8 -8
- package/dist/photos/shares/index.js +34 -34
- package/dist/photos/types.d.ts +154 -154
- package/dist/photos/types.js +19 -19
- package/dist/photos/users/index.d.ts +7 -7
- package/dist/photos/users/index.js +46 -46
- package/dist/shared/headers/index.d.ts +21 -21
- package/dist/shared/headers/index.js +78 -79
- package/dist/shared/http/client.d.ts +85 -85
- package/dist/shared/http/client.js +172 -172
- package/dist/shared/http/types.d.ts +7 -7
- package/dist/shared/http/types.js +2 -2
- package/dist/shared/index.d.ts +1 -1
- package/dist/shared/index.js +17 -13
- package/dist/shared/types/apiConnection.d.ts +12 -12
- package/dist/shared/types/apiConnection.js +2 -2
- package/dist/shared/types/appsumo.d.ts +16 -16
- package/dist/shared/types/appsumo.js +12 -12
- package/dist/shared/types/errors.d.ts +5 -5
- package/dist/shared/types/errors.js +28 -28
- package/dist/shared/types/teams.d.ts +9 -9
- package/dist/shared/types/teams.js +2 -2
- package/dist/shared/types/userSettings.d.ts +43 -29
- package/dist/shared/types/userSettings.js +2 -2
- package/dist/utils.d.ts +3 -3
- package/dist/utils.js +24 -25
- package/dist/workspaces/index.d.ts +176 -176
- package/dist/workspaces/index.js +419 -415
- package/dist/workspaces/index.test.d.ts +1 -1
- package/dist/workspaces/index.test.js +908 -903
- package/dist/workspaces/types.d.ts +294 -291
- package/dist/workspaces/types.js +2 -2
- package/package.json +13 -13
|
@@ -1,85 +1,85 @@
|
|
|
1
|
-
import { Headers, Parameters, RequestCanceler, URL, UnauthorizedCallback } from './types';
|
|
2
|
-
export { RequestCanceler } from './types';
|
|
3
|
-
export declare class HttpClient {
|
|
4
|
-
private readonly axios;
|
|
5
|
-
private readonly unauthorizedCallback;
|
|
6
|
-
static create(baseURL: URL, unauthorizedCallback?: UnauthorizedCallback): HttpClient;
|
|
7
|
-
private constructor();
|
|
8
|
-
/**
|
|
9
|
-
* Requests a GET
|
|
10
|
-
* @param url
|
|
11
|
-
* @param headers
|
|
12
|
-
*/
|
|
13
|
-
get<Response>(url: URL, headers: Headers): Promise<Response>;
|
|
14
|
-
/**
|
|
15
|
-
* Requests a GET
|
|
16
|
-
* @param url
|
|
17
|
-
* @param params
|
|
18
|
-
* @param headers
|
|
19
|
-
*/
|
|
20
|
-
getWithParams<Response>(url: URL, params: Parameters, headers: Headers): Promise<Response>;
|
|
21
|
-
/**
|
|
22
|
-
* Requests a GET with option to cancel
|
|
23
|
-
* @param url
|
|
24
|
-
* @param headers
|
|
25
|
-
*/
|
|
26
|
-
getCancellable<Response>(url: URL, headers: Headers): {
|
|
27
|
-
promise: Promise<Response>;
|
|
28
|
-
requestCanceler: RequestCanceler;
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* Requests a POST
|
|
32
|
-
* @param url
|
|
33
|
-
* @param params
|
|
34
|
-
* @param headers
|
|
35
|
-
*/
|
|
36
|
-
post<Response>(url: URL, params: Parameters, headers: Headers): Promise<Response>;
|
|
37
|
-
/**
|
|
38
|
-
* Requests a POST with option to cancel
|
|
39
|
-
* @param url
|
|
40
|
-
* @param params
|
|
41
|
-
* @param headers
|
|
42
|
-
*/
|
|
43
|
-
postCancellable<Response>(url: URL, params: Parameters, headers: Headers): {
|
|
44
|
-
promise: Promise<Response>;
|
|
45
|
-
requestCanceler: RequestCanceler;
|
|
46
|
-
};
|
|
47
|
-
/**
|
|
48
|
-
* Requests PATCH
|
|
49
|
-
* @param url
|
|
50
|
-
* @param params
|
|
51
|
-
* @param headers
|
|
52
|
-
*/
|
|
53
|
-
patch<Response>(url: URL, params: Parameters, headers: Headers): Promise<Response>;
|
|
54
|
-
/**
|
|
55
|
-
* Requests a PUT
|
|
56
|
-
* @param url
|
|
57
|
-
* @param params
|
|
58
|
-
* @param headers
|
|
59
|
-
*/
|
|
60
|
-
put<Response>(url: URL, params: Parameters, headers: Headers): Promise<Response>;
|
|
61
|
-
/**
|
|
62
|
-
* Requests a DELETE
|
|
63
|
-
* @param url
|
|
64
|
-
* @param headers
|
|
65
|
-
* @param params
|
|
66
|
-
*/
|
|
67
|
-
delete<Response>(url: URL, headers: Headers, params?: Parameters): Promise<Response>;
|
|
68
|
-
/**
|
|
69
|
-
* Sets middlewares into the client for common behaviour managing
|
|
70
|
-
* @private
|
|
71
|
-
*/
|
|
72
|
-
private initializeMiddleware;
|
|
73
|
-
/**
|
|
74
|
-
* Extracts the valuable data from the server's response
|
|
75
|
-
* @param response
|
|
76
|
-
* @private
|
|
77
|
-
*/
|
|
78
|
-
private static extractData;
|
|
79
|
-
/**
|
|
80
|
-
* Converts the specific client error into a proprietary error for our apps
|
|
81
|
-
* @param error
|
|
82
|
-
* @private
|
|
83
|
-
*/
|
|
84
|
-
private normalizeError;
|
|
85
|
-
}
|
|
1
|
+
import { Headers, Parameters, RequestCanceler, URL, UnauthorizedCallback } from './types';
|
|
2
|
+
export { RequestCanceler } from './types';
|
|
3
|
+
export declare class HttpClient {
|
|
4
|
+
private readonly axios;
|
|
5
|
+
private readonly unauthorizedCallback;
|
|
6
|
+
static create(baseURL: URL, unauthorizedCallback?: UnauthorizedCallback): HttpClient;
|
|
7
|
+
private constructor();
|
|
8
|
+
/**
|
|
9
|
+
* Requests a GET
|
|
10
|
+
* @param url
|
|
11
|
+
* @param headers
|
|
12
|
+
*/
|
|
13
|
+
get<Response>(url: URL, headers: Headers): Promise<Response>;
|
|
14
|
+
/**
|
|
15
|
+
* Requests a GET
|
|
16
|
+
* @param url
|
|
17
|
+
* @param params
|
|
18
|
+
* @param headers
|
|
19
|
+
*/
|
|
20
|
+
getWithParams<Response>(url: URL, params: Parameters, headers: Headers): Promise<Response>;
|
|
21
|
+
/**
|
|
22
|
+
* Requests a GET with option to cancel
|
|
23
|
+
* @param url
|
|
24
|
+
* @param headers
|
|
25
|
+
*/
|
|
26
|
+
getCancellable<Response>(url: URL, headers: Headers): {
|
|
27
|
+
promise: Promise<Response>;
|
|
28
|
+
requestCanceler: RequestCanceler;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Requests a POST
|
|
32
|
+
* @param url
|
|
33
|
+
* @param params
|
|
34
|
+
* @param headers
|
|
35
|
+
*/
|
|
36
|
+
post<Response>(url: URL, params: Parameters, headers: Headers): Promise<Response>;
|
|
37
|
+
/**
|
|
38
|
+
* Requests a POST with option to cancel
|
|
39
|
+
* @param url
|
|
40
|
+
* @param params
|
|
41
|
+
* @param headers
|
|
42
|
+
*/
|
|
43
|
+
postCancellable<Response>(url: URL, params: Parameters, headers: Headers): {
|
|
44
|
+
promise: Promise<Response>;
|
|
45
|
+
requestCanceler: RequestCanceler;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Requests PATCH
|
|
49
|
+
* @param url
|
|
50
|
+
* @param params
|
|
51
|
+
* @param headers
|
|
52
|
+
*/
|
|
53
|
+
patch<Response>(url: URL, params: Parameters, headers: Headers): Promise<Response>;
|
|
54
|
+
/**
|
|
55
|
+
* Requests a PUT
|
|
56
|
+
* @param url
|
|
57
|
+
* @param params
|
|
58
|
+
* @param headers
|
|
59
|
+
*/
|
|
60
|
+
put<Response>(url: URL, params: Parameters, headers: Headers): Promise<Response>;
|
|
61
|
+
/**
|
|
62
|
+
* Requests a DELETE
|
|
63
|
+
* @param url
|
|
64
|
+
* @param headers
|
|
65
|
+
* @param params
|
|
66
|
+
*/
|
|
67
|
+
delete<Response>(url: URL, headers: Headers, params?: Parameters): Promise<Response>;
|
|
68
|
+
/**
|
|
69
|
+
* Sets middlewares into the client for common behaviour managing
|
|
70
|
+
* @private
|
|
71
|
+
*/
|
|
72
|
+
private initializeMiddleware;
|
|
73
|
+
/**
|
|
74
|
+
* Extracts the valuable data from the server's response
|
|
75
|
+
* @param response
|
|
76
|
+
* @private
|
|
77
|
+
*/
|
|
78
|
+
private static extractData;
|
|
79
|
+
/**
|
|
80
|
+
* Converts the specific client error into a proprietary error for our apps
|
|
81
|
+
* @param error
|
|
82
|
+
* @private
|
|
83
|
+
*/
|
|
84
|
+
private normalizeError;
|
|
85
|
+
}
|
|
@@ -1,172 +1,172 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.HttpClient = void 0;
|
|
7
|
-
var axios_1 = __importDefault(require("axios"));
|
|
8
|
-
var errors_1 = __importDefault(require("../types/errors"));
|
|
9
|
-
var HttpClient = /** @class */ (function () {
|
|
10
|
-
function HttpClient(baseURL, unauthorizedCallback) {
|
|
11
|
-
this.axios = axios_1.default.create({
|
|
12
|
-
baseURL: baseURL,
|
|
13
|
-
});
|
|
14
|
-
this.unauthorizedCallback = unauthorizedCallback;
|
|
15
|
-
this.initializeMiddleware();
|
|
16
|
-
}
|
|
17
|
-
HttpClient.create = function (baseURL, unauthorizedCallback) {
|
|
18
|
-
if (unauthorizedCallback === undefined) {
|
|
19
|
-
unauthorizedCallback = function () { return null; };
|
|
20
|
-
}
|
|
21
|
-
return new HttpClient(baseURL, unauthorizedCallback);
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* Requests a GET
|
|
25
|
-
* @param url
|
|
26
|
-
* @param headers
|
|
27
|
-
*/
|
|
28
|
-
HttpClient.prototype.get = function (url, headers) {
|
|
29
|
-
return this.axios.get(url, {
|
|
30
|
-
headers: headers,
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* Requests a GET
|
|
35
|
-
* @param url
|
|
36
|
-
* @param params
|
|
37
|
-
* @param headers
|
|
38
|
-
*/
|
|
39
|
-
HttpClient.prototype.getWithParams = function (url, params, headers) {
|
|
40
|
-
return this.axios.get(url, {
|
|
41
|
-
params: params,
|
|
42
|
-
headers: headers,
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
/**
|
|
46
|
-
* Requests a GET with option to cancel
|
|
47
|
-
* @param url
|
|
48
|
-
* @param headers
|
|
49
|
-
*/
|
|
50
|
-
HttpClient.prototype.getCancellable = function (url, headers) {
|
|
51
|
-
var cancelTokenSource = axios_1.default.CancelToken.source();
|
|
52
|
-
var config = {
|
|
53
|
-
headers: headers,
|
|
54
|
-
cancelToken: cancelTokenSource.token,
|
|
55
|
-
};
|
|
56
|
-
var promise = this.axios.get(url, config);
|
|
57
|
-
return {
|
|
58
|
-
promise: promise,
|
|
59
|
-
requestCanceler: {
|
|
60
|
-
cancel: cancelTokenSource.cancel,
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
|
-
/**
|
|
65
|
-
* Requests a POST
|
|
66
|
-
* @param url
|
|
67
|
-
* @param params
|
|
68
|
-
* @param headers
|
|
69
|
-
*/
|
|
70
|
-
HttpClient.prototype.post = function (url, params, headers) {
|
|
71
|
-
return this.axios.post(url, params, {
|
|
72
|
-
headers: headers,
|
|
73
|
-
});
|
|
74
|
-
};
|
|
75
|
-
/**
|
|
76
|
-
* Requests a POST with option to cancel
|
|
77
|
-
* @param url
|
|
78
|
-
* @param params
|
|
79
|
-
* @param headers
|
|
80
|
-
*/
|
|
81
|
-
HttpClient.prototype.postCancellable = function (url, params, headers) {
|
|
82
|
-
var cancelTokenSource = axios_1.default.CancelToken.source();
|
|
83
|
-
var config = {
|
|
84
|
-
headers: headers,
|
|
85
|
-
cancelToken: cancelTokenSource.token,
|
|
86
|
-
};
|
|
87
|
-
var promise = this.axios.post(url, params, config);
|
|
88
|
-
return {
|
|
89
|
-
promise: promise,
|
|
90
|
-
requestCanceler: {
|
|
91
|
-
cancel: cancelTokenSource.cancel,
|
|
92
|
-
},
|
|
93
|
-
};
|
|
94
|
-
};
|
|
95
|
-
/**
|
|
96
|
-
* Requests PATCH
|
|
97
|
-
* @param url
|
|
98
|
-
* @param params
|
|
99
|
-
* @param headers
|
|
100
|
-
*/
|
|
101
|
-
HttpClient.prototype.patch = function (url, params, headers) {
|
|
102
|
-
return this.axios.patch(url, params, {
|
|
103
|
-
headers: headers,
|
|
104
|
-
});
|
|
105
|
-
};
|
|
106
|
-
/**
|
|
107
|
-
* Requests a PUT
|
|
108
|
-
* @param url
|
|
109
|
-
* @param params
|
|
110
|
-
* @param headers
|
|
111
|
-
*/
|
|
112
|
-
HttpClient.prototype.put = function (url, params, headers) {
|
|
113
|
-
return this.axios.put(url, params, {
|
|
114
|
-
headers: headers,
|
|
115
|
-
});
|
|
116
|
-
};
|
|
117
|
-
/**
|
|
118
|
-
* Requests a DELETE
|
|
119
|
-
* @param url
|
|
120
|
-
* @param headers
|
|
121
|
-
* @param params
|
|
122
|
-
*/
|
|
123
|
-
HttpClient.prototype.delete = function (url, headers, params) {
|
|
124
|
-
return this.axios.delete(url, {
|
|
125
|
-
headers: headers,
|
|
126
|
-
data: params,
|
|
127
|
-
});
|
|
128
|
-
};
|
|
129
|
-
/**
|
|
130
|
-
* Sets middlewares into the client for common behaviour managing
|
|
131
|
-
* @private
|
|
132
|
-
*/
|
|
133
|
-
HttpClient.prototype.initializeMiddleware = function () {
|
|
134
|
-
this.axios.interceptors.response.use(HttpClient.extractData, this.normalizeError.bind(this));
|
|
135
|
-
};
|
|
136
|
-
/**
|
|
137
|
-
* Extracts the valuable data from the server's response
|
|
138
|
-
* @param response
|
|
139
|
-
* @private
|
|
140
|
-
*/
|
|
141
|
-
HttpClient.extractData = function (response) {
|
|
142
|
-
return response.data;
|
|
143
|
-
};
|
|
144
|
-
/**
|
|
145
|
-
* Converts the specific client error into a proprietary error for our apps
|
|
146
|
-
* @param error
|
|
147
|
-
* @private
|
|
148
|
-
*/
|
|
149
|
-
HttpClient.prototype.normalizeError = function (error) {
|
|
150
|
-
var errorMessage, errorStatus, errorCode;
|
|
151
|
-
if (error.response) {
|
|
152
|
-
var response = error.response;
|
|
153
|
-
if (response.status === 401) {
|
|
154
|
-
this.unauthorizedCallback();
|
|
155
|
-
}
|
|
156
|
-
errorMessage = response.data.message || response.data.error || JSON.stringify(response.data);
|
|
157
|
-
errorStatus = response.status;
|
|
158
|
-
errorCode = response.data.code;
|
|
159
|
-
}
|
|
160
|
-
else if (error.request) {
|
|
161
|
-
errorMessage = 'Server unavailable';
|
|
162
|
-
errorStatus = 500;
|
|
163
|
-
}
|
|
164
|
-
else {
|
|
165
|
-
errorMessage = error.message;
|
|
166
|
-
errorStatus = 400;
|
|
167
|
-
}
|
|
168
|
-
throw new errors_1.default(errorMessage, errorStatus, errorCode);
|
|
169
|
-
};
|
|
170
|
-
return HttpClient;
|
|
171
|
-
}());
|
|
172
|
-
exports.HttpClient = HttpClient;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.HttpClient = void 0;
|
|
7
|
+
var axios_1 = __importDefault(require("axios"));
|
|
8
|
+
var errors_1 = __importDefault(require("../types/errors"));
|
|
9
|
+
var HttpClient = /** @class */ (function () {
|
|
10
|
+
function HttpClient(baseURL, unauthorizedCallback) {
|
|
11
|
+
this.axios = axios_1.default.create({
|
|
12
|
+
baseURL: baseURL,
|
|
13
|
+
});
|
|
14
|
+
this.unauthorizedCallback = unauthorizedCallback;
|
|
15
|
+
this.initializeMiddleware();
|
|
16
|
+
}
|
|
17
|
+
HttpClient.create = function (baseURL, unauthorizedCallback) {
|
|
18
|
+
if (unauthorizedCallback === undefined) {
|
|
19
|
+
unauthorizedCallback = function () { return null; };
|
|
20
|
+
}
|
|
21
|
+
return new HttpClient(baseURL, unauthorizedCallback);
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Requests a GET
|
|
25
|
+
* @param url
|
|
26
|
+
* @param headers
|
|
27
|
+
*/
|
|
28
|
+
HttpClient.prototype.get = function (url, headers) {
|
|
29
|
+
return this.axios.get(url, {
|
|
30
|
+
headers: headers,
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Requests a GET
|
|
35
|
+
* @param url
|
|
36
|
+
* @param params
|
|
37
|
+
* @param headers
|
|
38
|
+
*/
|
|
39
|
+
HttpClient.prototype.getWithParams = function (url, params, headers) {
|
|
40
|
+
return this.axios.get(url, {
|
|
41
|
+
params: params,
|
|
42
|
+
headers: headers,
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Requests a GET with option to cancel
|
|
47
|
+
* @param url
|
|
48
|
+
* @param headers
|
|
49
|
+
*/
|
|
50
|
+
HttpClient.prototype.getCancellable = function (url, headers) {
|
|
51
|
+
var cancelTokenSource = axios_1.default.CancelToken.source();
|
|
52
|
+
var config = {
|
|
53
|
+
headers: headers,
|
|
54
|
+
cancelToken: cancelTokenSource.token,
|
|
55
|
+
};
|
|
56
|
+
var promise = this.axios.get(url, config);
|
|
57
|
+
return {
|
|
58
|
+
promise: promise,
|
|
59
|
+
requestCanceler: {
|
|
60
|
+
cancel: cancelTokenSource.cancel,
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Requests a POST
|
|
66
|
+
* @param url
|
|
67
|
+
* @param params
|
|
68
|
+
* @param headers
|
|
69
|
+
*/
|
|
70
|
+
HttpClient.prototype.post = function (url, params, headers) {
|
|
71
|
+
return this.axios.post(url, params, {
|
|
72
|
+
headers: headers,
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Requests a POST with option to cancel
|
|
77
|
+
* @param url
|
|
78
|
+
* @param params
|
|
79
|
+
* @param headers
|
|
80
|
+
*/
|
|
81
|
+
HttpClient.prototype.postCancellable = function (url, params, headers) {
|
|
82
|
+
var cancelTokenSource = axios_1.default.CancelToken.source();
|
|
83
|
+
var config = {
|
|
84
|
+
headers: headers,
|
|
85
|
+
cancelToken: cancelTokenSource.token,
|
|
86
|
+
};
|
|
87
|
+
var promise = this.axios.post(url, params, config);
|
|
88
|
+
return {
|
|
89
|
+
promise: promise,
|
|
90
|
+
requestCanceler: {
|
|
91
|
+
cancel: cancelTokenSource.cancel,
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Requests PATCH
|
|
97
|
+
* @param url
|
|
98
|
+
* @param params
|
|
99
|
+
* @param headers
|
|
100
|
+
*/
|
|
101
|
+
HttpClient.prototype.patch = function (url, params, headers) {
|
|
102
|
+
return this.axios.patch(url, params, {
|
|
103
|
+
headers: headers,
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Requests a PUT
|
|
108
|
+
* @param url
|
|
109
|
+
* @param params
|
|
110
|
+
* @param headers
|
|
111
|
+
*/
|
|
112
|
+
HttpClient.prototype.put = function (url, params, headers) {
|
|
113
|
+
return this.axios.put(url, params, {
|
|
114
|
+
headers: headers,
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Requests a DELETE
|
|
119
|
+
* @param url
|
|
120
|
+
* @param headers
|
|
121
|
+
* @param params
|
|
122
|
+
*/
|
|
123
|
+
HttpClient.prototype.delete = function (url, headers, params) {
|
|
124
|
+
return this.axios.delete(url, {
|
|
125
|
+
headers: headers,
|
|
126
|
+
data: params,
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Sets middlewares into the client for common behaviour managing
|
|
131
|
+
* @private
|
|
132
|
+
*/
|
|
133
|
+
HttpClient.prototype.initializeMiddleware = function () {
|
|
134
|
+
this.axios.interceptors.response.use(HttpClient.extractData, this.normalizeError.bind(this));
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* Extracts the valuable data from the server's response
|
|
138
|
+
* @param response
|
|
139
|
+
* @private
|
|
140
|
+
*/
|
|
141
|
+
HttpClient.extractData = function (response) {
|
|
142
|
+
return response.data;
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* Converts the specific client error into a proprietary error for our apps
|
|
146
|
+
* @param error
|
|
147
|
+
* @private
|
|
148
|
+
*/
|
|
149
|
+
HttpClient.prototype.normalizeError = function (error) {
|
|
150
|
+
var errorMessage, errorStatus, errorCode;
|
|
151
|
+
if (error.response) {
|
|
152
|
+
var response = error.response;
|
|
153
|
+
if (response.status === 401) {
|
|
154
|
+
this.unauthorizedCallback();
|
|
155
|
+
}
|
|
156
|
+
errorMessage = response.data.message || response.data.error || JSON.stringify(response.data);
|
|
157
|
+
errorStatus = response.status;
|
|
158
|
+
errorCode = response.data.code;
|
|
159
|
+
}
|
|
160
|
+
else if (error.request) {
|
|
161
|
+
errorMessage = 'Server unavailable';
|
|
162
|
+
errorStatus = 500;
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
errorMessage = error.message;
|
|
166
|
+
errorStatus = 400;
|
|
167
|
+
}
|
|
168
|
+
throw new errors_1.default(errorMessage, errorStatus, errorCode);
|
|
169
|
+
};
|
|
170
|
+
return HttpClient;
|
|
171
|
+
}());
|
|
172
|
+
exports.HttpClient = HttpClient;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export interface RequestCanceler {
|
|
5
|
-
cancel: (message?: string) => void;
|
|
6
|
-
}
|
|
7
|
-
export
|
|
1
|
+
export type URL = string;
|
|
2
|
+
export type Headers = Record<string, string>;
|
|
3
|
+
export type Parameters = Record<string, unknown> | FormData;
|
|
4
|
+
export interface RequestCanceler {
|
|
5
|
+
cancel: (message?: string) => void;
|
|
6
|
+
}
|
|
7
|
+
export type UnauthorizedCallback = () => void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/dist/shared/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './types/apiConnection';
|
|
1
|
+
export * from './types/apiConnection';
|
package/dist/shared/index.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
__exportStar(
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./types/apiConnection"), exports);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Token } from '../../auth';
|
|
2
|
-
import { UnauthorizedCallback } from '../http/types';
|
|
3
|
-
export
|
|
4
|
-
export interface AppDetails {
|
|
5
|
-
clientName: string;
|
|
6
|
-
clientVersion: string;
|
|
7
|
-
}
|
|
8
|
-
export interface ApiSecurity {
|
|
9
|
-
token: Token;
|
|
10
|
-
workspaceToken?: Token;
|
|
11
|
-
unauthorizedCallback?: UnauthorizedCallback;
|
|
12
|
-
}
|
|
1
|
+
import { Token } from '../../auth';
|
|
2
|
+
import { UnauthorizedCallback } from '../http/types';
|
|
3
|
+
export type ApiUrl = string;
|
|
4
|
+
export interface AppDetails {
|
|
5
|
+
clientName: string;
|
|
6
|
+
clientVersion: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ApiSecurity {
|
|
9
|
+
token: Token;
|
|
10
|
+
workspaceToken?: Token;
|
|
11
|
+
unauthorizedCallback?: UnauthorizedCallback;
|
|
12
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
export interface AppSumoDetails {
|
|
2
|
-
createdAt: string;
|
|
3
|
-
id: number;
|
|
4
|
-
invoiceItemUuid: string;
|
|
5
|
-
planId: AppSumoTier;
|
|
6
|
-
updatedAt: '';
|
|
7
|
-
uuid: string;
|
|
8
|
-
}
|
|
9
|
-
export declare enum AppSumoTier {
|
|
10
|
-
Free = "internxt_free1",
|
|
11
|
-
Tier1 = "internxt_tier1",
|
|
12
|
-
Tier2 = "internxt_tier2",
|
|
13
|
-
Tier3 = "internxt_tier3",
|
|
14
|
-
Tier4 = "internxt_tier4",
|
|
15
|
-
Tier5 = "internxt_tier5"
|
|
16
|
-
}
|
|
1
|
+
export interface AppSumoDetails {
|
|
2
|
+
createdAt: string;
|
|
3
|
+
id: number;
|
|
4
|
+
invoiceItemUuid: string;
|
|
5
|
+
planId: AppSumoTier;
|
|
6
|
+
updatedAt: '';
|
|
7
|
+
uuid: string;
|
|
8
|
+
}
|
|
9
|
+
export declare enum AppSumoTier {
|
|
10
|
+
Free = "internxt_free1",
|
|
11
|
+
Tier1 = "internxt_tier1",
|
|
12
|
+
Tier2 = "internxt_tier2",
|
|
13
|
+
Tier3 = "internxt_tier3",
|
|
14
|
+
Tier4 = "internxt_tier4",
|
|
15
|
+
Tier5 = "internxt_tier5"
|
|
16
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AppSumoTier = void 0;
|
|
4
|
-
var AppSumoTier;
|
|
5
|
-
(function (AppSumoTier) {
|
|
6
|
-
AppSumoTier["Free"] = "internxt_free1";
|
|
7
|
-
AppSumoTier["Tier1"] = "internxt_tier1";
|
|
8
|
-
AppSumoTier["Tier2"] = "internxt_tier2";
|
|
9
|
-
AppSumoTier["Tier3"] = "internxt_tier3";
|
|
10
|
-
AppSumoTier["Tier4"] = "internxt_tier4";
|
|
11
|
-
AppSumoTier["Tier5"] = "internxt_tier5";
|
|
12
|
-
})(AppSumoTier
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AppSumoTier = void 0;
|
|
4
|
+
var AppSumoTier;
|
|
5
|
+
(function (AppSumoTier) {
|
|
6
|
+
AppSumoTier["Free"] = "internxt_free1";
|
|
7
|
+
AppSumoTier["Tier1"] = "internxt_tier1";
|
|
8
|
+
AppSumoTier["Tier2"] = "internxt_tier2";
|
|
9
|
+
AppSumoTier["Tier3"] = "internxt_tier3";
|
|
10
|
+
AppSumoTier["Tier4"] = "internxt_tier4";
|
|
11
|
+
AppSumoTier["Tier5"] = "internxt_tier5";
|
|
12
|
+
})(AppSumoTier || (exports.AppSumoTier = AppSumoTier = {}));
|