@rasadov/lumoar-sdk 1.0.1 → 1.0.3

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/base.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: 0.1.0
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).
package/common.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: 0.1.0
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).
package/configuration.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: 0.1.0
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).
@@ -14,16 +14,16 @@
14
14
 
15
15
  import axios, { AxiosInstance, AxiosResponse } from 'axios';
16
16
  import {
17
- DefaultApi,
18
- AuthApi,
19
- CompanyApi,
20
- ControlsApi,
21
- EvidenceApi,
22
- PaymentsApi,
23
- PoliciesApi,
24
- RolesApi,
25
- UserApi
26
- } from './api';
17
+ HealthApi,
18
+ AuthApi,
19
+ CompanyApi,
20
+ ControlsApi,
21
+ EvidenceApi,
22
+ PaymentsApi,
23
+ PoliciesApi,
24
+ RolesApi,
25
+ UserApi
26
+ } from './api';
27
27
 
28
28
 
29
29
  export interface ConfigurationParameters {
@@ -128,101 +128,88 @@ export class Configuration {
128
128
  }
129
129
 
130
130
 
131
+
131
132
  export class ApiSDK {
132
- private defaultApi: DefaultApi;
133
- private authApi: AuthApi;
134
- private companyApi: CompanyApi;
135
- private controlsApi: ControlsApi;
136
- private evidenceApi: EvidenceApi;
137
- private paymentsApi: PaymentsApi;
138
- private policiesApi: PoliciesApi;
139
- private rolesApi: RolesApi;
140
- private userApi: UserApi;
141
- private token: string | null = null;
142
- private axiosInstance: AxiosInstance;
133
+ private helthApi: HealthApi;
134
+ private authApi: AuthApi;
135
+ private companyApi: CompanyApi;
136
+ private controlsApi: ControlsApi;
137
+ private evidenceApi: EvidenceApi;
138
+ private paymentsApi: PaymentsApi;
139
+ private policiesApi: PoliciesApi;
140
+ private rolesApi: RolesApi;
141
+ private userApi: UserApi;
142
+ private token: string | null = null;
143
+ private axiosInstance: AxiosInstance;
143
144
 
144
- constructor(basePath?: string) {
145
- this.axiosInstance = axios.create({
146
- baseURL: basePath,
147
- withCredentials: true // Include cookies (e.g., session_id) in requests
148
- });
149
- this.setupInterceptors();
150
- const config = new Configuration({
151
- basePath,
152
- apiKey: () => this.getAuthHeader(),
153
- baseOptions: {
154
- axios: this.axiosInstance // Ensure generated API uses this instance
155
- },
156
- });
157
-
158
- // Create instances of all API classes
159
- this.defaultApi = new DefaultApi(config, undefined, this.axiosInstance);
160
- this.authApi = new AuthApi(config, undefined, this.axiosInstance);
161
- this.companyApi = new CompanyApi(config, undefined, this.axiosInstance);
162
- this.controlsApi = new ControlsApi(config, undefined, this.axiosInstance);
163
- this.evidenceApi = new EvidenceApi(config, undefined, this.axiosInstance);
164
- this.paymentsApi = new PaymentsApi(config, undefined, this.axiosInstance);
165
- this.policiesApi = new PoliciesApi(config, undefined, this.axiosInstance);
166
- this.rolesApi = new RolesApi(config, undefined, this.axiosInstance);
167
- this.userApi = new UserApi(config, undefined, this.axiosInstance);
168
- }
145
+ constructor(basePath?: string) {
146
+ this.axiosInstance = axios.create({
147
+ baseURL: basePath,
148
+ withCredentials: true
149
+ });
150
+ this.setupInterceptors();
151
+ const config = new Configuration({
152
+ basePath,
153
+ apiKey: () => this.getAuthHeader(),
154
+ baseOptions: {
155
+ axios: this.axiosInstance
156
+ },
157
+ });
158
+
159
+ this.helthApi = new HealthApi(config, undefined, this.axiosInstance);
160
+ this.authApi = new AuthApi(config, undefined, this.axiosInstance);
161
+ this.companyApi = new CompanyApi(config, undefined, this.axiosInstance);
162
+ this.controlsApi = new ControlsApi(config, undefined, this.axiosInstance);
163
+ this.evidenceApi = new EvidenceApi(config, undefined, this.axiosInstance);
164
+ this.paymentsApi = new PaymentsApi(config, undefined, this.axiosInstance);
165
+ this.policiesApi = new PoliciesApi(config, undefined, this.axiosInstance);
166
+ this.rolesApi = new RolesApi(config, undefined, this.axiosInstance);
167
+ this.userApi = new UserApi(config, undefined, this.axiosInstance);
168
+ }
169
169
 
170
- // Set or update token
171
- public setToken(newToken: string) {
172
- this.token = newToken;
170
+ public setToken(newToken: string) {
171
+ this.token = newToken;
172
+ }
173
+ private getAuthHeader(): string {
174
+ if (!this.token) {
175
+ throw new Error('No token set. Call setToken() first.');
173
176
  }
174
-
175
- // Get auth header
176
- private getAuthHeader(): string {
177
- if (!this.token) {
178
- throw new Error('No token set. Call setToken() first.');
177
+ return `Bearer ${this.token}`;
178
+ }
179
+
180
+ private setupInterceptors() {
181
+ this.axiosInstance.interceptors.request.use((config) => {
182
+ if (this.token) {
183
+ config.headers['Authorization'] = this.getAuthHeader();
179
184
  }
180
- return `Bearer ${this.token}`;
181
- }
185
+ return config;
186
+ });
182
187
 
183
- // Setup interceptors for requests and responses
184
- private setupInterceptors() {
185
- // Request interceptor: Always set latest token
186
- this.axiosInstance.interceptors.request.use((config) => {
187
- if (this.token) {
188
- config.headers['Authorization'] = this.getAuthHeader();
189
- }
190
- return config;
191
- });
192
-
193
- this.axiosInstance.interceptors.response.use((response: AxiosResponse) => {
194
- const newToken = response.data.newToken || response.headers['Authorization'];
195
- if (newToken) {
196
- this.setToken(newToken.replace('Bearer ', ''));
197
- console.log('Token automatically updated via backend refresh');
198
- }
199
- return response;
200
- }, (error) => {
201
- if (error.response?.status === 401) {
202
- console.error('Authentication failed - session expired');
203
- // TODO: emit event or callback to app for login redirect
204
- }
205
- return Promise.reject(error);
206
- });
207
- }
208
-
209
- // Expose API methods (proxies the generated API)
210
- public getApi() {
211
- return {
212
- defaultApi: this.defaultApi,
213
- authApi: this.authApi,
214
- companyApi: this.companyApi,
215
- controlsApi: this.controlsApi,
216
- evidenceApi: this.evidenceApi,
217
- paymentsApi: this.paymentsApi,
218
- policiesApi: this.policiesApi,
219
- rolesApi: this.rolesApi,
220
- userApi: this.userApi,
221
- // Legacy support - keep the old health check methods accessible
222
- getRedisHealthHealthRedisGet: () => this.defaultApi.getRedisHealthHealthRedisGet(),
223
- getHealthHealthGet: () => this.defaultApi.getHealthHealthGet(),
224
- getDbHealthHealthDbGet: () => this.defaultApi.getDbHealthHealthDbGet(),
225
- getListmonkHealthHealthListmonkGet: () => this.defaultApi.getListmonkHealthHealthListmonkGet(),
226
- };
227
- }
228
- }
188
+ this.axiosInstance.interceptors.response.use((response: AxiosResponse) => {
189
+ const newToken = response.data.newToken || response.headers['Authorization'];
190
+ if (newToken) {
191
+ this.setToken(newToken.replace('Bearer ', ''));
192
+ console.log('Token automatically updated via backend refresh');
193
+ }
194
+ return response;
195
+ }, (error) => {
196
+ if (error.response?.status === 401) {
197
+ console.error('Authentication failed - session expired');
198
+ }
199
+ return Promise.reject(error);
200
+ });
201
+ }
202
+ public getApi() {
203
+ return {
204
+ helthApi: this.helthApi,
205
+ authApi: this.authApi,
206
+ companyApi: this.companyApi,
207
+ controlsApi: this.controlsApi,
208
+ evidenceApi: this.evidenceApi,
209
+ paymentsApi: this.paymentsApi,
210
+ policiesApi: this.policiesApi,
211
+ rolesApi: this.rolesApi,
212
+ userApi: this.userApi,
213
+ };
214
+ }
215
+ }