pangea-server 3.3.75 → 3.3.76
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/router/call-controller.js +13 -10
- package/package.json +1 -1
|
@@ -55,11 +55,16 @@ function hasInstancesAndTotalCount(obj) {
|
|
|
55
55
|
return typeof obj === 'object' && obj !== null && 'instances' in obj && 'totalCount' in obj;
|
|
56
56
|
}
|
|
57
57
|
async function setFilesUrls(data) {
|
|
58
|
-
console.log('[setFilesUrls] Iniciando setFilesUrls...');
|
|
59
|
-
const singularSuffixes = ['Image', 'Video'];
|
|
60
|
-
const pluralSuffixes = ['Images', 'Videos'];
|
|
61
58
|
const entries = [];
|
|
62
59
|
const visited = new WeakSet();
|
|
60
|
+
function matchesSingular(key) {
|
|
61
|
+
const k = key.toLowerCase();
|
|
62
|
+
return k === 'image' || k === 'video' || k.endsWith('image') || k.endsWith('video');
|
|
63
|
+
}
|
|
64
|
+
function matchesPlural(key) {
|
|
65
|
+
const k = key.toLowerCase();
|
|
66
|
+
return k === 'images' || k === 'videos' || k.endsWith('images') || k.endsWith('videos');
|
|
67
|
+
}
|
|
63
68
|
function collect(node) {
|
|
64
69
|
if (!node)
|
|
65
70
|
return;
|
|
@@ -79,13 +84,13 @@ async function setFilesUrls(data) {
|
|
|
79
84
|
visited.add(payload);
|
|
80
85
|
}
|
|
81
86
|
for (const [key, value] of Object.entries(payload)) {
|
|
82
|
-
if (typeof value === 'string' && value.length) {
|
|
83
|
-
if (
|
|
87
|
+
if (typeof value === 'string' && value.length > 0) {
|
|
88
|
+
if (matchesSingular(key)) {
|
|
84
89
|
entries.push({ node: payload, field: key, type: 'singular' });
|
|
85
90
|
}
|
|
86
91
|
}
|
|
87
92
|
else if (Array.isArray(value) && value.every((v) => typeof v === 'string')) {
|
|
88
|
-
if (
|
|
93
|
+
if (matchesPlural(key)) {
|
|
89
94
|
entries.push({ node: payload, field: key, type: 'plural' });
|
|
90
95
|
}
|
|
91
96
|
}
|
|
@@ -95,7 +100,6 @@ async function setFilesUrls(data) {
|
|
|
95
100
|
}
|
|
96
101
|
}
|
|
97
102
|
collect(data);
|
|
98
|
-
console.log(`[setFilesUrls] Entries encontrados: ${entries.length}`, entries.map((e) => e.field));
|
|
99
103
|
if (!entries.length)
|
|
100
104
|
return;
|
|
101
105
|
const allFileKeys = new Set();
|
|
@@ -114,11 +118,10 @@ async function setFilesUrls(data) {
|
|
|
114
118
|
uniqueKeys.forEach((key, i) => urlMap.set(key, urls[i]));
|
|
115
119
|
for (const { node, field, type } of entries) {
|
|
116
120
|
if (type === 'singular') {
|
|
117
|
-
node[`${field}Url`] = urlMap.get(node[field]);
|
|
121
|
+
node[`${field}Url`] = urlMap.get(node[field]) || null;
|
|
118
122
|
}
|
|
119
123
|
else {
|
|
120
|
-
node[`${field}Urls`] = node[field].map((v) => urlMap.get(v));
|
|
124
|
+
node[`${field}Urls`] = node[field].map((v) => urlMap.get(v) || null);
|
|
121
125
|
}
|
|
122
126
|
}
|
|
123
|
-
console.log(`[setFilesUrls] URLs asignadas exitosamente`);
|
|
124
127
|
}
|