@zerosls/clm-sdk 1.1.4 → 1.1.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.
package/.gitlab-ci.yml CHANGED
@@ -20,4 +20,4 @@ publish:
20
20
  - echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
21
21
  - npm publish --access public
22
22
  rules:
23
- - if: $CI_COMMIT_BRANCH == "main"
23
+ - if: $CI_COMMIT_BRANCH == "develop"
@@ -0,0 +1,26 @@
1
+ export interface LegacyLoginRequest {
2
+ userName: string;
3
+ password: string;
4
+ }
5
+ export interface LegacyLoginResponse {
6
+ dataResult: {
7
+ token: string;
8
+ userType: string;
9
+ userId: string;
10
+ userName: string;
11
+ area: string;
12
+ id_Area: number;
13
+ id_Role: string;
14
+ };
15
+ statusResponse: {
16
+ code: number;
17
+ success: boolean;
18
+ message: string;
19
+ };
20
+ }
21
+ export declare class LegacyApiClient {
22
+ private baseUrl;
23
+ constructor(baseUrl: string);
24
+ login(userName: string, password: string): Promise<LegacyLoginResponse>;
25
+ logout(): void;
26
+ }
@@ -0,0 +1,34 @@
1
+ export class LegacyApiClient {
2
+ constructor(baseUrl) {
3
+ this.baseUrl = baseUrl;
4
+ }
5
+ async login(userName, password) {
6
+ var _a, _b;
7
+ const url = `${this.baseUrl}/auth/login`;
8
+ const response = await fetch(url, {
9
+ method: 'POST',
10
+ headers: { 'Content-Type': 'application/json' },
11
+ body: JSON.stringify({ userName, password }),
12
+ });
13
+ if (!response.ok) {
14
+ const errorData = await response.json().catch(() => ({
15
+ statusResponse: {
16
+ code: response.status,
17
+ success: false,
18
+ message: response.statusText
19
+ }
20
+ }));
21
+ throw new Error(((_a = errorData.statusResponse) === null || _a === void 0 ? void 0 : _a.message) || 'Legacy login failed');
22
+ }
23
+ const data = await response.json();
24
+ if ((_b = data.dataResult) === null || _b === void 0 ? void 0 : _b.token) {
25
+ sessionStorage.setItem('legacy_token', data.dataResult.token);
26
+ window.__LEGACY_TOKEN__ = data.dataResult.token;
27
+ }
28
+ return data;
29
+ }
30
+ logout() {
31
+ sessionStorage.removeItem('legacy_token');
32
+ delete window.__LEGACY_TOKEN__;
33
+ }
34
+ }
package/dist/index.d.ts CHANGED
@@ -12,6 +12,7 @@ import { ClassificationTypesApi } from "./modules/legacy/classificationtypes/cla
12
12
  */
