contentoh-components-library 21.6.19 → 21.6.21
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/.env.test +2 -1
- package/dist/components/atoms/InheritanceTag/index.js +8 -0
- package/dist/components/molecules/TagAndInput/index.js +1 -0
- package/dist/components/molecules/TagAndInputv2/index.js +1 -0
- package/dist/components/organisms/LinkVariantsModal/api.js +102 -0
- package/dist/components/organisms/LinkVariantsModal/index.js +620 -0
- package/dist/components/organisms/LinkVariantsModal/styles.js +60 -0
- package/dist/components/pages/ProviderProductEdition/context/reducers/inputs.js +8 -2
- package/dist/components/pages/ProviderProductEdition/index.js +198 -89
- package/dist/components/pages/ProviderProductEdition/styles.js +2 -2
- package/dist/components/pages/ProviderProductEdition/utils.js +8 -0
- package/dist/index.js +25 -12
- package/package.json +1 -1
- package/src/components/atoms/InheritanceTag/index.js +7 -0
- package/src/components/molecules/TagAndInput/index.js +1 -0
- package/src/components/molecules/TagAndInputv2/index.js +1 -0
- package/src/components/organisms/LinkVariantsModal/api.js +61 -0
- package/src/components/organisms/LinkVariantsModal/index.js +479 -0
- package/src/components/organisms/LinkVariantsModal/styles.js +264 -0
- package/src/components/pages/ProviderProductEdition/context/reducers/inputs.js +21 -13
- package/src/components/pages/ProviderProductEdition/index.js +76 -0
- package/src/components/pages/ProviderProductEdition/styles.js +23 -0
- package/src/components/pages/ProviderProductEdition/utils.js +8 -0
- package/src/index.js +1 -0
- package/dist/ai/prompts/attribute.prompt.js +0 -28
- package/dist/ai/prompts/description.prompt.js +0 -33
- package/dist/ai/schemas/attribute.schema.js +0 -35
- package/dist/ai/schemas/description.schema.js +0 -27
package/.env.test
CHANGED
|
@@ -18,12 +18,19 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
18
18
|
* así que es el que lleva acento y el que ofrece la acción de volver a heredar.
|
|
19
19
|
* "Heredado" es el caso normal y se mantiene discreto: si gritara en cada campo,
|
|
20
20
|
* la ficha entera se volvería ruido.
|
|
21
|
+
*
|
|
22
|
+
* Un campo VACÍO no lleva marca: no heredó nada y tampoco tiene valor propio, así
|
|
23
|
+
* que llamarlo "Heredado" es falso además de ruidoso. Sin esto la ficha de una
|
|
24
|
+
* variante sale con el chip repetido en cada campo, incluidos los obligatorios en
|
|
25
|
+
* rojo que están sin capturar, y la marca deja de distinguir nada.
|
|
21
26
|
*/
|
|
22
27
|
var InheritanceTag = function InheritanceTag(_ref) {
|
|
23
28
|
var _ref$isVariant = _ref.isVariant,
|
|
24
29
|
isVariant = _ref$isVariant === void 0 ? false : _ref$isVariant,
|
|
25
30
|
_ref$isOverridden = _ref.isOverridden,
|
|
26
31
|
isOverridden = _ref$isOverridden === void 0 ? false : _ref$isOverridden,
|
|
32
|
+
_ref$hasValue = _ref.hasValue,
|
|
33
|
+
hasValue = _ref$hasValue === void 0 ? true : _ref$hasValue,
|
|
27
34
|
parentUpc = _ref.parentUpc,
|
|
28
35
|
onRestore = _ref.onRestore,
|
|
29
36
|
_ref$restoreLabel = _ref.restoreLabel,
|
|
@@ -31,6 +38,7 @@ var InheritanceTag = function InheritanceTag(_ref) {
|
|
|
31
38
|
_ref$className = _ref.className,
|
|
32
39
|
className = _ref$className === void 0 ? "" : _ref$className;
|
|
33
40
|
if (!isVariant) return null;
|
|
41
|
+
if (!hasValue) return null;
|
|
34
42
|
var state = isOverridden ? "own" : "inherited";
|
|
35
43
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Container, {
|
|
36
44
|
className: "inheritance-tag ".concat(state, " ").concat(className),
|
|
@@ -430,6 +430,7 @@ var TagAndInput = function TagAndInput(_ref) {
|
|
|
430
430
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_InheritanceTag.InheritanceTag, {
|
|
431
431
|
isVariant: isVariant,
|
|
432
432
|
isOverridden: isOverridden,
|
|
433
|
+
hasValue: "".concat(value !== null && value !== void 0 ? value : "").trim() !== "",
|
|
433
434
|
parentUpc: parentUpc,
|
|
434
435
|
onRestore: onRestoreInheritance ? function () {
|
|
435
436
|
return onRestoreInheritance(inputId);
|
|
@@ -70,6 +70,7 @@ var TagAndInputv2 = function TagAndInputv2(_ref) {
|
|
|
70
70
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_InheritanceTag.InheritanceTag, {
|
|
71
71
|
isVariant: isVariant,
|
|
72
72
|
isOverridden: isOverridden,
|
|
73
|
+
hasValue: "".concat(value !== null && value !== void 0 ? value : "").trim() !== "",
|
|
73
74
|
parentUpc: parentUpc,
|
|
74
75
|
onRestore: onRestoreInheritance ? function () {
|
|
75
76
|
return onRestoreInheritance(inputId);
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.unwrap = exports.readPayload = exports.ApiError = void 0;
|
|
9
|
+
|
|
10
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/createClass"));
|
|
11
|
+
|
|
12
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/classCallCheck"));
|
|
13
|
+
|
|
14
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/inherits"));
|
|
15
|
+
|
|
16
|
+
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/createSuper"));
|
|
17
|
+
|
|
18
|
+
var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/wrapNativeSuper"));
|
|
19
|
+
|
|
20
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/typeof"));
|
|
21
|
+
|
|
22
|
+
/*
|
|
23
|
+
Las lambdas de este API están declaradas con `integration: lambda`, no con
|
|
24
|
+
lambda-proxy. Eso tiene dos consecuencias que se pagan caras si se ignoran:
|
|
25
|
+
|
|
26
|
+
1. La respuesta llega ENVUELTA: axios entrega { statusCode, headers, body },
|
|
27
|
+
con `body` en texto. Leer `res.data.candidates` da undefined.
|
|
28
|
+
2. El HTTP siempre es 200, incluso cuando la lambda respondió 400 o 500. Un
|
|
29
|
+
try/catch alrededor de axios NUNCA se dispara por un error de negocio: el
|
|
30
|
+
error viaja dentro del cuerpo y hay que mirar `statusCode` a mano.
|
|
31
|
+
|
|
32
|
+
El repo ya vive con esto —provider-product-edition.context.jsx hace
|
|
33
|
+
JSON.parse(res.data.body)— pero sin un lugar común cada llamada nueva vuelve a
|
|
34
|
+
tropezar. Esto lo centraliza.
|
|
35
|
+
*/
|
|
36
|
+
var unwrap = function unwrap(res) {
|
|
37
|
+
var _res$status;
|
|
38
|
+
|
|
39
|
+
var payload = res === null || res === void 0 ? void 0 : res.data;
|
|
40
|
+
var envuelto = payload && (0, _typeof2.default)(payload) === "object" && "statusCode" in payload && "body" in payload;
|
|
41
|
+
if (!envuelto) return {
|
|
42
|
+
status: (_res$status = res === null || res === void 0 ? void 0 : res.status) !== null && _res$status !== void 0 ? _res$status : 200,
|
|
43
|
+
body: payload
|
|
44
|
+
};
|
|
45
|
+
var body = typeof payload.body === "string" ? safeParse(payload.body) : payload.body;
|
|
46
|
+
return {
|
|
47
|
+
status: Number(payload.statusCode),
|
|
48
|
+
body: body
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
exports.unwrap = unwrap;
|
|
53
|
+
|
|
54
|
+
var safeParse = function safeParse(text) {
|
|
55
|
+
try {
|
|
56
|
+
return JSON.parse(text);
|
|
57
|
+
} catch (error) {
|
|
58
|
+
return {
|
|
59
|
+
message: text
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
/*
|
|
64
|
+
Error de negocio con el código estable que manda el backend
|
|
65
|
+
(VARIANT_CROSS_COMPANY, VARIANT_ALREADY_LINKED, ...). Se lanza para que el
|
|
66
|
+
llamador use un try/catch normal, aunque el transporte haya dicho 200.
|
|
67
|
+
*/
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
var ApiError = /*#__PURE__*/function (_Error) {
|
|
71
|
+
(0, _inherits2.default)(ApiError, _Error);
|
|
72
|
+
|
|
73
|
+
var _super = (0, _createSuper2.default)(ApiError);
|
|
74
|
+
|
|
75
|
+
function ApiError(code, message) {
|
|
76
|
+
var _this;
|
|
77
|
+
|
|
78
|
+
(0, _classCallCheck2.default)(this, ApiError);
|
|
79
|
+
_this = _super.call(this, message);
|
|
80
|
+
_this.name = "ApiError";
|
|
81
|
+
_this.code = code;
|
|
82
|
+
return _this;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return (0, _createClass2.default)(ApiError);
|
|
86
|
+
}( /*#__PURE__*/(0, _wrapNativeSuper2.default)(Error));
|
|
87
|
+
|
|
88
|
+
exports.ApiError = ApiError;
|
|
89
|
+
|
|
90
|
+
var readPayload = function readPayload(res) {
|
|
91
|
+
var _unwrap = unwrap(res),
|
|
92
|
+
status = _unwrap.status,
|
|
93
|
+
body = _unwrap.body;
|
|
94
|
+
|
|
95
|
+
if (status >= 400) {
|
|
96
|
+
throw new ApiError(body === null || body === void 0 ? void 0 : body.code, (body === null || body === void 0 ? void 0 : body.message) || "La operación falló.");
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return body !== null && body !== void 0 ? body : {};
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
exports.readPayload = readPayload;
|