@asteby/metacore-runtime-react 53.5.0 → 53.7.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.
@@ -0,0 +1,79 @@
1
+ import type { StepStatus } from './types';
2
+ export type ConnectorBlockKind = 'webhook_url' | 'instructions' | 'action';
3
+ export interface ConnectorBlockLink {
4
+ label: string;
5
+ url: string;
6
+ }
7
+ /** One non-input element of a connector setup step, as the host serves it. */
8
+ export interface ConnectorFormBlock {
9
+ key: string;
10
+ kind: ConnectorBlockKind | string;
11
+ title?: string;
12
+ description?: string;
13
+ /** kind=webhook_url: webhooks[].key (the host fills `value`). */
14
+ webhook?: string;
15
+ links?: ConnectorBlockLink[];
16
+ /** kind=action: wasm export the host runs. */
17
+ export?: string;
18
+ /** kind=action: button text (literal or i18n key). */
19
+ label?: string;
20
+ /** Host-computed value (kind=webhook_url: the org's absolute URL). */
21
+ value?: string;
22
+ }
23
+ export type BlockDetailKind = 'text' | 'id' | 'url';
24
+ export interface BlockResultDetail {
25
+ key?: string;
26
+ label?: string;
27
+ value: string;
28
+ kind?: BlockDetailKind | string;
29
+ }
30
+ /** Normalized outcome of an action block run. */
31
+ export interface BlockResult {
32
+ status: StepStatus;
33
+ message: string;
34
+ details: BlockResultDetail[];
35
+ }
36
+ /** Only absolute https URLs are ever turned into links. */
37
+ export declare function safeHttpsUrl(raw: unknown): string | null;
38
+ /**
39
+ * Reads what an action export (or a connector test_export) answered. Accepts
40
+ * the kernel envelope `{success, data, error}` or a bare `data`. Never invents
41
+ * success: anything without an explicit ok/ok-status is an error.
42
+ */
43
+ export declare function normalizeBlockResult(raw: unknown, fallbackError?: string): BlockResult;
44
+ /** Message of a failed HTTP call (axios-like error), or the fallback. */
45
+ export declare function errorMessage(err: unknown, fallback: string): string;
46
+ export interface WizardSectionInput {
47
+ key: string;
48
+ title?: string;
49
+ description?: string;
50
+ blocks?: ConnectorFormBlock[];
51
+ }
52
+ export interface WizardStep {
53
+ key: string;
54
+ title?: string;
55
+ description?: string;
56
+ kind: 'creds' | 'settings';
57
+ blocks: ConnectorFormBlock[];
58
+ }
59
+ /**
60
+ * Wizard steps of a connector form_layout: every section that has fields OR
61
+ * blocks (a step that only shows the webhook URL and a test is a real step),
62
+ * plus a final "Ajustes" step when the addon ships settings.
63
+ */
64
+ export declare function buildWizardSteps(sections: WizardSectionInput[], fieldSections: (string | undefined)[], hasSettings: boolean, settingsTitle?: string): WizardStep[];
65
+ /** Whether an explicit action block already runs the connector's test_export. */
66
+ export declare function hasExplicitTest(sections: WizardSectionInput[], testExport?: string): boolean;
67
+ /**
68
+ * Status of a wizard step for the stepper: an error (failed field or action)
69
+ * wins; then a finished verification; then "visited".
70
+ */
71
+ export declare function stepStatus(opts: {
72
+ index: number;
73
+ current: number;
74
+ fieldKeys: string[];
75
+ fieldErrors: Record<string, string>;
76
+ blockKeys: string[];
77
+ results: Record<string, BlockResult | undefined>;
78
+ }): StepStatus;
79
+ //# sourceMappingURL=connector-blocks-model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connector-blocks-model.d.ts","sourceRoot":"","sources":["../../src/setup/connector-blocks-model.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEzC,MAAM,MAAM,kBAAkB,GAAG,aAAa,GAAG,cAAc,GAAG,QAAQ,CAAA;AAE1E,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;CACZ;AAED,8EAA8E;AAC9E,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,kBAAkB,GAAG,MAAM,CAAA;IACjC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,iEAAiE;IACjE,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,kBAAkB,EAAE,C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ED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,kBAAkB,EAAE,EAC9B,aAAa,EAAE,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,EACrC,WAAW,EAAE,OAAO,EACpB,aAAa,SAAsC,GAClD,UAAU,EAAE,CAOd;AAED,iFAAiF;AACjF,wBAAgB,eAAe,CAAC,QAAQ,EAAE,kBAAkB,EAAE,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAG5F;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE;IAC/B,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,EAAE,CAAA;IACnB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACnC,SAAS,EAAE,MAAM,EAAE,CAAA;IACnB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,CAAC,CAAA;CACjD,GAAG,UAAU,CASb"}
@@ -0,0 +1,96 @@
1
+ const STATUSES = ['pending', 'running', 'ok', 'warn', 'error', 'blocked'];
2
+ /** Only absolute https URLs are ever turned into links. */
3
+ export function safeHttpsUrl(raw) {
4
+ if (typeof raw !== 'string')
5
+ return null;
6
+ try {
7
+ const u = new URL(raw);
8
+ if (u.protocol !== 'https:' || !u.host || u.username || u.password)
9
+ return null;
10
+ return u.toString();
11
+ }
12
+ catch {
13
+ return null;
14
+ }
15
+ }
16
+ /**
17
+ * Reads what an action export (or a connector test_export) answered. Accepts
18
+ * the kernel envelope `{success, data, error}` or a bare `data`. Never invents
19
+ * success: anything without an explicit ok/ok-status is an error.
20
+ */
21
+ export function normalizeBlockResult(raw, fallbackError = '') {
22
+ const env = (raw ?? {});
23
+ const hasEnvelope = 'success' in env || 'data' in env || 'error' in env;
24
+ if (hasEnvelope && env.success === false) {
25
+ const msg = env.error?.message ?? env.message ?? fallbackError;
26
+ return { status: 'error', message: String(msg ?? ''), details: [] };
27
+ }
28
+ const data = ((hasEnvelope ? env.data : env) ?? {});
29
+ let status;
30
+ if (typeof data.status === 'string' && STATUSES.includes(data.status)) {
31
+ status = data.status;
32
+ }
33
+ else {
34
+ status = data.ok === true ? 'ok' : 'error';
35
+ }
36
+ // An explicit ok:false wins over a status that claims success.
37
+ if (data.ok === false && (status === 'ok' || status === 'warn'))
38
+ status = 'error';
39
+ const details = Array.isArray(data.details)
40
+ ? data.details
41
+ .filter((d) => d && (typeof d.value === 'string' || typeof d.value === 'number'))
42
+ .slice(0, 12)
43
+ .map((d) => ({
44
+ key: typeof d.key === 'string' ? d.key : undefined,
45
+ label: typeof d.label === 'string' ? d.label : undefined,
46
+ value: String(d.value),
47
+ kind: d.kind === 'id' || d.kind === 'url' ? d.kind : 'text',
48
+ }))
49
+ : [];
50
+ const message = typeof data.message === 'string' && data.message ? data.message : status === 'error' ? fallbackError : '';
51
+ return { status, message, details };
52
+ }
53
+ /** Message of a failed HTTP call (axios-like error), or the fallback. */
54
+ export function errorMessage(err, fallback) {
55
+ const e = err;
56
+ return e?.response?.data?.message || e?.response?.data?.error?.message || fallback;
57
+ }
58
+ /**
59
+ * Wizard steps of a connector form_layout: every section that has fields OR
60
+ * blocks (a step that only shows the webhook URL and a test is a real step),
61
+ * plus a final "Ajustes" step when the addon ships settings.
62
+ */
63
+ export function buildWizardSteps(sections, fieldSections, hasSettings, settingsTitle = 'installed_addons.section_settings') {
64
+ const withFields = new Set(fieldSections.filter(Boolean));
65
+ const steps = sections
66
+ .filter((s) => withFields.has(s.key) || (s.blocks?.length ?? 0) > 0)
67
+ .map((s) => ({ key: s.key, title: s.title, description: s.description, kind: 'creds', blocks: s.blocks ?? [] }));
68
+ if (hasSettings)
69
+ steps.push({ key: '__settings', title: settingsTitle, kind: 'settings', blocks: [] });
70
+ return steps;
71
+ }
72
+ /** Whether an explicit action block already runs the connector's test_export. */
73
+ export function hasExplicitTest(sections, testExport) {
74
+ if (!testExport)
75
+ return false;
76
+ return sections.some((s) => (s.blocks ?? []).some((b) => b.kind === 'action' && b.export === testExport));
77
+ }
78
+ /**
79
+ * Status of a wizard step for the stepper: an error (failed field or action)
80
+ * wins; then a finished verification; then "visited".
81
+ */
82
+ export function stepStatus(opts) {
83
+ const { index, current, fieldKeys, fieldErrors, blockKeys, results } = opts;
84
+ if (fieldKeys.some((k) => !!fieldErrors[k]))
85
+ return 'error';
86
+ const rs = blockKeys.map((k) => results[k]).filter(Boolean);
87
+ if (rs.some((r) => r.status === 'error' || r.status === 'blocked'))
88
+ return 'error';
89
+ if (rs.some((r) => r.status === 'warn'))
90
+ return 'warn';
91
+ if (rs.length > 0 && rs.every((r) => r.status === 'ok'))
92
+ return 'ok';
93
+ if (index < current)
94
+ return 'ok';
95
+ return 'pending';
96
+ }
@@ -0,0 +1,48 @@
1
+ import { type BlockResult, type ConnectorFormBlock } from './connector-blocks-model';
2
+ /** Long help is clamped to 3 lines with a "Ver más" toggle: never cut for good. */
3
+ export declare function HelpText({ text, id, className, clampAt, }: {
4
+ text: string;
5
+ id?: string;
6
+ className?: string;
7
+ /** Characters above which the text starts collapsed. */
8
+ clampAt?: number;
9
+ }): import("react").JSX.Element | null;
10
+ /** A read-only value (wraps, never truncates) with a 44px Copy button. */
11
+ export declare function CopyValue({ value, label, mono }: {
12
+ value: string;
13
+ label: string;
14
+ mono?: boolean;
15
+ }): import("react").JSX.Element;
16
+ export declare function WebhookUrlBlock({ block }: {
17
+ block: ConnectorFormBlock;
18
+ }): import("react").JSX.Element;
19
+ export declare function InstructionsBlock({ block }: {
20
+ block: ConnectorFormBlock;
21
+ }): import("react").JSX.Element;
22
+ export interface ActionBlockProps {
23
+ block: ConnectorFormBlock;
24
+ /** Runs the action; resolves to the normalized result (never throws). */
25
+ run: () => Promise<BlockResult>;
26
+ result?: BlockResult;
27
+ onResult?: (r: BlockResult) => void;
28
+ disabled?: boolean;
29
+ /** Shown under the button (e.g. "Se guardarán tus cambios antes de probar"). */
30
+ note?: string;
31
+ }
32
+ export declare function ActionBlock({ block, run, result, onResult, disabled, note }: ActionBlockProps): import("react").JSX.Element;
33
+ export declare function BlockResultView({ result }: {
34
+ result: BlockResult;
35
+ }): import("react").JSX.Element;
36
+ export interface ConnectorBlocksProps {
37
+ blocks: ConnectorFormBlock[];
38
+ /** Runs an action block by key. */
39
+ runAction: (block: ConnectorFormBlock) => Promise<BlockResult>;
40
+ results?: Record<string, BlockResult | undefined>;
41
+ onResult?: (key: string, r: BlockResult) => void;
42
+ /** Disables actions (e.g. the viewer may not run them). */
43
+ actionsDisabled?: boolean;
44
+ actionNote?: string;
45
+ }
46
+ /** Renders a step's blocks in declared order; unknown kinds are skipped. */
47
+ export declare function ConnectorBlocks({ blocks, runAction, results, onResult, actionsDisabled, actionNote }: ConnectorBlocksProps): import("react").JSX.Element | null;
48
+ //# sourceMappingURL=connector-blocks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connector-blocks.d.ts","sourceRoot":"","sources":["../../src/setup/connector-blocks.tsx"],"names":[],"mappings":"AAmBA,OAAO,EAAgB,KAAK,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAmBlG,mFAAmF;AACnF,wBAAgB,QAAQ,CAAC,EACvB,IAAI,EACJ,EAAE,EACF,SAAS,EACT,OAAa,GACd,EAAE;IACD,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,wDAAwD;IACxD,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,sCA+BA;AAGD,0EAA0E;AAC1E,wBAAgB,SAAS,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAW,EAAE,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,+BAwCxG;AAmCD,wBAAgB,eAAe,CAAC,EAAE,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EAAE,eAAe,EAAE,UAAU,EAAE,EAAE,oBAAoB,sCA4B1H"}
@@ -0,0 +1,132 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // Connector setup blocks: what a step of the "Configurar <addon>" wizard shows
3
+ // besides inputs. Declared by the addon manifest (kernel
4
+ // connectors[].form_layout.sections[].blocks), computed / run by the host, and
5
+ // rendered here the same for every addon:
6
+ // • webhook_url — the org's webhook URL, read-only, with Copy + links
7
+ // • instructions — help text (expandable) + https links to the provider
8
+ // • action — a verification button with a live, structured result
9
+ // Plus the small building blocks the wizard reuses: HelpText (long help never
10
+ // gets cut: it expands) and CopyValue.
11
+ import { useCallback, useEffect, useId, useRef, useState } from 'react';
12
+ import { useTranslation } from 'react-i18next';
13
+ import { Check, Copy, ExternalLink, Loader2, Play, RotateCcw } from 'lucide-react';
14
+ import { Button } from '@asteby/metacore-ui/primitives';
15
+ import { cn } from '@asteby/metacore-ui/lib';
16
+ import { useSetupT } from './messages';
17
+ import { copyText } from './records-table';
18
+ import { StepStatusBadge } from './step-status-badge';
19
+ import { STEP_TONE, TONE_BADGE } from './tone';
20
+ import { textOrFallback } from './connector-form-model';
21
+ import { safeHttpsUrl } from './connector-blocks-model';
22
+ /** Resolves an addon i18n key (or literal); never paints a raw dotted key. */
23
+ function useAddonText() {
24
+ const { t } = useTranslation();
25
+ return useCallback((key, fallback = '') => {
26
+ if (!key)
27
+ return fallback;
28
+ const out = t(key, { defaultValue: '' });
29
+ const resolved = textOrFallback(out, key, '');
30
+ if (resolved)
31
+ return resolved;
32
+ // A literal sentence (has spaces, no dots-only shape) is shown as is.
33
+ return /\s/.test(key) || !key.includes('.') ? key : fallback;
34
+ }, [t]);
35
+ }
36
+ // ─── HelpText ────────────────────────────────────────────────────────────────
37
+ /** Long help is clamped to 3 lines with a "Ver más" toggle: never cut for good. */
38
+ export function HelpText({ text, id, className, clampAt = 160, }) {
39
+ const st = useSetupT();
40
+ const [open, setOpen] = useState(false);
41
+ const autoId = useId();
42
+ const bodyId = id ?? `${autoId}-help`;
43
+ if (!text)
44
+ return null;
45
+ const long = text.length > clampAt;
46
+ return (_jsxs("div", { className: cn('flex flex-col items-start gap-0.5', className), children: [_jsx("p", { id: bodyId, className: cn('text-xs leading-relaxed whitespace-pre-line break-words text-muted-foreground', long && !open && 'line-clamp-3'), children: text }), long ? (_jsx("button", { type: 'button', className: 'inline-flex min-h-11 items-center text-xs font-medium text-primary underline-offset-2 hover:underline focus-visible:outline-2 focus-visible:outline-ring sm:min-h-6', "aria-expanded": open, "aria-controls": bodyId, onClick: () => setOpen((v) => !v), children: open ? st('blocks.less') : st('blocks.more') })) : null] }));
47
+ }
48
+ // ─── CopyValue ───────────────────────────────────────────────────────────────
49
+ /** A read-only value (wraps, never truncates) with a 44px Copy button. */
50
+ export function CopyValue({ value, label, mono = true }) {
51
+ const st = useSetupT();
52
+ const [state, setState] = useState('idle');
53
+ const timer = useRef(undefined);
54
+ useEffect(() => () => clearTimeout(timer.current), []);
55
+ const onCopy = async () => {
56
+ const ok = await copyText(value);
57
+ setState(ok ? 'copied' : 'failed');
58
+ clearTimeout(timer.current);
59
+ timer.current = setTimeout(() => setState('idle'), 2500);
60
+ };
61
+ return (_jsxs("div", { className: 'flex flex-col gap-1', children: [_jsxs("div", { className: 'flex items-stretch gap-2', children: [_jsx("output", { "aria-label": label, className: cn('min-w-0 flex-1 rounded-md border bg-muted/50 px-3 py-2.5 text-sm break-all select-all', mono && 'font-mono text-[13px]'), children: value }), _jsxs(Button, { type: 'button', variant: 'outline', className: 'h-auto min-h-11 shrink-0 gap-1.5 px-3', onClick: onCopy, "aria-label": st('blocks.copy_label', { what: label }), children: [state === 'copied' ? _jsx(Check, { "aria-hidden": 'true', className: 'h-4 w-4' }) : _jsx(Copy, { "aria-hidden": 'true', className: 'h-4 w-4' }), _jsx("span", { className: 'hidden sm:inline', children: state === 'copied' ? st('records.copied') : st('records.copy') })] })] }), _jsx("p", { className: 'sr-only', role: 'status', "aria-live": 'polite', children: state === 'copied' ? st('records.copied') : state === 'failed' ? st('records.copy_failed') : '' }), state === 'failed' ? _jsx("p", { className: 'text-xs text-destructive', children: st('records.copy_failed') }) : null] }));
62
+ }
63
+ function BlockLinks({ links }) {
64
+ const tx = useAddonText();
65
+ const safe = (links ?? []).map((l) => ({ ...l, href: safeHttpsUrl(l.url) })).filter((l) => !!l.href);
66
+ if (safe.length === 0)
67
+ return null;
68
+ return (_jsx("ul", { className: 'flex flex-wrap gap-x-4 gap-y-1', children: safe.map((l) => (_jsx("li", { children: _jsxs("a", { href: l.href, target: '_blank', rel: 'noopener noreferrer', className: 'inline-flex min-h-11 items-center gap-1.5 text-sm font-medium text-primary underline-offset-2 hover:underline sm:min-h-8', children: [_jsx(ExternalLink, { "aria-hidden": 'true', className: 'h-3.5 w-3.5' }), tx(l.label, l.href)] }) }, l.href))) }));
69
+ }
70
+ function BlockFrame({ title, children, className }) {
71
+ return (_jsxs("section", { className: cn('flex flex-col gap-2 rounded-lg border border-border/70 bg-card p-3', className), children: [title ? _jsx("h4", { className: 'text-sm font-medium', children: title }) : null, children] }));
72
+ }
73
+ // ─── webhook_url ─────────────────────────────────────────────────────────────
74
+ export function WebhookUrlBlock({ block }) {
75
+ const st = useSetupT();
76
+ const tx = useAddonText();
77
+ const title = tx(block.title, st('blocks.webhook_title'));
78
+ const value = typeof block.value === 'string' ? block.value.trim() : '';
79
+ return (_jsxs(BlockFrame, { title: title, children: [value ? (_jsx(CopyValue, { value: value, label: title })) : (_jsx("p", { className: 'text-sm text-muted-foreground', role: 'note', children: st('blocks.webhook_unavailable') })), _jsx(HelpText, { text: tx(block.description, st('blocks.webhook_help')) }), _jsx(BlockLinks, { links: block.links })] }));
80
+ }
81
+ // ─── instructions ────────────────────────────────────────────────────────────
82
+ export function InstructionsBlock({ block }) {
83
+ const tx = useAddonText();
84
+ return (_jsxs(BlockFrame, { title: tx(block.title), className: 'bg-muted/30', children: [_jsx(HelpText, { text: tx(block.description), clampAt: 240 }), _jsx(BlockLinks, { links: block.links })] }));
85
+ }
86
+ export function ActionBlock({ block, run, result, onResult, disabled, note }) {
87
+ const st = useSetupT();
88
+ const tx = useAddonText();
89
+ const [busy, setBusy] = useState(false);
90
+ const [local, setLocal] = useState(undefined);
91
+ const shown = result ?? local;
92
+ const label = tx(block.label, st('blocks.run'));
93
+ const onRun = async () => {
94
+ setBusy(true);
95
+ try {
96
+ const r = await run();
97
+ setLocal(r);
98
+ onResult?.(r);
99
+ }
100
+ finally {
101
+ setBusy(false);
102
+ }
103
+ };
104
+ const failed = shown && (shown.status === 'error' || shown.status === 'blocked');
105
+ return (_jsxs(BlockFrame, { title: tx(block.title), children: [_jsx(HelpText, { text: tx(block.description) }), _jsxs("div", { className: 'flex flex-wrap items-center gap-2', children: [_jsxs(Button, { type: 'button', variant: failed ? 'outline' : 'secondary', className: 'h-auto min-h-11 gap-2 whitespace-normal text-left', onClick: onRun, disabled: busy || disabled, "aria-describedby": note ? `${block.key}-note` : undefined, children: [busy ? (_jsx(Loader2, { "aria-hidden": 'true', className: 'h-4 w-4 shrink-0 animate-spin motion-reduce:animate-none' })) : shown ? (_jsx(RotateCcw, { "aria-hidden": 'true', className: 'h-4 w-4 shrink-0' })) : (_jsx(Play, { "aria-hidden": 'true', className: 'h-4 w-4 shrink-0' })), busy ? st('blocks.running') : shown ? st('blocks.retry_with', { label }) : label] }), note ? (_jsx("span", { id: `${block.key}-note`, className: 'text-xs text-muted-foreground', children: note })) : null] }), _jsx("div", { role: 'status', "aria-live": 'polite', "aria-atomic": 'true', className: 'empty:hidden', children: shown ? _jsx(BlockResultView, { result: shown }) : null })] }));
106
+ }
107
+ export function BlockResultView({ result }) {
108
+ const st = useSetupT();
109
+ const tone = STEP_TONE[result.status] ?? 'neutral';
110
+ return (_jsxs("div", { className: cn('flex flex-col gap-2 rounded-md border px-3 py-2', TONE_BADGE[tone]), "data-result-status": result.status, children: [_jsxs("div", { className: 'flex flex-wrap items-center gap-2', children: [_jsx(StepStatusBadge, { status: result.status, label: st(`blocks.result.${result.status}`) }), result.message ? _jsx("span", { className: 'text-sm break-words text-foreground', children: result.message }) : null] }), result.details.length > 0 ? (_jsx("dl", { className: 'flex flex-col gap-2', children: result.details.map((d, i) => {
111
+ const label = d.label || d.key || '';
112
+ const href = d.kind === 'url' ? safeHttpsUrl(d.value) : null;
113
+ return (_jsxs("div", { className: 'flex flex-col gap-1', children: [_jsx("dt", { className: 'text-xs font-medium text-muted-foreground', children: label }), _jsx("dd", { className: 'text-sm text-foreground', children: d.kind === 'id' ? (_jsx(CopyValue, { value: d.value, label: label || st('blocks.value') })) : href ? (_jsxs("a", { href: href, target: '_blank', rel: 'noopener noreferrer', className: 'inline-flex min-h-11 items-center gap-1.5 break-all font-medium text-primary underline-offset-2 hover:underline sm:min-h-8', children: [_jsx(ExternalLink, { "aria-hidden": 'true', className: 'h-3.5 w-3.5 shrink-0' }), st('blocks.open_link')] })) : (_jsx("span", { className: 'break-words', children: d.value })) })] }, d.key ?? i));
114
+ }) })) : null] }));
115
+ }
116
+ /** Renders a step's blocks in declared order; unknown kinds are skipped. */
117
+ export function ConnectorBlocks({ blocks, runAction, results, onResult, actionsDisabled, actionNote }) {
118
+ if (blocks.length === 0)
119
+ return null;
120
+ return (_jsx("div", { className: 'flex flex-col gap-3', children: blocks.map((b) => {
121
+ switch (b.kind) {
122
+ case 'webhook_url':
123
+ return _jsx(WebhookUrlBlock, { block: b }, b.key);
124
+ case 'instructions':
125
+ return _jsx(InstructionsBlock, { block: b }, b.key);
126
+ case 'action':
127
+ return (_jsx(ActionBlock, { block: b, run: () => runAction(b), result: results?.[b.key], onResult: (r) => onResult?.(b.key, r), disabled: actionsDisabled, note: actionNote }, b.key));
128
+ default:
129
+ return null;
130
+ }
131
+ }) }));
132
+ }
@@ -8,4 +8,6 @@ export { SetupFlow, type SetupFlowProps, type SetupCustomStepProps } from './set
8
8
  export { SetupFormStep, type SetupFormStepProps } from './setup-form-step';
