node-consul-service 1.0.27 → 1.0.29

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,5 +6,5 @@ interface LinkSchema {
6
6
  headers?: AxiosRequestHeaders;
7
7
  cacheGetter?: (ids: string[]) => Promise<(any | null)[]>;
8
8
  }
9
- export declare function dataLink(data: any[], schema: LinkSchema[]): Promise<any[]>;
9
+ export declare function dataLink(data: any[] | any, schema: LinkSchema[]): Promise<any[] | any>;
10
10
  export {};
package/dist/index.cjs.js CHANGED
@@ -19437,10 +19437,13 @@ function normalizeId(id) {
19437
19437
  return id;
19438
19438
  }
19439
19439
  async function dataLink(data, schema) {
19440
- const result = [...data];
19440
+ const isArray = Array.isArray(data);
19441
+ const sourceData = isArray ? data : [data];
19442
+ // ✅ ننسخ كل عنصر بدون التأثير على الأصل
19443
+ const result = sourceData.map(item => ({ ...item }));
19441
19444
  await Promise.all(schema.map(async ({ filed, service, path, headers, cacheGetter }) => {
19442
19445
  var _a;
19443
- const uniqueIds = Array.from(new Set(data.flatMap(item => {
19446
+ const uniqueIds = Array.from(new Set(sourceData.flatMap(item => {
19444
19447
  const value = item[filed];
19445
19448
  if (typeof value === "string" ||
19446
19449
  (value && typeof value === "object" && typeof value.toString === "function")) {
@@ -19509,7 +19512,7 @@ async function dataLink(data, schema) {
19509
19512
  }
19510
19513
  }
19511
19514
  }));
19512
- return result;
19515
+ return isArray ? result : result[0];
19513
19516
  }
19514
19517
 
19515
19518
  exports.callService = callService;
package/dist/index.esm.js CHANGED
@@ -19435,10 +19435,13 @@ function normalizeId(id) {
19435
19435
  return id;
19436
19436
  }
19437
19437
  async function dataLink(data, schema) {
19438
- const result = [...data];
19438
+ const isArray = Array.isArray(data);
19439
+ const sourceData = isArray ? data : [data];
19440
+ // ✅ ننسخ كل عنصر بدون التأثير على الأصل
19441
+ const result = sourceData.map(item => ({ ...item }));
19439
19442
  await Promise.all(schema.map(async ({ filed, service, path, headers, cacheGetter }) => {
19440
19443
  var _a;
19441
- const uniqueIds = Array.from(new Set(data.flatMap(item => {
19444
+ const uniqueIds = Array.from(new Set(sourceData.flatMap(item => {
19442
19445
  const value = item[filed];
19443
19446
  if (typeof value === "string" ||
19444
19447
  (value && typeof value === "object" && typeof value.toString === "function")) {
@@ -19507,7 +19510,7 @@ async function dataLink(data, schema) {
19507
19510
  }
19508
19511
  }
19509
19512
  }));
19510
- return result;
19513
+ return isArray ? result : result[0];
19511
19514
  }
19512
19515
 
19513
19516
  export { callService, dataLink, deregisterService, getRandomServiceInstance, getServiceInstances, getServiceUrl, listServices, registerService };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-consul-service",
3
- "version": "1.0.27",
3
+ "version": "1.0.29",
4
4
  "main": "dist/index.cjs.js",
5
5
  "module": "dist/index.esm.js",
6
6
  "types": "dist/index.d.ts",