@asteby/metacore-runtime-react 53.15.0 → 53.16.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 +6 -0
- package/dist/setup/addon-config-surface.d.ts +7 -0
- package/dist/setup/addon-config-surface.d.ts.map +1 -1
- package/dist/setup/addon-config-surface.js +36 -3
- package/dist/setup/messages.d.ts.map +1 -1
- package/dist/setup/messages.js +16 -0
- package/dist/slots/addon-slot.d.ts +9 -0
- package/dist/slots/addon-slot.d.ts.map +1 -1
- package/dist/slots/addon-slot.js +6 -2
- package/package.json +1 -1
- package/src/__tests__/addon-config-surface.test.tsx +27 -0
- package/src/__tests__/addon-slot.test.tsx +19 -0
- package/src/setup/addon-config-surface.tsx +79 -2
- package/src/setup/messages.ts +16 -0
- package/src/slots/addon-slot.tsx +17 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @asteby/metacore-runtime-react
|
|
2
2
|
|
|
3
|
+
## 53.16.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 97aaf79: AddonConfigSurface: una credencial de conector con `auto` (generada por el host) ya no se pide; la superficie muestra "Conectada automáticamente" / "Clave manual vigente" / "Requiere acción" y un botón Rotar que muestra la clave nueva una sola vez (`POST /integrations/:provider/auto/:key/rotate`). Sin `auto` nada cambia.
|
|
8
|
+
|
|
3
9
|
## 53.15.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
|
@@ -45,6 +45,11 @@ export interface ConnectorCredentialField {
|
|
|
45
45
|
/** Shown only while a sibling credential has this value (kernel Setting.visible_when). */
|
|
46
46
|
visible_when?: VisibleWhen;
|
|
47
47
|
visibleWhen?: VisibleWhen;
|
|
48
|
+
/**
|
|
49
|
+
* Kernel Setting.auto: the HOST generates this secret (e.g. "storefront_bearer"),
|
|
50
|
+
* so the form never asks for it; the surface shows its state and "Rotar".
|
|
51
|
+
*/
|
|
52
|
+
auto?: string;
|
|
48
53
|
}
|
|
49
54
|
export interface ConnectorFormLayoutSection {
|
|
50
55
|
key: string;
|
|
@@ -71,6 +76,8 @@ export interface ConnectorEntry {
|
|
|
71
76
|
status?: string;
|
|
72
77
|
resources?: string[];
|
|
73
78
|
credentials?: ConnectorCredentialField[];
|
|
79
|
+
/** State of each host-generated credential: generated | manual | missing. */
|
|
80
|
+
auto_credentials?: Record<string, 'generated' | 'manual' | 'missing' | string>;
|
|
74
81
|
form_layout?: ConnectorFormLayout;
|
|
75
82
|
test_export?: string;
|
|
76
83
|
sync_endpoint?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addon-config-surface.d.ts","sourceRoot":"","sources":["../../src/setup/addon-config-surface.tsx"],"names":[],"mappings":"AAsCA,OAAO,EAAU,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAEvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAI3C,OAAO,EAOL,KAAK,kBAAkB,EACxB,MAAM,0BAA0B,CAAA;AAWjC,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,OAAO,CAAC,EAAE;QAAE,KAAK,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;IAC7C,+EAA+E;IAC/E,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,oEAAoE;IACpE,YAAY,CAAC,EAAE,WAAW,CAAA;IAC1B,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,8DAA8D;IAC9D,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,4DAA4D;IAC5D,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAA;IACjB,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AO,KAAK,IAAI,CAAA;IACrC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,oFAAoF;IACpF,YAAY,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAA;IACnD,4EAA4E;IAC5E,iBAAiB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,KAAK,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAChF,+BAA+B;IAC/B,MAAM,CAAC,EAAE,mBAAmB,CAAA;IAC5B,uCAAuC;IACvC,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC5C,oEAAoE;IACpE,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;;OAIG;IACH,cAAc,CAAC,EAAE,CAAC,SAAS,EAAE,cAAc,KAAK,IAAI,CAAA;CACrD;AAmQD,6EAA6E;AAC7E,wBAAgB,yBAAyB,SAExC;AA0JD,wBAAgB,kBAAkB,CAAC,EACjC,KAAK,EACL,SAAS,EACT,IAAI,EACJ,YAAY,EACZ,OAAO,EACP,eAAsB,EACtB,gBAAwB,EACxB,YAAmB,EACnB,iBAAiB,EACjB,MAAc,EACd,MAAM,EACN,mBAAqC,EACrC,WAAW,EACX,cAAc,GACf,EAAE,uBAAuB,+BA6pCzB"}
|
|
@@ -235,7 +235,32 @@ export function AddonConfigSurface({ addon, connector, open, onOpenChange, onSav
|
|
|
235
235
|
if (!open)
|
|
236
236
|
clearConnectorLookupCache();
|
|
237
237
|
}, [open]);
|
|
238
|
-
const
|
|
238
|
+
const allCredFields = connector?.credentials ?? [];
|
|
239
|
+
// Host-generated credentials (auto) are never asked from a person.
|
|
240
|
+
const credFields = allCredFields.filter((f) => !f.auto);
|
|
241
|
+
const autoFields = allCredFields.filter((f) => !!f.auto);
|
|
242
|
+
const [autoState, setAutoState] = useState({});
|
|
243
|
+
const [revealedOnce, setRevealedOnce] = useState({});
|
|
244
|
+
const [rotating, setRotating] = useState(null);
|
|
245
|
+
const autoStateOf = (k) => autoState[k] ?? connector?.auto_credentials?.[k] ?? 'missing';
|
|
246
|
+
const rotateAuto = async (k) => {
|
|
247
|
+
if (!connector)
|
|
248
|
+
return;
|
|
249
|
+
setRotating(k);
|
|
250
|
+
try {
|
|
251
|
+
const res = await api.post(`/integrations/${connector.provider}/auto/${k}/rotate`, {});
|
|
252
|
+
const value = res?.data?.data?.value;
|
|
253
|
+
setAutoState((prev) => ({ ...prev, [k]: 'generated' }));
|
|
254
|
+
if (value)
|
|
255
|
+
setRevealedOnce((prev) => ({ ...prev, [k]: value }));
|
|
256
|
+
}
|
|
257
|
+
catch {
|
|
258
|
+
toast.error(st('auto.rotate_failed'));
|
|
259
|
+
}
|
|
260
|
+
finally {
|
|
261
|
+
setRotating(null);
|
|
262
|
+
}
|
|
263
|
+
};
|
|
239
264
|
// A connector with a form_layout groups its credentials into titled sections
|
|
240
265
|
// (a light wizard). Fall back to the required/advanced split when absent.
|
|
241
266
|
const layoutSections = connector?.form_layout?.sections ?? [];
|
|
@@ -842,7 +867,7 @@ export function AddonConfigSurface({ addon, connector, open, onOpenChange, onSav
|
|
|
842
867
|
? 'saved'
|
|
843
868
|
: 'clean';
|
|
844
869
|
const hasAnyBlocks = layoutSections.some((s) => (s.blocks?.length ?? 0) > 0) || extraBlocks.length > 0;
|
|
845
|
-
const nothingToConfigure = !hasCredentials && !hasSettings && !isOAuth && !hasAnyBlocks;
|
|
870
|
+
const nothingToConfigure = !hasCredentials && !hasSettings && !isOAuth && !hasAnyBlocks && autoFields.length === 0;
|
|
846
871
|
const nothingToSave = !hasCredentials && !hasSettings;
|
|
847
872
|
return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsx(DialogContent, { className: 'flex max-h-[85vh] flex-col max-sm:max-h-[calc(100dvh-1rem)] max-sm:gap-3 max-sm:p-4', children: _jsxs(ConnectorFormStateContext.Provider, { value: { fields: credFields, errors: fieldErrors, idPrefix, client: api, expectedOptionKinds, reloadNonce }, children: [_jsxs(DialogHeader, { className: 'shrink-0 pe-8 text-start', children: [_jsx(DialogTitle, { className: 'leading-snug', children: st('installed_addons.configure_title', { name: displayName ?? addon.manifest.display_name ?? addon.manifest.name }) }), _jsx(DialogDescription, { children: st('installed_addons.configure_description') })] }), _jsx("div", { className: '-mr-2 flex min-h-0 flex-col gap-6 overflow-y-auto py-2 pr-2', children: loading ? (_jsx("div", { className: 'flex justify-center py-8', children: _jsx(Loader2, { className: 'h-5 w-5 animate-spin text-muted-foreground' }) })) : useStepper ? (_jsxs("div", { className: 'flex flex-col gap-5', children: [_jsxs("nav", { "aria-label": st('wizard.steps'), className: 'flex flex-col gap-2', children: [_jsx("ol", { className: 'flex items-center', children: wizardSteps.map((s, i) => {
|
|
848
873
|
const status = stepState(i);
|
|
@@ -862,7 +887,15 @@ export function AddonConfigSurface({ addon, connector, open, onOpenChange, onSav
|
|
|
862
887
|
: 'border-border text-muted-foreground'), children: !active && status === 'error' ? (_jsx(AlertCircle, { className: 'h-4 w-4' })) : !active && status === 'ok' ? (_jsx(Check, { className: 'h-4 w-4' })) : (i + 1) }) }), i < wizardSteps.length - 1 && (_jsx("span", { "aria-hidden": 'true', className: cn('mx-1 h-0.5 flex-1 rounded-full transition-colors', i < stepIdx ? 'bg-primary' : 'bg-border') }))] }, s.key));
|
|
863
888
|
}) }), _jsxs("div", { className: 'flex items-start justify-between gap-3', children: [_jsx("h3", { ref: stepHeadingRef, tabIndex: -1, className: 'min-w-0 text-base leading-snug font-semibold break-words outline-none', children: t(activeStep?.title ?? '', {
|
|
864
889
|
defaultValue: humanizeKey(activeStep?.title),
|
|
865
|
-
}) }), _jsx("span", { className: 'mt-0.5 shrink-0 text-xs font-medium tabular-nums text-muted-foreground', children: st('flow.step_of', { n: stepIdx + 1, total: totalSteps }) })] })] }), _jsxs("div", { className: 'flex flex-col gap-4', children: [activeStep?.description && (_jsx(HelpText, { text: addonText(activeStep.description) })), activeStep?.kind === 'settings' ? (settingsBody) : !canManageIssuer ? (_jsxs(_Fragment, { children: [issuerAdminNote, renderBlocks(blocksFor(activeStep?.key ?? '', activeStep?.blocks))] })) : (_jsxs(_Fragment, { children: [renderBlocks(leadBlocks(blocksFor(activeStep?.key ?? '', activeStep?.blocks))), activeFields.filter((f) => f.section === activeStep?.key).map(renderCred), renderBlocks(trailBlocks(blocksFor(activeStep?.key ?? '', activeStep?.blocks)))] }))] })] })) : (_jsxs(_Fragment, { children: [oauthPanel,
|
|
890
|
+
}) }), _jsx("span", { className: 'mt-0.5 shrink-0 text-xs font-medium tabular-nums text-muted-foreground', children: st('flow.step_of', { n: stepIdx + 1, total: totalSteps }) })] })] }), _jsxs("div", { className: 'flex flex-col gap-4', children: [activeStep?.description && (_jsx(HelpText, { text: addonText(activeStep.description) })), activeStep?.kind === 'settings' ? (settingsBody) : !canManageIssuer ? (_jsxs(_Fragment, { children: [issuerAdminNote, renderBlocks(blocksFor(activeStep?.key ?? '', activeStep?.blocks))] })) : (_jsxs(_Fragment, { children: [renderBlocks(leadBlocks(blocksFor(activeStep?.key ?? '', activeStep?.blocks))), activeFields.filter((f) => f.section === activeStep?.key).map(renderCred), renderBlocks(trailBlocks(blocksFor(activeStep?.key ?? '', activeStep?.blocks)))] }))] })] })) : (_jsxs(_Fragment, { children: [oauthPanel, autoFields.length > 0 && (_jsx("section", { className: 'flex flex-col gap-3', "data-testid": 'auto-credentials', children: autoFields.map((f) => {
|
|
891
|
+
const state = autoStateOf(f.key);
|
|
892
|
+
const once = revealedOnce[f.key];
|
|
893
|
+
return (_jsxs("div", { className: 'flex flex-col gap-2 rounded-md border border-border/60 px-3 py-3', children: [_jsxs("div", { className: 'flex items-center justify-between gap-2', children: [_jsxs("div", { className: 'flex flex-col gap-1', children: [_jsx("span", { className: 'text-sm font-medium', children: state === 'missing'
|
|
894
|
+
? st('auto.needs_action')
|
|
895
|
+
: state === 'manual'
|
|
896
|
+
? st('auto.manual')
|
|
897
|
+
: st('auto.connected') }), _jsx(HelpText, { text: st('auto.help') })] }), _jsxs(Button, { type: 'button', variant: 'outline', size: 'sm', disabled: rotating === f.key || !canManageIssuer, onClick: () => void rotateAuto(f.key), children: [rotating === f.key ? (_jsx(Loader2, { className: 'h-4 w-4 animate-spin' })) : (_jsx(RefreshCw, { className: 'h-4 w-4' })), state === 'missing' ? st('auto.generate') : st('auto.rotate')] })] }), once && (_jsxs("div", { className: 'flex flex-col gap-1', children: [_jsx("code", { className: 'break-all rounded bg-muted px-2 py-1 text-xs', children: once }), _jsx(HelpText, { text: st('auto.show_once') })] }))] }, f.key));
|
|
898
|
+
}) })), hasCredentials && (_jsxs("section", { className: 'flex flex-col gap-3', children: [_jsxs("div", { className: 'flex items-center gap-2', children: [_jsx(Cable, { className: 'h-4 w-4 text-muted-foreground' }), _jsx("h3", { className: 'text-sm font-semibold', children: st('installed_addons.section_credentials') })] }), !canManageIssuer ? (issuerAdminNote) : useLayout ? (
|
|
866
899
|
// form_layout: one titled group per section, in declared order.
|
|
867
900
|
activeSections.map((sec) => {
|
|
868
901
|
const fields = activeFields.filter((f) => f.section === sec.key);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/setup/messages.ts"],"names":[],"mappings":"AAMA,KAAK,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAElC,eAAO,MAAM,iBAAiB,EAAE,
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/setup/messages.ts"],"names":[],"mappings":"AAMA,KAAK,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAElC,eAAO,MAAM,iBAAiB,EAAE,IAmK/B,CAAA;AAED,eAAO,MAAM,iBAAiB,EAAE,IAgK/B,CAAA;AAED,MAAM,MAAM,GAAG,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,MAAM,CAAA;AAOzE,8EAA8E;AAC9E,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAGjE;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,IAAI,GAAG,CAa/B"}
|
package/dist/setup/messages.js
CHANGED
|
@@ -106,6 +106,14 @@ export const SETUP_MESSAGES_ES = {
|
|
|
106
106
|
'oauth.help': 'Este addon se conecta con tu cuenta del proveedor. Te llevamos a su página para autorizarlo.',
|
|
107
107
|
'oauth.connect': 'Conectar cuenta',
|
|
108
108
|
'oauth.reconnect': 'Volver a conectar',
|
|
109
|
+
'auto.connected': 'Conectada automáticamente',
|
|
110
|
+
'auto.manual': 'Clave manual vigente',
|
|
111
|
+
'auto.needs_action': 'Requiere acción',
|
|
112
|
+
'auto.help': 'La clave la genera y guarda el sistema, cifrada. No hay nada que inventar ni pegar.',
|
|
113
|
+
'auto.rotate': 'Rotar',
|
|
114
|
+
'auto.generate': 'Generar',
|
|
115
|
+
'auto.show_once': 'Cópiala ahora: no se vuelve a mostrar. La anterior ya no funciona.',
|
|
116
|
+
'auto.rotate_failed': 'No se pudo rotar la clave',
|
|
109
117
|
'empty.title': 'Nada que configurar',
|
|
110
118
|
'empty.help': 'Este addon funciona sin configuración. Si necesitas cambiar algo, revisa su documentación o abre el addon.',
|
|
111
119
|
// AddonConfigSurface (same keys the ops host already ships)
|
|
@@ -264,6 +272,14 @@ export const SETUP_MESSAGES_EN = {
|
|
|
264
272
|
'installed_addons.configure_title': 'Configure {{name}}',
|
|
265
273
|
'installed_addons.configure_description': 'Credentials and settings for this addon.',
|
|
266
274
|
'installed_addons.section_credentials': 'Credentials',
|
|
275
|
+
'auto.connected': 'Connected automatically',
|
|
276
|
+
'auto.manual': 'Manual key in use',
|
|
277
|
+
'auto.needs_action': 'Action required',
|
|
278
|
+
'auto.help': 'The system generates and stores the key, encrypted. Nothing to invent or paste.',
|
|
279
|
+
'auto.rotate': 'Rotate',
|
|
280
|
+
'auto.generate': 'Generate',
|
|
281
|
+
'auto.show_once': 'Copy it now: it is not shown again. The previous one no longer works.',
|
|
282
|
+
'auto.rotate_failed': 'Could not rotate the key',
|
|
267
283
|
'installed_addons.section_settings': 'Settings',
|
|
268
284
|
'installed_addons.advanced': 'Advanced',
|
|
269
285
|
'installed_addons.no_settings': 'This addon has nothing to configure.',
|
|
@@ -40,6 +40,11 @@ export interface AddonSlotContribution {
|
|
|
40
40
|
order?: number;
|
|
41
41
|
props?: Record<string, unknown>;
|
|
42
42
|
timeout_ms?: number;
|
|
43
|
+
/**
|
|
44
|
+
* Qué se ve si esta contribución falla (manifest v3 `slots[].fallback`): `hide` (por omisión)
|
|
45
|
+
* usa el `fallback` del host (nada si no hay); `notice` pinta un aviso discreto en su lugar.
|
|
46
|
+
*/
|
|
47
|
+
fallback?: 'hide' | 'notice';
|
|
43
48
|
}
|
|
44
49
|
/** Lo que recibe el componente del remoto además de `context` y `props`. */
|
|
45
50
|
export interface AddonSlotSDK {
|
|
@@ -82,6 +87,10 @@ export interface AddonSlotProps {
|
|
|
82
87
|
/** Qué se pinta cuando el slot no tiene ninguna contribución (por omisión nada). */
|
|
83
88
|
empty?: ReactNode;
|
|
84
89
|
}
|
|
90
|
+
/** Aviso de `fallback: "notice"`: sin detalles internos del error. */
|
|
91
|
+
export declare function SlotFailureNotice({ failure }: {
|
|
92
|
+
failure: AddonSlotFailure;
|
|
93
|
+
}): React.JSX.Element;
|
|
85
94
|
/** Orden canónico: `order` ascendente, luego `priority` descendente, luego inserción. */
|
|
86
95
|
export declare function sortSlotItems<T extends {
|
|
87
96
|
order: number;
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9B,SAAS,EACT,UAAU,EACV,gBAAwB,EACxB,SAAyC,EACzC,OAAO,EACP,QAAQ,GACX,EAAE,sBAAsB,qBAcxB;AAED,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACjC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,2EAA2E;IAC3E,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,OAAO,CAAC,EAAE,qBAAqB,CAAA;IAC/B,iDAAiD;IACjD,OAAO,CAAC,EAAE,SAAS,CAAA;IACnB,gFAAgF;IAChF,QAAQ,CAAC,EAAE,SAAS,GAAG,CAAC,CAAC,OAAO,EAAE,gBAAgB,KAAK,SAAS,CAAC,CAAA;IACjE,oFAAoF;IACpF,KAAK,CAAC,EAAE,SAAS,CAAA;CACpB;AAcD,sEAAsE;AACtE,wBAAgB,iBAAiB,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,gBAAgB,CAAA;CAAE,qBAM3E;AAID,yFAAyF;AACzF,wBAAgB,aAAa,CAAC,CAAC,SAAS;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,GAAG,CAAC,EAAE,CAKrG;AAkKD,wBAAgB,SAAS,CAAC,EACtB,IAAI,EACJ,OAAO,EACP,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,OAAO,EACP,OAAc,EACd,QAAe,EACf,KAAY,GACf,EAAE,cAAc,qBAyFhB"}
|
package/dist/slots/addon-slot.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
// AddonSlot — punto de montaje de contribuciones de addons en un host.
|
|
3
3
|
//
|
|
4
4
|
// <AddonSlot kind="invoice.footer" context={{ invoiceId }} />
|
|
@@ -53,6 +53,10 @@ export function AddonSlotProvider({ manifests, sdkVersion, requireIntegrity = fa
|
|
|
53
53
|
}), [manifests, sdkVersion, requireIntegrity, timeoutMs]);
|
|
54
54
|
return _jsx(Ctx.Provider, { value: value, children: children });
|
|
55
55
|
}
|
|
56
|
+
/** Aviso de `fallback: "notice"`: sin detalles internos del error. */
|
|
57
|
+
export function SlotFailureNotice({ failure }) {
|
|
58
|
+
return (_jsxs("div", { role: "status", "data-addon-slot-notice": failure.addon, "data-reason": failure.reason, children: ["No se pudo cargar este m\u00F3dulo (", failure.addon, ")."] }));
|
|
59
|
+
}
|
|
56
60
|
const EMPTY_OBJ = Object.freeze({});
|
|
57
61
|
/** Orden canónico: `order` ascendente, luego `priority` descendente, luego inserción. */
|
|
58
62
|
export function sortSlotItems(items) {
|
|
@@ -215,5 +219,5 @@ export function AddonSlot({ kind, context, className, timeoutMs, requireIntegrit
|
|
|
215
219
|
const renderFallback = (f) => typeof fallback === 'function' ? fallback(f) : fallback;
|
|
216
220
|
if (items.length === 0)
|
|
217
221
|
return _jsx(_Fragment, { children: empty });
|
|
218
|
-
return (_jsx("div", { "data-addon-slot": kind, className: className, style: className ? undefined : { display: 'contents' }, children: items.map((item) => (_jsx("div", { "data-addon-slot-item": item.addon, style: { display: 'contents' }, children: item.type === 'remote' ? (_jsx(RemoteItem, { kind: kind, item: item, context: ctx, cfg: cfg, requireIntegrity: effRequire, timeoutMs: effTimeout, loading: loading, renderFallback: renderFallback, report: report })) : (_jsx(RenderGuard, { addon: item.addon, kind: kind, renderFallback: renderFallback, report: report, children: _jsx(item.entry.component, { ...ctx, context: ctx, props: EMPTY_OBJ, sdk: { addon: item.addon, kind, sdkVersion: cfg?.sdkVersion } }) })) }, item.id))) }));
|
|
222
|
+
return (_jsx("div", { "data-addon-slot": kind, className: className, style: className ? undefined : { display: 'contents' }, children: items.map((item) => (_jsx("div", { "data-addon-slot-item": item.addon, style: { display: 'contents' }, children: item.type === 'remote' ? (_jsx(RemoteItem, { kind: kind, item: item, context: ctx, cfg: cfg, requireIntegrity: effRequire, timeoutMs: effTimeout, loading: loading, renderFallback: item.slot.fallback === 'notice' ? (f) => _jsx(SlotFailureNotice, { failure: f }) : renderFallback, report: report })) : (_jsx(RenderGuard, { addon: item.addon, kind: kind, renderFallback: renderFallback, report: report, children: _jsx(item.entry.component, { ...ctx, context: ctx, props: EMPTY_OBJ, sdk: { addon: item.addon, kind, sdkVersion: cfg?.sdkVersion } }) })) }, item.id))) }));
|
|
219
223
|
}
|
package/package.json
CHANGED
|
@@ -325,3 +325,30 @@ describe('AddonConfigSurface', () => {
|
|
|
325
325
|
expect(screen.queryByText('Serie N1')).toBeNull()
|
|
326
326
|
})
|
|
327
327
|
})
|
|
328
|
+
|
|
329
|
+
describe('host-generated (auto) credentials', () => {
|
|
330
|
+
const autoConnector: ConnectorEntry = {
|
|
331
|
+
addon_key: 'pay',
|
|
332
|
+
provider: 'local_reviews',
|
|
333
|
+
connected: true,
|
|
334
|
+
credentials: [{ key: 'api_key', type: 'secret', required: true, auto: 'storefront_bearer', label: 'pay.token' }],
|
|
335
|
+
auto_credentials: { api_key: 'generated' },
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
it('hides the field, shows the state and rotates showing the value once', async () => {
|
|
339
|
+
const { calls } = setup(
|
|
340
|
+
{ connector: autoConnector },
|
|
341
|
+
{ 'POST /integrations/local_reviews/auto/api_key/rotate': { data: { value: 'mcs_NEWSECRET' } } },
|
|
342
|
+
)
|
|
343
|
+
expect(await screen.findByText('Conectada automáticamente')).toBeTruthy()
|
|
344
|
+
expect(screen.queryByLabelText(/Token/)).toBeNull()
|
|
345
|
+
fireEvent.click(screen.getByText('Rotar'))
|
|
346
|
+
await waitFor(() => expect(screen.getByText('mcs_NEWSECRET')).toBeTruthy())
|
|
347
|
+
expect(calls.some((c) => c.m === 'POST' && c.url === '/integrations/local_reviews/auto/api_key/rotate')).toBe(true)
|
|
348
|
+
})
|
|
349
|
+
|
|
350
|
+
it('asks for action when it was never generated', async () => {
|
|
351
|
+
setup({ connector: { ...autoConnector, auto_credentials: { api_key: 'missing' } } })
|
|
352
|
+
expect(await screen.findByText('Requiere acción')).toBeTruthy()
|
|
353
|
+
})
|
|
354
|
+
})
|
|
@@ -115,6 +115,25 @@ describe('AddonSlot', () => {
|
|
|
115
115
|
expect(onEvent).toHaveBeenCalledWith('addon_slot_failed', expect.objectContaining({ addon: 'bad', reason: 'load' }))
|
|
116
116
|
})
|
|
117
117
|
|
|
118
|
+
it('slots[].fallback=notice pinta el aviso del SDK; hide conserva el fallback del host', async () => {
|
|
119
|
+
mf.loadRemote.mockImplementation(async (id: string) => {
|
|
120
|
+
if (id.endsWith('bad') || id.endsWith('quiet')) throw new Error('404 expose')
|
|
121
|
+
return remote('ok')
|
|
122
|
+
})
|
|
123
|
+
const withFallback = (key: string, fb: 'hide' | 'notice'): AddonSlotManifest => {
|
|
124
|
+
const m = manifest(key)
|
|
125
|
+
m.contributions!.slots![0].fallback = fb
|
|
126
|
+
return m
|
|
127
|
+
}
|
|
128
|
+
render(<Shell manifests={[withFallback('bad', 'notice'), withFallback('quiet', 'hide'), manifest('ok')]} />)
|
|
129
|
+
await screen.findByTestId('remote-ok')
|
|
130
|
+
const notice = await screen.findByRole('status')
|
|
131
|
+
expect(notice.getAttribute('data-addon-slot-notice')).toBe('bad')
|
|
132
|
+
expect(notice.textContent).not.toContain('404')
|
|
133
|
+
expect(screen.queryByTestId('fb-bad')).toBeNull()
|
|
134
|
+
expect(screen.getByTestId('fb-quiet')).toBeTruthy()
|
|
135
|
+
})
|
|
136
|
+
|
|
118
137
|
it('un remoto colgado muestra el fallback tras timeoutMs y el hermano sí pinta', async () => {
|
|
119
138
|
vi.useFakeTimers()
|
|
120
139
|
mf.loadRemote.mockImplementation((id: string) =>
|
|
@@ -101,6 +101,11 @@ export interface ConnectorCredentialField {
|
|
|
101
101
|
/** Shown only while a sibling credential has this value (kernel Setting.visible_when). */
|
|
102
102
|
visible_when?: VisibleWhen
|
|
103
103
|
visibleWhen?: VisibleWhen
|
|
104
|
+
/**
|
|
105
|
+
* Kernel Setting.auto: the HOST generates this secret (e.g. "storefront_bearer"),
|
|
106
|
+
* so the form never asks for it; the surface shows its state and "Rotar".
|
|
107
|
+
*/
|
|
108
|
+
auto?: string
|
|
104
109
|
}
|
|
105
110
|
|
|
106
111
|
export interface ConnectorFormLayoutSection {
|
|
@@ -129,6 +134,8 @@ export interface ConnectorEntry {
|
|
|
129
134
|
status?: string
|
|
130
135
|
resources?: string[]
|
|
131
136
|
credentials?: ConnectorCredentialField[]
|
|
137
|
+
/** State of each host-generated credential: generated | manual | missing. */
|
|
138
|
+
auto_credentials?: Record<string, 'generated' | 'manual' | 'missing' | string>
|
|
132
139
|
form_layout?: ConnectorFormLayout
|
|
133
140
|
test_export?: string
|
|
134
141
|
// ops-native connectors (e.g. `hub`) expose a route "Sincronizar ahora" POSTs to.
|
|
@@ -629,7 +636,28 @@ export function AddonConfigSurface({
|
|
|
629
636
|
if (!open) clearConnectorLookupCache()
|
|
630
637
|
}, [open])
|
|
631
638
|
|
|
632
|
-
const
|
|
639
|
+
const allCredFields = connector?.credentials ?? []
|
|
640
|
+
// Host-generated credentials (auto) are never asked from a person.
|
|
641
|
+
const credFields = allCredFields.filter((f) => !f.auto)
|
|
642
|
+
const autoFields = allCredFields.filter((f) => !!f.auto)
|
|
643
|
+
const [autoState, setAutoState] = useState<Record<string, string>>({})
|
|
644
|
+
const [revealedOnce, setRevealedOnce] = useState<Record<string, string>>({})
|
|
645
|
+
const [rotating, setRotating] = useState<string | null>(null)
|
|
646
|
+
const autoStateOf = (k: string) => autoState[k] ?? connector?.auto_credentials?.[k] ?? 'missing'
|
|
647
|
+
const rotateAuto = async (k: string) => {
|
|
648
|
+
if (!connector) return
|
|
649
|
+
setRotating(k)
|
|
650
|
+
try {
|
|
651
|
+
const res = await api.post(`/integrations/${connector.provider}/auto/${k}/rotate`, {})
|
|
652
|
+
const value = (res as { data?: { data?: { value?: string } } })?.data?.data?.value
|
|
653
|
+
setAutoState((prev) => ({ ...prev, [k]: 'generated' }))
|
|
654
|
+
if (value) setRevealedOnce((prev) => ({ ...prev, [k]: value }))
|
|
655
|
+
} catch {
|
|
656
|
+
toast.error(st('auto.rotate_failed'))
|
|
657
|
+
} finally {
|
|
658
|
+
setRotating(null)
|
|
659
|
+
}
|
|
660
|
+
}
|
|
633
661
|
// A connector with a form_layout groups its credentials into titled sections
|
|
634
662
|
// (a light wizard). Fall back to the required/advanced split when absent.
|
|
635
663
|
const layoutSections = connector?.form_layout?.sections ?? []
|
|
@@ -1411,7 +1439,8 @@ export function AddonConfigSurface({
|
|
|
1411
1439
|
: 'clean'
|
|
1412
1440
|
|
|
1413
1441
|
const hasAnyBlocks = layoutSections.some((s) => (s.blocks?.length ?? 0) > 0) || extraBlocks.length > 0
|
|
1414
|
-
const nothingToConfigure =
|
|
1442
|
+
const nothingToConfigure =
|
|
1443
|
+
!hasCredentials && !hasSettings && !isOAuth && !hasAnyBlocks && autoFields.length === 0
|
|
1415
1444
|
const nothingToSave = !hasCredentials && !hasSettings
|
|
1416
1445
|
|
|
1417
1446
|
return (
|
|
@@ -1537,6 +1566,54 @@ export function AddonConfigSurface({
|
|
|
1537
1566
|
) : (
|
|
1538
1567
|
<>
|
|
1539
1568
|
{oauthPanel}
|
|
1569
|
+
{/* Credenciales generadas por el host: estado + Rotar, nunca un campo */}
|
|
1570
|
+
{autoFields.length > 0 && (
|
|
1571
|
+
<section className='flex flex-col gap-3' data-testid='auto-credentials'>
|
|
1572
|
+
{autoFields.map((f) => {
|
|
1573
|
+
const state = autoStateOf(f.key)
|
|
1574
|
+
const once = revealedOnce[f.key]
|
|
1575
|
+
return (
|
|
1576
|
+
<div
|
|
1577
|
+
key={f.key}
|
|
1578
|
+
className='flex flex-col gap-2 rounded-md border border-border/60 px-3 py-3'
|
|
1579
|
+
>
|
|
1580
|
+
<div className='flex items-center justify-between gap-2'>
|
|
1581
|
+
<div className='flex flex-col gap-1'>
|
|
1582
|
+
<span className='text-sm font-medium'>
|
|
1583
|
+
{state === 'missing'
|
|
1584
|
+
? st('auto.needs_action')
|
|
1585
|
+
: state === 'manual'
|
|
1586
|
+
? st('auto.manual')
|
|
1587
|
+
: st('auto.connected')}
|
|
1588
|
+
</span>
|
|
1589
|
+
<HelpText text={st('auto.help')} />
|
|
1590
|
+
</div>
|
|
1591
|
+
<Button
|
|
1592
|
+
type='button'
|
|
1593
|
+
variant='outline'
|
|
1594
|
+
size='sm'
|
|
1595
|
+
disabled={rotating === f.key || !canManageIssuer}
|
|
1596
|
+
onClick={() => void rotateAuto(f.key)}
|
|
1597
|
+
>
|
|
1598
|
+
{rotating === f.key ? (
|
|
1599
|
+
<Loader2 className='h-4 w-4 animate-spin' />
|
|
1600
|
+
) : (
|
|
1601
|
+
<RefreshCw className='h-4 w-4' />
|
|
1602
|
+
)}
|
|
1603
|
+
{state === 'missing' ? st('auto.generate') : st('auto.rotate')}
|
|
1604
|
+
</Button>
|
|
1605
|
+
</div>
|
|
1606
|
+
{once && (
|
|
1607
|
+
<div className='flex flex-col gap-1'>
|
|
1608
|
+
<code className='break-all rounded bg-muted px-2 py-1 text-xs'>{once}</code>
|
|
1609
|
+
<HelpText text={st('auto.show_once')} />
|
|
1610
|
+
</div>
|
|
1611
|
+
)}
|
|
1612
|
+
</div>
|
|
1613
|
+
)
|
|
1614
|
+
})}
|
|
1615
|
+
</section>
|
|
1616
|
+
)}
|
|
1540
1617
|
{/* Credenciales */}
|
|
1541
1618
|
{hasCredentials && (
|
|
1542
1619
|
<section className='flex flex-col gap-3'>
|
package/src/setup/messages.ts
CHANGED
|
@@ -109,6 +109,14 @@ export const SETUP_MESSAGES_ES: Dict = {
|
|
|
109
109
|
'oauth.help': 'Este addon se conecta con tu cuenta del proveedor. Te llevamos a su página para autorizarlo.',
|
|
110
110
|
'oauth.connect': 'Conectar cuenta',
|
|
111
111
|
'oauth.reconnect': 'Volver a conectar',
|
|
112
|
+
'auto.connected': 'Conectada automáticamente',
|
|
113
|
+
'auto.manual': 'Clave manual vigente',
|
|
114
|
+
'auto.needs_action': 'Requiere acción',
|
|
115
|
+
'auto.help': 'La clave la genera y guarda el sistema, cifrada. No hay nada que inventar ni pegar.',
|
|
116
|
+
'auto.rotate': 'Rotar',
|
|
117
|
+
'auto.generate': 'Generar',
|
|
118
|
+
'auto.show_once': 'Cópiala ahora: no se vuelve a mostrar. La anterior ya no funciona.',
|
|
119
|
+
'auto.rotate_failed': 'No se pudo rotar la clave',
|
|
112
120
|
'empty.title': 'Nada que configurar',
|
|
113
121
|
'empty.help': 'Este addon funciona sin configuración. Si necesitas cambiar algo, revisa su documentación o abre el addon.',
|
|
114
122
|
// AddonConfigSurface (same keys the ops host already ships)
|
|
@@ -270,6 +278,14 @@ export const SETUP_MESSAGES_EN: Dict = {
|
|
|
270
278
|
'installed_addons.configure_title': 'Configure {{name}}',
|
|
271
279
|
'installed_addons.configure_description': 'Credentials and settings for this addon.',
|
|
272
280
|
'installed_addons.section_credentials': 'Credentials',
|
|
281
|
+
'auto.connected': 'Connected automatically',
|
|
282
|
+
'auto.manual': 'Manual key in use',
|
|
283
|
+
'auto.needs_action': 'Action required',
|
|
284
|
+
'auto.help': 'The system generates and stores the key, encrypted. Nothing to invent or paste.',
|
|
285
|
+
'auto.rotate': 'Rotate',
|
|
286
|
+
'auto.generate': 'Generate',
|
|
287
|
+
'auto.show_once': 'Copy it now: it is not shown again. The previous one no longer works.',
|
|
288
|
+
'auto.rotate_failed': 'Could not rotate the key',
|
|
273
289
|
'installed_addons.section_settings': 'Settings',
|
|
274
290
|
'installed_addons.advanced': 'Advanced',
|
|
275
291
|
'installed_addons.no_settings': 'This addon has nothing to configure.',
|
package/src/slots/addon-slot.tsx
CHANGED
|
@@ -91,6 +91,11 @@ export interface AddonSlotContribution {
|
|
|
91
91
|
order?: number
|
|
92
92
|
props?: Record<string, unknown>
|
|
93
93
|
timeout_ms?: number
|
|
94
|
+
/**
|
|
95
|
+
* Qué se ve si esta contribución falla (manifest v3 `slots[].fallback`): `hide` (por omisión)
|
|
96
|
+
* usa el `fallback` del host (nada si no hay); `notice` pinta un aviso discreto en su lugar.
|
|
97
|
+
*/
|
|
98
|
+
fallback?: 'hide' | 'notice'
|
|
94
99
|
}
|
|
95
100
|
|
|
96
101
|
/** Lo que recibe el componente del remoto además de `context` y `props`. */
|
|
@@ -182,6 +187,15 @@ type RemoteItem_ = {
|
|
|
182
187
|
type LocalItem_ = { type: 'local'; id: string; addon: string; order: number; priority: number; entry: SlotEntry }
|
|
183
188
|
type Item = RemoteItem_ | LocalItem_
|
|
184
189
|
|
|
190
|
+
/** Aviso de `fallback: "notice"`: sin detalles internos del error. */
|
|
191
|
+
export function SlotFailureNotice({ failure }: { failure: AddonSlotFailure }) {
|
|
192
|
+
return (
|
|
193
|
+
<div role="status" data-addon-slot-notice={failure.addon} data-reason={failure.reason}>
|
|
194
|
+
No se pudo cargar este módulo ({failure.addon}).
|
|
195
|
+
</div>
|
|
196
|
+
)
|
|
197
|
+
}
|
|
198
|
+
|
|
185
199
|
const EMPTY_OBJ: Record<string, unknown> = Object.freeze({}) as Record<string, unknown>
|
|
186
200
|
|
|
187
201
|
/** Orden canónico: `order` ascendente, luego `priority` descendente, luego inserción. */
|
|
@@ -432,7 +446,9 @@ export function AddonSlot({
|
|
|
432
446
|
requireIntegrity={effRequire}
|
|
433
447
|
timeoutMs={effTimeout}
|
|
434
448
|
loading={loading}
|
|
435
|
-
renderFallback={
|
|
449
|
+
renderFallback={
|
|
450
|
+
item.slot.fallback === 'notice' ? (f) => <SlotFailureNotice failure={f} /> : renderFallback
|
|
451
|
+
}
|
|
436
452
|
report={report}
|
|
437
453
|
/>
|
|
438
454
|
) : (
|