@asteby/metacore-runtime-react 53.4.0 → 53.5.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.
Files changed (67) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +73 -0
  3. package/dist/display-value.d.ts +11 -0
  4. package/dist/display-value.d.ts.map +1 -1
  5. package/dist/display-value.js +26 -1
  6. package/dist/dynamic-columns.d.ts.map +1 -1
  7. package/dist/dynamic-columns.js +17 -6
  8. package/dist/index.d.ts +2 -0
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +4 -0
  11. package/dist/setup/addon-config-surface.d.ts +110 -0
  12. package/dist/setup/addon-config-surface.d.ts.map +1 -0
  13. package/dist/setup/addon-config-surface.js +553 -0
  14. package/dist/setup/connector-form-model.d.ts +40 -0
  15. package/dist/setup/connector-form-model.d.ts.map +1 -0
  16. package/dist/setup/connector-form-model.js +76 -0
  17. package/dist/setup/flow-model.d.ts +49 -0
  18. package/dist/setup/flow-model.d.ts.map +1 -0
  19. package/dist/setup/flow-model.js +124 -0
  20. package/dist/setup/health-card.d.ts +25 -0
  21. package/dist/setup/health-card.d.ts.map +1 -0
  22. package/dist/setup/health-card.js +21 -0
  23. package/dist/setup/index.d.ts +11 -0
  24. package/dist/setup/index.d.ts.map +1 -0
  25. package/dist/setup/index.js +13 -0
  26. package/dist/setup/messages.d.ts +15 -0
  27. package/dist/setup/messages.d.ts.map +1 -0
  28. package/dist/setup/messages.js +249 -0
  29. package/dist/setup/records-table.d.ts +24 -0
  30. package/dist/setup/records-table.d.ts.map +1 -0
  31. package/dist/setup/records-table.js +80 -0
  32. package/dist/setup/setup-flow.d.ts +30 -0
  33. package/dist/setup/setup-flow.d.ts.map +1 -0
  34. package/dist/setup/setup-flow.js +277 -0
  35. package/dist/setup/setup-form-step.d.ts +20 -0
  36. package/dist/setup/setup-form-step.d.ts.map +1 -0
  37. package/dist/setup/setup-form-step.js +173 -0
  38. package/dist/setup/step-status-badge.d.ts +12 -0
  39. package/dist/setup/step-status-badge.d.ts.map +1 -0
  40. package/dist/setup/step-status-badge.js +21 -0
  41. package/dist/setup/tone.d.ts +8 -0
  42. package/dist/setup/tone.d.ts.map +1 -0
  43. package/dist/setup/tone.js +33 -0
  44. package/dist/setup/types.d.ts +130 -0
  45. package/dist/setup/types.d.ts.map +1 -0
  46. package/dist/setup/types.js +1 -0
  47. package/package.json +5 -1
  48. package/src/__tests__/addon-config-surface.test.tsx +248 -0
  49. package/src/__tests__/image-stack.test.tsx +58 -1
  50. package/src/__tests__/setup-components.test.tsx +147 -0
  51. package/src/__tests__/setup-flow-model.test.ts +117 -0
  52. package/src/__tests__/setup-flow.test.tsx +424 -0
  53. package/src/display-value.tsx +30 -1
  54. package/src/dynamic-columns.tsx +21 -5
  55. package/src/index.ts +25 -0
  56. package/src/setup/addon-config-surface.tsx +1262 -0
  57. package/src/setup/connector-form-model.ts +115 -0
  58. package/src/setup/flow-model.ts +156 -0
  59. package/src/setup/health-card.tsx +131 -0
  60. package/src/setup/index.ts +23 -0
  61. package/src/setup/messages.ts +263 -0
  62. package/src/setup/records-table.tsx +186 -0
  63. package/src/setup/setup-flow.tsx +562 -0
  64. package/src/setup/setup-form-step.tsx +342 -0
  65. package/src/setup/step-status-badge.tsx +47 -0
  66. package/src/setup/tone.ts +44 -0
  67. package/src/setup/types.ts +147 -0
