pangea-server 3.3.73 → 3.3.75

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.
@@ -55,57 +55,49 @@ 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] data recibida:', JSON.stringify(data, null, 2));
58
+ console.log('[setFilesUrls] Iniciando setFilesUrls...');
59
59
  const singularSuffixes = ['Image', 'Video'];
60
60
  const pluralSuffixes = ['Images', 'Videos'];
61
61
  const entries = [];
62
62
  const visited = new WeakSet();
63
63
  function collect(node) {
64
- if (!node) {
65
- console.log('[setFilesUrls] collect: node es falsy, salteando');
64
+ if (!node)
66
65
  return;
67
- }
66
+ if (typeof node !== 'object')
67
+ return;
68
+ if (visited.has(node))
69
+ return;
70
+ visited.add(node);
68
71
  if (Array.isArray(node)) {
69
- console.log('[setFilesUrls] collect: node es array con', node.length, 'elementos');
70
72
  node.forEach(collect);
71
73
  return;
72
74
  }
73
- if (typeof node !== 'object') {
74
- console.log('[setFilesUrls] collect: node no es object, es', typeof node);
75
- return;
75
+ const payload = node.dataValues ? node.dataValues : node;
76
+ if (payload !== node) {
77
+ if (visited.has(payload))
78
+ return;
79
+ visited.add(payload);
76
80
  }
77
- if (visited.has(node))
78
- return;
79
- visited.add(node);
80
- console.log('[setFilesUrls] collect: analizando objeto con keys:', Object.keys(node));
81
- for (const [key, value] of Object.entries(node)) {
82
- const valueType = Array.isArray(value) ? 'array' : typeof value;
83
- console.log(`[setFilesUrls] key="${key}" valueType=${valueType} value=`, Array.isArray(value) ? `[${value.length} items]` : typeof value === 'string' ? `"${value.substring(0, 50)}"` : value);
81
+ for (const [key, value] of Object.entries(payload)) {
84
82
  if (typeof value === 'string' && value.length) {
85
- const matchSingular = singularSuffixes.find((s) => key === s.toLowerCase() || (key.length > s.length && key.endsWith(s)));
86
- console.log(`[setFilesUrls] -> string check: matchSingular=${matchSingular || 'none'}`);
87
- if (matchSingular) {
88
- entries.push({ node, field: key, type: 'singular' });
89
- console.log(`[setFilesUrls] -> MATCH SINGULAR: field="${key}"`);
83
+ if (singularSuffixes.some((s) => key === s.toLowerCase() || (key.length > s.length && key.endsWith(s)))) {
84
+ entries.push({ node: payload, field: key, type: 'singular' });
90
85
  }
91
86
  }
92
- else if (Array.isArray(value) && value.length && value.every((v) => typeof v === 'string')) {
93
- const matchPlural = pluralSuffixes.find((s) => key === s.toLowerCase() || (key.length > s.length && key.endsWith(s)));
94
- console.log(`[setFilesUrls] -> string[] check: matchPlural=${matchPlural || 'none'}`);
95
- if (matchPlural) {
96
- entries.push({ node, field: key, type: 'plural' });
97
- console.log(`[setFilesUrls] -> MATCH PLURAL: field="${key}"`);
87
+ else if (Array.isArray(value) && value.every((v) => typeof v === 'string')) {
88
+ if (pluralSuffixes.some((s) => key === s.toLowerCase() || (key.length > s.length && key.endsWith(s)))) {
89
+ entries.push({ node: payload, field: key, type: 'plural' });
98
90
  }
99
91
  }
92
+ if (typeof value === 'object' && value !== null) {
93
+ collect(value);
94
+ }
100
95
  }
101
- Object.values(node).forEach(collect);
102
96
  }
103
97
  collect(data);
104
- console.log('[setFilesUrls] entries encontrados:', entries.map((e) => ({ field: e.field, type: e.type })));
105
- if (!entries.length) {
106
- console.log('[setFilesUrls] No hay entries, saliendo');
98
+ console.log(`[setFilesUrls] Entries encontrados: ${entries.length}`, entries.map((e) => e.field));
99
+ if (!entries.length)
107
100
  return;
108
- }
109
101
  const allFileKeys = new Set();
110
102
  for (const { node, field, type } of entries) {
111
103
  if (type === 'singular') {
@@ -117,20 +109,16 @@ async function setFilesUrls(data) {
117
109
  }
118
110
  }
119
111
  const uniqueKeys = Array.from(allFileKeys);
120
- console.log('[setFilesUrls] uniqueKeys:', uniqueKeys);
121
112
  const urls = await Promise.all(uniqueKeys.map((key) => helpers_1.FileStorage.GenerateDownloadUrl(key)));
122
- console.log('[setFilesUrls] urls generadas:', urls);
123
113
  const urlMap = new Map();
124
114
  uniqueKeys.forEach((key, i) => urlMap.set(key, urls[i]));
125
115
  for (const { node, field, type } of entries) {
126
116
  if (type === 'singular') {
127
117
  node[`${field}Url`] = urlMap.get(node[field]);
128
- console.log(`[setFilesUrls] asignado ${field}Url =`, node[`${field}Url`]);
129
118
  }
130
119
  else {
131
120
  node[`${field}Urls`] = node[field].map((v) => urlMap.get(v));
132
- console.log(`[setFilesUrls] asignado ${field}Urls =`, node[`${field}Urls`]);
133
121
  }
134
122
  }
135
- console.log('[setFilesUrls] FIN');
123
+ console.log(`[setFilesUrls] URLs asignadas exitosamente`);
136
124
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pangea-server",
3
3
  "description": "",
4
- "version": "3.3.73",
4
+ "version": "3.3.75",
5
5
  "files": [
6
6
  "dist"
7
7
  ],