@rasadov/lumoar-sdk 1.0.3 → 1.0.5

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.
@@ -4,6 +4,10 @@ api.ts
4
4
  base.ts
5
5
  common.ts
6
6
  configuration.ts
7
+ docs/AuditLogAction.md
8
+ docs/AuditLogEntity.md
9
+ docs/AuditLogResponse.md
10
+ docs/AuditLogsApi.md
7
11
  docs/AuthApi.md
8
12
  docs/AuthenticationSuccess.md
9
13
  docs/CheckoutSessionResponse.md
package/api.ts CHANGED
@@ -23,6 +23,92 @@ import type { RequestArgs } from './base';
23
23
  // @ts-ignore
24
24
  import { BASE_PATH, COLLECTION_FORMATS, BaseAPI, RequiredError, operationServerMap } from './base';
25
25
 
26
+ /**
27
+ *
28
+ * @export
29
+ * @enum {string}
30
+ */
31
+
32
+ export const AuditLogAction = {
33
+ Invite: 'invite',
34
+ Create: 'create',
35
+ Update: 'update',
36
+ Delete: 'delete'
37
+ } as const;
38
+
39
+ export type AuditLogAction = typeof AuditLogAction[keyof typeof AuditLogAction];
40
+
41
+
42
+ /**
43
+ *
44
+ * @export
45
+ * @enum {string}
46
+ */
47
+
48
+ export const AuditLogEntity = {
49
+ CompanyControls: 'company_controls',
50
+ Evidences: 'evidences',
51
+ Policies: 'policies',
52
+ Reports: 'reports',
53
+ Companies: 'companies',
54
+ Users: 'users',
55
+ Tasks: 'tasks'
56
+ } as const;
57
+
58
+ export type AuditLogEntity = typeof AuditLogEntity[keyof typeof AuditLogEntity];
59
+
60
+
61
+ /**
62
+ *
63
+ * @export
64
+ * @interface AuditLogResponse
65
+ */
66
+ export interface AuditLogResponse {
67
+ /**
68
+ *
69
+ * @type {string}
70
+ * @memberof AuditLogResponse
71
+ */
72
+ 'company_id': string;
73
+ /**
74
+ *
75
+ * @type {AuditLogAction}
76
+ * @memberof AuditLogResponse
77
+ */
78
+ 'action': AuditLogAction;
79
+ /**
80
+ *
81
+ * @type {AuditLogEntity}
82
+ * @memberof AuditLogResponse
83
+ */
84
+ 'entity_type': AuditLogEntity;
85
+ /**
86
+ *
87
+ * @type {string}
88
+ * @memberof AuditLogResponse
89
+ */
90
+ 'entity_id': string;
91
+ /**
92
+ *
93
+ * @type {string}
94
+ * @memberof AuditLogResponse
95
+ */
96
+ 'entity_name': string;
97
+ /**
98
+ *
99
+ * @type {string}
100
+ * @memberof AuditLogResponse
101
+ */
102
+ 'timestamp': string;
103
+ /**
104
+ *
105
+ * @type {{ [key: string]: any; }}
106
+ * @memberof AuditLogResponse
107
+ */
108
+ 'details': { [key: string]: any; } | null;
109
+ }
110
+
111
+
26
112
  /**
27
113
  * Authentication success response schema. Attributes: - access_token: str - token_type: str - user_id: str - role: str
28
114
  * @export
@@ -1465,6 +1551,184 @@ export interface ValidationError {
1465
1551
  export interface ValidationErrorLocInner {
1466
1552
  }
1467
1553
 
1554
+ /**
1555
+ * AuditLogsApi - axios parameter creator
1556
+ * @export
1557
+ */
1558
+ export const AuditLogsApiAxiosParamCreator = function (configuration?: Configuration) {
1559
+ return {
1560
+ /**
1561
+ *
1562
+ * @summary List Audit Logs
1563
+ * @param {string} companyId
1564
+ * @param {number} page
1565
+ * @param {number} elements
1566
+ * @param {AuditLogEntity | null} [entityType]
1567
+ * @param {AuditLogAction | null} [action]
1568
+ * @param {string | null} [startDate]
1569
+ * @param {string | null} [endDate]
1570
+ * @param {string} [authorization]
1571
+ * @param {string} [sessionId]
1572
+ * @param {*} [options] Override http request option.
1573
+ * @throws {RequiredError}
1574
+ */
1575
+ listAuditLogsV1AuditLogsListGet: async (companyId: string, page: number, elements: number, entityType?: AuditLogEntity | null, action?: AuditLogAction | null, startDate?: string | null, endDate?: string | null, authorization?: string, sessionId?: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
1576
+ // verify required parameter 'companyId' is not null or undefined
1577
+ assertParamExists('listAuditLogsV1AuditLogsListGet', 'companyId', companyId)
1578
+ // verify required parameter 'page' is not null or undefined
1579
+ assertParamExists('listAuditLogsV1AuditLogsListGet', 'page', page)
1580
+ // verify required parameter 'elements' is not null or undefined
1581
+ assertParamExists('listAuditLogsV1AuditLogsListGet', 'elements', elements)
1582
+ const localVarPath = `/v1/audit-logs/list`;
1583
+ // use dummy base URL string because the URL constructor only accepts absolute URLs.
1584
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
1585
+ let baseOptions;
1586
+ if (configuration) {
1587
+ baseOptions = configuration.baseOptions;
1588
+ }
1589
+
1590
+ const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
1591
+ const localVarHeaderParameter = {} as any;
1592
+ const localVarQueryParameter = {} as any;
1593
+
1594
+ if (companyId !== undefined) {
1595
+ localVarQueryParameter['company_id'] = companyId;
1596
+ }
1597
+
1598
+ if (page !== undefined) {
1599
+ localVarQueryParameter['page'] = page;
1600
+ }
1601
+
1602
+ if (elements !== undefined) {
1603
+ localVarQueryParameter['elements'] = elements;
1604
+ }
1605
+
1606
+ if (entityType !== undefined) {
1607
+ localVarQueryParameter['entity_type'] = entityType;
1608
+ }
1609
+
1610
+ if (action !== undefined) {
1611
+ localVarQueryParameter['action'] = action;
1612
+ }
1613
+
1614
+ if (startDate !== undefined) {
1615
+ localVarQueryParameter['start_date'] = (startDate as any instanceof Date) ?
1616
+ (startDate as any).toISOString() :
1617
+ startDate;
1618
+ }
1619
+
1620
+ if (endDate !== undefined) {
1621
+ localVarQueryParameter['end_date'] = (endDate as any instanceof Date) ?
1622
+ (endDate as any).toISOString() :
1623
+ endDate;
1624
+ }
1625
+
1626
+
1627
+
1628
+ if (authorization != null) {
1629
+ localVarHeaderParameter['Authorization'] = String(authorization);
1630
+ }
1631
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
1632
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
1633
+ localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
1634
+
1635
+ return {
1636
+ url: toPathString(localVarUrlObj),
1637
+ options: localVarRequestOptions,
1638
+ };
1639
+ },
1640
+ }
1641
+ };
1642
+
1643
+ /**
1644
+ * AuditLogsApi - functional programming interface
1645
+ * @export
1646
+ */
1647
+ export const AuditLogsApiFp = function(configuration?: Configuration) {
1648
+ const localVarAxiosParamCreator = AuditLogsApiAxiosParamCreator(configuration)
1649
+ return {
1650
+ /**
1651
+ *
1652
+ * @summary List Audit Logs
1653
+ * @param {string} companyId
1654
+ * @param {number} page
1655
+ * @param {number} elements
1656
+ * @param {AuditLogEntity | null} [entityType]
1657
+ * @param {AuditLogAction | null} [action]
1658
+ * @param {string | null} [startDate]
1659
+ * @param {string | null} [endDate]
1660
+ * @param {string} [authorization]
1661
+ * @param {string} [sessionId]
1662
+ * @param {*} [options] Override http request option.
1663
+ * @throws {RequiredError}
1664
+ */
1665
+ async listAuditLogsV1AuditLogsListGet(companyId: string, page: number, elements: number, entityType?: AuditLogEntity | null, action?: AuditLogAction | null, startDate?: string | null, endDate?: string | null, authorization?: string, sessionId?: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<AuditLogResponse>>> {
1666
+ const localVarAxiosArgs = await localVarAxiosParamCreator.listAuditLogsV1AuditLogsListGet(companyId, page, elements, entityType, action, startDate, endDate, authorization, sessionId, options);
1667
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
1668
+ const localVarOperationServerBasePath = operationServerMap['AuditLogsApi.listAuditLogsV1AuditLogsListGet']?.[localVarOperationServerIndex]?.url;
1669
+ return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
1670
+ },
1671
+ }
1672
+ };
1673
+
1674
+ /**
1675
+ * AuditLogsApi - factory interface
1676
+ * @export
1677
+ */
1678
+ export const AuditLogsApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
1679
+ const localVarFp = AuditLogsApiFp(configuration)
1680
+ return {
1681
+ /**
1682
+ *
1683
+ * @summary List Audit Logs
1684
+ * @param {string} companyId
1685
+ * @param {number} page
1686
+ * @param {number} elements
1687
+ * @param {AuditLogEntity | null} [entityType]
1688
+ * @param {AuditLogAction | null} [action]
1689
+ * @param {string | null} [startDate]
1690
+ * @param {string | null} [endDate]
1691
+ * @param {string} [authorization]
1692
+ * @param {string} [sessionId]
1693
+ * @param {*} [options] Override http request option.
1694
+ * @throws {RequiredError}
1695
+ */
1696
+ listAuditLogsV1AuditLogsListGet(companyId: string, page: number, elements: number, entityType?: AuditLogEntity | null, action?: AuditLogAction | null, startDate?: string | null, endDate?: string | null, authorization?: string, sessionId?: string, options?: RawAxiosRequestConfig): AxiosPromise<Array<AuditLogResponse>> {
1697
+ return localVarFp.listAuditLogsV1AuditLogsListGet(companyId, page, elements, entityType, action, startDate, endDate, authorization, sessionId, options).then((request) => request(axios, basePath));
1698
+ },
1699
+ };
1700
+ };
1701
+
1702
+ /**
1703
+ * AuditLogsApi - object-oriented interface
1704
+ * @export
1705
+ * @class AuditLogsApi
1706
+ * @extends {BaseAPI}
1707
+ */
1708
+ export class AuditLogsApi extends BaseAPI {
1709
+ /**
1710
+ *
1711
+ * @summary List Audit Logs
1712
+ * @param {string} companyId
1713
+ * @param {number} page
1714
+ * @param {number} elements
1715
+ * @param {AuditLogEntity | null} [entityType]
1716
+ * @param {AuditLogAction | null} [action]
1717
+ * @param {string | null} [startDate]
1718
+ * @param {string | null} [endDate]
1719
+ * @param {string} [authorization]
1720
+ * @param {string} [sessionId]
1721
+ * @param {*} [options] Override http request option.
1722
+ * @throws {RequiredError}
1723
+ * @memberof AuditLogsApi
1724
+ */
1725
+ public listAuditLogsV1AuditLogsListGet(companyId: string, page: number, elements: number, entityType?: AuditLogEntity | null, action?: AuditLogAction | null, startDate?: string | null, endDate?: string | null, authorization?: string, sessionId?: string, options?: RawAxiosRequestConfig) {
1726
+ return AuditLogsApiFp(this.configuration).listAuditLogsV1AuditLogsListGet(companyId, page, elements, entityType, action, startDate, endDate, authorization, sessionId, options).then((request) => request(this.axios, this.basePath));
1727
+ }
1728
+ }
1729
+
1730
+
1731
+
1468
1732
  /**
1469
1733
  * AuthApi - axios parameter creator
1470
1734
  * @export
package/configuration.ts CHANGED
@@ -12,19 +12,6 @@
12
12
  * Do not edit the class manually.
13
13
  */