9
9
  export { AddonConfigSurface, clearConnectorLookupCache, type AddonConfigSurfaceProps, type AddonConfigAddon, type AddonConfigNotifier, type AddonSettingDef, type ConnectorEntry, type ConnectorCredentialField, type ConnectorFormLayout, } from './addon-config-surface';
10
10
  export * from './connector-form-model';
11
+ export * from './connector-blocks-model';
12
+ export { ConnectorBlocks, WebhookUrlBlock, InstructionsBlock, ActionBlock, BlockResultView, HelpText, CopyValue, type ConnectorBlocksProps, type ActionBlockProps, } from './connector-blocks';
11
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/setup/index.ts"],"names":[],"mappings":"AAGA,cAAc,SAAS,CAAA;AACvB,cAAc,cAAc,CAAA;AAC5B,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAC5E,OAAO,EAAE,eAAe,EAAE,KAAK,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAChF,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAChF,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,eAAe,CAAA;AAChE,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,KAAK,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACxF,OAAO,EAAE,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAC1E,OAAO,EACH,kBAAkB,EAClB,yBAAyB,EACzB,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,GAC3B,MAAM,wBAAwB,CAAA;AAC/B,cAAc,wBAAwB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/setup/index.ts"],"names":[],"mappings":"AAGA,cAAc,SAAS,CAAA;AACvB,cAAc,cAAc,CAAA;AAC5B,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAC5E,OAAO,EAAE,eAAe,EAAE,KAAK,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAChF,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAChF,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,eAAe,CAAA;AAChE,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,KAAK,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACxF,OAAO,EAAE,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAC1E,OAAO,EACH,kBAAkB,EAClB,yBAAyB,EACzB,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,GAC3B,MAAM,wBAAwB,CAAA;AAC/B,cAAc,wBAAwB,CAAA;AACtC,cAAc,0BAA0B,CAAA;AACxC,OAAO,EACH,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,eAAe,EACf,QAAQ,EACR,SAAS,EACT,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,GACxB,MAAM,oBAAoB,CAAA"}
@@ -11,3 +11,5 @@ export { SetupFlow } from './setup-flow';
11
11
  export { SetupFormStep } from './setup-form-step';
