node-consul-service 1.0.61 → 1.0.63
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 +10 -0
- package/dist/index.esm.js +10 -0
- package/dist/utils/hasValueAtPath.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -19062,6 +19062,10 @@ function getValueByPath(obj, path) {
|
|
|
19062
19062
|
return path.split(".").reduce((acc, key) => acc === null || acc === void 0 ? void 0 : acc[key], obj);
|
|
19063
19063
|
}
|
|
19064
19064
|
|
|
19065
|
+
function hasValueAtPath(obj, path) {
|
|
19066
|
+
return getValueByPath(obj, path) !== undefined;
|
|
19067
|
+
}
|
|
19068
|
+
|
|
19065
19069
|
function normalizeId(id) {
|
|
19066
19070
|
if (id && typeof id === "object" && typeof id.toString === "function") {
|
|
19067
19071
|
return id.toString();
|
|
@@ -19082,6 +19086,9 @@ function setValueByPath(obj, path, value) {
|
|
|
19082
19086
|
}
|
|
19083
19087
|
|
|
19084
19088
|
function applyResolvedValues(item, field, cacheMap) {
|
|
19089
|
+
// لو القيمة مش موجودة أصلاً، ما نعملش أي حاجة
|
|
19090
|
+
if (!hasValueAtPath(item, field))
|
|
19091
|
+
return;
|
|
19085
19092
|
const value = getValueByPath(item, field);
|
|
19086
19093
|
// ✅ تجاهل الحقول غير الموجودة أو الفارغة تمامًا
|
|
19087
19094
|
if (value === undefined || value === null)
|
|
@@ -19187,7 +19194,9 @@ async function getCachedAndUncachedItems(ids, cacheGetter) {
|
|
|
19187
19194
|
async function dataLink(data, schema) {
|
|
19188
19195
|
const isArray = Array.isArray(data);
|
|
19189
19196
|
const sourceData = isArray ? data : [data];
|
|
19197
|
+
console.log("🚀 ~ dataLink ~ sourceData:", sourceData);
|
|
19190
19198
|
const result = sourceData.map((item) => ({ ...item }));
|
|
19199
|
+
console.log("🚀 ~ dataLink ~ result:", result);
|
|
19191
19200
|
for (const { field, service, path, headers, cacheGetter } of schema) {
|
|
19192
19201
|
const allIds = Array.from(new Set(sourceData.flatMap((item) => extractIdsFromField(item, field))));
|
|
19193
19202
|
if (allIds.length === 0)
|
|
@@ -19201,6 +19210,7 @@ async function dataLink(data, schema) {
|
|
|
19201
19210
|
}
|
|
19202
19211
|
}
|
|
19203
19212
|
}
|
|
19213
|
+
console.log("🚀 ~ dataLink ~ result:", result);
|
|
19204
19214
|
for (const item of result) {
|
|
19205
19215
|
applyResolvedValues(item, field, cacheMap);
|
|
19206
19216
|
}
|
package/dist/index.esm.js
CHANGED
|
@@ -19060,6 +19060,10 @@ function getValueByPath(obj, path) {
|
|
|
19060
19060
|
return path.split(".").reduce((acc, key) => acc === null || acc === void 0 ? void 0 : acc[key], obj);
|
|
19061
19061
|
}
|
|
19062
19062
|
|
|
19063
|
+
function hasValueAtPath(obj, path) {
|
|
19064
|
+
return getValueByPath(obj, path) !== undefined;
|
|
19065
|
+
}
|
|
19066
|
+
|
|
19063
19067
|
function normalizeId(id) {
|
|
19064
19068
|
if (id && typeof id === "object" && typeof id.toString === "function") {
|
|
19065
19069
|
return id.toString();
|
|
@@ -19080,6 +19084,9 @@ function setValueByPath(obj, path, value) {
|
|
|
19080
19084
|
}
|
|
19081
19085
|
|
|
19082
19086
|
function applyResolvedValues(item, field, cacheMap) {
|
|
19087
|
+
// لو القيمة مش موجودة أصلاً، ما نعملش أي حاجة
|
|
19088
|
+
if (!hasValueAtPath(item, field))
|
|
19089
|
+
return;
|
|
19083
19090
|
const value = getValueByPath(item, field);
|
|
19084
19091
|
// ✅ تجاهل الحقول غير الموجودة أو الفارغة تمامًا
|
|
19085
19092
|
if (value === undefined || value === null)
|
|
@@ -19185,7 +19192,9 @@ async function getCachedAndUncachedItems(ids, cacheGetter) {
|
|
|
19185
19192
|
async function dataLink(data, schema) {
|
|
19186
19193
|
const isArray = Array.isArray(data);
|
|
19187
19194
|
const sourceData = isArray ? data : [data];
|
|
19195
|
+
console.log("🚀 ~ dataLink ~ sourceData:", sourceData);
|
|
19188
19196
|
const result = sourceData.map((item) => ({ ...item }));
|
|
19197
|
+
console.log("🚀 ~ dataLink ~ result:", result);
|
|
19189
19198
|
for (const { field, service, path, headers, cacheGetter } of schema) {
|
|
19190
19199
|
const allIds = Array.from(new Set(sourceData.flatMap((item) => extractIdsFromField(item, field))));
|
|
19191
19200
|
if (allIds.length === 0)
|
|
@@ -19199,6 +19208,7 @@ async function dataLink(data, schema) {
|
|
|
19199
19208
|
}
|
|
19200
19209
|
}
|
|
19201
19210
|
}
|
|
19211
|
+
console.log("🚀 ~ dataLink ~ result:", result);
|
|
19202
19212
|
for (const item of result) {
|
|
19203
19213
|
applyResolvedValues(item, field, cacheMap);
|
|
19204
19214
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function hasValueAtPath(obj: any, path: string): boolean;
|