@zerosls/clm-sdk 1.1.5 → 1.1.6

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.
@@ -62,27 +62,32 @@ export class ApiClient {
62
62
  ...(options.headers || {}),
63
63
  });
64
64
  const headers = new Headers(base);
65
- const legacyPattern = /(^|\/)legacy(\/|$)/i;
66
- const isLegacyEndpoint = legacyPattern.test(endpoint);
67
- if (isLegacyEndpoint) {
68
- const legacyToken = window.__LEGACY_TOKEN__ ||
69
- sessionStorage.getItem("legacy_token") ||
70
- null;
71
- if (legacyToken) {
72
- headers.set("Authorization", `Bearer ${legacyToken}`);
73
- if (this.debug) {
74
- console.log("🔐 Using legacy token for:", endpoint);
75
- }
65
+ //const legacyPattern = /(^|\/)legacy(\/|$)/i;
66
+ //const isLegacyEndpoint = legacyPattern.test(endpoint);
67
+ //if (isLegacyEndpoint) {
68
+ const legacyToken = window.__LEGACY_TOKEN__ ||
69
+ sessionStorage.getItem("legacy_token") ||
70
+ null;
71
+ if (legacyToken) {
72
+ headers.set("Authorization", `Bearer ${legacyToken}`);
73
+ if (this.debug) {
74
+ console.log("🔐 Using legacy token for:", endpoint);
76
75
  }
77
- else {
78
- console.warn("⚠️ No legacy token available for legacy endpoint:", endpoint);
76
+ }
77
+ else if (this.token) {
78
+ // ✅ Si no hay legacy token, usar token v1
79
+ if (this.debug) {
80
+ console.log("🔐 Using v1 token for:", endpoint);
79
81
  }
80
82
  }
81
83
  else {
82
- if (!this.token) {
83
- headers.delete("Authorization");
84
- }
84
+ console.warn("⚠️ No token available for endpoint:", endpoint);
85
85
  }
86
+ //} else {
87
+ // if (!this.token) {
88
+ // headers.delete("Authorization");
89
+ // }
90
+ //}
86
91
  const useCache = this.cacheEnabled && options.useCache !== false;
87
92
  if (useCache && method === "GET") {
88
93
  const cacheKey = generateCacheKey(method, url, data);
@@ -8,6 +8,7 @@ export class LegacyApiClient {
8
8
  const response = await fetch(url, {
9
9
  method: 'POST',
10
10
  headers: { 'Content-Type': 'application/json' },
11
+ credentials: 'include',
11
12
  body: JSON.stringify({ userName, password }),
12
13
  });
13
14
  if (!response.ok) {
@@ -1,6 +1,6 @@
1
1
  export class ClassificationTypesApi {
2
2
  constructor(apiClient) {
3
- this.basePath = "/legacy/catalog/clasificationtype";
3
+ this.basePath = "/catalog/clasificationtype";
4
4
  this.apiClient = apiClient;
5
5
  }
6
6
  async getClassificationTypes(options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zerosls/clm-sdk",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
4
4
  "description": "SDK for ZeroCLM API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -138,33 +138,36 @@ export class ApiClient {
138
138
 
139
139
  const headers = new Headers(base);
140
140
 
141
- const legacyPattern = /(^|\/)legacy(\/|$)/i;
142
- const isLegacyEndpoint = legacyPattern.test(endpoint);
143
-
144
- if (isLegacyEndpoint) {
145
- const legacyToken =
146
- (window as any).__LEGACY_TOKEN__ ||
147
- sessionStorage.getItem("legacy_token") ||
148
- null;
149
-
150
- if (legacyToken) {
151
- headers.set("Authorization", `Bearer ${legacyToken}`);
141
+ //const legacyPattern = /(^|\/)legacy(\/|$)/i;
142
+ //const isLegacyEndpoint = legacyPattern.test(endpoint);
152
143
 
153
- if (this.debug) {
154
- console.log("🔐 Using legacy token for:", endpoint);
155
- }
156
- } else {
157
- console.warn(
158
- "⚠️ No legacy token available for legacy endpoint:",
159
- endpoint
160
- );
144
+ //if (isLegacyEndpoint) {
145
+ const legacyToken =
146
+ (window as any).__LEGACY_TOKEN__ ||
147
+ sessionStorage.getItem("legacy_token") ||
148
+ null;
149
+
150
+ if (legacyToken) {
151
+ headers.set("Authorization", `Bearer ${legacyToken}`);
152
+
153
+ if (this.debug) {
154
+ console.log("🔐 Using legacy token for:", endpoint);
161
155
  }
162
- } else {
163
- if (!this.token) {
164
- headers.delete("Authorization");
156
+ } else if (this.token) {
157
+ // ✅ Si no hay legacy token, usar token v1
158
+ if (this.debug) {
159
+ console.log("🔐 Using v1 token for:", endpoint);
165
160
  }
161
+ } else {
162
+ console.warn("⚠️ No token available for endpoint:", endpoint);
166
163
  }
167
164
 
165
+ //} else {
166
+ // if (!this.token) {
167
+ // headers.delete("Authorization");
168
+ // }
169
+ //}
170
+
168
171
  const useCache = this.cacheEnabled && options.useCache !== false;
169
172
  if (useCache && method === "GET") {
170
173
  const cacheKey = generateCacheKey(method, url, data);
@@ -33,6 +33,7 @@ export class LegacyApiClient {
33
33
  const response = await fetch(url, {
34
34
  method: 'POST',
35
35
  headers: { 'Content-Type': 'application/json' },
36
+ credentials: 'include',
36
37
  body: JSON.stringify({ userName, password }),
37
38
  });
38
39
 
@@ -10,7 +10,7 @@ import {
10
10
 
11
11
  export class ClassificationTypesApi {
12
12
  private apiClient: ApiClient;
13
- private readonly basePath = "/legacy/catalog/clasificationtype";
13
+ private readonly basePath = "/catalog/clasificationtype";
14
14
 
15
15
  constructor(apiClient: ApiClient) {
16
16
  this.apiClient = apiClient;