13
13
  export declare class ClmSdk {
14
14
  private apiClient;
15
+ private legacyClient;
15
16
  private eventEmitter;
16
17
  private cacheInstance;
17
18
  auth: AuthApi;
@@ -22,6 +23,8 @@ export declare class ClmSdk {
22
23
  areas: AreasApi;
23
24
  classificationTypes: ClassificationTypesApi;
24
25
  constructor(config: Partial<SdkConfig>);
26
+ legacyLogin(userName: string, password: string): Promise<import("./core/legacy-api-client").LegacyLoginResponse>;
27
+ legacyLogout(): void;
25
28
  /**
26
29
  * Access to events system
27
30
  */
@@ -40,5 +43,6 @@ export * from "./modules/v1/auth/types";
40
43
  export * from "./modules/v1/users/types";
41
44
  export * from "./modules/v1/notifications/types";
42
45
  export * from "./modules/v1/_logs/types";
46
+ export * from "./core/legacy-api-client";
43
47
  export * from "./modules/legacy/areas/types";
44
48
  export * from "./modules/legacy/classificationtypes/types";
package/dist/index.js CHANGED
@@ -11,6 +11,7 @@ import { LogsApi } from "./modules/v1/_logs/logs-api";
11
11
  // Legacy
12
12
  import { AreasApi } from "./modules/legacy/areas/areas-api";
13
13
  import { ClassificationTypesApi } from "./modules/legacy/classificationtypes/classificationtypes-api";
14
+ import { LegacyApiClient } from "./core/legacy-api-client";
14
15
  /**
15
16
  * Main SDK for consuming CLM API
16
17
  */
@@ -30,6 +31,7 @@ export class ClmSdk {
30
31
  // Initialize core utilities
31
32
  this.cacheInstance = new Cache((_a = fullConfig.cache) === null || _a === void 0 ? void 0 : _a.ttl);
32
33
  this.apiClient = new ApiClient(fullConfig, this.eventEmitter);
34
+ this.legacyClient = new LegacyApiClient("http://216.250.117.119/ZeroServicesQA/api/v1");
33
35
  // Initialize modules v1
34
36
  this.auth = new AuthApi(this.apiClient);
35
37
  this.users = new UsersApi(this.apiClient);
@@ -40,6 +42,12 @@ export class ClmSdk {
40
42
  this.areas = new AreasApi(this.apiClient);
41
43
  this.classificationTypes = new ClassificationTypesApi(this.apiClient);
42
44
  }
45
+ async legacyLogin(userName, password) {
46
+ return await this.legacyClient.login(userName, password);
47
+ }
48
+ legacyLogout() {
49
+ this.legacyClient.logout();
50
+ }
43
51
  /**
44
52
  * Access to events system
45
53
  */
@@ -55,5 +63,6 @@ export * from "./modules/v1/users/types";
55
63
  export * from "./modules/v1/notifications/types";
56
64
  export * from "./modules/v1/_logs/types";
57
65
  // Export legacy types
66
+ export * from "./core/legacy-api-client";
58
67
  export * from "./modules/legacy/areas/types";
59
68
  export * from "./modules/legacy/classificationtypes/types";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zerosls/clm-sdk",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "description": "SDK for ZeroCLM API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -0,0 +1,65 @@
1
+ export interface LegacyLoginRequest {
2
+ userName: string;
3
+ password: string;
4
+ }
5
+
6
+ export interface LegacyLoginResponse {
7
+ dataResult: {
8
+ token: string;
9
+ userType: string;
10
+ userId: string;
11
+ userName: string;
12
+ area: string;
13
+ id_Area: number;
14
+ id_Role: string;
15
+ };
16
+ statusResponse: {
17
+ code: number;
18
+ success: boolean;
19
+ message: string;
20
+ };
21
+ }
22
+
23
+ export class LegacyApiClient {
24
+ private baseUrl: string;
25
+
26
+ constructor(baseUrl: string) {
27
+ this.baseUrl = baseUrl;
28
+ }
29
+
30
+ async login(userName: string, password: string): Promise<LegacyLoginResponse> {
31
+ const url = `${this.baseUrl}/auth/login`;
32
+
33
+ const response = await fetch(url, {
34
+ method: 'POST',
35
+ headers: { 'Content-Type': 'application/json' },
36
+ body: JSON.stringify({ userName, password }),
37
+ });
38
+
39
+ if (!response.ok) {
40
+ const errorData = await response.json().catch(() => ({
41
+ statusResponse: {
42
+ code: response.status,
43
+ success: false,
44
+ message: response.statusText
45
+ }
46
+ }));
47
+
48
+ throw new Error(errorData.statusResponse?.message || 'Legacy login failed');
49
+ }
50
+
51
+ const data: LegacyLoginResponse = await response.json();
52
+
53
+ if (data.dataResult?.token) {
54
+ sessionStorage.setItem('legacy_token', data.dataResult.token);
55
+ (window as any).__LEGACY_TOKEN__ = data.dataResult.token;
56
+ }
57
+
58
+ return data;
59
+ }
60
+
61
+ logout(): void {
62
+ sessionStorage.removeItem('legacy_token');
63
+ delete (window as any).__LEGACY_TOKEN__;
64
+ }
65
+ }
package/src/index.ts CHANGED
@@ -15,12 +15,14 @@ import { LogsApi } from "./modules/v1/_logs/logs-api";
15
15
  // Legacy
16
16
  import { AreasApi } from "./modules/legacy/areas/areas-api";
17
17
  import { ClassificationTypesApi } from "./modules/legacy/classificationtypes/classificationtypes-api";
18
+ import { LegacyApiClient } from "./core/legacy-api-client";
18
19
 
19
20
  /**
20
21
  * Main SDK for consuming CLM API
21
22
  */
22
23
  export class ClmSdk {
23
24
  private apiClient: ApiClient;
25
+ private legacyClient: LegacyApiClient;
24
26
  private eventEmitter: EventEmitter;
25
27
  private cacheInstance: Cache;
26
28
 
@@ -45,6 +47,10 @@ export class ClmSdk {
45
47
  this.cacheInstance = new Cache(fullConfig.cache?.ttl);
46
48
  this.apiClient = new ApiClient(fullConfig, this.eventEmitter);
47
49
 
50
+ this.legacyClient = new LegacyApiClient(
51
+ "http://216.250.117.119/ZeroServicesQA/api/v1"
52
+ );
53
+
48
54
  // Initialize modules v1
49
55
  this.auth = new AuthApi(this.apiClient);
50
56
  this.users = new UsersApi(this.apiClient);
@@ -57,6 +63,14 @@ export class ClmSdk {
57
63
  this.classificationTypes = new ClassificationTypesApi(this.apiClient);
58
64
  }
59
65
 
66
+ async legacyLogin(userName: string, password: string) {
67
+ return await this.legacyClient.login(userName, password);
68
+ }
69
+
70
+ legacyLogout(): void {
71
+ this.legacyClient.logout();
72
+ }
73
+
60
74
  /**
61
75
  * Access to events system
62
76
  */
@@ -75,7 +89,7 @@ export class ClmSdk {
75
89
  clearByPrefix: (prefix: string) => this.cacheInstance.clearByPrefix(prefix),
76
90
  };
77
91
  }
78
-
92
+
79
93
  export * from "./types/common";
80
94
  export * from "./types/sdk";
81
95
 
@@ -86,5 +100,6 @@ export * from "./modules/v1/notifications/types";
86
100
  export * from "./modules/v1/_logs/types";
87
101
 
88
102
  // Export legacy types
103
+ export * from "./core/legacy-api-client";
89
104
  export * from "./modules/legacy/areas/types";
90
105
  export * from "./modules/legacy/classificationtypes/types";