14
14
 
15
- import axios, { AxiosInstance, AxiosResponse } from 'axios';
16
- import {
17
- HealthApi,
18
- AuthApi,
19
- CompanyApi,
20
- ControlsApi,
21
- EvidenceApi,
22
- PaymentsApi,
23
- PoliciesApi,
24
- RolesApi,
25
- UserApi
26
- } from './api';
27
-
28
15
 
29
16
  export interface ConfigurationParameters {
30
17
  apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
@@ -126,90 +113,3 @@ export class Configuration {
126
113
  return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
127
114
  }
128
115
  }
129
-
130
-
131
-
132
- export class ApiSDK {
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;
144
-
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
-
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.');
176
- }
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();
184
- }
185
- return config;
186
- });
187
-
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
- }
package/dist/api.d.ts CHANGED
@@ -13,6 +13,84 @@ import type { Configuration } from './configuration';
13
13
  import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios';
14
14
  import type { RequestArgs } from './base';
15
15
  import { BaseAPI } from './base';
16
+ /**
17
+ *
18
+ * @export
19
+ * @enum {string}
20
+ */
21
+ export declare const AuditLogAction: {
22
+ readonly Invite: "invite";
23
+ readonly Create: "create";
24
+ readonly Update: "update";
25
+ readonly Delete: "delete";
26
+ };
27
+ export type AuditLogAction = typeof AuditLogAction[keyof typeof AuditLogAction];
28
+ /**
29
+ *
30
+ * @export
31
+ * @enum {string}
32
+ */
33
+ export declare const AuditLogEntity: {
34
+ readonly CompanyControls: "company_controls";
35
+ readonly Evidences: "evidences";
36
+ readonly Policies: "policies";
37
+ readonly Reports: "reports";
38
+ readonly Companies: "companies";
39
+ readonly Users: "users";
40
+ readonly Tasks: "tasks";
41
+ };
42
+ export type AuditLogEntity = typeof AuditLogEntity[keyof typeof AuditLogEntity];
43
+ /**
44
+ *
45
+ * @export
46
+ * @interface AuditLogResponse
47
+ */
48
+ export interface AuditLogResponse {
49
+ /**
50
+ *
51
+ * @type {string}
52
+ * @memberof AuditLogResponse
53
+ */
54
+ 'company_id': string;
55
+ /**
56
+ *
57
+ * @type {AuditLogAction}
58
+ * @memberof AuditLogResponse
59
+ */
60
+ 'action': AuditLogAction;
61
+ /**
62
+ *
63
+ * @type {AuditLogEntity}
64
+ * @memberof AuditLogResponse
65
+ */
66
+ 'entity_type': AuditLogEntity;
67
+ /**
68
+ *
69
+ * @type {string}
70
+ * @memberof AuditLogResponse
71
+ */
72
+ 'entity_id': string;
73
+ /**
74
+ *
75
+ * @type {string}
76
+ * @memberof AuditLogResponse
77
+ */
78
+ 'entity_name': string;
79
+ /**
80
+ *
81
+ * @type {string}
82
+ * @memberof AuditLogResponse
83
+ */
84
+ 'timestamp': string;
85
+ /**
86
+ *
87
+ * @type {{ [key: string]: any; }}
88
+ * @memberof AuditLogResponse
89
+ */
90
+ 'details': {
91
+ [key: string]: any;
92
+ } | null;
93
+ }
16
94
  /**
17
95
  * Authentication success response schema. Attributes: - access_token: str - token_type: str - user_id: str - role: str
18
96
  * @export
@@ -1444,6 +1522,97 @@ export interface ValidationError {
1444
1522
  */
