node-consul-service 1.0.27 → 1.0.28
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 +5 -3
- package/dist/index.esm.js +5 -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,12 @@ 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
|
+
const result = [...sourceData];
|
|
19441
19443
|
await Promise.all(schema.map(async ({ filed, service, path, headers, cacheGetter }) => {
|
|
19442
19444
|
var _a;
|
|
19443
|
-
const uniqueIds = Array.from(new Set(
|
|
19445
|
+
const uniqueIds = Array.from(new Set(sourceData.flatMap(item => {
|
|
19444
19446
|
const value = item[filed];
|
|
19445
19447
|
if (typeof value === "string" ||
|
|
19446
19448
|
(value && typeof value === "object" && typeof value.toString === "function")) {
|
|
@@ -19509,7 +19511,7 @@ async function dataLink(data, schema) {
|
|
|
19509
19511
|
}
|
|
19510
19512
|
}
|
|
19511
19513
|
}));
|
|
19512
|
-
return result;
|
|
19514
|
+
return isArray ? result : result[0];
|
|
19513
19515
|
}
|
|
19514
19516
|
|
|
19515
19517
|
exports.callService = callService;
|
package/dist/index.esm.js
CHANGED
|
@@ -19435,10 +19435,12 @@ 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
|
+
const result = [...sourceData];
|
|
19439
19441
|
await Promise.all(schema.map(async ({ filed, service, path, headers, cacheGetter }) => {
|
|
19440
19442
|
var _a;
|
|
19441
|
-
const uniqueIds = Array.from(new Set(
|
|
19443
|
+
const uniqueIds = Array.from(new Set(sourceData.flatMap(item => {
|
|
19442
19444
|
const value = item[filed];
|
|
19443
19445
|
if (typeof value === "string" ||
|
|
19444
19446
|
(value && typeof value === "object" && typeof value.toString === "function")) {
|
|
@@ -19507,7 +19509,7 @@ async function dataLink(data, schema) {
|
|
|
19507
19509
|
}
|
|
19508
19510
|
}
|
|
19509
19511
|
}));
|
|
19510
|
-
return result;
|
|
19512
|
+
return isArray ? result : result[0];
|
|
19511
19513
|
}
|
|
19512
19514
|
|
|
19513
19515
|
export { callService, dataLink, deregisterService, getRandomServiceInstance, getServiceInstances, getServiceUrl, listServices, registerService };
|