@rasadov/lumoar-sdk 1.0.2 → 1.0.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/.openapi-generator/FILES +5 -1
- package/api.ts +360 -34
- package/base.ts +1 -1
- package/common.ts +1 -1
- package/configuration.ts +1 -108
- package/dist/api.d.ts +215 -17
- package/dist/api.js +277 -30
- package/dist/base.d.ts +1 -1
- package/dist/base.js +1 -1
- package/dist/common.d.ts +1 -1
- package/dist/common.js +1 -1
- package/dist/configuration.d.ts +11 -29
- package/dist/configuration.js +1 -80
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/sdk.d.ts +29 -0
- package/dist/sdk.js +73 -0
- package/docs/AuditLogAction.md +14 -0
- package/docs/AuditLogEntity.md +20 -0
- package/docs/AuditLogResponse.md +32 -0
- package/docs/AuditLogsApi.md +83 -0
- package/docs/HealthApi.md +44 -0
- package/docs/PaymentsApi.md +13 -13
- package/docs/ResponseGetCustomerManagementSessionV1PaymentsCustomerManagementGet.md +22 -0
- package/index.ts +2 -2
- package/package.json +1 -1
- package/sdk.ts +98 -0
package/dist/sdk.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { HealthApi, AuthApi, CompanyApi, ControlsApi, EvidenceApi, PaymentsApi, PoliciesApi, RolesApi, UserApi } from './api';
|
|
2
|
+
export declare class ApiSDK {
|
|
3
|
+
private helthApi;
|
|
4
|
+
private authApi;
|
|
5
|
+
private companyApi;
|
|
6
|
+
private controlsApi;
|
|
7
|
+
private evidenceApi;
|
|
8
|
+
private paymentsApi;
|
|
9
|
+
private policiesApi;
|
|
10
|
+
private rolesApi;
|
|
11
|
+
private userApi;
|
|
12
|
+
private token;
|
|
13
|
+
private axiosInstance;
|
|
14
|
+
constructor(basePath?: string);
|
|
15
|
+
setToken(newToken: string): void;
|
|
16
|
+
private getAuthHeader;
|
|
17
|
+
private setupInterceptors;
|
|
18
|
+
getApi(): {
|
|
19
|
+
helthApi: HealthApi;
|
|
20
|
+
authApi: AuthApi;
|
|
21
|
+
companyApi: CompanyApi;
|
|
22
|
+
controlsApi: ControlsApi;
|
|
23
|
+
evidenceApi: EvidenceApi;
|
|
24
|
+
paymentsApi: PaymentsApi;
|
|
25
|
+
policiesApi: PoliciesApi;
|
|
26
|
+
rolesApi: RolesApi;
|
|
27
|
+
userApi: UserApi;
|
|
28
|
+
};
|
|
29
|
+
}
|
package/dist/sdk.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import { HealthApi, AuthApi, CompanyApi, ControlsApi, EvidenceApi, PaymentsApi, PoliciesApi, RolesApi, UserApi } from './api';
|
|
3
|
+
import { Configuration } from './configuration';
|
|
4
|
+
export class ApiSDK {
|
|
5
|
+
constructor(basePath) {
|
|
6
|
+
this.token = null;
|
|
7
|
+
this.axiosInstance = axios.create({
|
|
8
|
+
baseURL: basePath,
|
|
9
|
+
withCredentials: true
|
|
10
|
+
});
|
|
11
|
+
this.setupInterceptors();
|
|
12
|
+
const config = new Configuration({
|
|
13
|
+
basePath,
|
|
14
|
+
apiKey: () => this.getAuthHeader(),
|
|
15
|
+
baseOptions: {
|
|
16
|
+
axios: this.axiosInstance
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
this.helthApi = new HealthApi(config, undefined, this.axiosInstance);
|
|
20
|
+
this.authApi = new AuthApi(config, undefined, this.axiosInstance);
|
|
21
|
+
this.companyApi = new CompanyApi(config, undefined, this.axiosInstance);
|
|
22
|
+
this.controlsApi = new ControlsApi(config, undefined, this.axiosInstance);
|
|
23
|
+
this.evidenceApi = new EvidenceApi(config, undefined, this.axiosInstance);
|
|
24
|
+
this.paymentsApi = new PaymentsApi(config, undefined, this.axiosInstance);
|
|
25
|
+
this.policiesApi = new PoliciesApi(config, undefined, this.axiosInstance);
|
|
26
|
+
this.rolesApi = new RolesApi(config, undefined, this.axiosInstance);
|
|
27
|
+
this.userApi = new UserApi(config, undefined, this.axiosInstance);
|
|
28
|
+
}
|
|
29
|
+
setToken(newToken) {
|
|
30
|
+
this.token = newToken;
|
|
31
|
+
}
|
|
32
|
+
getAuthHeader() {
|
|
33
|
+
if (!this.token) {
|
|
34
|
+
throw new Error('No token set. Call setToken() first.');
|
|
35
|
+
}
|
|
36
|
+
return `Bearer ${this.token}`;
|
|
37
|
+
}
|
|
38
|
+
setupInterceptors() {
|
|
39
|
+
this.axiosInstance.interceptors.request.use((config) => {
|
|
40
|
+
if (this.token) {
|
|
41
|
+
config.headers['Authorization'] = this.getAuthHeader();
|
|
42
|
+
}
|
|
43
|
+
return config;
|
|
44
|
+
});
|
|
45
|
+
this.axiosInstance.interceptors.response.use((response) => {
|
|
46
|
+
const newToken = response.data.newToken || response.headers['Authorization'];
|
|
47
|
+
if (newToken) {
|
|
48
|
+
this.setToken(newToken.replace('Bearer ', ''));
|
|
49
|
+
console.log('Token automatically updated via backend refresh');
|
|
50
|
+
}
|
|
51
|
+
return response;
|
|
52
|
+
}, (error) => {
|
|
53
|
+
var _a;
|
|
54
|
+
if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 401) {
|
|
55
|
+
console.error('Authentication failed - session expired');
|
|
56
|
+
}
|
|
57
|
+
return Promise.reject(error);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
getApi() {
|
|
61
|
+
return {
|
|
62
|
+
helthApi: this.helthApi,
|
|
63
|
+
authApi: this.authApi,
|
|
64
|
+
companyApi: this.companyApi,
|
|
65
|
+
controlsApi: this.controlsApi,
|
|
66
|
+
evidenceApi: this.evidenceApi,
|
|
67
|
+
paymentsApi: this.paymentsApi,
|
|
68
|
+
policiesApi: this.policiesApi,
|
|
69
|
+
rolesApi: this.rolesApi,
|
|
70
|
+
userApi: this.userApi,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# AuditLogAction
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
## Enum
|
|
5
|
+
|
|
6
|
+
* `Invite` (value: `'invite'`)
|
|
7
|
+
|
|
8
|
+
* `Create` (value: `'create'`)
|
|
9
|
+
|
|
10
|
+
* `Update` (value: `'update'`)
|
|
11
|
+
|
|
12
|
+
* `Delete` (value: `'delete'`)
|
|
13
|
+
|
|
14
|
+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# AuditLogEntity
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
## Enum
|
|
5
|
+
|
|
6
|
+
* `CompanyControls` (value: `'company_controls'`)
|
|
7
|
+
|
|
8
|
+
* `Evidences` (value: `'evidences'`)
|
|
9
|
+
|
|
10
|
+
* `Policies` (value: `'policies'`)
|
|
11
|
+
|
|
12
|
+
* `Reports` (value: `'reports'`)
|
|
13
|
+
|
|
14
|
+
* `Companies` (value: `'companies'`)
|
|
15
|
+
|
|
16
|
+
* `Users` (value: `'users'`)
|
|
17
|
+
|
|
18
|
+
* `Tasks` (value: `'tasks'`)
|
|
19
|
+
|
|
20
|
+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# AuditLogResponse
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
## Properties
|
|
5
|
+
|
|
6
|
+
Name | Type | Description | Notes
|
|
7
|
+
------------ | ------------- | ------------- | -------------
|
|
8
|
+
**company_id** | **string** | | [default to undefined]
|
|
9
|
+
**action** | [**AuditLogAction**](AuditLogAction.md) | | [default to undefined]
|
|
10
|
+
**entity_type** | [**AuditLogEntity**](AuditLogEntity.md) | | [default to undefined]
|
|
11
|
+
**entity_id** | **string** | | [default to undefined]
|
|
12
|
+
**entity_name** | **string** | | [default to undefined]
|
|
13
|
+
**timestamp** | **string** | | [default to undefined]
|
|
14
|
+
**details** | **{ [key: string]: any; }** | | [default to undefined]
|
|
15
|
+
|
|
16
|
+
## Example
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
import { AuditLogResponse } from './api';
|
|
20
|
+
|
|
21
|
+
const instance: AuditLogResponse = {
|
|
22
|
+
company_id,
|
|
23
|
+
action,
|
|
24
|
+
entity_type,
|
|
25
|
+
entity_id,
|
|
26
|
+
entity_name,
|
|
27
|
+
timestamp,
|
|
28
|
+
details,
|
|
29
|
+
};
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# AuditLogsApi
|
|
2
|
+
|
|
3
|
+
All URIs are relative to *http://localhost*
|
|
4
|
+
|
|
5
|
+
|Method | HTTP request | Description|
|
|
6
|
+
|------------- | ------------- | -------------|
|
|
7
|
+
|[**listAuditLogsV1AuditLogsListGet**](#listauditlogsv1auditlogslistget) | **GET** /v1/audit-logs/list | List Audit Logs|
|
|
8
|
+
|
|
9
|
+
# **listAuditLogsV1AuditLogsListGet**
|
|
10
|
+
> Array<AuditLogResponse> listAuditLogsV1AuditLogsListGet()
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Example
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import {
|
|
17
|
+
AuditLogsApi,
|
|
18
|
+
Configuration
|
|
19
|
+
} from './api';
|
|
20
|
+
|
|
21
|
+
const configuration = new Configuration();
|
|
22
|
+
const apiInstance = new AuditLogsApi(configuration);
|
|
23
|
+
|
|
24
|
+
let companyId: string; // (default to undefined)
|
|
25
|
+
let page: number; // (default to undefined)
|
|
26
|
+
let elements: number; // (default to undefined)
|
|
27
|
+
let entityType: AuditLogEntity; // (optional) (default to undefined)
|
|
28
|
+
let action: AuditLogAction; // (optional) (default to undefined)
|
|
29
|
+
let startDate: string; // (optional) (default to undefined)
|
|
30
|
+
let endDate: string; // (optional) (default to undefined)
|
|
31
|
+
let authorization: string; // (optional) (default to undefined)
|
|
32
|
+
let sessionId: string; // (optional) (default to undefined)
|
|
33
|
+
|
|
34
|
+
const { status, data } = await apiInstance.listAuditLogsV1AuditLogsListGet(
|
|
35
|
+
companyId,
|
|
36
|
+
page,
|
|
37
|
+
elements,
|
|
38
|
+
entityType,
|
|
39
|
+
action,
|
|
40
|
+
startDate,
|
|
41
|
+
endDate,
|
|
42
|
+
authorization,
|
|
43
|
+
sessionId
|
|
44
|
+
);
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Parameters
|
|
48
|
+
|
|
49
|
+
|Name | Type | Description | Notes|
|
|
50
|
+
|------------- | ------------- | ------------- | -------------|
|
|
51
|
+
| **companyId** | [**string**] | | defaults to undefined|
|
|
52
|
+
| **page** | [**number**] | | defaults to undefined|
|
|
53
|
+
| **elements** | [**number**] | | defaults to undefined|
|
|
54
|
+
| **entityType** | **AuditLogEntity** | | (optional) defaults to undefined|
|
|
55
|
+
| **action** | **AuditLogAction** | | (optional) defaults to undefined|
|
|
56
|
+
| **startDate** | [**string**] | | (optional) defaults to undefined|
|
|
57
|
+
| **endDate** | [**string**] | | (optional) defaults to undefined|
|
|
58
|
+
| **authorization** | [**string**] | | (optional) defaults to undefined|
|
|
59
|
+
| **sessionId** | [**string**] | | (optional) defaults to undefined|
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
### Return type
|
|
63
|
+
|
|
64
|
+
**Array<AuditLogResponse>**
|
|
65
|
+
|
|
66
|
+
### Authorization
|
|
67
|
+
|
|
68
|
+
No authorization required
|
|
69
|
+
|
|
70
|
+
### HTTP request headers
|
|
71
|
+
|
|
72
|
+
- **Content-Type**: Not defined
|
|
73
|
+
- **Accept**: application/json
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
### HTTP response details
|
|
77
|
+
| Status code | Description | Response headers |
|
|
78
|
+
|-------------|-------------|------------------|
|
|
79
|
+
|**200** | Successful Response | - |
|
|
80
|
+
|**422** | Validation Error | - |
|
|
81
|
+
|
|
82
|
+
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
|
83
|
+
|
package/docs/HealthApi.md
CHANGED
|
@@ -7,6 +7,7 @@ All URIs are relative to *http://localhost*
|
|
|
7
7
|
|[**getDbHealthHealthDbGet**](#getdbhealthhealthdbget) | **GET** /health/db | Get Db Health|
|
|
8
8
|
|[**getHealthHealthGet**](#gethealthhealthget) | **GET** /health | Get Health|
|
|
9
9
|
|[**getListmonkHealthHealthListmonkGet**](#getlistmonkhealthhealthlistmonkget) | **GET** /health/listmonk | Get Listmonk Health|
|
|
10
|
+
|[**getRateLimitHealthHealthRateLimitGet**](#getratelimithealthhealthratelimitget) | **GET** /health/rate_limit | Get Rate Limit Health|
|
|
10
11
|
|[**getRedisHealthHealthRedisGet**](#getredishealthhealthredisget) | **GET** /health/redis | Get Redis Health|
|
|
11
12
|
|
|
12
13
|
# **getDbHealthHealthDbGet**
|
|
@@ -117,6 +118,49 @@ const { status, data } = await apiInstance.getListmonkHealthHealthListmonkGet();
|
|
|
117
118
|
This endpoint does not have any parameters.
|
|
118
119
|
|
|
119
120
|
|
|
121
|
+
### Return type
|
|
122
|
+
|
|
123
|
+
**any**
|
|
124
|
+
|
|
125
|
+
### Authorization
|
|
126
|
+
|
|
127
|
+
No authorization required
|
|
128
|
+
|
|
129
|
+
### HTTP request headers
|
|
130
|
+
|
|
131
|
+
- **Content-Type**: Not defined
|
|
132
|
+
- **Accept**: application/json
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
### HTTP response details
|
|
136
|
+
| Status code | Description | Response headers |
|
|
137
|
+
|-------------|-------------|------------------|
|
|
138
|
+
|**200** | Successful Response | - |
|
|
139
|
+
|
|
140
|
+
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
|
141
|
+
|
|
142
|
+
# **getRateLimitHealthHealthRateLimitGet**
|
|
143
|
+
> any getRateLimitHealthHealthRateLimitGet()
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
### Example
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
import {
|
|
150
|
+
HealthApi,
|
|
151
|
+
Configuration
|
|
152
|
+
} from './api';
|
|
153
|
+
|
|
154
|
+
const configuration = new Configuration();
|
|
155
|
+
const apiInstance = new HealthApi(configuration);
|
|
156
|
+
|
|
157
|
+
const { status, data } = await apiInstance.getRateLimitHealthHealthRateLimitGet();
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Parameters
|
|
161
|
+
This endpoint does not have any parameters.
|
|
162
|
+
|
|
163
|
+
|
|
120
164
|
### Return type
|
|
121
165
|
|
|
122
166
|
**any**
|
package/docs/PaymentsApi.md
CHANGED
|
@@ -4,12 +4,12 @@ All URIs are relative to *http://localhost*
|
|
|
4
4
|
|
|
5
5
|
|Method | HTTP request | Description|
|
|
6
6
|
|------------- | ------------- | -------------|
|
|
7
|
-
|[**
|
|
8
|
-
|[**
|
|
9
|
-
|[**
|
|
7
|
+
|[**getCheckoutSessionV1PaymentsCheckoutGet**](#getcheckoutsessionv1paymentscheckoutget) | **GET** /v1/payments/checkout | Get Checkout Session|
|
|
8
|
+
|[**getCustomerManagementSessionV1PaymentsCustomerManagementGet**](#getcustomermanagementsessionv1paymentscustomermanagementget) | **GET** /v1/payments/customer/management | Get Customer Management Session|
|
|
9
|
+
|[**webhookV1PaymentsWebhookPost**](#webhookv1paymentswebhookpost) | **POST** /v1/payments/webhook | Webhook|
|
|
10
10
|
|
|
11
|
-
# **
|
|
12
|
-
> CheckoutSessionResponse
|
|
11
|
+
# **getCheckoutSessionV1PaymentsCheckoutGet**
|
|
12
|
+
> CheckoutSessionResponse getCheckoutSessionV1PaymentsCheckoutGet()
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
### Example
|
|
@@ -28,7 +28,7 @@ let productId: string; // (default to undefined)
|
|
|
28
28
|
let authorization: string; // (optional) (default to undefined)
|
|
29
29
|
let sessionId: string; // (optional) (default to undefined)
|
|
30
30
|
|
|
31
|
-
const { status, data } = await apiInstance.
|
|
31
|
+
const { status, data } = await apiInstance.getCheckoutSessionV1PaymentsCheckoutGet(
|
|
32
32
|
companyId,
|
|
33
33
|
productId,
|
|
34
34
|
authorization,
|
|
@@ -68,8 +68,8 @@ No authorization required
|
|
|
68
68
|
|
|
69
69
|
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
|
70
70
|
|
|
71
|
-
# **
|
|
72
|
-
>
|
|
71
|
+
# **getCustomerManagementSessionV1PaymentsCustomerManagementGet**
|
|
72
|
+
> ResponseGetCustomerManagementSessionV1PaymentsCustomerManagementGet getCustomerManagementSessionV1PaymentsCustomerManagementGet()
|
|
73
73
|
|
|
74
74
|
|
|
75
75
|
### Example
|
|
@@ -86,7 +86,7 @@ const apiInstance = new PaymentsApi(configuration);
|
|
|
86
86
|
let authorization: string; // (optional) (default to undefined)
|
|
87
87
|
let sessionId: string; // (optional) (default to undefined)
|
|
88
88
|
|
|
89
|
-
const { status, data } = await apiInstance.
|
|
89
|
+
const { status, data } = await apiInstance.getCustomerManagementSessionV1PaymentsCustomerManagementGet(
|
|
90
90
|
authorization,
|
|
91
91
|
sessionId
|
|
92
92
|
);
|
|
@@ -102,7 +102,7 @@ const { status, data } = await apiInstance.getCustomerManagementSessionPaymentsC
|
|
|
102
102
|
|
|
103
103
|
### Return type
|
|
104
104
|
|
|
105
|
-
**
|
|
105
|
+
**ResponseGetCustomerManagementSessionV1PaymentsCustomerManagementGet**
|
|
106
106
|
|
|
107
107
|
### Authorization
|
|
108
108
|
|
|
@@ -122,8 +122,8 @@ No authorization required
|
|
|
122
122
|
|
|
123
123
|
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
|
124
124
|
|
|
125
|
-
# **
|
|
126
|
-
> any
|
|
125
|
+
# **webhookV1PaymentsWebhookPost**
|
|
126
|
+
> any webhookV1PaymentsWebhookPost()
|
|
127
127
|
|
|
128
128
|
|
|
129
129
|
### Example
|
|
@@ -137,7 +137,7 @@ import {
|
|
|
137
137
|
const configuration = new Configuration();
|
|
138
138
|
const apiInstance = new PaymentsApi(configuration);
|
|
139
139
|
|
|
140
|
-
const { status, data } = await apiInstance.
|
|
140
|
+
const { status, data } = await apiInstance.webhookV1PaymentsWebhookPost();
|
|
141
141
|
```
|
|
142
142
|
|
|
143
143
|
### Parameters
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# ResponseGetCustomerManagementSessionV1PaymentsCustomerManagementGet
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
## Properties
|
|
5
|
+
|
|
6
|
+
Name | Type | Description | Notes
|
|
7
|
+
------------ | ------------- | ------------- | -------------
|
|
8
|
+
**link** | **string** | | [default to undefined]
|
|
9
|
+
**message** | **string** | | [optional] [default to 'You don\'t have any active subscriptions']
|
|
10
|
+
|
|
11
|
+
## Example
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { ResponseGetCustomerManagementSessionV1PaymentsCustomerManagementGet } from './api';
|
|
15
|
+
|
|
16
|
+
const instance: ResponseGetCustomerManagementSessionV1PaymentsCustomerManagementGet = {
|
|
17
|
+
link,
|
|
18
|
+
message,
|
|
19
|
+
};
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
package/index.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Lumoar API
|
|
5
5
|
* Compliance as a service
|
|
6
6
|
*
|
|
7
|
-
* The version of the OpenAPI document:
|
|
7
|
+
* The version of the OpenAPI document: 1.0.0
|
|
8
8
|
*
|
|
9
9
|
*
|
|
10
10
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
@@ -15,4 +15,4 @@
|
|
|
15
15
|
|
|
16
16
|
export * from "./api";
|
|
17
17
|
export * from "./configuration";
|
|
18
|
-
|
|
18
|
+
export * from "./sdk";
|
package/package.json
CHANGED
package/sdk.ts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import axios, { AxiosInstance, AxiosResponse } from 'axios';
|
|
2
|
+
import {
|
|
3
|
+
HealthApi,
|
|
4
|
+
AuthApi,
|
|
5
|
+
CompanyApi,
|
|
6
|
+
ControlsApi,
|
|
7
|
+
EvidenceApi,
|
|
8
|
+
PaymentsApi,
|
|
9
|
+
PoliciesApi,
|
|
10
|
+
RolesApi,
|
|
11
|
+
UserApi
|
|
12
|
+
} from './api';
|
|
13
|
+
import { Configuration } from './configuration';
|
|
14
|
+
|
|
15
|
+
export class ApiSDK {
|
|
16
|
+
private helthApi: HealthApi;
|
|
17
|
+
private authApi: AuthApi;
|
|
18
|
+
private companyApi: CompanyApi;
|
|
19
|
+
private controlsApi: ControlsApi;
|
|
20
|
+
private evidenceApi: EvidenceApi;
|
|
21
|
+
private paymentsApi: PaymentsApi;
|
|
22
|
+
private policiesApi: PoliciesApi;
|
|
23
|
+
private rolesApi: RolesApi;
|
|
24
|
+
private userApi: UserApi;
|
|
25
|
+
private token: string | null = null;
|
|
26
|
+
private axiosInstance: AxiosInstance;
|
|
27
|
+
|
|
28
|
+
constructor(basePath?: string) {
|
|
29
|
+
this.axiosInstance = axios.create({
|
|
30
|
+
baseURL: basePath,
|
|
31
|
+
withCredentials: true
|
|
32
|
+
});
|
|
33
|
+
this.setupInterceptors();
|
|
34
|
+
const config = new Configuration({
|
|
35
|
+
basePath,
|
|
36
|
+
apiKey: () => this.getAuthHeader(),
|
|
37
|
+
baseOptions: {
|
|
38
|
+
axios: this.axiosInstance
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
this.helthApi = new HealthApi(config, undefined, this.axiosInstance);
|
|
43
|
+
this.authApi = new AuthApi(config, undefined, this.axiosInstance);
|
|
44
|
+
this.companyApi = new CompanyApi(config, undefined, this.axiosInstance);
|
|
45
|
+
this.controlsApi = new ControlsApi(config, undefined, this.axiosInstance);
|
|
46
|
+
this.evidenceApi = new EvidenceApi(config, undefined, this.axiosInstance);
|
|
47
|
+
this.paymentsApi = new PaymentsApi(config, undefined, this.axiosInstance);
|
|
48
|
+
this.policiesApi = new PoliciesApi(config, undefined, this.axiosInstance);
|
|
49
|
+
this.rolesApi = new RolesApi(config, undefined, this.axiosInstance);
|
|
50
|
+
this.userApi = new UserApi(config, undefined, this.axiosInstance);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
public setToken(newToken: string) {
|
|
54
|
+
this.token = newToken;
|
|
55
|
+
}
|
|
56
|
+
private getAuthHeader(): string {
|
|
57
|
+
if (!this.token) {
|
|
58
|
+
throw new Error('No token set. Call setToken() first.');
|
|
59
|
+
}
|
|
60
|
+
return `Bearer ${this.token}`;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
private setupInterceptors() {
|
|
64
|
+
this.axiosInstance.interceptors.request.use((config) => {
|
|
65
|
+
if (this.token) {
|
|
66
|
+
config.headers['Authorization'] = this.getAuthHeader();
|
|
67
|
+
}
|
|
68
|
+
return config;
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
this.axiosInstance.interceptors.response.use((response: AxiosResponse) => {
|
|
72
|
+
const newToken = response.data.newToken || response.headers['Authorization'];
|
|
73
|
+
if (newToken) {
|
|
74
|
+
this.setToken(newToken.replace('Bearer ', ''));
|
|
75
|
+
console.log('Token automatically updated via backend refresh');
|
|
76
|
+
}
|
|
77
|
+
return response;
|
|
78
|
+
}, (error) => {
|
|
79
|
+
if (error.response?.status === 401) {
|
|
80
|
+
console.error('Authentication failed - session expired');
|
|
81
|
+
}
|
|
82
|
+
return Promise.reject(error);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
public getApi() {
|
|
86
|
+
return {
|
|
87
|
+
helthApi: this.helthApi,
|
|
88
|
+
authApi: this.authApi,
|
|
89
|
+
companyApi: this.companyApi,
|
|
90
|
+
controlsApi: this.controlsApi,
|
|
91
|
+
evidenceApi: this.evidenceApi,
|
|
92
|
+
paymentsApi: this.paymentsApi,
|
|
93
|
+
policiesApi: this.policiesApi,
|
|
94
|
+
rolesApi: this.rolesApi,
|
|
95
|
+
userApi: this.userApi,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
}
|