1445
1523
  export interface ValidationErrorLocInner {
1446
1524
  }
1525
+ /**
1526
+ * AuditLogsApi - axios parameter creator
1527
+ * @export
1528
+ */
1529
+ export declare const AuditLogsApiAxiosParamCreator: (configuration?: Configuration) => {
1530
+ /**
1531
+ *
1532
+ * @summary List Audit Logs
1533
+ * @param {string} companyId
1534
+ * @param {number} page
1535
+ * @param {number} elements
1536
+ * @param {AuditLogEntity | null} [entityType]
1537
+ * @param {AuditLogAction | null} [action]
1538
+ * @param {string | null} [startDate]
1539
+ * @param {string | null} [endDate]
1540
+ * @param {string} [authorization]
1541
+ * @param {string} [sessionId]
1542
+ * @param {*} [options] Override http request option.
1543
+ * @throws {RequiredError}
1544
+ */
1545
+ listAuditLogsV1AuditLogsListGet: (companyId: string, page: number, elements: number, entityType?: AuditLogEntity | null, action?: AuditLogAction | null, startDate?: string | null, endDate?: string | null, authorization?: string, sessionId?: string, options?: RawAxiosRequestConfig) => Promise<RequestArgs>;
1546
+ };
1547
+ /**
1548
+ * AuditLogsApi - functional programming interface
1549
+ * @export
1550
+ */
1551
+ export declare const AuditLogsApiFp: (configuration?: Configuration) => {
1552
+ /**
1553
+ *
1554
+ * @summary List Audit Logs
1555
+ * @param {string} companyId
1556
+ * @param {number} page
1557
+ * @param {number} elements
1558
+ * @param {AuditLogEntity | null} [entityType]
1559
+ * @param {AuditLogAction | null} [action]
1560
+ * @param {string | null} [startDate]
1561
+ * @param {string | null} [endDate]
1562
+ * @param {string} [authorization]
1563
+ * @param {string} [sessionId]
1564
+ * @param {*} [options] Override http request option.
1565
+ * @throws {RequiredError}
1566
+ */
1567
+ listAuditLogsV1AuditLogsListGet(companyId: string, page: number, elements: number, entityType?: AuditLogEntity | null, action?: AuditLogAction | null, startDate?: string | null, endDate?: string | null, authorization?: string, sessionId?: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<AuditLogResponse>>>;
1568
+ };
1569
+ /**
1570
+ * AuditLogsApi - factory interface
1571
+ * @export
1572
+ */
1573
+ export declare const AuditLogsApiFactory: (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) => {
1574
+ /**
1575
+ *
1576
+ * @summary List Audit Logs
1577
+ * @param {string} companyId
1578
+ * @param {number} page
1579
+ * @param {number} elements
1580
+ * @param {AuditLogEntity | null} [entityType]
1581
+ * @param {AuditLogAction | null} [action]
1582
+ * @param {string | null} [startDate]
1583
+ * @param {string | null} [endDate]
1584
+ * @param {string} [authorization]
1585
+ * @param {string} [sessionId]
1586
+ * @param {*} [options] Override http request option.
1587
+ * @throws {RequiredError}
1588
+ */
1589
+ listAuditLogsV1AuditLogsListGet(companyId: string, page: number, elements: number, entityType?: AuditLogEntity | null, action?: AuditLogAction | null, startDate?: string | null, endDate?: string | null, authorization?: string, sessionId?: string, options?: RawAxiosRequestConfig): AxiosPromise<Array<AuditLogResponse>>;
1590
+ };
1591
+ /**
1592
+ * AuditLogsApi - object-oriented interface
1593
+ * @export
1594
+ * @class AuditLogsApi
1595
+ * @extends {BaseAPI}
1596
+ */
1597
+ export declare class AuditLogsApi extends BaseAPI {
1598
+ /**
1599
+ *
1600
+ * @summary List Audit Logs
1601
+ * @param {string} companyId
1602
+ * @param {number} page
1603
+ * @param {number} elements
1604
+ * @param {AuditLogEntity | null} [entityType]
1605
+ * @param {AuditLogAction | null} [action]
1606
+ * @param {string | null} [startDate]
1607
+ * @param {string | null} [endDate]
1608
+ * @param {string} [authorization]
1609
+ * @param {string} [sessionId]
1610
+ * @param {*} [options] Override http request option.
1611
+ * @throws {RequiredError}
1612
+ * @memberof AuditLogsApi
1613
+ */
1614
+ listAuditLogsV1AuditLogsListGet(companyId: string, page: number, elements: number, entityType?: AuditLogEntity | null, action?: AuditLogAction | null, startDate?: string | null, endDate?: string | null, authorization?: string, sessionId?: string, options?: RawAxiosRequestConfig): Promise<import("axios").AxiosResponse<AuditLogResponse[], any, {}>>;
1615
+ }
1447
1616
  /**
1448
1617
  * AuthApi - axios parameter creator
1449
1618
  * @export
package/dist/api.js CHANGED
@@ -26,6 +26,31 @@ import globalAxios from 'axios';
26
26
  import { DUMMY_BASE_URL, assertParamExists, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from './common';
27
27
  // @ts-ignore
28
28
  import { BASE_PATH, BaseAPI, operationServerMap } from './base';
29
+ /**
30
+ *
31
+ * @export
32
+ * @enum {string}
33
+ */
34
+ export const AuditLogAction = {
35
+ Invite: 'invite',
36
+ Create: 'create',
37
+ Update: 'update',
38
+ Delete: 'delete'
39
+ };
40
+ /**
41
+ *
42
+ * @export
43
+ * @enum {string}
44
+ */
45
+ export const AuditLogEntity = {
46
+ CompanyControls: 'company_controls',
47
+ Evidences: 'evidences',
48
+ Policies: 'policies',
49
+ Reports: 'reports',
50
+ Companies: 'companies',
51
+ Users: 'users',
52
+ Tasks: 'tasks'
53
+ };
29
54
  /**
30
55
  *
31
56
  * @export
@@ -58,6 +83,169 @@ export const PermissionType = {
58
83
  Member: 'member',
59
84
  Auditor: 'auditor'
60
85
  };
86
+ /**
87
+ * AuditLogsApi - axios parameter creator
88
+ * @export
89
+ */
90
+ export const AuditLogsApiAxiosParamCreator = function (configuration) {
91
+ return {
92
+ /**
93
+ *
94
+ * @summary List Audit Logs
95
+ * @param {string} companyId
96
+ * @param {number} page
97
+ * @param {number} elements
98
+ * @param {AuditLogEntity | null} [entityType]
99
+ * @param {AuditLogAction | null} [action]
100
+ * @param {string | null} [startDate]
101
+ * @param {string | null} [endDate]
102
+ * @param {string} [authorization]
103
+ * @param {string} [sessionId]
104
+ * @param {*} [options] Override http request option.
105
+ * @throws {RequiredError}
106
+ */
107
+ listAuditLogsV1AuditLogsListGet: (companyId_1, page_1, elements_1, entityType_1, action_1, startDate_1, endDate_1, authorization_1, sessionId_1, ...args_1) => __awaiter(this, [companyId_1, page_1, elements_1, entityType_1, action_1, startDate_1, endDate_1, authorization_1, sessionId_1, ...args_1], void 0, function* (companyId, page, elements, entityType, action, startDate, endDate, authorization, sessionId, options = {}) {
108
+ // verify required parameter 'companyId' is not null or undefined
109
+ assertParamExists('listAuditLogsV1AuditLogsListGet', 'companyId', companyId);
110
+ // verify required parameter 'page' is not null or undefined
111
+ assertParamExists('listAuditLogsV1AuditLogsListGet', 'page', page);
112
+ // verify required parameter 'elements' is not null or undefined
113
+ assertParamExists('listAuditLogsV1AuditLogsListGet', 'elements', elements);
114
+ const localVarPath = `/v1/audit-logs/list`;
115
+ // use dummy base URL string because the URL constructor only accepts absolute URLs.
116
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
117
+ let baseOptions;
118
+ if (configuration) {
119
+ baseOptions = configuration.baseOptions;
120
+ }
121
+ const localVarRequestOptions = Object.assign(Object.assign({ method: 'GET' }, baseOptions), options);
122
+ const localVarHeaderParameter = {};
123
+ const localVarQueryParameter = {};
124
+ if (companyId !== undefined) {
125
+ localVarQueryParameter['company_id'] = companyId;
126
+ }
127
+ if (page !== undefined) {
128
+ localVarQueryParameter['page'] = page;
129
+ }
130
+ if (elements !== undefined) {
131
+ localVarQueryParameter['elements'] = elements;
132
+ }
133
+ if (entityType !== undefined) {
134
+ localVarQueryParameter['entity_type'] = entityType;
135
+ }
136
+ if (action !== undefined) {
137
+ localVarQueryParameter['action'] = action;
138
+ }
139
+ if (startDate !== undefined) {
140
+ localVarQueryParameter['start_date'] = (startDate instanceof Date) ?
141
+ startDate.toISOString() :
142
+ startDate;
143
+ }
144
+ if (endDate !== undefined) {
145
+ localVarQueryParameter['end_date'] = (endDate instanceof Date) ?
146
+ endDate.toISOString() :
147
+ endDate;
148
+ }
149
+ if (authorization != null) {
150
+ localVarHeaderParameter['Authorization'] = String(authorization);
151
+ }
152
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
153
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
154
+ localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
155
+ return {
156
+ url: toPathString(localVarUrlObj),
157
+ options: localVarRequestOptions,
158
+ };
159
+ }),
160
+ };
161
+ };
162
+ /**
163
+ * AuditLogsApi - functional programming interface
164
+ * @export
165
+ */
166
+ export const AuditLogsApiFp = function (configuration) {
167
+ const localVarAxiosParamCreator = AuditLogsApiAxiosParamCreator(configuration);
168
+ return {
169
+ /**
170
+ *
171
+ * @summary List Audit Logs
172
+ * @param {string} companyId
173
+ * @param {number} page
174
+ * @param {number} elements
175
+ * @param {AuditLogEntity | null} [entityType]
176
+ * @param {AuditLogAction | null} [action]
177
+ * @param {string | null} [startDate]
178
+ * @param {string | null} [endDate]
179
+ * @param {string} [authorization]
180
+ * @param {string} [sessionId]
181
+ * @param {*} [options] Override http request option.
182
+ * @throws {RequiredError}
183
+ */
184
+ listAuditLogsV1AuditLogsListGet(companyId, page, elements, entityType, action, startDate, endDate, authorization, sessionId, options) {
185
+ return __awaiter(this, void 0, void 0, function* () {
186
+ var _a, _b, _c;
187
+ const localVarAxiosArgs = yield localVarAxiosParamCreator.listAuditLogsV1AuditLogsListGet(companyId, page, elements, entityType, action, startDate, endDate, authorization, sessionId, options);
188
+ const localVarOperationServerIndex = (_a = configuration === null || configuration === void 0 ? void 0 : configuration.serverIndex) !== null && _a !== void 0 ? _a : 0;
189
+ const localVarOperationServerBasePath = (_c = (_b = operationServerMap['AuditLogsApi.listAuditLogsV1AuditLogsListGet']) === null || _b === void 0 ? void 0 : _b[localVarOperationServerIndex]) === null || _c === void 0 ? void 0 : _c.url;
190
+ return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
191
+ });
192
+ },
193
+ };
194
+ };
195
+ /**
196
+ * AuditLogsApi - factory interface
197
+ * @export
198
+ */
199
+ export const AuditLogsApiFactory = function (configuration, basePath, axios) {
200
+ const localVarFp = AuditLogsApiFp(configuration);
201
+ return {
202
+ /**
203
+ *
204
+ * @summary List Audit Logs
205
+ * @param {string} companyId
206
+ * @param {number} page
207
+ * @param {number} elements
208
+ * @param {AuditLogEntity | null} [entityType]
209
+ * @param {AuditLogAction | null} [action]
210
+ * @param {string | null} [startDate]
211
+ * @param {string | null} [endDate]
212
+ * @param {string} [authorization]
213
+ * @param {string} [sessionId]
214
+ * @param {*} [options] Override http request option.
215
+ * @throws {RequiredError}
216
+ */
217
+ listAuditLogsV1AuditLogsListGet(companyId, page, elements, entityType, action, startDate, endDate, authorization, sessionId, options) {
218
+ return localVarFp.listAuditLogsV1AuditLogsListGet(companyId, page, elements, entityType, action, startDate, endDate, authorization, sessionId, options).then((request) => request(axios, basePath));
219
+ },
220
+ };
221
+ };
222
+ /**
223
+ * AuditLogsApi - object-oriented interface
224
+ * @export
225
+ * @class AuditLogsApi
226
+ * @extends {BaseAPI}
227
+ */
228
+ export class AuditLogsApi extends BaseAPI {
229
+ /**
230
+ *
231
+ * @summary List Audit Logs
232
+ * @param {string} companyId
233
+ * @param {number} page
234
+ * @param {number} elements
235
+ * @param {AuditLogEntity | null} [entityType]
236
+ * @param {AuditLogAction | null} [action]
237
+ * @param {string | null} [startDate]
238
+ * @param {string | null} [endDate]
239
+ * @param {string} [authorization]
240
+ * @param {string} [sessionId]
241
+ * @param {*} [options] Override http request option.
242
+ * @throws {RequiredError}
243
+ * @memberof AuditLogsApi
244
+ */
245
+ listAuditLogsV1AuditLogsListGet(companyId, page, elements, entityType, action, startDate, endDate, authorization, sessionId, options) {
246
+ return AuditLogsApiFp(this.configuration).listAuditLogsV1AuditLogsListGet(companyId, page, elements, entityType, action, startDate, endDate, authorization, sessionId, options).then((request) => request(this.axios, this.basePath));
247
+ }
248
+ }
61
249
  /**
62
250
  * AuthApi - axios parameter creator
63
251
  * @export
@@ -9,7 +9,6 @@
9
9
  * https://openapi-generator.tech
10
10
  * Do not edit the class manually.
11
11
  */
12
- import { HealthApi, AuthApi, CompanyApi, ControlsApi, EvidenceApi, PaymentsApi, PoliciesApi, RolesApi, UserApi } from './api';
13
12
  export interface ConfigurationParameters {
14
13
  apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
15
14
  username?: string;
@@ -90,31 +89,3 @@ export declare class Configuration {
90
89
  */
91
90
  isJsonMime(mime: string): boolean;
92
91
  }
93
- export declare class ApiSDK {
94
- private helthApi;
95
- private authApi;
96
- private companyApi;
97
- private controlsApi;
98
- private evidenceApi;
99
- private paymentsApi;
100
- private policiesApi;
101
- private rolesApi;
102
- private userApi;
103
- private token;
104
- private axiosInstance;
105
- constructor(basePath?: string);
106
- setToken(newToken: string): void;
107
- private getAuthHeader;
108
- private setupInterceptors;
109
- getApi(): {
110
- helthApi: HealthApi;
111
- authApi: AuthApi;
112
- companyApi: CompanyApi;
113
- controlsApi: ControlsApi;
114
- evidenceApi: EvidenceApi;
115
- paymentsApi: PaymentsApi;
116
- policiesApi: PoliciesApi;
117
- rolesApi: RolesApi;
118
- userApi: UserApi;
119
- };
120
- }
@@ -11,8 +11,6 @@
11
11
  * https://openapi-generator.tech
12
12
  * Do not edit the class manually.
13
13
  */
14
- import axios from 'axios';
15
- import { HealthApi, AuthApi, CompanyApi, ControlsApi, EvidenceApi, PaymentsApi, PoliciesApi, RolesApi, UserApi } from './api';
16
14
  export class Configuration {
17
15
  constructor(param = {}) {
18
16
  var _a;
@@ -40,73 +38,3 @@ export class Configuration {
40
38
  return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
41
39
  }
42
40
  }
43
- export class ApiSDK {
44
- constructor(basePath) {
45
- this.token = null;
46
- this.axiosInstance = axios.create({
47
- baseURL: basePath,
48
- withCredentials: true
49
- });
50
- this.setupInterceptors();
51
- const config = new Configuration({
52
- basePath,
53
- apiKey: () => this.getAuthHeader(),
54
- baseOptions: {
55
- axios: this.axiosInstance
56
- },
57
- });
58
- this.helthApi = new HealthApi(config, undefined, this.axiosInstance);
59
- this.authApi = new AuthApi(config, undefined, this.axiosInstance);
60
- this.companyApi = new CompanyApi(config, undefined, this.axiosInstance);
61
- this.controlsApi = new ControlsApi(config, undefined, this.axiosInstance);
62
- this.evidenceApi = new EvidenceApi(config, undefined, this.axiosInstance);
63
- this.paymentsApi = new PaymentsApi(config, undefined, this.axiosInstance);
64
- this.policiesApi = new PoliciesApi(config, undefined, this.axiosInstance);
65
- this.rolesApi = new RolesApi(config, undefined, this.axiosInstance);
66
- this.userApi = new UserApi(config, undefined, this.axiosInstance);
67
- }
68
- setToken(newToken) {
69
- this.token = newToken;
70
- }
71
- getAuthHeader() {
72
- if (!this.token) {
73
- throw new Error('No token set. Call setToken() first.');
74
- }
75
- return `Bearer ${this.token}`;
76
- }
77
- setupInterceptors() {
78
- this.axiosInstance.interceptors.request.use((config) => {
79
- if (this.token) {
80
- config.headers['Authorization'] = this.getAuthHeader();
81
- }
82
- return config;
83
- });
84
- this.axiosInstance.interceptors.response.use((response) => {
85
- const newToken = response.data.newToken || response.headers['Authorization'];
86
- if (newToken) {
87
- this.setToken(newToken.replace('Bearer ', ''));
88
- console.log('Token automatically updated via backend refresh');
89
- }
90
- return response;
91
- }, (error) => {
92
- var _a;
93
- if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 401) {
94
- console.error('Authentication failed - session expired');
95
- }
96
- return Promise.reject(error);
97
- });
98
- }
99
- getApi() {
100
- return {
101
- helthApi: this.helthApi,
102
- authApi: this.authApi,
103
- companyApi: this.companyApi,
104
- controlsApi: this.controlsApi,
105
- evidenceApi: this.evidenceApi,
106
- paymentsApi: this.paymentsApi,
107
- policiesApi: this.policiesApi,
108
- rolesApi: this.rolesApi,
109
- userApi: this.userApi,
110
- };
111
- }
112
- }
package/dist/index.d.ts CHANGED
@@ -11,3 +11,4 @@
11
11
  */
12
12
  export * from "./api";
13
13
  export * from "./configuration";
14
+ export * from "./sdk";
package/dist/index.js CHANGED
@@ -13,3 +13,4 @@
13
13
  */
14
14
  export * from "./api";
15
15
  export * from "./configuration";
16
+ export * from "./sdk";
package/dist/sdk.d.ts ADDED
@@ -0,0 +1,31 @@
1
+ import { HealthApi, AuthApi, CompanyApi, ControlsApi, AuditLogsApi, 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 auditLogsApi;
8
+ private evidenceApi;
9
+ private paymentsApi;
10
+ private policiesApi;
11
+ private rolesApi;
12
+ private userApi;
13
+ private token;
14
+ private axiosInstance;
15
+ constructor(basePath?: string);
16
+ setToken(newToken: string): void;
17
+ private getAuthHeader;
18
+ private setupInterceptors;
19
+ getApi(): {
20
+ helthApi: HealthApi;
21
+ authApi: AuthApi;
22
+ companyApi: CompanyApi;
23
+ controlsApi: ControlsApi;
24
+ auditLogsApi: AuditLogsApi;
25
+ evidenceApi: EvidenceApi;
26
+ paymentsApi: PaymentsApi;
27
+ policiesApi: PoliciesApi;
28
+ rolesApi: RolesApi;
29
+ userApi: UserApi;
30
+ };
31
+ }
package/dist/sdk.js ADDED
@@ -0,0 +1,75 @@
1
+ import axios from 'axios';
2
+ import { HealthApi, AuthApi, CompanyApi, ControlsApi, AuditLogsApi, 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.auditLogsApi = new AuditLogsApi(config, undefined, this.axiosInstance);
24
+ this.evidenceApi = new EvidenceApi(config, undefined, this.axiosInstance);
25
+ this.paymentsApi = new PaymentsApi(config, undefined, this.axiosInstance);
26
+ this.policiesApi = new PoliciesApi(config, undefined, this.axiosInstance);
27
+ this.rolesApi = new RolesApi(config, undefined, this.axiosInstance);
28
+ this.userApi = new UserApi(config, undefined, this.axiosInstance);
29
+ }
30
+ setToken(newToken) {
31
+ this.token = newToken;
32
+ }
33
+ getAuthHeader() {
34
+ if (!this.token) {
35
+ throw new Error('No token set. Call setToken() first.');
36
+ }
37
+ return `Bearer ${this.token}`;
38
+ }
39
+ setupInterceptors() {
40
+ this.axiosInstance.interceptors.request.use((config) => {
41
+ if (this.token) {
42
+ config.headers['Authorization'] = this.getAuthHeader();
43
+ }
44
+ return config;
45
+ });
46
+ this.axiosInstance.interceptors.response.use((response) => {
47
+ const newToken = response.data.newToken || response.headers['Authorization'];
48
+ if (newToken) {
49
+ this.setToken(newToken.replace('Bearer ', ''));
50
+ console.log('Token automatically updated via backend refresh');
51
+ }
52
+ return response;
53
+ }, (error) => {
54
+ var _a;
55
+ if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 401) {
56
+ console.error('Authentication failed - session expired');
57
+ }
58
+ return Promise.reject(error);
59
+ });
60
+ }
61
+ getApi() {
62
+ return {
63
+ helthApi: this.helthApi,
64
+ authApi: this.authApi,
65
+ companyApi: this.companyApi,
66
+ controlsApi: this.controlsApi,
67
+ auditLogsApi: this.auditLogsApi,
68
+ evidenceApi: this.evidenceApi,
69
+ paymentsApi: this.paymentsApi,
70
+ policiesApi: this.policiesApi,
71
+ rolesApi: this.rolesApi,
72
+ userApi: this.userApi,
73
+ };
74
+ }
75
+ }
@@ -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/index.ts CHANGED
@@ -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
@@ -4,7 +4,7 @@
4
4
  "openapi-generator-cli": "^1.0.0"
