@asteby/metacore-runtime-react 29.2.15 → 30.0.0
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/CHANGELOG.md +13 -0
- package/dist/dialogs/import.d.ts.map +1 -1
- package/dist/dialogs/import.js +38 -4
- package/package.json +3 -3
- package/src/dialogs/import.tsx +36 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @asteby/metacore-runtime-react
|
|
2
2
|
|
|
3
|
+
## 30.0.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [30fe202]
|
|
8
|
+
- @asteby/metacore-ui@2.14.0
|
|
9
|
+
|
|
10
|
+
## 29.2.16
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- f46d82e: Fix `ImportDialog` swallowing the real per-row error report when the backend answers a validate/import failure with a non-2xx status (e.g. 422). Previously any non-2xx response fell into a generic "Error al importar los datos" / "Error al validar el archivo" toast, discarding the `data.failures`/`data.errors` detail the backend had already computed. Now the dialog renders that report when present, and only falls back to the generic toast when the response carries no usable payload.
|
|
15
|
+
|
|
3
16
|
## 29.2.15
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import.d.ts","sourceRoot":"","sources":["../../src/dialogs/import.tsx"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAG7C,UAAU,iBAAiB;IACvB,IAAI,EAAE,OAAO,CAAA;IACb,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;IACrC,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,aAAa,CAAA;IACvB,UAAU,CAAC,EAAE,MAAM,IAAI,CAAA;CAC1B;AAqCD,wBAAgB,YAAY,CAAC,EACzB,IAAI,EACJ,YAAY,EACZ,KAAK,EACL,QAAQ,EACR,UAAU,GACb,EAAE,iBAAiB,+
|
|
1
|
+
{"version":3,"file":"import.d.ts","sourceRoot":"","sources":["../../src/dialogs/import.tsx"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAG7C,UAAU,iBAAiB;IACvB,IAAI,EAAE,OAAO,CAAA;IACb,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;IACrC,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,aAAa,CAAA;IACvB,UAAU,CAAC,EAAE,MAAM,IAAI,CAAA;CAC1B;AAqCD,wBAAgB,YAAY,CAAC,EACzB,IAAI,EACJ,YAAY,EACZ,KAAK,EACL,QAAQ,EACR,UAAU,GACb,EAAE,iBAAiB,+BAgYnB"}
|
package/dist/dialogs/import.js
CHANGED
|
@@ -82,8 +82,23 @@ export function ImportDialog({ open, onOpenChange, model, metadata, onImported,
|
|
|
82
82
|
setStep('validation');
|
|
83
83
|
}
|
|
84
84
|
catch (err) {
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
// Backends may answer a validation failure with a non-2xx status
|
|
86
|
+
// (e.g. 422) while still carrying the real per-row report in the
|
|
87
|
+
// body. Render it instead of a body-less "something went wrong"
|
|
88
|
+
// toast whenever that shape is present.
|
|
89
|
+
const body = err?.response?.data;
|
|
90
|
+
const payload = body?.data ?? body;
|
|
91
|
+
if (payload && (Array.isArray(payload.errors) || typeof payload.rowCount === 'number' || typeof payload.valid === 'number')) {
|
|
92
|
+
setValidationResult({
|
|
93
|
+
valid: payload.rowCount ?? payload.valid ?? 0,
|
|
94
|
+
skipped: payload.skipped ?? 0,
|
|
95
|
+
errors: payload.errors ?? [],
|
|
96
|
+
});
|
|
97
|
+
setStep('validation');
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
toast.error(body?.message || 'Error al validar el archivo');
|
|
101
|
+
}
|
|
87
102
|
}
|
|
88
103
|
finally {
|
|
89
104
|
setValidating(false);
|
|
@@ -117,8 +132,27 @@ export function ImportDialog({ open, onOpenChange, model, metadata, onImported,
|
|
|
117
132
|
}
|
|
118
133
|
}
|
|
119
134
|
catch (err) {
|
|
120
|
-
|
|
121
|
-
|
|
135
|
+
// A partial or total import failure is still a real, displayable
|
|
136
|
+
// result — the backend computes per-row reasons in `data.failures`
|
|
137
|
+
// even when it answers with a non-2xx status (e.g. 422 when zero
|
|
138
|
+
// rows were created). Show that report instead of discarding it
|
|
139
|
+
// behind a generic toast.
|
|
140
|
+
const body = err?.response?.data;
|
|
141
|
+
const payload = body?.data ?? body;
|
|
142
|
+
if (payload && (Array.isArray(payload.failures) || Array.isArray(payload.errors) || typeof payload.created === 'number')) {
|
|
143
|
+
setImportResult({
|
|
144
|
+
created: payload.created ?? 0,
|
|
145
|
+
skipped: payload.skipped ?? 0,
|
|
146
|
+
errors: payload.failures ?? payload.errors ?? [],
|
|
147
|
+
});
|
|
148
|
+
setStep('results');
|
|
149
|
+
if ((payload.created ?? 0) > 0) {
|
|
150
|
+
onImported?.();
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
toast.error(body?.message || 'Error al importar los datos');
|
|
155
|
+
}
|
|
122
156
|
}
|
|
123
157
|
finally {
|
|
124
158
|
setImporting(false);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asteby/metacore-runtime-react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "30.0.0",
|
|
4
4
|
"description": "React runtime for metacore hosts — renders addon contributions dynamically",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"sonner": ">=1.7",
|
|
39
39
|
"zustand": ">=5",
|
|
40
40
|
"@asteby/metacore-sdk": "^3.4.0",
|
|
41
|
-
"@asteby/metacore-ui": "^2.
|
|
41
|
+
"@asteby/metacore-ui": "^2.14.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependenciesMeta": {
|
|
44
44
|
"@tanstack/react-router": {
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"vitest": "^4.0.0",
|
|
69
69
|
"zustand": "^5.0.0",
|
|
70
70
|
"@asteby/metacore-sdk": "3.4.0",
|
|
71
|
-
"@asteby/metacore-ui": "2.
|
|
71
|
+
"@asteby/metacore-ui": "2.14.0"
|
|
72
72
|
},
|
|
73
73
|
"scripts": {
|
|
74
74
|
"build": "tsc -p tsconfig.json",
|
package/src/dialogs/import.tsx
CHANGED
|
@@ -146,9 +146,22 @@ export function ImportDialog({
|
|
|
146
146
|
})
|
|
147
147
|
setStep('validation')
|
|
148
148
|
} catch (err: any) {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
149
|
+
// Backends may answer a validation failure with a non-2xx status
|
|
150
|
+
// (e.g. 422) while still carrying the real per-row report in the
|
|
151
|
+
// body. Render it instead of a body-less "something went wrong"
|
|
152
|
+
// toast whenever that shape is present.
|
|
153
|
+
const body = err?.response?.data
|
|
154
|
+
const payload = body?.data ?? body
|
|
155
|
+
if (payload && (Array.isArray(payload.errors) || typeof payload.rowCount === 'number' || typeof payload.valid === 'number')) {
|
|
156
|
+
setValidationResult({
|
|
157
|
+
valid: payload.rowCount ?? payload.valid ?? 0,
|
|
158
|
+
skipped: payload.skipped ?? 0,
|
|
159
|
+
errors: payload.errors ?? [],
|
|
160
|
+
})
|
|
161
|
+
setStep('validation')
|
|
162
|
+
} else {
|
|
163
|
+
toast.error(body?.message || 'Error al validar el archivo')
|
|
164
|
+
}
|
|
152
165
|
} finally {
|
|
153
166
|
setValidating(false)
|
|
154
167
|
}
|
|
@@ -187,9 +200,26 @@ export function ImportDialog({
|
|
|
187
200
|
onImported?.()
|
|
188
201
|
}
|
|
189
202
|
} catch (err: any) {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
203
|
+
// A partial or total import failure is still a real, displayable
|
|
204
|
+
// result — the backend computes per-row reasons in `data.failures`
|
|
205
|
+
// even when it answers with a non-2xx status (e.g. 422 when zero
|
|
206
|
+
// rows were created). Show that report instead of discarding it
|
|
207
|
+
// behind a generic toast.
|
|
208
|
+
const body = err?.response?.data
|
|
209
|
+
const payload = body?.data ?? body
|
|
210
|
+
if (payload && (Array.isArray(payload.failures) || Array.isArray(payload.errors) || typeof payload.created === 'number')) {
|
|
211
|
+
setImportResult({
|
|
212
|
+
created: payload.created ?? 0,
|
|
213
|
+
skipped: payload.skipped ?? 0,
|
|
214
|
+
errors: payload.failures ?? payload.errors ?? [],
|
|
215
|
+
})
|
|
216
|
+
setStep('results')
|
|
217
|
+
if ((payload.created ?? 0) > 0) {
|
|
218
|
+
onImported?.()
|
|
219
|
+
}
|
|
220
|
+
} else {
|
|
221
|
+
toast.error(body?.message || 'Error al importar los datos')
|
|
222
|
+
}
|
|
193
223
|
} finally {
|
|
194
224
|
setImporting(false)
|
|
195
225
|
setProgress(0)
|