node-consul-service 1.0.16 → 1.0.17

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
@@ -19422,7 +19422,7 @@ async function dataLink(data, schema) {
19422
19422
  let cacheMap = new Map();
19423
19423
  let idsToFetch = uniqueIds;
19424
19424
  if (cacheGetter) {
19425
- const cacheResults = await Promise.all(uniqueIds.map(id => cacheGetter(id)));
19425
+ const cacheResults = await Promise.all(uniqueIds.map((id) => cacheGetter(id)));
19426
19426
  idsToFetch = [];
19427
19427
  cacheResults.forEach((item, index) => {
19428
19428
  if (item) {
@@ -19433,13 +19433,24 @@ async function dataLink(data, schema) {
19433
19433
  }
19434
19434
  });
19435
19435
  }
19436
- if (idsToFetch.length > 0) {
19437
- const apiData = await callService(service, {
19438
- method: "POST",
19439
- path,
19440
- data: { ids: idsToFetch },
19441
- });
19442
- apiData.forEach((item) => cacheMap.set(item._id, item));
19436
+ if (Array.isArray(idsToFetch) && idsToFetch.length > 0) {
19437
+ try {
19438
+ const response = await callService(service, {
19439
+ method: "POST",
19440
+ path,
19441
+ data: { ids: idsToFetch },
19442
+ });
19443
+ if ((response === null || response === void 0 ? void 0 : response.success) && Array.isArray(response.data)) {
19444
+ for (const item of response.data) {
19445
+ if (item === null || item === void 0 ? void 0 : item._id) {
19446
+ cacheMap.set(item._id, item);
19447
+ }
19448
+ }
19449
+ }
19450
+ }
19451
+ catch (error) {
19452
+ console.error(`❌ Failed to fetch from ${service}${path}:`, error);
19453
+ }
19443
19454
  }
19444
19455
  for (const item of result) {
19445
19456
  if (cacheMap.has(item[filed])) {
package/dist/index.esm.js CHANGED
@@ -19420,7 +19420,7 @@ async function dataLink(data, schema) {
19420
19420
  let cacheMap = new Map();
19421
19421
  let idsToFetch = uniqueIds;
19422
19422
  if (cacheGetter) {
19423
- const cacheResults = await Promise.all(uniqueIds.map(id => cacheGetter(id)));
19423
+ const cacheResults = await Promise.all(uniqueIds.map((id) => cacheGetter(id)));
19424
19424
  idsToFetch = [];
19425
19425
  cacheResults.forEach((item, index) => {
19426
19426
  if (item) {
@@ -19431,13 +19431,24 @@ async function dataLink(data, schema) {
19431
19431
  }
19432
19432
  });
19433
19433
  }
19434
- if (idsToFetch.length > 0) {
19435
- const apiData = await callService(service, {
19436
- method: "POST",
19437
- path,
19438
- data: { ids: idsToFetch },
19439
- });
19440
- apiData.forEach((item) => cacheMap.set(item._id, item));
19434
+ if (Array.isArray(idsToFetch) && idsToFetch.length > 0) {
19435
+ try {
19436
+ const response = await callService(service, {
19437
+ method: "POST",
19438
+ path,
19439
+ data: { ids: idsToFetch },
19440
+ });
19441
+ if ((response === null || response === void 0 ? void 0 : response.success) && Array.isArray(response.data)) {
19442
+ for (const item of response.data) {
19443
+ if (item === null || item === void 0 ? void 0 : item._id) {
19444
+ cacheMap.set(item._id, item);
19445
+ }
19446
+ }
19447
+ }
19448
+ }
19449
+ catch (error) {
19450
+ console.error(`❌ Failed to fetch from ${service}${path}:`, error);
19451
+ }
19441
19452
  }
19442
19453
  for (const item of result) {
19443
19454
  if (cacheMap.has(item[filed])) {
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "node-consul-service",
3
- "version": "1.0.16",
3
+ "version": "1.0.17",
4
4
  "main": "dist/index.cjs.js",
5
5
  "module": "dist/index.esm.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "scripts": {
8
8
  "build": "rollup -c",
9
- "dev": "ts-node src/index.ts",
9
+ "dev": "rollup -c -w",
10
10
  "pub": "npm run build && npm version patch && npm publish"
11
11
  },
12
12
  "keywords": [