@@ -0,0 +1,76 @@
1
+ // Pure helpers for the connector credentials form (no React, no i18n instance):
2
+ // shape detection of pasted values, save-error parsing and required-field
3
+ // checks. Kept free of any provider name on purpose: the rules look at the
4
+ // SHAPE of a value and at how the form's own fields are declared, so every
5
+ // connector (any addon) benefits and none is special-cased.
6
+ const UUID = '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}';
7
+ // Public (publishable) keys are short identifiers: "<PREFIX>-<uuid>" or the
8
+ // pk_live_/pk_test_ family. Server-side tokens are longer, numeric/hex blobs
9
+ // or sk_/rk_ prefixed. These are generic conventions, not one provider's.
10
+ const PUBLIC_SHAPES = [new RegExp(`^(?:[A-Z_]+-)?${UUID}$`, 'i'), /^pk_(?:live|test)_[A-Za-z0-9]+$/];
11
+ const SECRET_SHAPES = [/^(?:sk|rk)_(?:live|test)_[A-Za-z0-9]+$/, /^[A-Z_]+-\d{6,}-\d{4,}-[0-9a-f]{16,}-\d+$/i];
12
+ /** What a pasted value looks like, or null when it is not recognisable. */
13
+ export function credentialShape(raw) {
14
+ const v = raw.trim();
15
+ if (!v)
16
+ return null;
17
+ if (PUBLIC_SHAPES.some((r) => r.test(v)))
18
+ return 'public_key';
19
+ if (SECRET_SHAPES.some((r) => r.test(v)))
20
+ return 'secret_key';
21
+ return null;
22
+ }
23
+ export const isSecretCredential = (f) => !!f.secret || f.type === 'secret';
24
+ const looksPublic = (f) => /public|publishable|client_id/i.test(f.key);
25
+ /**
26
+ * A value pasted in the wrong box: a public key in the secret token field, or
27
+ * a secret in the public-key field. Only a warning (never blocks), and only
28
+ * raised when the form really has a field for what the value looks like.
29
+ */
30
+ export function shapeMismatch(field, value, fields) {
31
+ const shape = credentialShape(value);
32
+ if (!shape)
33
+ return null;
34
+ const siblings = fields.filter((f) => f.key !== field.key);
35
+ if (shape === 'public_key' && isSecretCredential(field) && !looksPublic(field)) {
36
+ const target = siblings.find(looksPublic);
37
+ return target ? { shape, suggestedKey: target.key } : null;
38
+ }
39
+ if (shape === 'secret_key' && looksPublic(field)) {
40
+ const target = siblings.find((f) => isSecretCredential(f) && !looksPublic(f));
41
+ return target ? { shape, suggestedKey: target.key } : null;
42
+ }
43
+ return null;
44
+ }
45
+ /** Required fields still empty. A stored secret (connected) counts as filled. */
46
+ export function missingRequired(fields, values, connected) {
47
+ return fields
48
+ .filter((f) => f.required)
49
+ .filter((f) => !(values[f.key] ?? '').trim())
50
+ .filter((f) => !(connected && isSecretCredential(f)))
51
+ .filter((f) => !(f.default != null && f.default !== ''))
52
+ .map((f) => f.key);
53
+ }
54
+ /** Reads the kernel/ops error envelope: {message, errors: {field: [{code}]}}. */
55
+ export function parseSaveError(err, fallback) {
56
+ const data = err?.response
57
+ ?.data;
58
+ const message = typeof data?.message === 'string' && data.message.trim() ? data.message.trim() : fallback;
59
+ const errors = data?.errors;
60
+ const fieldKeys = errors && typeof errors === 'object' && !Array.isArray(errors) ? Object.keys(errors) : [];
61
+ return { message, fieldKeys };
62
+ }
63
+ /** Never show a raw dotted key: fall back to `fallback` when the text is the key. */
64
+ export function textOrFallback(text, key, fallback) {
65
+ if (!text || text === key)
66
+ return fallback;
67
+ return text;
68
+ }
69
+ /** Cheap content hash so a re-published bundle with the same key count re-merges. */
70
+ export function bundleSignature(labels) {
71
+ let h = 5381;
72
+ const s = JSON.stringify(labels);
73
+ for (let i = 0; i < s.length; i++)
74
+ h = ((h << 5) + h + s.charCodeAt(i)) | 0;
75
+ return `${Object.keys(labels).length}:${(h >>> 0).toString(36)}`;
76
+ }
@@ -0,0 +1,49 @@
1
+ import type { SetupFlowState, SetupStepDef, SetupStepState, StepStatus } from './types';
2
+ export declare const STEP_STATUSES: StepStatus[];
3
+ /** Accepts the array or the by-key map the server may send. */
4
+ export declare function normalizeState(raw: SetupFlowState | null | undefined): Record<string, SetupStepState>;
5
+ /** A step counts as satisfied (unblocks dependants) when ok, warn or skipped. */
6
+ export declare function isSatisfied(st: SetupStepState | undefined): boolean;
7
+ /** Steps this one waits on that are not satisfied yet. */
8
+ export declare function unmetDependencies(def: SetupStepDef, states: Record<string, SetupStepState>): string[];
9
+ /**
10
+ * Status shown for a step: the server's, except that a step whose
11
+ * dependencies are unmet is `blocked` (unless it is already running/ok, which
12
+ * the server decides). A skipped step reads as `ok`.
13
+ */
14
+ export declare function effectiveStatus(def: SetupStepDef, states: Record<string, SetupStepState>): StepStatus;
15
+ /** First step that needs the person: not satisfied and not blocked; else the last. */
16
+ export declare function pickActiveStep(defs: SetupStepDef[], states: Record<string, SetupStepState>): string | undefined;
17
+ export interface FlowProgress {
18
+ done: number;
19
+ total: number;
20
+ percent: number;
21
+ complete: boolean;
22
+ }
23
+ /**
24
+ * Progress over the REQUIRED steps (optional ones do not hold completion
25
+ * back, but count as done when they are). The flow is complete when every
26
+ * required step is satisfied; an error step is never satisfied.
27
+ */
28
+ export declare function flowProgress(defs: SetupStepDef[], states: Record<string, SetupStepState>, serverCompleted?: boolean): FlowProgress;
29
+ export interface BackoffOptions {
30
+ baseMs?: number;
31
+ factor?: number;
32
+ maxMs?: number;
33
+ /** Ceiling honoured for a server `retry_after_s`. */
34
+ maxRetryAfterMs?: number;
35
+ }
36
+ /**
37
+ * Delay before the next poll. Without a hint: exponential from `baseMs`
38
+ * (2s, 3.2s, 5.1s…) capped at `maxMs` (30s). A server `retry_after_s` wins,
39
+ * but never below 1s nor above `maxRetryAfterMs` (5 min).
40
+ */
41
+ export declare function nextPollDelayMs(attempt: number, retryAfterS?: number, opts?: BackoffOptions): number;
42
+ /** Only http(s) and app-relative paths may be opened from a `fix.url`. */
43
+ export declare function safeUrl(url: string | undefined): string | null;
44
+ /** Merges a runStep/skipStep answer (step or whole flow) into the local map. */
45
+ export declare function mergeAnswer(current: Record<string, SetupStepState>, key: string, answer: SetupStepState | SetupFlowState | void | undefined): {
46
+ next: Record<string, SetupStepState>;
47
+ needsRefetch: boolean;
48
+ };
49
+ //# sourceMappingURL=flow-model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flow-model.d.ts","sourceRoot":"","sources":["../../src/setup/flow-model.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEvF,eAAO,MAAM,aAAa,EAAE,UAAU,EAA6D,CAAA;AAEnG,+DAA+D;AAC/D,wBAAgB,cAAc,CAAC,GAAG,EAAE,cAAc,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAUrG;AAED,iFAAiF;AACjF,wBAAgB,WAAW,CAAC,EAAE,EAAE,cAAc,GAAG,SAAS,GAAG,OAAO,CAGnE;AAED,0DAA0D;AAC1D,wBAAgB,iBAAiB,CAC7B,GAAG,EAAE,YAAY,EACjB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,GACvC,MAAM,EAAE,CAEV;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC3B,GAAG,EAAE,YAAY,EACjB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,GACvC,UAAU,CAOZ;AAED,sFAAsF;AACtF,wBAAgB,cAAc,CAC1B,IAAI,EAAE,YAAY,EAAE,EACpB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,GACvC,MAAM,GAAG,SAAS,CAOpB;AAED,MAAM,WAAW,YAAY;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,OAAO,CAAA;CACpB;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CACxB,IAAI,EAAE,YAAY,EAAE,EACpB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,EACtC,eAAe,CAAC,EAAE,OAAO,GAC1B,YAAY,CAYd;AAED,MAAM,WAAW,cAAc;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,qDAAqD;IACrD,eAAe,CAAC,EAAE,MAAM,CAAA;CAC3B;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC3B,OAAO,EAAE,MAAM,EACf,WAAW,CAAC,EAAE,MAAM,EACpB,IAAI,GAAE,cAAmB,GAC1B,MAAM,CAOR;AAED,0EAA0E;AAC1E,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAuB9D;AAED,gFAAgF;AAChF,wBAAgB,WAAW,CACvB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,EACvC,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,cAAc,GAAG,cAAc,GAAG,IAAI,GAAG,SAAS,GAC3D;IAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAAC,YAAY,EAAE,OAAO,CAAA;CAAE,CAIjE"}
@@ -0,0 +1,124 @@
1
+ export const STEP_STATUSES = ['pending', 'running', 'ok', 'warn', 'error', 'blocked'];
2
+ /** Accepts the array or the by-key map the server may send. */
3
+ export function normalizeState(raw) {
4
+ const out = {};
5
+ const steps = raw?.steps;
6
+ if (!steps)
7
+ return out;
8
+ if (Array.isArray(steps)) {
9
+ for (const s of steps)
10
+ if (s?.key)
11
+ out[s.key] = s;
12
+ }
13
+ else {
14
+ for (const [k, s] of Object.entries(steps))
15
+ if (s)
16
+ out[k] = { ...s, key: s.key ?? k };
17
+ }
18
+ return out;
19
+ }
20
+ /** A step counts as satisfied (unblocks dependants) when ok, warn or skipped. */
21
+ export function isSatisfied(st) {
22
+ if (!st)
23
+ return false;
24
+ return st.status === 'ok' || st.status === 'warn' || st.skipped === true;
25
+ }
26
+ /** Steps this one waits on that are not satisfied yet. */
27
+ export function unmetDependencies(def, states) {
28
+ return (def.depends_on ?? []).filter((k) => !isSatisfied(states[k]));
29
+ }
30
+ /**
31
+ * Status shown for a step: the server's, except that a step whose
32
+ * dependencies are unmet is `blocked` (unless it is already running/ok, which
33
+ * the server decides). A skipped step reads as `ok`.
34
+ */
35
+ export function effectiveStatus(def, states) {
36
+ const st = states[def.key];
37
+ if (st?.skipped)
38
+ return 'ok';
39
+ const own = st?.status ?? 'pending';
40
+ if (own === 'ok' || own === 'running')
41
+ return own;
42
+ if (unmetDependencies(def, states).length > 0)
43
+ return 'blocked';
44
+ return own === 'blocked' ? 'pending' : own;
45
+ }
46
+ /** First step that needs the person: not satisfied and not blocked; else the last. */
47
+ export function pickActiveStep(defs, states) {
48
+ if (defs.length === 0)
49
+ return undefined;
50
+ const open = defs.find((d) => {
51
+ const eff = effectiveStatus(d, states);
52
+ return eff !== 'blocked' && !isSatisfied(states[d.key]);
53
+ });
54
+ return (open ?? defs[defs.length - 1]).key;
55
+ }
56
+ /**
57
+ * Progress over the REQUIRED steps (optional ones do not hold completion
58
+ * back, but count as done when they are). The flow is complete when every
59
+ * required step is satisfied; an error step is never satisfied.
60
+ */
61
+ export function flowProgress(defs, states, serverCompleted) {
62
+ const required = defs.filter((d) => !d.optional);
63
+ const total = required.length;
64
+ const done = required.filter((d) => isSatisfied(states[d.key])).length;
65
+ const complete = serverCompleted === true || (total > 0 && done === total);
66
+ const shown = serverCompleted === true ? total : done;
67
+ return {
68
+ done: shown,
69
+ total,
70
+ percent: total === 0 ? 100 : Math.round((shown / total) * 100),
71
+ complete,
72
+ };
73
+ }
74
+ /**
75
+ * Delay before the next poll. Without a hint: exponential from `baseMs`
76
+ * (2s, 3.2s, 5.1s…) capped at `maxMs` (30s). A server `retry_after_s` wins,
77
+ * but never below 1s nor above `maxRetryAfterMs` (5 min).
78
+ */
79
+ export function nextPollDelayMs(attempt, retryAfterS, opts = {}) {
80
+ const { baseMs = 2000, factor = 1.6, maxMs = 30000, maxRetryAfterMs = 300000 } = opts;
81
+ if (typeof retryAfterS === 'number' && Number.isFinite(retryAfterS) && retryAfterS > 0) {
82
+ return Math.min(Math.max(retryAfterS * 1000, 1000), maxRetryAfterMs);
83
+ }
84
+ const n = Math.max(0, Math.floor(attempt));
85
+ return Math.min(Math.round(baseMs * Math.pow(factor, n)), maxMs);
86
+ }
87
+ /** Only http(s) and app-relative paths may be opened from a `fix.url`. */
88
+ export function safeUrl(url) {
89
+ if (!url)
90
+ return null;
91
+ const u = url.trim();
92
+ // Browsers strip tabs/newlines and treat `\` as `/`, so `/\evil.com` or
93
+ // `/<TAB>/evil.com` resolve to another host: reject control chars and
94
+ // backslashes outright, then require the resolved origin to be ours.
95
+ // eslint-disable-next-line no-control-regex
96
+ if (/[\\\u0000-\u001f\u007f]/.test(u))
97
+ return null;
98
+ if (u.startsWith('/')) {
99
+ if (u.startsWith('//'))
100
+ return null;
101
+ const origin = typeof location !== 'undefined' && location.origin ? location.origin : 'http://localhost';
102
+ try {
103
+ return new URL(u, origin).origin === origin ? u : null;
104
+ }
105
+ catch {
106
+ return null;
107
+ }
108
+ }
109
+ try {
110
+ const p = new URL(u);
111
+ return p.protocol === 'https:' || p.protocol === 'http:' ? p.toString() : null;
112
+ }
113
+ catch {
114
+ return null;
115
+ }
116
+ }
117
+ /** Merges a runStep/skipStep answer (step or whole flow) into the local map. */
118
+ export function mergeAnswer(current, key, answer) {
119
+ if (!answer)
120
+ return { next: current, needsRefetch: true };
121
+ if ('steps' in answer)
122
+ return { next: normalizeState(answer), needsRefetch: false };
123
+ return { next: { ...current, [key]: { ...answer, key: answer.key ?? key } }, needsRefetch: false };
124
+ }
@@ -0,0 +1,25 @@
1
+ import type { HealthIssue, HealthMetric, HealthStatus, SetupFix } from './types';
2
+ export interface HealthCardProps {
3
+ title?: string;
4
+ status: HealthStatus;
5
+ /** One line under the status. */
6
+ summary?: string;
7
+ metrics?: HealthMetric[];
8
+ issues?: HealthIssue[];
9
+ /** ISO date or preformatted text shown as "Checked …". */
10
+ checkedAt?: string;
11
+ /** Setup progress, for a card in the installed-addons list. */
12
+ progress?: {
13
+ done: number;
14
+ total: number;
15
+ };
16
+ onFix?: (fix: SetupFix, issue: HealthIssue) => void;
17
+ onRefresh?: () => void;
18
+ refreshing?: boolean;
19
+ /** Shows "Continue setup" (resumes the setup page). */
20
+ onContinue?: () => void;
21
+ className?: string;
22
+ }
23
+ /** Status + metrics (with tone) + issues (with fix) of an addon's health probe. */
24
+ export declare function HealthCard({ title, status, summary, metrics, issues, checkedAt, progress, onFix, onRefresh, refreshing, onContinue, className, }: HealthCardProps): import("react").JSX.Element;
25
+ //# sourceMappingURL=health-card.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"health-card.d.ts","sourceRoot":"","sources":["../../src/setup/health-card.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAsB,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAOpG,MAAM,WAAW,eAAe;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,YAAY,CAAA;IACpB,iCAAiC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,YAAY,EAAE,CAAA;IACxB,MAAM,CAAC,EAAE,WAAW,EAAE,CAAA;IACtB,0DAA0D;IAC1D,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,+DAA+D;IAC/D,QAAQ,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;IAC1C,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,WAAW,KAAK,IAAI,CAAA;IACnD,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;IACtB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,uDAAuD;IACvD,UAAU,CAAC,EAAE,MAAM,IAAI,CAAA;IACvB,SAAS,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,mFAAmF;AACnF,wBAAgB,UAAU,CAAC,EACvB,KAAK,EACL,MAAM,EACN,OAAO,EACP,OAAO,EACP,MAAM,EACN,SAAS,EACT,QAAQ,EACR,KAAK,EACL,SAAS,EACT,UAAU,EACV,UAAU,EACV,SAAS,GACZ,EAAE,eAAe,+BAqFjB"}
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { AlertTriangle, CheckCircle2, HelpCircle, Info, RefreshCw, XCircle } from 'lucide-react';
3
+ import { Button } from '@asteby/metacore-ui/primitives';
4
+ import { cn } from '@asteby/metacore-ui/lib';
5
+ import { useSetupT } from './messages';
6
+ import { TONE_BADGE, TONE_TEXT, metricTone } from './tone';
7
+ const STATUS_TONE = { ok: 'good', warn: 'warn', error: 'bad', unknown: 'neutral' };
8
+ const STATUS_ICON = { ok: CheckCircle2, warn: AlertTriangle, error: XCircle, unknown: HelpCircle };
9
+ const SEVERITY_ICON = { info: Info, warn: AlertTriangle, error: XCircle };
10
+ const SEVERITY_TONE = { info: 'info', warn: 'warn', error: 'bad' };
11
+ /** Status + metrics (with tone) + issues (with fix) of an addon's health probe. */
12
+ export function HealthCard({ title, status, summary, metrics, issues, checkedAt, progress, onFix, onRefresh, refreshing, onContinue, className, }) {
13
+ const t = useSetupT();
14
+ const known = status in STATUS_TONE ? status : 'unknown';
15
+ const Icon = STATUS_ICON[known];
16
+ const pct = progress && progress.total > 0 ? Math.round((progress.done / progress.total) * 100) : null;
17
+ return (_jsxs("section", { className: cn('flex flex-col gap-4 rounded-lg border bg-card p-4 text-card-foreground', className), "aria-label": title ?? t('health.metrics'), children: [_jsxs("header", { className: 'flex flex-wrap items-start justify-between gap-3', children: [_jsxs("div", { className: 'min-w-0', children: [title ? _jsx("h3", { className: 'truncate text-sm font-semibold', children: title }) : null, _jsxs("div", { className: 'flex items-center gap-2 pt-1', children: [_jsxs("span", { "data-health-status": known, className: cn('inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-xs font-medium', TONE_BADGE[STATUS_TONE[known]]), children: [_jsx(Icon, { className: 'h-3.5 w-3.5', "aria-hidden": 'true' }), t(`health.status.${known}`)] }), checkedAt ? _jsx("span", { className: 'text-xs text-muted-foreground', children: t('health.checked_at', { when: checkedAt }) }) : null] }), summary ? _jsx("p", { className: 'pt-2 text-sm text-muted-foreground', children: summary }) : null] }), _jsxs("div", { className: 'flex items-center gap-2', children: [onRefresh ? (_jsxs(Button, { type: 'button', variant: 'outline', size: 'sm', onClick: onRefresh, disabled: refreshing, className: 'gap-2', children: [_jsx(RefreshCw, { className: cn('h-3.5 w-3.5', refreshing && 'animate-spin motion-reduce:animate-none'), "aria-hidden": 'true' }), t('health.refresh')] })) : null, onContinue ? (_jsx(Button, { type: 'button', size: 'sm', onClick: onContinue, children: t('health.continue') })) : null] })] }), pct !== null && progress ? (_jsxs("div", { className: 'flex flex-col gap-1', children: [_jsx("div", { role: 'progressbar', "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": pct, "aria-label": t('flow.progress'), className: 'h-1.5 w-full overflow-hidden rounded-full bg-muted', children: _jsx("div", { className: 'h-full rounded-full bg-primary transition-all motion-reduce:transition-none', style: { width: `${pct}%` } }) }), _jsx("span", { className: 'text-xs text-muted-foreground', children: t('health.progress', { done: progress.done, total: progress.total }) })] })) : null, metrics && metrics.length > 0 ? (_jsx("dl", { className: 'grid grid-cols-2 gap-3 sm:grid-cols-3', children: metrics.map((m) => (_jsxs("div", { className: 'min-w-0 rounded-md border px-3 py-2', "data-metric-tone": metricTone(m.tone), children: [_jsx("dt", { className: 'truncate text-xs text-muted-foreground', children: m.label }), _jsxs("dd", { className: cn('truncate text-lg font-semibold tabular-nums', TONE_TEXT[metricTone(m.tone)]), children: [m.value, m.unit ? _jsx("span", { className: 'pl-1 text-xs font-normal text-muted-foreground', children: m.unit }) : null] }), m.hint ? _jsx("p", { className: 'truncate text-xs text-muted-foreground', children: m.hint }) : null] }, m.key))) })) : null, issues && issues.length > 0 ? (_jsx("ul", { className: 'flex flex-col gap-2', "aria-label": t('health.issues'), children: issues.map((is, i) => {
18
+ const SevIcon = SEVERITY_ICON[is.severity] ?? Info;
19
+ return (_jsxs("li", { className: 'flex flex-wrap items-start justify-between gap-2 rounded-md border px-3 py-2', "data-severity": is.severity, children: [_jsxs("div", { className: 'flex min-w-0 flex-1 items-start gap-2', children: [_jsx(SevIcon, { className: cn('mt-0.5 h-4 w-4 shrink-0', TONE_TEXT[SEVERITY_TONE[is.severity] ?? 'info']), "aria-hidden": 'true' }), _jsxs("p", { className: 'min-w-0 text-sm', children: [is.message, is.detail ? _jsx("span", { className: 'block break-words text-xs text-muted-foreground', children: is.detail }) : null] })] }), is.fix && onFix ? (_jsx(Button, { type: 'button', size: 'sm', variant: 'outline', className: 'h-7', onClick: () => onFix(is.fix, is), children: is.fix.label ?? t('flow.fix') })) : null] }, is.id ?? i));
20
+ }) })) : issues ? (_jsx("p", { className: 'text-sm text-muted-foreground', children: t('health.no_issues') })) : null] }));
21
+ }
@@ -0,0 +1,11 @@
1
+ export * from './types';
2
+ export * from './flow-model';
3
+ export { useSetupT, SETUP_MESSAGES_ES, SETUP_MESSAGES_EN } from './messages';
4
+ export { StepStatusBadge, type StepStatusBadgeProps } from './step-status-badge';
5
+ export { RecordsTable, copyText, type RecordsTableProps } from './records-table';
6
+ export { HealthCard, type HealthCardProps } from './health-card';
7
+ export { SetupFlow, type SetupFlowProps, type SetupCustomStepProps } from './setup-flow';
8
+ export { SetupFormStep, type SetupFormStepProps } from './setup-form-step';
9
+ export { AddonConfigSurface, clearConnectorLookupCache, type AddonConfigSurfaceProps, type AddonConfigAddon, type AddonConfigNotifier, type AddonSettingDef, type ConnectorEntry, type ConnectorCredentialField, type ConnectorFormLayout, } from './addon-config-surface';
10
+ export * from './connector-form-model';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,13 @@
1
+ // Setup flow + health components (kernel `contributions.setup` / `.health`) and
2
+ // the unified addon configuration surface. Import from the package root or from
3
+ // `@asteby/metacore-runtime-react/setup` to pull only this slice.
4
+ export * from './types';
5
+ export * from './flow-model';
6
+ export { useSetupT, SETUP_MESSAGES_ES, SETUP_MESSAGES_EN } from './messages';
7
+ export { StepStatusBadge } from './step-status-badge';
8
+ export { RecordsTable, copyText } from './records-table';
9
+ export { HealthCard } from './health-card';
10
+ export { SetupFlow } from './setup-flow';
11
+ export { SetupFormStep } from './setup-form-step';
12
+ export { AddonConfigSurface, clearConnectorLookupCache, } from './addon-config-surface';
13
+ export * from './connector-form-model';
@@ -0,0 +1,15 @@
1
+ type Dict = Record<string, string>;
2
+ export declare const SETUP_MESSAGES_ES: Dict;
3
+ export declare const SETUP_MESSAGES_EN: Dict;
4
+ export type TFn = (key: string, vars?: Record<string, unknown>) => string;
5
+ /** Resolves the bundled text for `lang` (es default; any `en*` → English). */
6
+ export declare function defaultMessage(key: string, lang?: string): string;
7
+ /**
8
+ * Translator for the setup components. Keys that start with `setup.` (or are
9
+ * the shared `installed_addons.*` / `common.*` ones) go through i18next first,
10
+ * so a host can override; the bundled es/en text is the default value.
11
+ * Interpolation is done here too, so it works even without an i18next instance.
12
+ */
13
+ export declare function useSetupT(): TFn;
14
+ export {};
15
+ //# sourceMappingURL=messages.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,249 @@
1
+ // i18n for the setup / health components. Every string resolves through
2
+ // react-i18next (`setup.*` keys, so a host can override any of them) with the
3
+ // bundled es/en text as the default. No bundle has to be registered.
4
+ import { useCallback } from 'react';
5
+ import { useTranslation } from 'react-i18next';
6
+ export const SETUP_MESSAGES_ES = {
7
+ 'status.pending': 'Pendiente',
8
+ 'status.running': 'En curso',
9
+ 'status.ok': 'Listo',
10
+ 'status.warn': 'Con avisos',
11
+ 'status.error': 'Con error',
12
+ 'status.blocked': 'Bloqueado',
13
+ 'status.skipped': 'Omitido',
14
+ 'record.status.ok': 'Correcto',
15
+ 'record.status.missing': 'No encontrado',
16
+ 'record.status.wrong_value': 'Valor distinto',
17
+ 'record.status.propagating': 'Propagando',
18
+ 'record.status.pending': 'Sin verificar',
19
+ 'record.status.error': 'Error',
20
+ 'health.status.ok': 'Todo en orden',
21
+ 'health.status.warn': 'Requiere atención',
22
+ 'health.status.error': 'Con problemas',
23
+ 'health.status.unknown': 'Sin datos',
24
+ 'health.metrics': 'Métricas',
25
+ 'health.issues': 'Avisos',
26
+ 'health.no_issues': 'Sin avisos.',
27
+ 'health.checked_at': 'Revisado {{when}}',
28
+ 'health.refresh': 'Actualizar',
29
+ 'health.continue': 'Continuar configuración',
30
+ 'health.progress': '{{done}} de {{total}} pasos',
31
+ 'records.type': 'Tipo',
32
+ 'records.name': 'Nombre',
33
+ 'records.value': 'Valor',
34
+ 'records.status': 'Estado',
35
+ 'records.copy': 'Copiar',
36
+ 'records.copy_label': 'Copiar {{what}}',
37
+ 'records.copied': 'Copiado',
38
+ 'records.copy_failed': 'No se pudo copiar. Selecciona el texto y cópialo a mano.',
39
+ 'records.empty': 'No hay registros por mostrar.',
40
+ 'records.found': 'Encontrado: {{value}}',
41
+ 'records.recheck': 'Verificar ahora',
42
+ 'flow.steps': 'Pasos de configuración',
43
+ 'flow.progress': 'Progreso de la configuración',
44
+ 'flow.step_of': 'Paso {{n}} de {{total}}',
45
+ 'flow.loading': 'Cargando configuración…',
46
+ 'flow.load_error': 'No se pudo cargar el estado de la configuración.',
47
+ 'flow.retry': 'Reintentar',
48
+ 'flow.complete': 'La configuración está completa.',
49
+ 'flow.optional': 'Opcional',
50
+ 'flow.skip': 'Omitir este paso',
51
+ 'flow.run': 'Ejecutar',
52
+ 'flow.check': 'Verificar',
53
+ 'flow.recheck': 'Volver a verificar',
54
+ 'flow.refresh': 'Revisar ahora',
55
+ 'flow.running': 'En curso…',
56
+ 'flow.waiting_for': 'Antes completa: {{steps}}',
57
+ 'flow.next_check': 'Próxima revisión en {{s}} s',
58
+ 'flow.poll_stopped': 'Dejamos de revisar solo. Pulsa «Revisar ahora» para actualizar.',
59
+ 'flow.step_failed': 'No se pudo ejecutar el paso.',
60
+ 'flow.custom_missing': 'Este paso no tiene una pantalla disponible.',
61
+ 'flow.fix': 'Arreglar',
62
+ 'flow.go_to_step': 'Ir al paso',
63
+ 'flow.open_link': 'Abrir',
64
+ 'flow.status_changed': '{{step}}: {{status}}',
65
+ 'form.continue': 'Guardar y continuar',
66
+ 'form.back': 'Atrás',
67
+ 'form.next': 'Siguiente',
68
+ 'form.saving': 'Guardando…',
69
+ 'form.saved': 'Guardado automáticamente',
70
+ 'form.save_error': 'No se pudo guardar automáticamente.',
71
+ 'form.missing': 'Faltan campos obligatorios: {{fields}}.',
72
+ 'form.field_required': 'Falta completar este campo.',
73
+ 'form.stored': 'Guardado. Escribe un valor nuevo solo si quieres cambiarlo.',
74
+ 'form.choose': 'Elige una opción',
75
+ 'form.step': 'Paso',
76
+ // AddonConfigSurface (same keys the ops host already ships)
77
+ 'installed_addons.configure_title': 'Configurar {{name}}',
78
+ 'installed_addons.configure_description': 'Credenciales y ajustes del addon.',
79
+ 'installed_addons.section_credentials': 'Credenciales',
80
+ 'installed_addons.section_settings': 'Ajustes',
81
+ 'installed_addons.advanced': 'Avanzado',
82
+ 'installed_addons.no_settings': 'Este addon no tiene nada que configurar.',
83
+ 'installed_addons.config_saved': 'Configuración guardada',
84
+ 'installed_addons.settings_error': 'No se pudo guardar la configuración',
85
+ 'installed_addons.test_connection': 'Probar conexión',
86
+ 'installed_addons.test_ok': 'Conexión válida',
87
+ 'installed_addons.test_failed': 'No se pudo conectar',
88
+ 'installed_addons.sync_now': 'Sincronizar ahora',
89
+ 'installed_addons.sync_skipped': 'Sincronización omitida',
90
+ 'installed_addons.sync_done': 'Sincronizado: {{licenses}} licencias, {{instances}} instancias, {{accounts}} cuentas',
91
+ 'installed_addons.sync_failed': 'No se pudo sincronizar',
92
+ 'installed_addons.issuer_admin_only': 'Solo un administrador de la organización puede ver y guardar los datos del emisor y el certificado. Pide a un administrador que los configure.',
93
+ 'installed_addons.field_required': 'Falta completar este campo.',
94
+ 'installed_addons.missing_fields': 'Faltan campos obligatorios: {{fields}}.',
95
+ 'installed_addons.shape_public_key': 'Este valor tiene forma de {{target}}. Pégalo en ese campo.',
96
+ 'installed_addons.shape_secret_key': 'Este valor tiene forma de una clave secreta. Pégalo en {{target}}.',
97
+ 'installed_addons.dynamic_select_error': 'No se pudieron listar las opciones. Guarda la conexión y vuelve a intentar.',
98
+ 'installed_addons.dynamic_select_choose': 'Elige una opción',
99
+ 'installed_addons.dynamic_select_placeholder': 'Guarda la conexión y actualiza para elegir',
100
+ 'installed_addons.dynamic_select_refresh': 'Actualizar opciones',
101
+ 'installed_addons.per_branch': 'Por sucursal',
102
+ 'installed_addons.inherit_pending': 'Heredará de la organización al guardar',
103
+ 'installed_addons.branch_own': 'Valor propio de esta sucursal',
104
+ 'installed_addons.branch_inherited': 'Hereda de la organización',
105
+ 'installed_addons.inherit': 'Heredar de la organización',
106
+ 'installed_addons.applies_to': 'Los ajustes aplican a:',
107
+ 'installed_addons.whole_org': 'Toda la organización',
108
+ 'installed_addons.only_branch': 'Solo {{name}}',
109
+ 'installed_addons.secret_stored': 'Hay un valor guardado. Déjalo vacío para conservarlo.',
110
+ 'common.back': 'Atrás',
111
+ 'common.next': 'Siguiente',
112
+ 'common.cancel': 'Cancelar',
113
+ 'common.save': 'Guardar',
114
+ };
115
+ export const SETUP_MESSAGES_EN = {
116
+ 'status.pending': 'Pending',
117
+ 'status.running': 'In progress',
118
+ 'status.ok': 'Done',
119
+ 'status.warn': 'Has warnings',
120
+ 'status.error': 'Has errors',
121
+ 'status.blocked': 'Blocked',
122
+ 'status.skipped': 'Skipped',
123
+ 'record.status.ok': 'Correct',
124
+ 'record.status.missing': 'Not found',
125
+ 'record.status.wrong_value': 'Different value',
126
+ 'record.status.propagating': 'Propagating',
127
+ 'record.status.pending': 'Not checked',
128
+ 'record.status.error': 'Error',
129
+ 'health.status.ok': 'All good',
130
+ 'health.status.warn': 'Needs attention',
131
+ 'health.status.error': 'Has problems',
132
+ 'health.status.unknown': 'No data',
133
+ 'health.metrics': 'Metrics',
134
+ 'health.issues': 'Issues',
135
+ 'health.no_issues': 'No issues.',
136
+ 'health.checked_at': 'Checked {{when}}',
137
+ 'health.refresh': 'Refresh',
138
+ 'health.continue': 'Continue setup',
139
+ 'health.progress': '{{done}} of {{total}} steps',
140
+ 'records.type': 'Type',
141
+ 'records.name': 'Name',
142
+ 'records.value': 'Value',
143
+ 'records.status': 'Status',
144
+ 'records.copy': 'Copy',
145
+ 'records.copy_label': 'Copy {{what}}',
146
+ 'records.copied': 'Copied',
147
+ 'records.copy_failed': 'Could not copy. Select the text and copy it by hand.',
148
+ 'records.empty': 'No records to show.',
149
+ 'records.found': 'Found: {{value}}',
150
+ 'records.recheck': 'Check now',
151
+ 'flow.steps': 'Setup steps',
152
+ 'flow.progress': 'Setup progress',
153
+ 'flow.step_of': 'Step {{n}} of {{total}}',
154
+ 'flow.loading': 'Loading setup…',
155
+ 'flow.load_error': 'Could not load the setup state.',
156
+ 'flow.retry': 'Try again',
157
+ 'flow.complete': 'Setup is complete.',
158
+ 'flow.optional': 'Optional',
159
+ 'flow.skip': 'Skip this step',
160
+ 'flow.run': 'Run',
161
+ 'flow.check': 'Check',
162
+ 'flow.recheck': 'Check again',
163
+ 'flow.refresh': 'Check now',
164
+ 'flow.running': 'In progress…',
165
+ 'flow.waiting_for': 'Finish first: {{steps}}',
166
+ 'flow.next_check': 'Next check in {{s}} s',
167
+ 'flow.poll_stopped': 'We stopped checking automatically. Press "Check now" to refresh.',
168
+ 'flow.step_failed': 'The step could not be run.',
169
+ 'flow.custom_missing': 'This step has no screen available.',
170
+ 'flow.fix': 'Fix',
171
+ 'flow.go_to_step': 'Go to step',
172
+ 'flow.open_link': 'Open',
173
+ 'flow.status_changed': '{{step}}: {{status}}',
174
+ 'form.continue': 'Save and continue',
175
+ 'form.back': 'Back',
176
+ 'form.next': 'Next',
177
+ 'form.saving': 'Saving…',
178
+ 'form.saved': 'Saved automatically',
179
+ 'form.save_error': 'Could not save automatically.',
180
+ 'form.missing': 'Required fields are missing: {{fields}}.',
181
+ 'form.field_required': 'This field is required.',
182
+ 'form.stored': 'Saved. Type a new value only if you want to change it.',
183
+ 'form.choose': 'Choose an option',
184
+ 'form.step': 'Step',
185
+ 'installed_addons.configure_title': 'Configure {{name}}',
186
+ 'installed_addons.configure_description': 'Credentials and settings for this addon.',
187
+ 'installed_addons.section_credentials': 'Credentials',
188
+ 'installed_addons.section_settings': 'Settings',
189
+ 'installed_addons.advanced': 'Advanced',
190
+ 'installed_addons.no_settings': 'This addon has nothing to configure.',
191
+ 'installed_addons.config_saved': 'Configuration saved',
192
+ 'installed_addons.settings_error': 'Could not save the configuration',
193
+ 'installed_addons.test_connection': 'Test connection',
194
+ 'installed_addons.test_ok': 'Connection is valid',
195
+ 'installed_addons.test_failed': 'Could not connect',
196
+ 'installed_addons.sync_now': 'Sync now',
197
+ 'installed_addons.sync_skipped': 'Sync skipped',
198
+ 'installed_addons.sync_done': 'Synced: {{licenses}} licenses, {{instances}} instances, {{accounts}} accounts',
199
+ 'installed_addons.sync_failed': 'Could not sync',
200
+ 'installed_addons.issuer_admin_only': 'Only an organization administrator can view and save the issuer and certificate data. Ask an administrator to set them up.',
201
+ 'installed_addons.field_required': 'This field is required.',
202
+ 'installed_addons.missing_fields': 'Required fields are missing: {{fields}}.',
203
+ 'installed_addons.shape_public_key': 'This value looks like {{target}}. Paste it in that field.',
204
+ 'installed_addons.shape_secret_key': 'This value looks like a secret key. Paste it in {{target}}.',
205
+ 'installed_addons.dynamic_select_error': 'Could not list the options. Save the connection and try again.',
206
+ 'installed_addons.dynamic_select_choose': 'Choose an option',
207
+ 'installed_addons.dynamic_select_placeholder': 'Save the connection and refresh to choose',
208
+ 'installed_addons.dynamic_select_refresh': 'Refresh options',
209
+ 'installed_addons.per_branch': 'Per branch',
210
+ 'installed_addons.inherit_pending': 'Will inherit from the organization on save',
211
+ 'installed_addons.branch_own': "This branch's own value",
212
+ 'installed_addons.branch_inherited': 'Inherits from the organization',
213
+ 'installed_addons.inherit': 'Inherit from the organization',
214
+ 'installed_addons.applies_to': 'Settings apply to:',
215
+ 'installed_addons.whole_org': 'Whole organization',
216
+ 'installed_addons.only_branch': 'Only {{name}}',
217
+ 'installed_addons.secret_stored': 'A value is stored. Leave it empty to keep it.',
218
+ 'common.back': 'Back',
219
+ 'common.next': 'Next',
220
+ 'common.cancel': 'Cancel',
221
+ 'common.save': 'Save',
222
+ };
223
+ function interpolate(s, vars) {
224
+ if (!vars)
225
+ return s;
226
+ return s.replace(/\{\{\s*(\w+)\s*\}\}/g, (_, k) => (vars[k] == null ? '' : String(vars[k])));
227
+ }
228
+ /** Resolves the bundled text for `lang` (es default; any `en*` → English). */
229
+ export function defaultMessage(key, lang) {
230
+ const dict = lang && lang.toLowerCase().startsWith('en') ? SETUP_MESSAGES_EN : SETUP_MESSAGES_ES;
231
+ return dict[key] ?? SETUP_MESSAGES_ES[key] ?? key;
232
+ }
233
+ /**
234
+ * Translator for the setup components. Keys that start with `setup.` (or are
235
+ * the shared `installed_addons.*` / `common.*` ones) go through i18next first,
236
+ * so a host can override; the bundled es/en text is the default value.
237
+ * Interpolation is done here too, so it works even without an i18next instance.
238
+ */
239
+ export function useSetupT() {
240
+ const { t, i18n } = useTranslation();
241
+ const lang = i18n?.language;
242
+ return useCallback((key, vars) => {
243
+ const hostKey = key.includes('.') && /^(installed_addons|common)\./.test(key) ? key : `setup.${key}`;
244
+ const fallback = defaultMessage(key, lang);
245
+ const out = t(hostKey, { ...(vars ?? {}), defaultValue: fallback });
246
+ // Mocked / minimal `t` implementations may ignore interpolation.
247
+ return interpolate(typeof out === 'string' ? out : fallback, vars);
248
+ }, [t, lang]);
249
+ }
@@ -0,0 +1,24 @@
1
+ import type { SetupFix, SetupRecord } from './types';
2
+ /**
3
+ * Copies text with a fallback: the async Clipboard API when the page may use
4
+ * it, otherwise a hidden textarea + `execCommand('copy')` (http pages, older
5
+ * webviews, denied permission). Resolves to whether something was copied.
6
+ */
7
+ export declare function copyText(text: string): Promise<boolean>;
8
+ export interface RecordsTableProps {
9
+ records: SetupRecord[];
10
+ caption?: string;
11
+ /** Fix button of a row's diagnostic (`fix.action|url|step`). */
12
+ onFix?: (fix: SetupFix, record: SetupRecord) => void;
13
+ /** Shows a "check now" button above the table. */
14
+ onRecheck?: () => void;
15
+ rechecking?: boolean;
16
+ className?: string;
17
+ }
18
+ /**
19
+ * Type / name / value table (DNS records and the like) with per-row copy,
20
+ * status and diagnostic. Scrolls horizontally on narrow screens instead of
21
+ * squeezing the values; values wrap (`break-all`) so a long DKIM key is readable.
22
+ */
23
+ export declare function RecordsTable({ records, caption, onFix, onRecheck, rechecking, className }: RecordsTableProps): import("react").JSX.Element;
24
+ //# sourceMappingURL=records-table.d.ts.map