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.
- package/dist/consul/dataLink.d.ts +1 -1
- package/dist/index.cjs.js +6 -3
- package/dist/index.esm.js +6 -3
- package/package.json +1 -1
|
@@ -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
|
|
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(
|
|
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
|
|
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(
|
|
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 };
|