node-consul-service 1.0.38 → 1.0.40
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 +7 -4
- package/dist/index.esm.js +7 -4
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -19421,7 +19421,7 @@ async function callService(serviceName, options = {}) {
|
|
|
19421
19421
|
};
|
|
19422
19422
|
}
|
|
19423
19423
|
catch (error) {
|
|
19424
|
-
|
|
19424
|
+
return {
|
|
19425
19425
|
success: false,
|
|
19426
19426
|
message: error.message,
|
|
19427
19427
|
status: (_a = error.response) === null || _a === void 0 ? void 0 : _a.status,
|
|
@@ -19458,8 +19458,8 @@ async function dataLink(data, schema) {
|
|
|
19458
19458
|
const result = sourceData.map((item) => ({ ...item }));
|
|
19459
19459
|
await Promise.all(schema.map(async ({ filed, service, path, headers, cacheGetter }) => {
|
|
19460
19460
|
var _a;
|
|
19461
|
-
|
|
19462
|
-
|
|
19461
|
+
// ✅ Safety check + trim path
|
|
19462
|
+
if (!path || !path.trim().startsWith("/")) {
|
|
19463
19463
|
throw new DataLinkError(service, path, new Error(`Invalid path: "${path}". Path must start with "/"`));
|
|
19464
19464
|
}
|
|
19465
19465
|
const uniqueIds = Array.from(new Set(sourceData.flatMap((item) => {
|
|
@@ -19498,8 +19498,8 @@ async function dataLink(data, schema) {
|
|
|
19498
19498
|
}
|
|
19499
19499
|
});
|
|
19500
19500
|
}
|
|
19501
|
+
// ✅ Fetch missing items from service
|
|
19501
19502
|
if (idsToFetch.length > 0) {
|
|
19502
|
-
// ✅ Fetch remaining from service
|
|
19503
19503
|
try {
|
|
19504
19504
|
const response = await callService(service, {
|
|
19505
19505
|
method: "POST",
|
|
@@ -19514,6 +19514,9 @@ async function dataLink(data, schema) {
|
|
|
19514
19514
|
}
|
|
19515
19515
|
}
|
|
19516
19516
|
}
|
|
19517
|
+
if (!(response === null || response === void 0 ? void 0 : response.success)) {
|
|
19518
|
+
throw new DataLinkError(service, path, response);
|
|
19519
|
+
}
|
|
19517
19520
|
}
|
|
19518
19521
|
catch (error) {
|
|
19519
19522
|
throw new DataLinkError(service, path, error);
|
package/dist/index.esm.js
CHANGED
|
@@ -19419,7 +19419,7 @@ async function callService(serviceName, options = {}) {
|
|
|
19419
19419
|
};
|
|
19420
19420
|
}
|
|
19421
19421
|
catch (error) {
|
|
19422
|
-
|
|
19422
|
+
return {
|
|
19423
19423
|
success: false,
|
|
19424
19424
|
message: error.message,
|
|
19425
19425
|
status: (_a = error.response) === null || _a === void 0 ? void 0 : _a.status,
|
|
@@ -19456,8 +19456,8 @@ async function dataLink(data, schema) {
|
|
|
19456
19456
|
const result = sourceData.map((item) => ({ ...item }));
|
|
19457
19457
|
await Promise.all(schema.map(async ({ filed, service, path, headers, cacheGetter }) => {
|
|
19458
19458
|
var _a;
|
|
19459
|
-
|
|
19460
|
-
|
|
19459
|
+
// ✅ Safety check + trim path
|
|
19460
|
+
if (!path || !path.trim().startsWith("/")) {
|
|
19461
19461
|
throw new DataLinkError(service, path, new Error(`Invalid path: "${path}". Path must start with "/"`));
|
|
19462
19462
|
}
|
|
19463
19463
|
const uniqueIds = Array.from(new Set(sourceData.flatMap((item) => {
|
|
@@ -19496,8 +19496,8 @@ async function dataLink(data, schema) {
|
|
|
19496
19496
|
}
|
|
19497
19497
|
});
|
|
19498
19498
|
}
|
|
19499
|
+
// ✅ Fetch missing items from service
|
|
19499
19500
|
if (idsToFetch.length > 0) {
|
|
19500
|
-
// ✅ Fetch remaining from service
|
|
19501
19501
|
try {
|
|
19502
19502
|
const response = await callService(service, {
|
|
19503
19503
|
method: "POST",
|
|
@@ -19512,6 +19512,9 @@ async function dataLink(data, schema) {
|
|
|
19512
19512
|
}
|
|
19513
19513
|
}
|
|
19514
19514
|
}
|
|
19515
|
+
if (!(response === null || response === void 0 ? void 0 : response.success)) {
|
|
19516
|
+
throw new DataLinkError(service, path, response);
|
|
19517
|
+
}
|
|
19515
19518
|
}
|
|
19516
19519
|
catch (error) {
|
|
19517
19520
|
throw new DataLinkError(service, path, error);
|