sgerp-frontend-lib 0.2.2 → 0.2.4

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../sgerplib/sgerp/routing/index.ts"],"names":[],"mappings":"AA6EA,UAAU,WAAW;IACnB,IAAI,EAAE,YAAY,CAAC;IACnB,WAAW,EAAE,MAAM,EAAE,EAAE,CAAC;CACzB;AAED,qBAAa,IAAI;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,WAAW,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;gBAEL,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;CASrF;AAED,qBAAa,GAAG;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,GAAG,EAAE,MAAM,EAAE,CAAC;IACd,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,WAAW,CAAC;gBAGnB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EAAE,EACf,GAAG,EAAE,MAAM,EAAE,EACb,KAAK,EAAE,IAAI,EAAE,EACb,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM;CAoBnB;AAED,wBAAgB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,GAAG,CAUpE;AAED,qBAAa,KAAK;IAChB,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,WAAW,CAAC;gBAET,IAAI,EAAE,GAAG,EAAE,EAAE,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I,CAAC;AAEV,qBAAa,aAAa;IACxB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,eAAe,GAAG,IAAI,CAAC;IACjC,cAAc,EAAE,OAAO,CAAC;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAGpC,mBAAmB,EAAE,MAAM,EAC3B,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,MAAM,EACX,eAAe,GAAE,MAAsC,EACvD,QAAQ,GAAE,eAAe,GAAG,IAAW;IA8DzC,MAAM,IAAI,MAAM;IAwCV,KAAK,CACT,MAAM,EAAE,MAAM,EAAE,EAAE,EAClB,IAAI,EAAE,OAAO,EACb,QAAQ,EAAE,aAAa,EACvB,eAAe,GAAE,OAAe,GAC/B,OAAO,CAAC,IAAI,CAAC;IAqHhB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM;CAgBhE"}
@@ -276,20 +276,30 @@ const fetchData = async (url) => {
276
276
  };
277
277
  class RoutingEngine {
278
278
  constructor(routing_engine_name, url, road_network, key, default_backend = detectBackendFromDeployment(), settings = null) {
279
+ var _a;
279
280
  this.routing_engine_name = routing_engine_name;
280
281
  this.default_backend = default_backend;
281
282
  console.log(`default backend in routing engine ${default_backend}`);
282
283
  this.settings = settings;
283
284
  this.useAirDistance = !url || url === 'null' || url === '' || url === undefined;
284
285
  if (!this.useAirDistance) {
285
- if (url.includes('gcstage')) {
286
- url = url.replace('gcstage', 'gcdev');
287
- }
288
- if (url === '' ||
289
- url === 'null' ||
290
- url === undefined ||
291
- url.includes('localhost')) {
292
- url = 'http://mapbox-osrm-proxy';
286
+ // Only normalize URLs that aren't already full URLs with proper domains
287
+ // A full URL should have http(s):// and contain a dot (indicating a domain)
288
+ // This excludes k8s internal placeholders like "http://mapbox-osrm-proxy"
289
+ const hasProtocol = url.startsWith('http://') || url.startsWith('https://');
290
+ const hasDomainDot = url.includes('://') && ((_a = url.split('://')[1]) === null || _a === void 0 ? void 0 : _a.includes('.'));
291
+ const isFullUrl = hasProtocol && hasDomainDot;
292
+ if (!isFullUrl) {
293
+ if (url.includes('gcstage')) {
294
+ url = url.replace('gcstage', 'gcdev');
295
+ }
296
+ if (url === '' ||
297
+ url === 'null' ||
298
+ url === undefined ||
299
+ url.includes('localhost') ||
300
+ url === 'http://mapbox-osrm-proxy') {
301
+ url = 'http://mapbox-osrm-proxy';
302
+ }
293
303
  }
294
304
  }
295
305
  if (road_network === undefined ||
@@ -316,15 +326,23 @@ class RoutingEngine {
316
326
  this.requestCache = {};
317
327
  }
318
328
  getUrl() {
319
- // If URL is a full URL (starts with http:// or https://), use it as-is
329
+ var _a;
330
+ // If URL is a full URL with a proper domain (contains a dot), use it as-is
320
331
  // This respects URLs from payloads that specify their own routing endpoint
321
- if (this.url.startsWith('http://') || this.url.startsWith('https://')) {
332
+ // But excludes k8s internal placeholders like "http://mapbox-osrm-proxy"
333
+ const hasProtocol = this.url.startsWith('http://') || this.url.startsWith('https://');
334
+ const hasDomainDot = this.url.includes('://') && ((_a = this.url.split('://')[1]) === null || _a === void 0 ? void 0 : _a.includes('.'));
335
+ const isFullUrl = hasProtocol && hasDomainDot;
336
+ console.log('[RoutingEngine.getUrl] this.url:', this.url, 'isFullUrl:', isFullUrl, 'hasProtocol:', hasProtocol, 'hasDomainDot:', hasDomainDot);
337
+ if (isFullUrl) {
338
+ console.log('[RoutingEngine.getUrl] Using as-is (full URL):', this.url);
322
339
  return this.url;
323
340
  }
324
341
  // Only apply env mapping or SGERP_DOMAINS for placeholder/relative URLs
325
342
  if (this.url === 'http://mapbox-osrm-proxy') {
326
343
  // First, check if there's an env-based mapping
327
344
  const envMappedUrl = getOSRMProxyFromEnvMapping();
345
+ console.log('[RoutingEngine.getUrl] envMappedUrl:', envMappedUrl, 'default_backend:', this.default_backend);
328
346
  if (envMappedUrl) {
329
347
  return envMappedUrl;
330
348
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sgerp-frontend-lib",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "TypeScript/React library for interacting with the SGERP API, providing client SDK, Backbone.js-style Collections, and pre-built React components",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",