node-consul-service 1.0.29 → 1.0.31

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/dist/index.cjs.js CHANGED
@@ -19421,7 +19421,7 @@ async function callService(serviceName, options = {}) {
19421
19421
  };
19422
19422
  }
19423
19423
  catch (error) {
19424
- return {
19424
+ throw {
19425
19425
  success: false,
19426
19426
  message: error.message,
19427
19427
  status: (_a = error.response) === null || _a === void 0 ? void 0 : _a.status,
@@ -19440,20 +19440,24 @@ async function dataLink(data, schema) {
19440
19440
  const isArray = Array.isArray(data);
19441
19441
  const sourceData = isArray ? data : [data];
19442
19442
  // ✅ ننسخ كل عنصر بدون التأثير على الأصل
19443
- const result = sourceData.map(item => ({ ...item }));
19443
+ const result = sourceData.map((item) => ({ ...item }));
19444
19444
  await Promise.all(schema.map(async ({ filed, service, path, headers, cacheGetter }) => {
19445
19445
  var _a;
19446
- const uniqueIds = Array.from(new Set(sourceData.flatMap(item => {
19446
+ const uniqueIds = Array.from(new Set(sourceData.flatMap((item) => {
19447
19447
  const value = item[filed];
19448
19448
  if (typeof value === "string" ||
19449
- (value && typeof value === "object" && typeof value.toString === "function")) {
19449
+ (value &&
19450
+ typeof value === "object" &&
19451
+ typeof value.toString === "function")) {
19450
19452
  return [normalizeId(value)];
19451
19453
  }
19452
19454
  if (Array.isArray(value)) {
19453
19455
  return value
19454
- .filter(v => typeof v === "string" ||
19455
- (v && typeof v === "object" && typeof v.toString === "function"))
19456
- .map(v => normalizeId(v));
19456
+ .filter((v) => typeof v === "string" ||
19457
+ (v &&
19458
+ typeof v === "object" &&
19459
+ typeof v.toString === "function"))
19460
+ .map((v) => normalizeId(v));
19457
19461
  }
19458
19462
  return [];
19459
19463
  })));
@@ -19491,20 +19495,22 @@ async function dataLink(data, schema) {
19491
19495
  }
19492
19496
  }
19493
19497
  catch (error) {
19494
- console.error(`❌ Failed to fetch from ${service}${path}:`, error);
19498
+ throw error;
19495
19499
  }
19496
19500
  }
19497
19501
  for (const item of result) {
19498
19502
  const value = item[filed];
19499
19503
  if (typeof value === "string" ||
19500
- (value && typeof value === "object" && typeof value.toString === "function")) {
19504
+ (value &&
19505
+ typeof value === "object" &&
19506
+ typeof value.toString === "function")) {
19501
19507
  const key = normalizeId(value);
19502
19508
  if (cacheMap.has(key)) {
19503
19509
  item[filed] = cacheMap.get(key);
19504
19510
  }
19505
19511
  }
19506
19512
  else if (Array.isArray(value)) {
19507
- item[filed] = value.map(id => {
19513
+ item[filed] = value.map((id) => {
19508
19514
  var _a;
19509
19515
  const key = normalizeId(id);
19510
19516
  return (_a = cacheMap.get(key)) !== null && _a !== void 0 ? _a : id;
package/dist/index.esm.js CHANGED
@@ -19419,7 +19419,7 @@ async function callService(serviceName, options = {}) {
19419
19419
  };
19420
19420
  }
19421
19421
  catch (error) {
19422
- return {
19422
+ throw {
19423
19423
  success: false,
19424
19424
  message: error.message,
19425
19425
  status: (_a = error.response) === null || _a === void 0 ? void 0 : _a.status,
@@ -19438,20 +19438,24 @@ async function dataLink(data, schema) {
19438
19438
  const isArray = Array.isArray(data);
19439
19439
  const sourceData = isArray ? data : [data];
19440
19440
  // ✅ ننسخ كل عنصر بدون التأثير على الأصل
19441
- const result = sourceData.map(item => ({ ...item }));
19441
+ const result = sourceData.map((item) => ({ ...item }));
19442
19442
  await Promise.all(schema.map(async ({ filed, service, path, headers, cacheGetter }) => {
19443
19443
  var _a;
19444
- const uniqueIds = Array.from(new Set(sourceData.flatMap(item => {
19444
+ const uniqueIds = Array.from(new Set(sourceData.flatMap((item) => {
19445
19445
  const value = item[filed];
19446
19446
  if (typeof value === "string" ||
19447
- (value && typeof value === "object" && typeof value.toString === "function")) {
19447
+ (value &&
19448
+ typeof value === "object" &&
19449
+ typeof value.toString === "function")) {
19448
19450
  return [normalizeId(value)];
19449
19451
  }
19450
19452
  if (Array.isArray(value)) {
19451
19453
  return value
19452
- .filter(v => typeof v === "string" ||
19453
- (v && typeof v === "object" && typeof v.toString === "function"))
19454
- .map(v => normalizeId(v));
19454
+ .filter((v) => typeof v === "string" ||
19455
+ (v &&
19456
+ typeof v === "object" &&
19457
+ typeof v.toString === "function"))
19458
+ .map((v) => normalizeId(v));
19455
19459
  }
19456
19460
  return [];
19457
19461
  })));
@@ -19489,20 +19493,22 @@ async function dataLink(data, schema) {
19489
19493
  }
19490
19494
  }
19491
19495
  catch (error) {
19492
- console.error(`❌ Failed to fetch from ${service}${path}:`, error);
19496
+ throw error;
19493
19497
  }
19494
19498
  }
19495
19499
  for (const item of result) {
19496
19500
  const value = item[filed];
19497
19501
  if (typeof value === "string" ||
19498
- (value && typeof value === "object" && typeof value.toString === "function")) {
19502
+ (value &&
19503
+ typeof value === "object" &&
19504
+ typeof value.toString === "function")) {
19499
19505
  const key = normalizeId(value);
19500
19506
  if (cacheMap.has(key)) {
19501
19507
  item[filed] = cacheMap.get(key);
19502
19508
  }
19503
19509
  }
19504
19510
  else if (Array.isArray(value)) {
19505
- item[filed] = value.map(id => {
19511
+ item[filed] = value.map((id) => {
19506
19512
  var _a;
19507
19513
  const key = normalizeId(id);
19508
19514
  return (_a = cacheMap.get(key)) !== null && _a !== void 0 ? _a : id;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-consul-service",
3
- "version": "1.0.29",
3
+ "version": "1.0.31",
4
4
  "main": "dist/index.cjs.js",
5
5
  "module": "dist/index.esm.js",
6
6
  "types": "dist/index.d.ts",