12
12
  export { AddonConfigSurface, clearConnectorLookupCache, } from './addon-config-surface';
13
13
  export * from './connector-form-model';
14
+ export * from './connector-blocks-model';
15
+ export { ConnectorBlocks, WebhookUrlBlock, InstructionsBlock, ActionBlock, BlockResultView, HelpText, CopyValue, } from './connector-blocks';
@@ -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,IA8G/B,CAAA;AAED,eAAO,MAAM,iBAAiB,EAAE,IA4G/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"}
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,IAuJ/B,CAAA;AAED,eAAO,MAAM,iBAAiB,EAAE,IAoJ/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"}
@@ -73,6 +73,41 @@ export const SETUP_MESSAGES_ES = {
73
73
  'form.stored': 'Guardado. Escribe un valor nuevo solo si quieres cambiarlo.',
74
74
  'form.choose': 'Elige una opción',
75
75
  'form.step': 'Paso',
76
+ // Connector setup blocks + wizard
77
+ 'blocks.more': 'Ver más',
78
+ 'blocks.less': 'Ver menos',
79
+ 'blocks.copy_label': 'Copiar {{what}}',
80
+ 'blocks.value': 'Valor',
81
+ 'blocks.webhook_title': 'URL del webhook',
82
+ 'blocks.webhook_help': 'Pega esta URL en el panel del proveedor, en la sección de webhooks o notificaciones.',
83
+ 'blocks.webhook_unavailable': 'El servidor todavía no informa la URL de este webhook. Actualiza OPS o pide ayuda a soporte.',
84
+ 'blocks.run': 'Ejecutar prueba',
85
+ 'blocks.running': 'Probando…',
86
+ 'blocks.retry_with': 'Reintentar: {{label}}',
87
+ 'blocks.open_link': 'Abrir enlace',
88
+ 'blocks.save_first': 'Se guardarán tus cambios antes de probar.',
89
+ 'blocks.failed': 'No se pudo completar la prueba.',
90
+ 'blocks.result.ok': 'Correcto',
91
+ 'blocks.result.warn': 'Con avisos',
92
+ 'blocks.result.error': 'Falló',
93
+ 'blocks.result.pending': 'Pendiente',
94
+ 'blocks.result.running': 'En curso',
95
+ 'blocks.result.blocked': 'Bloqueado',
96
+ 'blocks.test_title': 'Verifica la conexión',
97
+ 'blocks.test_help': 'Usa las credenciales guardadas para hacer una llamada de solo lectura al proveedor.',
98
+ 'blocks.sync_title': 'Sincronización',
99
+ 'wizard.steps': 'Pasos de la configuración',
100
+ 'wizard.step_label': 'Paso {{n}} de {{total}}: {{title}} ({{status}})',
101
+ 'wizard.save': 'Guardar',
102
+ 'wizard.finish': 'Guardar y terminar',
103
+ 'oauth.title': 'Cuenta conectada',
104
+ 'oauth.connected': 'Conectado',
105
+ 'oauth.not_connected': 'Sin conectar',
106
+ 'oauth.help': 'Este addon se conecta con tu cuenta del proveedor. Te llevamos a su página para autorizarlo.',
107
+ 'oauth.connect': 'Conectar cuenta',
108
+ 'oauth.reconnect': 'Volver a conectar',
109
+ 'empty.title': 'Nada que configurar',
110
+ 'empty.help': 'Este addon funciona sin configuración. Si necesitas cambiar algo, revisa su documentación o abre el addon.',
76
111
  // AddonConfigSurface (same keys the ops host already ships)
77
112
  'installed_addons.configure_title': 'Configurar {{name}}',
78
113
  'installed_addons.configure_description': 'Credenciales y ajustes del addon.',
@@ -107,10 +142,16 @@ export const SETUP_MESSAGES_ES = {
107
142
  'installed_addons.whole_org': 'Toda la organización',
108
143
  'installed_addons.only_branch': 'Solo {{name}}',
109
144
  'installed_addons.secret_stored': 'Hay un valor guardado. Déjalo vacío para conservarlo.',
145
+ 'installed_addons.field_view': 'Ver',
146
+ 'installed_addons.field_hide': 'Ocultar',
147
+ 'installed_addons.field_edit': 'Editar',
148
+ 'installed_addons.field_cancel_edit': 'Cancelar edición',
149
+ 'installed_addons.field_reveal_error': 'No se pudo mostrar el valor.',
110
150
  'common.back': 'Atrás',
111
151
  'common.next': 'Siguiente',
112
152
  'common.cancel': 'Cancelar',
113
153
  'common.save': 'Guardar',
154
+ 'common.close': 'Cerrar',
114
155
  };
115
156
  export const SETUP_MESSAGES_EN = {
116
157
  'status.pending': 'Pending',
@@ -182,6 +223,40 @@ export const SETUP_MESSAGES_EN = {
182
223
  'form.stored': 'Saved. Type a new value only if you want to change it.',
183
224
  'form.choose': 'Choose an option',
184
225
  'form.step': 'Step',
226
+ 'blocks.more': 'Show more',
227
+ 'blocks.less': 'Show less',
228
+ 'blocks.copy_label': 'Copy {{what}}',
229
+ 'blocks.value': 'Value',
230
+ 'blocks.webhook_title': 'Webhook URL',
231
+ 'blocks.webhook_help': "Paste this URL in the provider's panel, in its webhooks or notifications section.",
232
+ 'blocks.webhook_unavailable': 'The server does not report this webhook URL yet. Update OPS or ask support.',
233
+ 'blocks.run': 'Run test',
234
+ 'blocks.running': 'Testing…',
235
+ 'blocks.retry_with': 'Retry: {{label}}',
236
+ 'blocks.open_link': 'Open link',
237
+ 'blocks.save_first': 'Your changes will be saved before testing.',
238
+ 'blocks.failed': 'The test could not be completed.',
239
+ 'blocks.result.ok': 'Passed',
240
+ 'blocks.result.warn': 'Has warnings',
241
+ 'blocks.result.error': 'Failed',
242
+ 'blocks.result.pending': 'Pending',
243
+ 'blocks.result.running': 'In progress',
244
+ 'blocks.result.blocked': 'Blocked',
245
+ 'blocks.test_title': 'Check the connection',
246
+ 'blocks.test_help': 'Uses the saved credentials to make a read-only call to the provider.',
247
+ 'blocks.sync_title': 'Sync',
248
+ 'wizard.steps': 'Setup steps',
249
+ 'wizard.step_label': 'Step {{n}} of {{total}}: {{title}} ({{status}})',
250
+ 'wizard.save': 'Save',
251
+ 'wizard.finish': 'Save and finish',
252
+ 'oauth.title': 'Connected account',
253
+ 'oauth.connected': 'Connected',
254
+ 'oauth.not_connected': 'Not connected',
255
+ 'oauth.help': "This addon connects to your provider account. We'll take you to its page to authorize it.",
256
+ 'oauth.connect': 'Connect account',
257
+ 'oauth.reconnect': 'Reconnect',
258
+ 'empty.title': 'Nothing to configure',
259
+ 'empty.help': 'This addon works without configuration. If you need to change something, check its documentation or open the addon.',
185
260
  'installed_addons.configure_title': 'Configure {{name}}',
186
261
  'installed_addons.configure_description': 'Credentials and settings for this addon.',
187
262
  'installed_addons.section_credentials': 'Credentials',
@@ -215,10 +290,16 @@ export const SETUP_MESSAGES_EN = {
215
290
  'installed_addons.whole_org': 'Whole organization',
216
291
  'installed_addons.only_branch': 'Only {{name}}',
217
292
  'installed_addons.secret_stored': 'A value is stored. Leave it empty to keep it.',
293
+ 'installed_addons.field_view': 'View',
294
+ 'installed_addons.field_hide': 'Hide',
295
+ 'installed_addons.field_edit': 'Edit',
296
+ 'installed_addons.field_cancel_edit': 'Cancel editing',
297
+ 'installed_addons.field_reveal_error': 'Could not show the value.',
218
298
  'common.back': 'Back',
219
299
  'common.next': 'Next',
220
300
  'common.cancel': 'Cancel',
221
301
  'common.save': 'Save',
302
+ 'common.close': 'Close',
222
303
  };
223
304
  function interpolate(s, vars) {
224
305
  if (!vars)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asteby/metacore-runtime-react",
3
- "version": "53.5.0",
3
+ "version": "53.7.0",
4
4
  "description": "React runtime for metacore hosts — renders addon contributions dynamically",
5
5
  "repository": {
6
6
  "type": "git",
@@ -41,8 +41,8 @@
41
41
  "zod": "^4.3.0"
42
42
  },
43
43
  "peerDependencies": {
44
- "@asteby/metacore-sdk": "^3.17.0",
45
- "@asteby/metacore-ui": "^2.29.0",
44
+ "@asteby/metacore-sdk": "^3.18.0",
45
+ "@asteby/metacore-ui": "^2.31.0",
46
46
  "@tanstack/react-query": ">=5",
47
47
  "@tanstack/react-router": ">=1.100",
48
48
  "@tanstack/react-table": ">=8",
@@ -73,8 +73,8 @@
73
73
  }
74
74
  },
75
75
  "devDependencies": {
76
- "@asteby/metacore-sdk": "3.17.0",
77
- "@asteby/metacore-ui": "2.29.0",
76
+ "@asteby/metacore-sdk": "3.18.0",
77
+ "@asteby/metacore-ui": "2.31.0",
78
78
  "@tanstack/react-query": "^5.95.0",
79
79
  "@tanstack/react-router": "^1.168.0",
80
80
  "@tanstack/react-table": "^8.20.0",