@zerosls/clm-sdk 1.1.1 → 1.1.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.
@@ -6,7 +6,7 @@ function resolveDefaultBaseUrl() {
6
6
  const fromWindow = (_a = globalThis === null || globalThis === void 0 ? void 0 : globalThis.SDK_CONFIG) === null || _a === void 0 ? void 0 : _a.API_BASE_URL;
7
7
  if (fromWindow)
8
8
  return normalizeUrl(String(fromWindow));
9
- return "https://api.clm-app.com/api";
9
+ return "http://216.250.117.119/ZeroApiQA/api/v1/";
10
10
  }
11
11
  export const DEFAULT_CONFIG = {
12
12
  baseUrl: resolveDefaultBaseUrl(),
@@ -12,7 +12,7 @@ export class ApiClient {
12
12
  this.cacheEnabled = ((_a = config.cache) === null || _a === void 0 ? void 0 : _a.enabled) !== false;
13
13
  this.cache = new Cache((_b = config.cache) === null || _b === void 0 ? void 0 : _b.ttl);
14
14
  this.debug = config.debug || false;
15
- this.credentials = config.credentials || 'include';
15
+ this.credentials = config.credentials || "include";
16
16
  }
17
17
  setToken(token) {
18
18
  this.token = token;
@@ -62,15 +62,20 @@ export class ApiClient {
62
62
  ...(options.headers || {}),
63
63
  });
64
64
  const headers = new Headers(base);
65
- if (endpoint.startsWith('/legacy')) {
65
+ const legacyPattern = /(^|\/)legacy(\/|$)/i;
66
+ const isLegacyEndpoint = legacyPattern.test(endpoint);
67
+ if (isLegacyEndpoint) {
66
68
  const legacyToken = window.__LEGACY_TOKEN__ ||
67
69
  sessionStorage.getItem("legacy_token") ||
68
70
  null;
69
71
  if (legacyToken) {
70
72
  headers.set("Authorization", `Bearer ${legacyToken}`);
73
+ if (this.debug) {
74
+ console.log("🔐 Using legacy token for:", endpoint);
75
+ }
71
76
  }
72
77
  else {
73
- console.warn('⚠️ No legacy token available for legacy endpoint:', endpoint);
78
+ console.warn("⚠️ No legacy token available for legacy endpoint:", endpoint);
74
79
  }
75
80
  }
76
81
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zerosls/clm-sdk",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "SDK for ZeroCLM API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -7,12 +7,12 @@ function normalizeUrl(url: string) {
7
7
  function resolveDefaultBaseUrl(): string {
8
8
  const fromWindow = (globalThis as any)?.SDK_CONFIG?.API_BASE_URL;
9
9
  if (fromWindow) return normalizeUrl(String(fromWindow));
10
- return "https://api.clm-app.com/api";
10
+ return "http://216.250.117.119/ZeroApiQA/api/v1/";
11
11
  }
12
12
 
13
13
 
14
14
  export const DEFAULT_CONFIG: Partial<SdkConfig> = {
15
- baseUrl: resolveDefaultBaseUrl(),
15
+ baseUrl: resolveDefaultBaseUrl(),
16
16
  organization: "default-org",
17
17
  cache: { enabled: true, ttl: 60000 },
18
18
  debug: true,
@@ -28,7 +28,7 @@ export class ApiClient {
28
28
  this.cacheEnabled = config.cache?.enabled !== false;
29
29
  this.cache = new Cache(config.cache?.ttl);
30
30
  this.debug = config.debug || false;
31
- this.credentials = config.credentials || 'include';
31
+ this.credentials = config.credentials || "include";
32
32
  }
33
33
 
34
34
  public setToken(token: string | null): void {
@@ -111,7 +111,6 @@ export class ApiClient {
111
111
  return result;
112
112
  }
113
113
 
114
-
115
114
  private invalidateCache(endpoint: string): void {
116
115
  if (this.cacheEnabled) {
117
116
  const basePath = endpoint.split("/").slice(0, 2).join("/");
@@ -139,7 +138,10 @@ export class ApiClient {
139
138
 
140
139
  const headers = new Headers(base);
141
140
 
142
- if (endpoint.startsWith('/legacy')) {
141
+ const legacyPattern = /(^|\/)legacy(\/|$)/i;
142
+ const isLegacyEndpoint = legacyPattern.test(endpoint);
143
+
144
+ if (isLegacyEndpoint) {
143
145
  const legacyToken =
144
146
  (window as any).__LEGACY_TOKEN__ ||
145
147
  sessionStorage.getItem("legacy_token") ||
@@ -147,8 +149,15 @@ export class ApiClient {
147
149
 
148
150
  if (legacyToken) {
149
151
  headers.set("Authorization", `Bearer ${legacyToken}`);
152
+
153
+ if (this.debug) {
154
+ console.log("🔐 Using legacy token for:", endpoint);
155
+ }
150
156
  } else {
151
- console.warn('⚠️ No legacy token available for legacy endpoint:', endpoint);
157
+ console.warn(
158
+ "⚠️ No legacy token available for legacy endpoint:",
159
+ endpoint
160
+ );
152
161
  }
153
162
  } else {
154
163
  if (!this.token) {
@@ -156,7 +165,6 @@ export class ApiClient {
156
165
  }
157
166
  }
158
167
 
159
-
160
168
  const useCache = this.cacheEnabled && options.useCache !== false;
161
169
  if (useCache && method === "GET") {
162
170
  const cacheKey = generateCacheKey(method, url, data);
@@ -245,4 +253,4 @@ export class ApiClient {
245
253
  });
246
254
  }
247
255
  }
248
- }
256
+ }