@selfcommunity/api-services 0.1.2-alpha.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/LICENSE.md +21 -0
- package/README.md +12 -0
- package/lib/cjs/client/index.js +170 -0
- package/lib/cjs/constants/Endpoints.js +622 -0
- package/lib/cjs/index.d.js +2 -0
- package/lib/cjs/index.js +46 -0
- package/lib/cjs/services/category/index.js +64 -0
- package/lib/cjs/services/feature/index.js +42 -0
- package/lib/cjs/services/preference/index.js +100 -0
- package/lib/cjs/services/user/index.js +85 -0
- package/lib/cjs/utils/http.js +51 -0
- package/lib/cjs/utils/token.js +36 -0
- package/lib/esm/api-services/src/client/index.d.ts +115 -0
- package/lib/esm/api-services/src/client/index.d.ts.map +1 -0
- package/lib/esm/api-services/src/constants/Endpoints.d.ts +10 -0
- package/lib/esm/api-services/src/constants/Endpoints.d.ts.map +1 -0
- package/lib/esm/api-services/src/index.d.ts +24 -0
- package/lib/esm/api-services/src/index.d.ts.map +1 -0
- package/lib/esm/api-services/src/services/category/index.d.ts +13 -0
- package/lib/esm/api-services/src/services/category/index.d.ts.map +1 -0
- package/lib/esm/api-services/src/services/feature/index.d.ts +10 -0
- package/lib/esm/api-services/src/services/feature/index.d.ts.map +1 -0
- package/lib/esm/api-services/src/services/preference/index.d.ts +16 -0
- package/lib/esm/api-services/src/services/preference/index.d.ts.map +1 -0
- package/lib/esm/api-services/src/services/user/index.d.ts +16 -0
- package/lib/esm/api-services/src/services/user/index.d.ts.map +1 -0
- package/lib/esm/api-services/src/utils/http.d.ts +6 -0
- package/lib/esm/api-services/src/utils/http.d.ts.map +1 -0
- package/lib/esm/api-services/src/utils/token.d.ts +16 -0
- package/lib/esm/api-services/src/utils/token.d.ts.map +1 -0
- package/lib/esm/client/index.js +170 -0
- package/lib/esm/constants/Endpoints.js +622 -0
- package/lib/esm/index.d.js +2 -0
- package/lib/esm/index.js +46 -0
- package/lib/esm/services/category/index.js +64 -0
- package/lib/esm/services/feature/index.js +42 -0
- package/lib/esm/services/preference/index.js +100 -0
- package/lib/esm/services/user/index.js +85 -0
- package/lib/esm/utils/http.js +51 -0
- package/lib/esm/utils/src/index.d.ts +7 -0
- package/lib/esm/utils/src/index.d.ts.map +1 -0
- package/lib/esm/utils/src/utils/string.d.ts +21 -0
- package/lib/esm/utils/src/utils/string.d.ts.map +1 -0
- package/lib/esm/utils/src/utils/url.d.ts +22 -0
- package/lib/esm/utils/src/utils/url.d.ts.map +1 -0
- package/lib/esm/utils/token.js +36 -0
- package/lib/umd/api-services.js +3 -0
- package/lib/umd/api-services.js.LICENSE.txt +1 -0
- package/lib/umd/api-services.js.map +1 -0
- package/package.json +114 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = exports.CategoryApiClient = void 0;
|
|
5
|
+
|
|
6
|
+
var _client = _interopRequireDefault(require("../../client"));
|
|
7
|
+
|
|
8
|
+
var _Endpoints = _interopRequireDefault(require("../../constants/Endpoints"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
class CategoryApiClient {
|
|
13
|
+
static getAllCategories() {
|
|
14
|
+
return _client.default.request({
|
|
15
|
+
url: _Endpoints.default.Category.url({}),
|
|
16
|
+
method: _Endpoints.default.Category.method
|
|
17
|
+
}).then(res => {
|
|
18
|
+
if (res.status >= 300) {
|
|
19
|
+
console.log(`Unable to retrieve categories (Response code: ${res.status}).`);
|
|
20
|
+
return Promise.reject(res);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return Promise.resolve(res);
|
|
24
|
+
}).catch(error => {
|
|
25
|
+
console.log('Unable to retrieve categories.');
|
|
26
|
+
return Promise.reject(error);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static getSpecificCategory(id) {
|
|
31
|
+
return _client.default.request({
|
|
32
|
+
url: _Endpoints.default.Category.url({
|
|
33
|
+
id
|
|
34
|
+
}),
|
|
35
|
+
method: _Endpoints.default.User.method
|
|
36
|
+
}).then(res => {
|
|
37
|
+
if (res.status >= 300) {
|
|
38
|
+
console.log(`Unable to retrieve category (Response code: ${res.status}).`);
|
|
39
|
+
return Promise.reject(res);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return Promise.resolve(res);
|
|
43
|
+
}).catch(error => {
|
|
44
|
+
console.log('Unable to retrieve category.');
|
|
45
|
+
return Promise.reject(error);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
exports.CategoryApiClient = CategoryApiClient;
|
|
52
|
+
|
|
53
|
+
class CategoryService {
|
|
54
|
+
static async getAllCategories() {
|
|
55
|
+
return CategoryApiClient.getAllCategories();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
static async getSpecificCategory(id) {
|
|
59
|
+
return CategoryApiClient.getSpecificCategory(id);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
exports.default = CategoryService;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = exports.FeatureApiClient = void 0;
|
|
5
|
+
|
|
6
|
+
var _client = _interopRequireDefault(require("../../client"));
|
|
7
|
+
|
|
8
|
+
var _Endpoints = _interopRequireDefault(require("../../constants/Endpoints"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
class FeatureApiClient {
|
|
13
|
+
static getAllFeatures() {
|
|
14
|
+
return _client.default.request({
|
|
15
|
+
url: _Endpoints.default.Feature.url({}),
|
|
16
|
+
method: _Endpoints.default.Feature.method
|
|
17
|
+
}).then(res => {
|
|
18
|
+
if (res.status >= 300) {
|
|
19
|
+
console.log(`Unable to retrieve community preferences (Response code: ${res.status}).`);
|
|
20
|
+
return Promise.reject(res);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const data = res.data['results'].map(f => f.name);
|
|
24
|
+
return Promise.resolve(data);
|
|
25
|
+
}).catch(error => {
|
|
26
|
+
console.log('Unable to retrieve features.');
|
|
27
|
+
return Promise.reject(error);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
exports.FeatureApiClient = FeatureApiClient;
|
|
34
|
+
|
|
35
|
+
class FeatureService {
|
|
36
|
+
static async getAllFeatures() {
|
|
37
|
+
return FeatureApiClient.getAllFeatures();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
exports.default = FeatureService;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = exports.PreferenceApiClient = void 0;
|
|
5
|
+
|
|
6
|
+
var _client = _interopRequireDefault(require("../../client"));
|
|
7
|
+
|
|
8
|
+
var _Endpoints = _interopRequireDefault(require("../../constants/Endpoints"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
class PreferenceApiClient {
|
|
13
|
+
static getAllPreferences() {
|
|
14
|
+
return _client.default.request({
|
|
15
|
+
url: _Endpoints.default.Preferences.url({}),
|
|
16
|
+
method: _Endpoints.default.Preferences.method
|
|
17
|
+
}).then(res => {
|
|
18
|
+
if (res.status >= 300) {
|
|
19
|
+
console.log(`Unable to retrieve community preferences (Response code: ${res.status}).`);
|
|
20
|
+
return Promise.reject(res);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const data = res.data['results'].reduce((obj, p) => Object.assign({}, obj, {
|
|
24
|
+
[`${p.section}.${p.name}`]: p
|
|
25
|
+
}), {});
|
|
26
|
+
return Promise.resolve(data);
|
|
27
|
+
}).catch(error => {
|
|
28
|
+
console.log('Unable to retrieve community preferences.');
|
|
29
|
+
return Promise.reject(error);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
static searchPreferences(search, section, keys, ordering) {
|
|
34
|
+
const params = new URLSearchParams(Object.assign({}, search && {
|
|
35
|
+
search: search
|
|
36
|
+
}, section && {
|
|
37
|
+
section: section
|
|
38
|
+
}, keys && {
|
|
39
|
+
keys: keys
|
|
40
|
+
}, ordering && {
|
|
41
|
+
ordering: ordering
|
|
42
|
+
}));
|
|
43
|
+
return _client.default.request({
|
|
44
|
+
url: `${_Endpoints.default.Preferences.url({})}?${params.toString()}`,
|
|
45
|
+
method: _Endpoints.default.Preferences.method
|
|
46
|
+
}).then(res => {
|
|
47
|
+
if (res.status >= 300) {
|
|
48
|
+
console.log(`Unable to retrieve community preferences (Response code: ${res.status}).`);
|
|
49
|
+
return Promise.reject(res);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const data = res.data['results'].reduce((obj, p) => Object.assign({}, obj, {
|
|
53
|
+
[`${p.section}.${p.name}`]: p
|
|
54
|
+
}), {});
|
|
55
|
+
return Promise.resolve(res);
|
|
56
|
+
}).catch(error => {
|
|
57
|
+
console.log('Unable to retrieve community preferences.');
|
|
58
|
+
return Promise.reject(error);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
static getSpecificPreference(id) {
|
|
63
|
+
return _client.default.request({
|
|
64
|
+
url: _Endpoints.default.Preferences.url({
|
|
65
|
+
id
|
|
66
|
+
}),
|
|
67
|
+
method: _Endpoints.default.Preferences.method
|
|
68
|
+
}).then(res => {
|
|
69
|
+
if (res.status >= 300) {
|
|
70
|
+
console.log(`Unable to retrieve community preference (Response code: ${res.status}).`);
|
|
71
|
+
return Promise.reject(res);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return Promise.resolve(res);
|
|
75
|
+
}).catch(error => {
|
|
76
|
+
console.log('Unable to retrieve community preference.');
|
|
77
|
+
return Promise.reject(error);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
exports.PreferenceApiClient = PreferenceApiClient;
|
|
84
|
+
|
|
85
|
+
class PreferenceService {
|
|
86
|
+
static async getAllPreferences() {
|
|
87
|
+
return PreferenceApiClient.getAllPreferences();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
static async searchPreferences(search, section, keys, ordering) {
|
|
91
|
+
return PreferenceApiClient.searchPreferences(search, section, keys, ordering);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
static async getSpecificPreference(id) {
|
|
95
|
+
return PreferenceApiClient.getSpecificPreference(id);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
exports.default = PreferenceService;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = exports.UserApiClient = void 0;
|
|
5
|
+
|
|
6
|
+
var _client = _interopRequireDefault(require("../../client"));
|
|
7
|
+
|
|
8
|
+
var _Endpoints = _interopRequireDefault(require("../../constants/Endpoints"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
class UserApiClient {
|
|
13
|
+
static getAllUsers() {
|
|
14
|
+
return _client.default.request({
|
|
15
|
+
url: _Endpoints.default.User.url({}),
|
|
16
|
+
method: _Endpoints.default.User.method
|
|
17
|
+
}).then(res => {
|
|
18
|
+
if (res.status >= 300) {
|
|
19
|
+
console.log(`Unable to retrieve users (Response code: ${res.status}).`);
|
|
20
|
+
return Promise.reject(res);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return Promise.resolve(res);
|
|
24
|
+
}).catch(error => {
|
|
25
|
+
console.log('Unable to retrieve users.');
|
|
26
|
+
return Promise.reject(error);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static getSpecificUser(id) {
|
|
31
|
+
return _client.default.request({
|
|
32
|
+
url: _Endpoints.default.User.url({
|
|
33
|
+
id
|
|
34
|
+
}),
|
|
35
|
+
method: _Endpoints.default.User.method
|
|
36
|
+
}).then(res => {
|
|
37
|
+
if (res.status >= 300) {
|
|
38
|
+
console.log(`Unable to retrieve user (Response code: ${res.status}).`);
|
|
39
|
+
return Promise.reject(res);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return Promise.resolve(res);
|
|
43
|
+
}).catch(error => {
|
|
44
|
+
console.log('Unable to retrieve user.');
|
|
45
|
+
return Promise.reject(error);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static getCurrentUser() {
|
|
50
|
+
return _client.default.request({
|
|
51
|
+
url: _Endpoints.default.Me.url(),
|
|
52
|
+
method: _Endpoints.default.Me.method
|
|
53
|
+
}).then(res => {
|
|
54
|
+
if (res.status >= 300) {
|
|
55
|
+
console.log(`Unable to retrieve user (Response code: ${res.status}).`);
|
|
56
|
+
return Promise.reject(res);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return Promise.resolve(res.data);
|
|
60
|
+
}).catch(error => {
|
|
61
|
+
console.log('Unable to retrieve user profile.');
|
|
62
|
+
return Promise.reject(error);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
exports.UserApiClient = UserApiClient;
|
|
69
|
+
|
|
70
|
+
class UserService {
|
|
71
|
+
static async getAllUsers() {
|
|
72
|
+
return UserApiClient.getAllUsers();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
static async getSpecificUser(id) {
|
|
76
|
+
return UserApiClient.getSpecificUser(id);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
static async getCurrentUser() {
|
|
80
|
+
return UserApiClient.getCurrentUser();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
exports.default = UserService;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.defaultError = defaultError;
|
|
5
|
+
exports.formatHttpError = formatHttpError;
|
|
6
|
+
|
|
7
|
+
var _utils = require("@selfcommunity/utils");
|
|
8
|
+
|
|
9
|
+
function defaultError(error) {
|
|
10
|
+
if (error.request) {
|
|
11
|
+
// The request was made but no response was received
|
|
12
|
+
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of
|
|
13
|
+
// http.ClientRequest in node.js
|
|
14
|
+
console.log(error.request);
|
|
15
|
+
} else {
|
|
16
|
+
// Something happened in setting up the request that triggered an Error
|
|
17
|
+
console.log('Error', error.message);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const formatError = error => {
|
|
22
|
+
const errors = {};
|
|
23
|
+
|
|
24
|
+
if (Array.isArray(error)) {
|
|
25
|
+
for (let i = 0; i < error.length; i++) {
|
|
26
|
+
const err = error[i];
|
|
27
|
+
|
|
28
|
+
if (err.field) {
|
|
29
|
+
errors[`${(0, _utils.camelCase)(err.field)}Error`] = Array.isArray(err.messages) ? formatError(err.messages) : err.messages;
|
|
30
|
+
} else {
|
|
31
|
+
errors.error = err.message;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
} else {
|
|
35
|
+
errors.error = error.errors;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return errors;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
function formatHttpError(error) {
|
|
42
|
+
let errors = {};
|
|
43
|
+
|
|
44
|
+
if (error.response && error.response.data && typeof error.response.data === 'object' && error.response.data.errors) {
|
|
45
|
+
errors = Object.assign({}, formatError(error.response.data.errors));
|
|
46
|
+
} else {
|
|
47
|
+
defaultError(error);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return errors;
|
|
51
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.generateJWTToken = generateJWTToken;
|
|
5
|
+
|
|
6
|
+
var jose = _interopRequireWildcard(require("jose"));
|
|
7
|
+
|
|
8
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
9
|
+
|
|
10
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Generate a JWT
|
|
14
|
+
:::tipContext can be consumed as following:
|
|
15
|
+
```jsx
|
|
16
|
+
1. const token = await generateJWTToken(userId, secretKey, expirationTime);
|
|
17
|
+
```
|
|
18
|
+
```jsx
|
|
19
|
+
2. generateJWTToken(userId, secretKey, expirationTime).then(token => {...});
|
|
20
|
+
```
|
|
21
|
+
:::
|
|
22
|
+
* @param userId
|
|
23
|
+
* @param secretKey
|
|
24
|
+
* @param expirationTime
|
|
25
|
+
*/
|
|
26
|
+
async function generateJWTToken(userId, secretKey, expirationTime) {
|
|
27
|
+
let data = {
|
|
28
|
+
token_type: 'access',
|
|
29
|
+
userId: 7
|
|
30
|
+
};
|
|
31
|
+
const privateKey = new TextEncoder().encode(secretKey);
|
|
32
|
+
return await new jose.SignJWT(data).setProtectedHeader({
|
|
33
|
+
alg: 'HS256',
|
|
34
|
+
typ: 'JWT'
|
|
35
|
+
}).setIssuedAt().setExpirationTime(expirationTime ? expirationTime : '2h').sign(privateKey);
|
|
36
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { AxiosInstance, AxiosRequestConfig } from 'axios';
|
|
2
|
+
/**
|
|
3
|
+
* List of all Http methods
|
|
4
|
+
*/
|
|
5
|
+
export declare type HttpMethod = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
|
|
6
|
+
/**
|
|
7
|
+
* AxiosResponseHeaders interface
|
|
8
|
+
*/
|
|
9
|
+
export declare type AxiosResponseHeaders = Record<string, string> & {
|
|
10
|
+
'set-cookie'?: string[];
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* General HttpResponse
|
|
14
|
+
*/
|
|
15
|
+
export interface HttpResponse<T = unknown, D = any> {
|
|
16
|
+
data: T;
|
|
17
|
+
status: number;
|
|
18
|
+
statusText: string;
|
|
19
|
+
headers: AxiosResponseHeaders;
|
|
20
|
+
config: AxiosRequestConfig<D>;
|
|
21
|
+
request?: any;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Interface for the ApiClient
|
|
25
|
+
*/
|
|
26
|
+
export interface ApiClientInterface {
|
|
27
|
+
request<TRequest, TResponse>(config?: any): Promise<HttpResponse<TResponse>>;
|
|
28
|
+
post<TRequest, TResponse>(path: string, object: TRequest, config?: any): Promise<HttpResponse<TResponse>>;
|
|
29
|
+
patch<TRequest, TResponse>(path: string, object: TRequest): Promise<HttpResponse<TResponse>>;
|
|
30
|
+
put<TRequest, TResponse>(path: string, object: TRequest): Promise<HttpResponse<TResponse>>;
|
|
31
|
+
get<TResponse>(path: string): Promise<HttpResponse<TResponse>>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Create an abstraction wrapping of axios
|
|
35
|
+
* Create a sort of interface between axios and the rest of application
|
|
36
|
+
* This makes it easy for instance, to swap axios out for another package,
|
|
37
|
+
* should we choose to do so in the future, without it breaking our app.
|
|
38
|
+
*/
|
|
39
|
+
export declare class ApiClient implements ApiClientInterface {
|
|
40
|
+
static DEFAULT_TIMEOUT: number;
|
|
41
|
+
protected readonly client: AxiosInstance;
|
|
42
|
+
protected createClient(config?: any): AxiosInstance;
|
|
43
|
+
constructor(config?: any);
|
|
44
|
+
/**
|
|
45
|
+
* Get client instance
|
|
46
|
+
*/
|
|
47
|
+
getClientInstance(): AxiosInstance;
|
|
48
|
+
/**
|
|
49
|
+
* Change configuration
|
|
50
|
+
* @param config
|
|
51
|
+
*/
|
|
52
|
+
config(config: any): void;
|
|
53
|
+
/**
|
|
54
|
+
* Set default header
|
|
55
|
+
* @param name
|
|
56
|
+
* @param value
|
|
57
|
+
* @param methods
|
|
58
|
+
*/
|
|
59
|
+
setDefaultHeader: ({ name, value, methods }: {
|
|
60
|
+
name: string;
|
|
61
|
+
value: string;
|
|
62
|
+
methods?: string[];
|
|
63
|
+
}) => void;
|
|
64
|
+
/**
|
|
65
|
+
* setSupportWithCredentials
|
|
66
|
+
* Disable/enable withCredentials
|
|
67
|
+
* Bypass cookie if disabled
|
|
68
|
+
* @param enable
|
|
69
|
+
*/
|
|
70
|
+
setSupportWithCredentials(enable: boolean): void;
|
|
71
|
+
/**
|
|
72
|
+
* setBasePortal
|
|
73
|
+
* Set base path of all http requests
|
|
74
|
+
* @param portal
|
|
75
|
+
*/
|
|
76
|
+
setBasePortal(baseUrl: string): void;
|
|
77
|
+
/**
|
|
78
|
+
* setAuthorizeToken
|
|
79
|
+
* Set authorization header for all http requests
|
|
80
|
+
* @param token
|
|
81
|
+
*/
|
|
82
|
+
setAuthorizeToken(token: string): void;
|
|
83
|
+
/**
|
|
84
|
+
* request wrapper
|
|
85
|
+
* @param config
|
|
86
|
+
*/
|
|
87
|
+
request<TRequest, TResponse>(config: any): Promise<HttpResponse<TResponse>>;
|
|
88
|
+
/**
|
|
89
|
+
* get wrapper
|
|
90
|
+
* @param path
|
|
91
|
+
*/
|
|
92
|
+
get<TResponse>(path: string): Promise<HttpResponse<TResponse>>;
|
|
93
|
+
/**
|
|
94
|
+
* post wrapper
|
|
95
|
+
* @param path
|
|
96
|
+
* @param payload
|
|
97
|
+
* @param config
|
|
98
|
+
*/
|
|
99
|
+
post<TRequest, TResponse>(path: string, payload: TRequest, config?: any): Promise<HttpResponse<TResponse>>;
|
|
100
|
+
/**
|
|
101
|
+
* patch wrapper
|
|
102
|
+
* @param path
|
|
103
|
+
* @param object
|
|
104
|
+
*/
|
|
105
|
+
patch<TRequest, TResponse>(path: string, payload: TRequest): Promise<HttpResponse<TResponse>>;
|
|
106
|
+
/**
|
|
107
|
+
* put wrapper
|
|
108
|
+
* @param path
|
|
109
|
+
* @param payload
|
|
110
|
+
*/
|
|
111
|
+
put<TRequest, TResponse>(path: string, payload: TRequest): Promise<HttpResponse<TResponse>>;
|
|
112
|
+
}
|
|
113
|
+
declare const client: ApiClient;
|
|
114
|
+
export default client;
|
|
115
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/client/index.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { HttpMethod } from '../client';
|
|
2
|
+
export interface EndpointType {
|
|
3
|
+
url: (params?: object) => string;
|
|
4
|
+
method: HttpMethod;
|
|
5
|
+
}
|
|
6
|
+
declare const Endpoints: {
|
|
7
|
+
[key: string]: EndpointType;
|
|
8
|
+
};
|
|
9
|
+
export default Endpoints;
|
|
10
|
+
//# sourceMappingURL=Endpoints.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Endpoints.d.ts","sourceRoot":"","sources":["../../../../../src/constants/Endpoints.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,UAAU,EAAC,MAAM,WAAW,CAAC;AAErC,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IACjC,MAAM,EAAE,UAAU,CAAC;CACpB;AAED,QAAA,MAAM,SAAS,EAAE;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,CAAA;CAglB5C,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Axios client wrapper
|
|
3
|
+
*/
|
|
4
|
+
import http, { HttpResponse, HttpMethod } from './client';
|
|
5
|
+
/**
|
|
6
|
+
* Endpoint component
|
|
7
|
+
*/
|
|
8
|
+
import Endpoints, { EndpointType } from './constants/Endpoints';
|
|
9
|
+
/**
|
|
10
|
+
* Utils
|
|
11
|
+
*/
|
|
12
|
+
import { formatHttpError } from './utils/http';
|
|
13
|
+
/**
|
|
14
|
+
* Services
|
|
15
|
+
*/
|
|
16
|
+
import PreferenceService, { PreferenceApiClient, PreferenceApiClientInterface } from './services/preference';
|
|
17
|
+
import UserService, { UserApiClient, UserApiClientInterface } from './services/user';
|
|
18
|
+
import FeatureService, { FeatureApiClient, FeatureApiClientInterface } from './services/feature';
|
|
19
|
+
import CategoryService, { CategoryApiClient, CategoryApiClientInterface } from './services/category';
|
|
20
|
+
/**
|
|
21
|
+
* Export all
|
|
22
|
+
*/
|
|
23
|
+
export { http, HttpResponse, HttpMethod, formatHttpError, Endpoints, EndpointType, PreferenceService, PreferenceApiClient, PreferenceApiClientInterface, UserService, UserApiClient, UserApiClientInterface, FeatureService, FeatureApiClient, FeatureApiClientInterface, CategoryService, CategoryApiClient, CategoryApiClientInterface };
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,IAAI,EAAE,EAAC,YAAY,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AAExD;;GAEG;AACH,OAAO,SAAS,EAAE,EAAC,YAAY,EAAC,MAAM,uBAAuB,CAAC;AAE9D;;GAEG;AACH,OAAO,EAAC,eAAe,EAAC,MAAM,cAAc,CAAC;AAG7C;;GAEG;AACH,OAAO,iBAAiB,EAAE,EAAC,mBAAmB,EAAE,4BAA4B,EAAC,MAAM,uBAAuB,CAAC;AAC3G,OAAO,WAAW,EAAE,EAAC,aAAa,EAAE,sBAAsB,EAAC,MAAM,iBAAiB,CAAC;AACnF,OAAO,cAAc,EAAE,EAAC,gBAAgB,EAAE,yBAAyB,EAAC,MAAM,oBAAoB,CAAC;AAC/F,OAAO,eAAe,EAAE,EAAC,iBAAiB,EAAE,0BAA0B,EAAC,MAAM,qBAAqB,CAAC;AAEnG;;GAEG;AACH,OAAO,EACL,IAAI,EACJ,YAAY,EACZ,UAAU,EACV,eAAe,EACf,SAAS,EACT,YAAY,EACZ,iBAAiB,EACjB,mBAAmB,EACnB,4BAA4B,EAC5B,WAAW,EACX,aAAa,EACb,sBAAsB,EACtB,cAAc,EACd,gBAAgB,EAChB,yBAAyB,EACzB,eAAe,EACf,iBAAiB,EACjB,0BAA0B,EAC3B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface CategoryApiClientInterface {
|
|
2
|
+
getAllCategories(): Promise<any>;
|
|
3
|
+
getSpecificCategory(id: number): Promise<any>;
|
|
4
|
+
}
|
|
5
|
+
export declare class CategoryApiClient {
|
|
6
|
+
static getAllCategories(): Promise<any>;
|
|
7
|
+
static getSpecificCategory(id: number): Promise<any>;
|
|
8
|
+
}
|
|
9
|
+
export default class CategoryService {
|
|
10
|
+
static getAllCategories(): Promise<any>;
|
|
11
|
+
static getSpecificCategory(id: number): Promise<any>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/services/category/index.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,0BAA0B;IACzC,gBAAgB,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC;IACjC,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;CAC/C;AAED,qBAAa,iBAAiB;IAC5B,MAAM,CAAC,gBAAgB,IAAI,OAAO,CAAC,GAAG,CAAC;IAmBvC,MAAM,CAAC,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;CAkBrD;AAED,MAAM,CAAC,OAAO,OAAO,eAAe;WACrB,gBAAgB,IAAI,OAAO,CAAC,GAAG,CAAC;WAIhC,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;CAG3D"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface FeatureApiClientInterface {
|
|
2
|
+
getAllFeatures(): Promise<any>;
|
|
3
|
+
}
|
|
4
|
+
export declare class FeatureApiClient {
|
|
5
|
+
static getAllFeatures(): Promise<any>;
|
|
6
|
+
}
|
|
7
|
+
export default class FeatureService {
|
|
8
|
+
static getAllFeatures(): Promise<any>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/services/feature/index.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,yBAAyB;IACxC,cAAc,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC;CAChC;AAED,qBAAa,gBAAgB;IAC3B,MAAM,CAAC,cAAc,IAAI,OAAO,CAAC,GAAG,CAAC;CAmBtC;AAED,MAAM,CAAC,OAAO,OAAO,cAAc;WACpB,cAAc,IAAI,OAAO,CAAC,GAAG,CAAC;CAG5C"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface PreferenceApiClientInterface {
|
|
2
|
+
getAllPreferences(): Promise<any>;
|
|
3
|
+
searchPreferences(search?: string, section?: string, keys?: string, ordering?: string): Promise<any>;
|
|
4
|
+
getSpecificPreference(id: number): Promise<any>;
|
|
5
|
+
}
|
|
6
|
+
export declare class PreferenceApiClient {
|
|
7
|
+
static getAllPreferences(): Promise<any>;
|
|
8
|
+
static searchPreferences(search?: string, section?: string, keys?: string, ordering?: string): Promise<any>;
|
|
9
|
+
static getSpecificPreference(id: number): Promise<any>;
|
|
10
|
+
}
|
|
11
|
+
export default class PreferenceService {
|
|
12
|
+
static getAllPreferences(): Promise<any>;
|
|
13
|
+
static searchPreferences(search?: string, section?: string, keys?: string, ordering?: string): Promise<any>;
|
|
14
|
+
static getSpecificPreference(id: number): Promise<any>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/services/preference/index.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,4BAA4B;IAC3C,iBAAiB,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC;IAClC,iBAAiB,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IACrG,qBAAqB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;CACjD;AAED,qBAAa,mBAAmB;IAC9B,MAAM,CAAC,iBAAiB,IAAI,OAAO,CAAC,GAAG,CAAC;IAoBxC,MAAM,CAAC,iBAAiB,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IA0B3G,MAAM,CAAC,qBAAqB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;CAkBvD;AAED,MAAM,CAAC,OAAO,OAAO,iBAAiB;WACvB,iBAAiB,IAAI,OAAO,CAAC,GAAG,CAAC;WAIjC,iBAAiB,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;WAIpG,qBAAqB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;CAG7D"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface UserApiClientInterface {
|
|
2
|
+
getAllUsers(): Promise<any>;
|
|
3
|
+
getSpecificUser(id: number): Promise<any>;
|
|
4
|
+
getCurrentUser(): Promise<any>;
|
|
5
|
+
}
|
|
6
|
+
export declare class UserApiClient {
|
|
7
|
+
static getAllUsers(): Promise<any>;
|
|
8
|
+
static getSpecificUser(id: number): Promise<any>;
|
|
9
|
+
static getCurrentUser(): Promise<any>;
|
|
10
|
+
}
|
|
11
|
+
export default class UserService {
|
|
12
|
+
static getAllUsers(): Promise<any>;
|
|
13
|
+
static getSpecificUser(id: number): Promise<any>;
|
|
14
|
+
static getCurrentUser(): Promise<any>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/services/user/index.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,sBAAsB;IACrC,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC;IAC5B,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAC1C,cAAc,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC;CAChC;AAED,qBAAa,aAAa;IACxB,MAAM,CAAC,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC;IAmBlC,MAAM,CAAC,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAmBhD,MAAM,CAAC,cAAc,IAAI,OAAO,CAAC,GAAG,CAAC;CAkBtC;AAED,MAAM,CAAC,OAAO,OAAO,WAAW;WACjB,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC;WAI3B,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;WAIzC,cAAc,IAAI,OAAO,CAAC,GAAG,CAAC;CAG5C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../../../src/utils/http.ts"],"names":[],"mappings":"AAEA,wBAAgB,YAAY,CAAC,KAAK,EAAE;IAAC,OAAO,CAAC,EAAE,GAAG,CAAC;IAAC,OAAO,CAAC,EAAE,GAAG,CAAA;CAAC,GAAG,IAAI,CAUxE;AAmBD,wBAAgB,eAAe,CAAC,KAAK,KAAA,OAQpC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate a JWT
|
|
3
|
+
:::tipContext can be consumed as following:
|
|
4
|
+
```jsx
|
|
5
|
+
1. const token = await generateJWTToken(userId, secretKey, expirationTime);
|
|
6
|
+
```
|
|
7
|
+
```jsx
|
|
8
|
+
2. generateJWTToken(userId, secretKey, expirationTime).then(token => {...});
|
|
9
|
+
```
|
|
10
|
+
:::
|
|
11
|
+
* @param userId
|
|
12
|
+
* @param secretKey
|
|
13
|
+
* @param expirationTime
|
|
14
|
+
*/
|
|
15
|
+
export declare function generateJWTToken(userId: any, secretKey: any, expirationTime: any): Promise<string>;
|
|
16
|
+
//# sourceMappingURL=token.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../../../../src/utils/token.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,wBAAsB,gBAAgB,CAAC,MAAM,KAAA,EAAE,SAAS,KAAA,EAAE,cAAc,KAAA,mBAWvE"}
|