5
5
  },
6
6
  "name": "@rasadov/lumoar-sdk",
7
- "version": "1.0.3",
7
+ "version": "1.0.5",
8
8
  "description": "Lumoar API SDK",
9
9
  "main": "dist/index.js",
10
10
  "directories": {
package/sdk.ts ADDED
@@ -0,0 +1,102 @@
1
+ import axios, { AxiosInstance, AxiosResponse } from 'axios';
2
+ import {
3
+ HealthApi,
4
+ AuthApi,
5
+ CompanyApi,
6
+ ControlsApi,
7
+ AuditLogsApi,
8
+ EvidenceApi,
9
+ PaymentsApi,
10
+ PoliciesApi,
11
+ RolesApi,
12
+ UserApi
13
+ } from './api';
14
+ import { Configuration } from './configuration';
15
+
16
+ export class ApiSDK {
17
+ private helthApi: HealthApi;
18
+ private authApi: AuthApi;
19
+ private companyApi: CompanyApi;
20
+ private controlsApi: ControlsApi;
21
+ private auditLogsApi: AuditLogsApi;
22
+ private evidenceApi: EvidenceApi;
23
+ private paymentsApi: PaymentsApi;
24
+ private policiesApi: PoliciesApi;
25
+ private rolesApi: RolesApi;
26
+ private userApi: UserApi;
27
+ private token: string | null = null;
28
+ private axiosInstance: AxiosInstance;
29
+
30
+ constructor(basePath?: string) {
31
+ this.axiosInstance = axios.create({
32
+ baseURL: basePath,
33
+ withCredentials: true
34
+ });
35
+ this.setupInterceptors();
36
+ const config = new Configuration({
37
+ basePath,
38
+ apiKey: () => this.getAuthHeader(),
39
+ baseOptions: {
40
+ axios: this.axiosInstance
41
+ },
42
+ });
43
+
44
+ this.helthApi = new HealthApi(config, undefined, this.axiosInstance);
45
+ this.authApi = new AuthApi(config, undefined, this.axiosInstance);
46
+ this.companyApi = new CompanyApi(config, undefined, this.axiosInstance);
47
+ this.controlsApi = new ControlsApi(config, undefined, this.axiosInstance);
48
+ this.auditLogsApi = new AuditLogsApi(config, undefined, this.axiosInstance);
49
+ this.evidenceApi = new EvidenceApi(config, undefined, this.axiosInstance);
50
+ this.paymentsApi = new PaymentsApi(config, undefined, this.axiosInstance);
51
+ this.policiesApi = new PoliciesApi(config, undefined, this.axiosInstance);
52
+ this.rolesApi = new RolesApi(config, undefined, this.axiosInstance);
53
+ this.userApi = new UserApi(config, undefined, this.axiosInstance);
54
+ }
55
+
56
+ public setToken(newToken: string) {
57
+ this.token = newToken;
58
+ }
59
+ private getAuthHeader(): string {
60
+ if (!this.token) {
61
+ throw new Error('No token set. Call setToken() first.');
62
+ }
63
+ return `Bearer ${this.token}`;
64
+ }
65
+
66
+ private setupInterceptors() {
67
+ this.axiosInstance.interceptors.request.use((config) => {
68
+ if (this.token) {
69
+ config.headers['Authorization'] = this.getAuthHeader();
70
+ }
71
+ return config;
72
+ });
73
+
74
+ this.axiosInstance.interceptors.response.use((response: AxiosResponse) => {
75
+ const newToken = response.data.newToken || response.headers['Authorization'];
76
+ if (newToken) {
77
+ this.setToken(newToken.replace('Bearer ', ''));
78
+ console.log('Token automatically updated via backend refresh');
79
+ }
80
+ return response;
81
+ }, (error) => {
82
+ if (error.response?.status === 401) {
83
+ console.error('Authentication failed - session expired');
84
+ }
85
+ return Promise.reject(error);
86
+ });
87
+ }
88
+ public getApi() {
89
+ return {
90
+ helthApi: this.helthApi,
91
+ authApi: this.authApi,
92
+ companyApi: this.companyApi,
93
+ controlsApi: this.controlsApi,
94
+ auditLogsApi: this.auditLogsApi,
95
+ evidenceApi: this.evidenceApi,
96
+ paymentsApi: this.paymentsApi,
97
+ policiesApi: this.policiesApi,
98
+ rolesApi: this.rolesApi,
99
+ userApi: this.userApi,
100
+ };
101
+ }
102
+ }