@asteby/metacore-runtime-react 53.2.0 → 53.4.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 (49) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/dynamic-columns.d.ts.map +1 -1
  3. package/dist/dynamic-columns.js +26 -4
  4. package/dist/index.d.ts +1 -1
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +1 -1
  7. package/dist/license/index.d.ts +3 -1
  8. package/dist/license/index.d.ts.map +1 -1
  9. package/dist/license/index.js +3 -1
  10. package/dist/license/license-expiry-banner.d.ts +8 -1
  11. package/dist/license/license-expiry-banner.d.ts.map +1 -1
  12. package/dist/license/license-expiry-banner.js +96 -54
  13. package/dist/license/license-gate.d.ts +14 -4
  14. package/dist/license/license-gate.d.ts.map +1 -1
  15. package/dist/license/license-gate.js +75 -63
  16. package/dist/license/license-status-badge.d.ts.map +1 -1
  17. package/dist/license/license-status-badge.js +8 -9
  18. package/dist/license/messages.d.ts +29 -0
  19. package/dist/license/messages.d.ts.map +1 -0
  20. package/dist/license/messages.js +159 -0
  21. package/dist/license/types.d.ts +30 -7
  22. package/dist/license/types.d.ts.map +1 -1
  23. package/dist/license/types.js +20 -6
  24. package/dist/license/use-license-t.d.ts +11 -0
  25. package/dist/license/use-license-t.d.ts.map +1 -0
  26. package/dist/license/use-license-t.js +18 -0
  27. package/dist/license/view.d.ts +40 -0
  28. package/dist/license/view.d.ts.map +1 -0
  29. package/dist/license/view.js +62 -0
  30. package/dist/relative-date.d.ts +37 -0
  31. package/dist/relative-date.d.ts.map +1 -0
  32. package/dist/relative-date.js +110 -0
  33. package/dist/types.d.ts +1 -1
  34. package/dist/types.d.ts.map +1 -1
  35. package/package.json +1 -1
  36. package/src/__tests__/license-states.test.tsx +381 -0
  37. package/src/__tests__/relative-date-brand-avatar.test.tsx +154 -0
  38. package/src/dynamic-columns.tsx +48 -6
  39. package/src/index.ts +13 -0
  40. package/src/license/index.ts +19 -0
  41. package/src/license/license-expiry-banner.tsx +155 -94
  42. package/src/license/license-gate.tsx +210 -147
  43. package/src/license/license-status-badge.tsx +8 -10
  44. package/src/license/messages.ts +185 -0
  45. package/src/license/types.ts +38 -6
  46. package/src/license/use-license-t.ts +23 -0
  47. package/src/license/view.ts +93 -0
  48. package/src/relative-date.tsx +142 -0
  49. package/src/types.ts +2 -0
@@ -7,12 +7,20 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
7
7
  * <AppShell />
8
8
  * </LicenseGate>
9
9
  *
10
- * Comportamiento según el estado (resuelto por el backend del host):
10
+ * Comportamiento según el estado (resuelto por el backend del host; la lógica de
11
+ * qué significa cada estado vive en `deriveLicenseView`):
11
12
  * - Sin enforcement, o estado operable (valid/stale/grace) → renderiza children.
12
- * stale/grace además montan el <LicenseExpiryBanner> degradado por encima.
13
- * - enforcement && missing/invalid/expired → modal BLOQUEANTE full-screen,
14
- * no descartable, con el formulario de activación. Al activar con éxito el
15
- * host refresca el estado y el gate se abre sin recargar.
13
+ * Los estados que piden atención montan el <LicenseExpiryBanner> por encima:
14
+ * por vencer, gracia, hub caído (solo dueño), clonada (solo dueño) y las
15
+ * licencias en solo lectura (vencida o desactivada con plazo), que además
16
+ * ofrecen exportar los datos si el host pasa `onExport`.
17
+ * - Sin licencia, no válida, desactivada o vencida sin solo lectura → modal
18
+ * BLOQUEANTE full-screen, no descartable, con el formulario de activación
19
+ * (enlace, código o clave) y el contacto del vendedor si la licencia lo trae.
20
+ * Al activar con éxito el host refresca el estado y el gate se abre sin recargar.
21
+ *
22
+ * El modal es un diálogo con encabezado y pie fijos: solo el cuerpo se desplaza,
23
+ * así el botón de activar nunca queda fuera de pantalla en un teléfono.
16
24
  *
17
25
  * Es branding-aware si el host pasa `branding` (logo/nombre desde el
18
26
  * PlatformConfig del SDK); si no, cae a un encabezado neutro.
@@ -22,45 +30,53 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
22
30
  */
23
31
  import { createPortal } from 'react-dom';
24
32
  import { useState } from 'react';
25
- import { useTranslation } from 'react-i18next';
26
33
  import { ShieldAlert, Clock, Loader2 } from 'lucide-react';
27
34
  import { Button, Input } from '@asteby/metacore-ui';
28
- import { isLicenseBlocking, isTrialExpired, } from './types';
35
+ import { deriveLicenseView, sellerContactLine } from './view';
36
+ import { formatLicenseDate } from './messages';
37
+ import { useLicenseT } from './use-license-t';
29
38
  import { LicenseStatusBadge } from './license-status-badge';
30
39
  import { LicenseExpiryBanner } from './license-expiry-banner';
31
40
  function cx(...parts) {
32
41
  return parts.filter(Boolean).join(' ');
33
42
  }
34
- export function LicenseGate({ state, onActivate, children, branding, onManage, canActivate = true, readOnlyMessage, className, }) {
35
- const blocking = isLicenseBlocking(state);
36
- return (_jsxs(_Fragment, { children: [!blocking && (_jsx(LicenseExpiryBanner, { state: state, onManage: onManage })), children, blocking && state && (_jsx(LicenseGateModal, { state: state, onActivate: onActivate, branding: branding, canActivate: canActivate, readOnlyMessage: readOnlyMessage, className: className }))] }));
43
+ export function LicenseGate({ state, onActivate, children, branding, onManage, onExport, isOwner = false, acceptsActivationLink = false, canActivate = true, readOnlyMessage, className, }) {
44
+ const view = deriveLicenseView(state);
45
+ const blocking = !!view?.blocking;
46
+ return (_jsxs(_Fragment, { children: [!blocking && (_jsx(LicenseExpiryBanner, { state: state, onManage: onManage, onExport: onExport, isOwner: isOwner })), children, blocking && state && (_jsx(LicenseGateModal, { state: state, onActivate: onActivate, branding: branding, canActivate: canActivate, readOnlyMessage: readOnlyMessage, acceptsActivationLink: acceptsActivationLink, onExport: onExport, className: className }))] }));
37
47
  }
38
- function LicenseGateModal({ state, onActivate, branding, canActivate, readOnlyMessage, className, }) {
39
- const { t } = useTranslation();
48
+ const FORM_ID = 'license-gate-form';
49
+ function LicenseGateModal({ state, onActivate, branding, canActivate, readOnlyMessage, acceptsActivationLink, onExport, className, }) {
50
+ const { t, lang } = useLicenseT();
40
51
  const [code, setCode] = useState('');
41
52
  const [submitting, setSubmitting] = useState(false);
42
53
  const [error, setError] = useState(null);
43
- const trialExpired = isTrialExpired(state);
54
+ const view = deriveLicenseView(state);
55
+ const trialExpired = !!view?.trialExpired;
56
+ const revoked = state.status === 'revoked';
57
+ const expired = state.status === 'expired';
58
+ const provider = t('license.gate.provider');
59
+ const who = state.seller?.name?.trim() || provider;
60
+ const expiredOn = formatLicenseDate(state.expires_at, lang);
61
+ const contact = sellerContactLine(state);
44
62
  const title = trialExpired
45
- ? t('license.gate.trial_title', {
46
- defaultValue: 'Tu prueba gratuita terminó',
47
- })
48
- : t('license.gate.title', { defaultValue: 'Activa tu licencia' });
63
+ ? t('license.gate.trial_title')
64
+ : revoked
65
+ ? t('license.gate.revoked_title')
66
+ : expired
67
+ ? t('license.gate.expired_title')
68
+ : t('license.gate.title');
49
69
  const description = trialExpired
50
- ? t('license.gate.trial_description', {
51
- defaultValue: 'Tu prueba gratuita terminó. Activa una licencia para continuar. Pega tu clave (lic_…) o el token firmado que te entregaron.',
52
- })
53
- : state.status === 'expired'
54
- ? t('license.gate.expired_description', {
55
- defaultValue: 'Tu licencia venció y el periodo de gracia terminó. Activa una licencia vigente para seguir operando. Pega tu clave (lic_…) o el token firmado.',
56
- })
57
- : state.status === 'invalid'
58
- ? t('license.gate.invalid_description', {
59
- defaultValue: 'La licencia de esta instancia no es válida. Pega una clave (lic_…) o el token firmado que te entregó tu proveedor para reactivarla.',
60
- })
61
- : t('license.gate.missing_description', {
62
- defaultValue: 'Esta instancia necesita una licencia activa para operar. Pega tu clave (lic_…) o el token firmado para activarla.',
63
- });
70
+ ? t('license.gate.trial_description')
71
+ : revoked
72
+ ? t('license.gate.revoked_description', { who })
73
+ : expired
74
+ ? expiredOn
75
+ ? t('license.gate.expired_description', { date: expiredOn })
76
+ : t('license.gate.expired_description_nodate')
77
+ : state.status === 'invalid'
78
+ ? t('license.gate.invalid_description')
79
+ : t('license.gate.missing_description');
64
80
  const canSubmit = code.trim().length > 0 && !submitting;
65
81
  const submit = async () => {
66
82
  if (!canSubmit)
@@ -73,42 +89,38 @@ function LicenseGateModal({ state, onActivate, branding, canActivate, readOnlyMe
73
89
  // modal se desmonta solo. No recargamos.
74
90
  }
75
91
  catch (e) {
76
- const message = e instanceof Error && e.message
77
- ? e.message
78
- : t('license.gate.activate_error', {
79
- defaultValue: 'No se pudo activar la licencia.',
80
- });
92
+ const hubCode = e?.code;
93
+ const known = hubCode && LICENSE_LINK_CODES.has(hubCode) ? t(`license.link.${hubCode}`) : null;
94
+ const message = known ??
95
+ (e instanceof Error && e.message ? e.message : t('license.gate.activate_error'));
81
96
  setError(message);
82
97
  setSubmitting(false);
83
98
  }
84
99
  };
85
100
  // In <body>: mounted inside a glass panel (backdrop-filter), a fixed veil
86
101
  // would cover only that panel.
87
- return createPortal(_jsx("div", { role: "dialog", "aria-modal": "true", "aria-labelledby": "license-gate-title", "data-license-status": state.status, className: cx('fixed inset-0 z-[100] flex items-center justify-center bg-background/90 p-4 backdrop-blur-sm', className), children: _jsx("div", { className: "w-full max-w-lg overflow-hidden rounded-2xl border bg-card text-card-foreground shadow-2xl", children: _jsxs("div", { className: "flex flex-col gap-4 p-6", children: [_jsxs("div", { className: "flex items-start gap-3", children: [branding?.logo ? (_jsx("img", { src: branding.logo, alt: branding.name ?? '', className: "h-10 w-10 shrink-0 rounded-xl object-contain" })) : (_jsx("div", { className: cx('flex h-10 w-10 shrink-0 items-center justify-center rounded-xl', trialExpired
88
- ? 'bg-primary/10 text-primary'
89
- : 'bg-destructive/10 text-destructive'), children: trialExpired ? (_jsx(Clock, { className: "h-5 w-5", "aria-hidden": true })) : (_jsx(ShieldAlert, { className: "h-5 w-5", "aria-hidden": true })) })), _jsxs("div", { className: "flex min-w-0 flex-col gap-1", children: [_jsx("h2", { id: "license-gate-title", className: "text-lg leading-tight font-semibold", children: title }), _jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsx(LicenseStatusBadge, { status: state.status }), _jsx("span", { className: "text-muted-foreground text-xs", children: branding?.name
90
- ? branding.name
91
- : t('license.gate.instance', {
92
- defaultValue: 'Esta instancia',
93
- }) })] })] })] }), _jsx("p", { className: "text-muted-foreground text-sm", children: description }), state.reason && (_jsx("p", { className: "bg-muted/50 text-muted-foreground rounded-md px-3 py-2 text-xs", children: state.reason })), !canActivate ? (_jsx("p", { role: "note", className: "border-border bg-muted/40 text-muted-foreground rounded-md border px-3 py-3 text-sm", children: readOnlyMessage ??
94
- t('license.gate.read_only', {
95
- defaultValue: 'Contacta al administrador de la plataforma para activar la licencia.',
96
- }) })) : (_jsxs("form", { className: "flex flex-col gap-2", onSubmit: (e) => {
97
- e.preventDefault();
98
- void submit();
99
- }, children: [_jsx("label", { htmlFor: "license-gate-code", className: "text-sm font-medium", children: t('license.gate.code_label', {
100
- defaultValue: 'Clave o token de licencia',
101
- }) }), _jsx(Input, { id: "license-gate-code", autoFocus: true, autoComplete: "off", spellCheck: false, placeholder: t('license.gate.code_placeholder', {
102
- defaultValue: 'lic_… o pega el token firmado',
103
- }), value: code, disabled: submitting, "aria-invalid": error ? true : undefined, onChange: (e) => {
104
- setCode(e.target.value);
105
- if (error)
106
- setError(null);
107
- } }), error && (_jsx("p", { role: "alert", className: "text-destructive text-sm", children: error })), _jsxs(Button, { type: "submit", className: "mt-1 w-full", disabled: !canSubmit, children: [submitting && (_jsx(Loader2, { className: "h-4 w-4 animate-spin", "aria-hidden": true })), submitting
108
- ? t('license.gate.activating', {
109
- defaultValue: 'Activando…',
110
- })
111
- : t('license.gate.activate', {
112
- defaultValue: 'Activar licencia',
113
- })] })] }))] }) }) }), document.body);
102
+ return createPortal(_jsx("div", { role: "dialog", "aria-modal": "true", "aria-labelledby": "license-gate-title", "data-license-status": state.status, className: cx('fixed inset-0 z-[100] flex items-center justify-center bg-background/90 p-4 backdrop-blur-sm', className), children: _jsxs("div", { className: "bg-card text-card-foreground flex max-h-[calc(100dvh-2rem)] w-full max-w-lg flex-col overflow-hidden rounded-2xl border shadow-2xl", children: [_jsxs("header", { "data-license-part": "header", className: "flex shrink-0 items-start gap-3 border-b p-6 pb-4", children: [branding?.logo ? (_jsx("img", { src: branding.logo, alt: branding.name ?? '', className: "h-10 w-10 shrink-0 rounded-xl object-contain" })) : (_jsx("div", { className: cx('flex h-10 w-10 shrink-0 items-center justify-center rounded-xl', trialExpired
103
+ ? 'bg-primary/10 text-primary'
104
+ : 'bg-destructive/10 text-destructive'), children: trialExpired ? (_jsx(Clock, { className: "h-5 w-5", "aria-hidden": true })) : (_jsx(ShieldAlert, { className: "h-5 w-5", "aria-hidden": true })) })), _jsxs("div", { className: "flex min-w-0 flex-col gap-1", children: [_jsx("h2", { id: "license-gate-title", className: "text-lg leading-tight font-semibold", children: title }), _jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsx(LicenseStatusBadge, { status: state.status }), _jsx("span", { className: "text-muted-foreground text-xs", children: branding?.name ? branding.name : t('license.gate.instance') })] })] })] }), _jsxs("div", { "data-license-part": "body", className: "flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto p-6", children: [_jsx("p", { className: "text-muted-foreground text-sm", children: description }), state.reason && (_jsx("p", { className: "bg-muted/50 text-muted-foreground rounded-md px-3 py-2 text-xs", children: state.reason })), contact && (_jsxs("p", { "data-license-part": "seller", className: "border-border bg-muted/40 rounded-md border px-3 py-2 text-sm", children: [_jsxs("span", { className: "text-muted-foreground", children: [t('license.gate.contact_label'), ":", ' '] }), state.seller?.name ? _jsx("strong", { children: state.seller.name }) : null, state.seller?.name ? ' · ' : null, contact] })), !canActivate ? (_jsx("p", { role: "note", className: "border-border bg-muted/40 text-muted-foreground rounded-md border px-3 py-3 text-sm", children: readOnlyMessage ?? t('license.gate.read_only') })) : (_jsxs("form", { id: FORM_ID, className: "flex flex-col gap-2", onSubmit: (e) => {
105
+ e.preventDefault();
106
+ void submit();
107
+ }, children: [_jsx("label", { htmlFor: "license-gate-code", className: "text-sm font-medium", children: acceptsActivationLink
108
+ ? t('license.gate.code_label_link')
109
+ : t('license.gate.code_label') }), _jsx(Input, { id: "license-gate-code", autoFocus: true, autoComplete: "off", spellCheck: false, placeholder: acceptsActivationLink
110
+ ? t('license.gate.code_placeholder_link')
111
+ : t('license.gate.code_placeholder'), value: code, disabled: submitting, "aria-invalid": error ? true : undefined, onChange: (e) => {
112
+ setCode(e.target.value);
113
+ if (error)
114
+ setError(null);
115
+ } }), error && (_jsx("p", { role: "alert", className: "text-destructive text-sm", children: error }))] }))] }), (canActivate || (expired && onExport)) && (_jsxs("footer", { "data-license-part": "footer", className: "flex shrink-0 flex-col gap-2 border-t p-6 pt-4 sm:flex-row-reverse", children: [canActivate && (_jsxs(Button, { type: "submit", form: FORM_ID, className: "w-full sm:w-auto", disabled: !canSubmit, children: [submitting && _jsx(Loader2, { className: "h-4 w-4 animate-spin", "aria-hidden": true }), submitting ? t('license.gate.activating') : t('license.gate.activate')] })), expired && onExport && (_jsx(Button, { type: "button", variant: "outline", className: "w-full sm:w-auto", onClick: onExport, children: t('license.gate.export') }))] }))] }) }), document.body);
114
116
  }
117
+ const LICENSE_LINK_CODES = new Set([
118
+ 'activation_not_found',
119
+ 'activation_used',
120
+ 'activation_conflict',
121
+ 'activation_expired',
122
+ 'activation_revoked',
123
+ 'license_revoked',
124
+ 'license_expired',
125
+ 'rate_limited',
126
+ ]);
@@ -1 +1 @@
1
- {"version":3,"file":"license-status-badge.d.ts","sourceRoot":"","sources":["../../src/license/license-status-badge.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAuD5C,MAAM,WAAW,uBAAuB;IACpC,MAAM,EAAE,aAAa,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,wBAAgB,kBAAkB,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,uBAAuB,+BAkBhF"}
1
+ {"version":3,"file":"license-status-badge.d.ts","sourceRoot":"","sources":["../../src/license/license-status-badge.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAsD5C,MAAM,WAAW,uBAAuB;IACpC,MAAM,EAAE,aAAa,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,wBAAgB,kBAAkB,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,uBAAuB,+BAkBhF"}
@@ -4,54 +4,53 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
4
  * color + etiqueta legible. Reutilizable suelto (p. ej. en Ajustes de licencia)
5
5
  * o embebido en el encabezado del <LicenseGate>.
6
6
  */
7
- import { useTranslation } from 'react-i18next';
8
7
  import { ShieldCheck, ShieldAlert, ShieldQuestion, Clock, CloudOff, } from 'lucide-react';
9
8
  import { Badge } from '@asteby/metacore-ui';
9
+ import { useLicenseT } from './use-license-t';
10
10
  const STATUS_META = {
11
11
  valid: {
12
12
  variant: 'default',
13
13
  Icon: ShieldCheck,
14
14
  key: 'license.status.valid',
15
- defaultValue: 'Activa',
16
15
  },
17
16
  stale: {
18
17
  variant: 'outline',
19
18
  Icon: CloudOff,
20
19
  key: 'license.status.stale',
21
- defaultValue: 'Sin verificar',
22
20
  warn: true,
23
21
  },
24
22
  grace: {
25
23
  variant: 'outline',
26
24
  Icon: Clock,
27
25
  key: 'license.status.grace',
28
- defaultValue: 'En gracia',
29
26
  warn: true,
30
27
  },
31
28
  expired: {
32
29
  variant: 'destructive',
33
30
  Icon: ShieldAlert,
34
31
  key: 'license.status.expired',
35
- defaultValue: 'Vencida',
36
32
  },
37
33
  missing: {
38
34
  variant: 'secondary',
39
35
  Icon: ShieldQuestion,
40
36
  key: 'license.status.missing',
41
- defaultValue: 'Sin licencia',
42
37
  },
43
38
  invalid: {
44
39
  variant: 'destructive',
45
40
  Icon: ShieldAlert,
46
41
  key: 'license.status.invalid',
47
- defaultValue: 'Inválida',
42
+ },
43
+ revoked: {
44
+ variant: 'destructive',
45
+ Icon: ShieldAlert,
46
+ key: 'license.status.revoked',
48
47
  },
49
48
  };
50
49
  export function LicenseStatusBadge({ status, className }) {
51
- const { t } = useTranslation();
50
+ const { t } = useLicenseT();
52
51
  const meta = STATUS_META[status] ?? STATUS_META.missing;
53
52
  const { Icon } = meta;
54
53
  return (_jsxs(Badge, { variant: meta.variant, className: (meta.warn
55
54
  ? 'border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-400 '
56
- : '') + (className ?? ''), children: [_jsx(Icon, { "aria-hidden": true }), t(meta.key, { defaultValue: meta.defaultValue })] }));
55
+ : '') + (className ?? ''), children: [_jsx(Icon, { "aria-hidden": true }), t(meta.key)] }));
57
56
  }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Textos del blindaje de licencia, en español e inglés. Son el copy exacto de
3
+ * cada estado: dicen QUÉ pasó y QUÉ sigue, sin repetir lo que ya dicen las
4
+ * etiquetas y botones de la pantalla (nada de "pega tu clave" junto a un campo
5
+ * que ya se llama "Clave…").
6
+ *
7
+ * Cada componente los pide con `t(key, { defaultValue })`: un host con i18n
8
+ * puede sobrescribir cualquier clave en su bundle; sin i18n sale este texto.
9
+ * `registerLicenseMessages(i18n)` los siembra en un i18next sin pisar lo del host.
10
+ *
11
+ * El SDK es genérico: aquí no hay marca, vertical ni vendedor concreto. El
12
+ * contacto del vendedor llega en el propio estado de la licencia.
13
+ */
14
+ export type LicenseLang = 'es' | 'en';
15
+ export declare function licenseLang(language?: string): LicenseLang;
16
+ export declare const LICENSE_MESSAGES: Record<LicenseLang, Record<string, string>>;
17
+ /** Fecha corta y estable (UTC) para los textos de licencia. */
18
+ export declare function formatLicenseDate(iso: string | undefined, lang: LicenseLang): string | undefined;
19
+ /** Minimal i18next surface needed to seed the bundles. */
20
+ interface I18nLike {
21
+ addResourceBundle?: (lng: string, ns: string, res: object, deep?: boolean, overwrite?: boolean) => unknown;
22
+ }
23
+ /**
24
+ * Siembra es/en en el i18next del host SIN pisar lo que ya tenga (overwrite=false):
25
+ * el host manda, el SDK solo rellena lo que falta.
26
+ */
27
+ export declare function registerLicenseMessages(i18n: I18nLike | undefined, ns?: string): void;
28
+ export {};
29
+ //# sourceMappingURL=messages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/license/messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,WAAW,GAAG,IAAI,GAAG,IAAI,CAAA;AAErC,wBAAgB,WAAW,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,WAAW,CAE1D;AAED,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA+HxE,CAAA;AAED,+DAA+D;AAC/D,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,WAAW,GAAG,MAAM,GAAG,SAAS,CAUhG;AAED,0DAA0D;AAC1D,UAAU,QAAQ;IACd,iBAAiB,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,SAAS,CAAC,EAAE,OAAO,KAAK,OAAO,CAAA;CAC7G;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,QAAQ,GAAG,SAAS,EAAE,EAAE,SAAgB,GAAG,IAAI,CAc5F"}
@@ -0,0 +1,159 @@
1
+ export function licenseLang(language) {
2
+ return (language ?? '').toLowerCase().startsWith('en') ? 'en' : 'es';
3
+ }
4
+ export const LICENSE_MESSAGES = {
5
+ es: {
6
+ // Insignias
7
+ 'license.status.valid': 'Activa',
8
+ 'license.status.stale': 'Sin verificar',
9
+ 'license.status.grace': 'En gracia',
10
+ 'license.status.expired': 'Vencida',
11
+ 'license.status.missing': 'Sin licencia',
12
+ 'license.status.invalid': 'Inválida',
13
+ 'license.status.revoked': 'Desactivada',
14
+ // Modal bloqueante
15
+ 'license.gate.instance': 'Esta instancia',
16
+ 'license.gate.title': 'Activa tu licencia',
17
+ 'license.gate.missing_description': 'Esta instancia todavía no tiene una licencia activa.',
18
+ 'license.gate.invalid_description': 'No pudimos validar la licencia de esta instancia.',
19
+ 'license.gate.expired_title': 'Tu licencia venció',
20
+ 'license.gate.expired_description': 'Tu licencia venció el {{date}} y el periodo de gracia terminó.',
21
+ 'license.gate.expired_description_nodate': 'Tu licencia venció y el periodo de gracia terminó.',
22
+ 'license.gate.trial_title': 'Tu prueba gratuita terminó',
23
+ 'license.gate.trial_description': 'La prueba gratuita de esta instancia terminó.',
24
+ 'license.gate.revoked_title': 'Licencia desactivada',
25
+ 'license.gate.revoked_description': '{{who}} desactivó la licencia de esta instancia.',
26
+ 'license.gate.read_only': 'Contacta al administrador de la plataforma para activar la licencia.',
27
+ 'license.gate.code_label': 'Clave o token de licencia',
28
+ 'license.gate.code_label_link': 'Enlace, código o clave de licencia',
29
+ 'license.gate.code_placeholder': 'lic_… o pega el token firmado',
30
+ 'license.gate.code_placeholder_link': 'https://…/a/acs_…, acs_… o lic_…',
31
+ 'license.gate.activate': 'Activar licencia',
32
+ 'license.gate.activating': 'Activando…',
33
+ 'license.gate.activate_error': 'No se pudo activar la licencia.',
34
+ 'license.gate.export': 'Exportar mis datos',
35
+ 'license.gate.provider': 'Tu proveedor',
36
+ 'license.gate.contact_label': 'Contacto',
37
+ // Errores de un enlace o código de activación (código estable del hub)
38
+ 'license.link.activation_not_found': 'No reconocemos ese enlace o código. Revisa que esté completo o pide uno nuevo a tu proveedor.',
39
+ 'license.link.activation_used': 'Este enlace ya se usó en otro servidor. Pide uno nuevo a tu proveedor.',
40
+ 'license.link.activation_conflict': 'Esta licencia ya funciona en otro servidor. Si lo reinstalaste, pide a tu proveedor que la libere.',
41
+ 'license.link.activation_expired': 'El enlace venció. Tu proveedor puede generarte otro en un minuto.',
42
+ 'license.link.activation_revoked': 'Tu proveedor revocó este enlace. Contáctalo para recibir uno nuevo.',
43
+ 'license.link.license_revoked': 'Tu proveedor desactivó esta licencia. Contáctalo para reactivarla.',
44
+ 'license.link.license_expired': 'La licencia de este enlace ya venció. Tu proveedor puede renovarla.',
45
+ 'license.link.rate_limited': 'Demasiados intentos. Espera unos minutos y vuelve a probar.',
46
+ // Banner
47
+ 'license.banner.upcoming': 'Tu licencia vence en {{days}} días.',
48
+ 'license.banner.upcoming_one': 'Tu licencia vence mañana.',
49
+ 'license.banner.upcoming_today': 'Tu licencia vence hoy.',
50
+ 'license.banner.grace': 'Tu licencia venció el {{date}}. Tienes {{days}} días para renovarla antes de que se bloqueen los cambios.',
51
+ 'license.banner.grace_nodate': 'Tu licencia venció. Tienes {{days}} días para renovarla antes de que se bloqueen los cambios.',
52
+ 'license.banner.expired_read_only': 'Tu licencia venció el {{date}}. Tu información sigue disponible para consultar y exportar; renueva para volver a registrar cambios.',
53
+ 'license.banner.expired_read_only_nodate': 'Tu licencia venció. Tu información sigue disponible para consultar y exportar; renueva para volver a registrar cambios.',
54
+ 'license.banner.expired': 'Tu licencia venció. Algunas acciones están bloqueadas.',
55
+ 'license.banner.revoked': '{{who}} desactivó esta licencia. Tu información sigue disponible para consultar y exportar hasta el {{date}}.',
56
+ 'license.banner.revoked_nodate': '{{who}} desactivó esta licencia. Tu información sigue disponible para consultar y exportar.',
57
+ 'license.banner.stale': 'No pudimos contactar al servidor de licencias desde el {{date}}. Seguimos funcionando.',
58
+ 'license.banner.stale_nodate': 'No pudimos contactar al servidor de licencias. Seguimos funcionando.',
59
+ 'license.banner.cloned': 'Detectamos esta licencia activa en otro servidor. Si no fue a propósito, avisa a {{who}}.',
60
+ 'license.banner.manage': 'Gestionar licencia',
61
+ 'license.banner.renew': 'Renovar',
62
+ 'license.banner.export': 'Exportar mis datos',
63
+ 'license.banner.dismiss': 'Descartar',
64
+ 'license.banner.contact': 'Contacto: {{contact}}',
65
+ 'license.banner.provider': 'tu proveedor',
66
+ },
67
+ en: {
68
+ 'license.status.valid': 'Active',
69
+ 'license.status.stale': 'Not verified',
70
+ 'license.status.grace': 'In grace period',
71
+ 'license.status.expired': 'Expired',
72
+ 'license.status.missing': 'No license',
73
+ 'license.status.invalid': 'Invalid',
74
+ 'license.status.revoked': 'Deactivated',
75
+ 'license.gate.instance': 'This instance',
76
+ 'license.gate.title': 'Activate your license',
77
+ 'license.gate.missing_description': "This instance doesn't have an active license yet.",
78
+ 'license.gate.invalid_description': "We couldn't validate this instance's license.",
79
+ 'license.gate.expired_title': 'Your license has expired',
80
+ 'license.gate.expired_description': 'Your license expired on {{date}} and the grace period has ended.',
81
+ 'license.gate.expired_description_nodate': 'Your license expired and the grace period has ended.',
82
+ 'license.gate.trial_title': 'Your free trial has ended',
83
+ 'license.gate.trial_description': "This instance's free trial has ended.",
84
+ 'license.gate.revoked_title': 'License deactivated',
85
+ 'license.gate.revoked_description': '{{who}} deactivated this instance\'s license.',
86
+ 'license.gate.read_only': 'Contact the platform administrator to activate the license.',
87
+ 'license.gate.code_label': 'License key or token',
88
+ 'license.gate.code_label_link': 'Activation link, code or license key',
89
+ 'license.gate.code_placeholder': 'lic_… or the signed token',
90
+ 'license.gate.code_placeholder_link': 'https://…/a/acs_…, acs_… or lic_…',
91
+ 'license.gate.activate': 'Activate license',
92
+ 'license.gate.activating': 'Activating…',
93
+ 'license.gate.activate_error': "The license couldn't be activated.",
94
+ 'license.gate.export': 'Export my data',
95
+ 'license.gate.provider': 'Your provider',
96
+ 'license.gate.contact_label': 'Contact',
97
+ 'license.link.activation_not_found': "We don't recognize that link or code. Check that it's complete, or ask your provider for a new one.",
98
+ 'license.link.activation_used': 'This link was already used on another server. Ask your provider for a new one.',
99
+ 'license.link.activation_conflict': 'This license already runs on another server. If you reinstalled, ask your provider to release it.',
100
+ 'license.link.activation_expired': 'The link has expired. Your provider can generate another in a minute.',
101
+ 'license.link.activation_revoked': 'Your provider revoked this link. Contact them to get a new one.',
102
+ 'license.link.license_revoked': 'Your provider deactivated this license. Contact them to reactivate it.',
103
+ 'license.link.license_expired': "This link's license has already expired. Your provider can renew it.",
104
+ 'license.link.rate_limited': 'Too many attempts. Wait a few minutes and try again.',
105
+ 'license.banner.upcoming': 'Your license expires in {{days}} days.',
106
+ 'license.banner.upcoming_one': 'Your license expires tomorrow.',
107
+ 'license.banner.upcoming_today': 'Your license expires today.',
108
+ 'license.banner.grace': 'Your license expired on {{date}}. You have {{days}} days to renew it before changes are blocked.',
109
+ 'license.banner.grace_nodate': 'Your license expired. You have {{days}} days to renew it before changes are blocked.',
110
+ 'license.banner.expired_read_only': 'Your license expired on {{date}}. Your data is still available to view and export; renew to record changes again.',
111
+ 'license.banner.expired_read_only_nodate': 'Your license expired. Your data is still available to view and export; renew to record changes again.',
112
+ 'license.banner.expired': 'Your license expired. Some actions are blocked.',
113
+ 'license.banner.revoked': '{{who}} deactivated this license. Your data stays available to view and export until {{date}}.',
114
+ 'license.banner.revoked_nodate': '{{who}} deactivated this license. Your data stays available to view and export.',
115
+ 'license.banner.stale': "We couldn't reach the license server since {{date}}. Everything keeps working.",
116
+ 'license.banner.stale_nodate': "We couldn't reach the license server. Everything keeps working.",
117
+ 'license.banner.cloned': "We detected this license active on another server. If that wasn't intended, let {{who}} know.",
118
+ 'license.banner.manage': 'Manage license',
119
+ 'license.banner.renew': 'Renew',
120
+ 'license.banner.export': 'Export my data',
121
+ 'license.banner.dismiss': 'Dismiss',
122
+ 'license.banner.contact': 'Contact: {{contact}}',
123
+ 'license.banner.provider': 'your provider',
124
+ },
125
+ };
126
+ /** Fecha corta y estable (UTC) para los textos de licencia. */
127
+ export function formatLicenseDate(iso, lang) {
128
+ if (!iso)
129
+ return undefined;
130
+ const d = new Date(iso);
131
+ if (Number.isNaN(d.getTime()))
132
+ return undefined;
133
+ return d.toLocaleDateString(lang === 'en' ? 'en-US' : 'es-MX', {
134
+ day: 'numeric',
135
+ month: 'long',
136
+ year: 'numeric',
137
+ timeZone: 'UTC',
138
+ });
139
+ }
140
+ /**
141
+ * Siembra es/en en el i18next del host SIN pisar lo que ya tenga (overwrite=false):
142
+ * el host manda, el SDK solo rellena lo que falta.
143
+ */
144
+ export function registerLicenseMessages(i18n, ns = 'translation') {
145
+ if (!i18n?.addResourceBundle)
146
+ return;
147
+ for (const lang of ['es', 'en']) {
148
+ const nested = {};
149
+ for (const [key, value] of Object.entries(LICENSE_MESSAGES[lang])) {
150
+ const parts = key.split('.');
151
+ let cur = nested;
152
+ parts.slice(0, -1).forEach((p) => {
153
+ cur = (cur[p] ??= {});
154
+ });
155
+ cur[parts[parts.length - 1]] = value;
156
+ }
157
+ i18n.addResourceBundle(lang, ns, nested, true, false);
158
+ }
159
+ }
@@ -12,7 +12,19 @@
12
12
  * - hosts → wiring (resuelven el estado y montan <LicenseGate> en 1 línea).
13
13
  */
14
14
  /** El estado operativo de la licencia, tal como lo deriva el backend. */
15
- export type LicenseStatus = 'valid' | 'stale' | 'grace' | 'expired' | 'missing' | 'invalid';
15
+ export type LicenseStatus = 'valid' | 'stale' | 'grace' | 'expired' | 'missing' | 'invalid'
16
+ /** El emisor desactivó la licencia (el hub respondió `license_revoked`). */
17
+ | 'revoked';
18
+ /** Contacto de quien vendió la licencia. Solo se muestra si la licencia lo trae. */
19
+ export interface LicenseSeller {
20
+ name?: string;
21
+ email?: string;
22
+ phone?: string;
23
+ url?: string;
24
+ }
25
+ /** Qué hace la instancia cuando la licencia termina: `read_only` deja consultar y
26
+ * exportar sin registrar cambios; `block` es el comportamiento clásico (modal). */
27
+ export type LicenseOnExpiry = 'read_only' | 'block';
16
28
  export interface LicenseState {
17
29
  /** Licensing activo en esta instancia (LICENSING_ENFORCE). Si es false el
18
30
  * gate es transparente: nunca bloquea ni degrada. */
@@ -35,17 +47,28 @@ export interface LicenseState {
35
47
  grace_until?: string;
36
48
  days_remaining: number;
37
49
  last_checked_at?: string;
50
+ /** Quien vendió la licencia, si el hub lo informó. */
51
+ seller?: LicenseSeller;
52
+ /** Política al vencer. Ausente = `block` (instancias sin enlace de activación). */
53
+ on_expiry?: LicenseOnExpiry;
54
+ /** Avisos para el dueño, p. ej. `clone_suspected` (licencia activa en otro servidor). */
55
+ notices?: string[];
38
56
  }
39
57
  /** La licencia es OPERABLE cuando permite operar (aunque sea degradada):
40
58
  * valid, la postura `stale` del lease, o dentro de la ventana de gracia.
41
- * missing/invalid/expired no son operables. Sin enforcement → siempre operable.
42
- * Espeja `State.Operable()` del backend. */
59
+ * missing/invalid/expired/revoked no son operables. Sin enforcement → siempre
60
+ * operable. Espeja `State.Operable()` del backend. */
43
61
  export declare function isLicenseOperable(state: LicenseState | undefined): boolean;
62
+ /** Vencida con política de solo lectura: la app sigue abierta para consultar y
63
+ * exportar, y el backend rechaza las escrituras. Solo aplica si el hub informó
64
+ * `on_expiry: 'read_only'`; sin él, vencida = bloqueo (comportamiento clásico). */
65
+ export declare function isLicenseReadOnly(state: LicenseState | undefined): boolean;
44
66
  /** La instancia debe BLOQUEARSE tras el modal de activación cuando hay
45
- * enforcement y la licencia es missing/invalid/expired (pasada la gracia).
46
- * grace/stale degradan con banner en vez de bloquear. Espeja `State.Blocking()`.
47
- * Mientras el estado aún carga (undefined) NO bloquea: fail-open en la UI para
48
- * que un check lento/fallido nunca destelle un candado sobre la app. */
67
+ * enforcement y la licencia es missing/invalid/revoked/expired (pasada la
68
+ * gracia), salvo que la política sea de solo lectura. grace/stale degradan con
69
+ * banner en vez de bloquear. Espeja `State.Blocking()`. Mientras el estado aún
70
+ * carga (undefined) NO bloquea: fail-open en la UI para que un check lento o
71
+ * fallido nunca destelle un candado sobre la app. */
49
72
  export declare function isLicenseBlocking(state: LicenseState | undefined): boolean;
50
73
  /** Un preset/vertical está habilitado si la licencia otorga wildcard o lo lista
51
74
  * explícitamente. Sin enforcement → todo habilitado. */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/license/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,yEAAyE;AACzE,MAAM,MAAM,aAAa,GACnB,OAAO,GACP,OAAO,GACP,OAAO,GACP,SAAS,GACT,SAAS,GACT,SAAS,CAAA;AAEf,MAAM,WAAW,YAAY;IACzB;yDACqD;IACrD,QAAQ,EAAE,OAAO,CAAA;IACjB,UAAU,EAAE,OAAO,CAAA;IACnB,KAAK,EAAE,OAAO,CAAA;IACd,MAAM,EAAE,aAAa,CAAA;IACrB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,YAAY,EAAE,MAAM,EAAE,CAAA;IACtB,QAAQ,EAAE,OAAO,CAAA;IACjB,oEAAoE;IACpE,KAAK,EAAE,OAAO,CAAA;IACd,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,OAAO,CAAA;IACjB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,cAAc,EAAE,MAAM,CAAA;IACtB,eAAe,CAAC,EAAE,MAAM,CAAA;CAC3B;AAED;;;4CAG4C;AAC5C,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,YAAY,GAAG,SAAS,GAAG,OAAO,CAG1E;AAED;;;;wEAIwE;AACxE,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,YAAY,GAAG,SAAS,GAAG,OAAO,CAG1E;AAED;wDACwD;AACxD,wBAAgB,gBAAgB,CAC5B,KAAK,EAAE,YAAY,GAAG,SAAS,EAC/B,SAAS,EAAE,MAAM,GAClB,OAAO,CAIT;AAED,0EAA0E;AAC1E,wBAAgB,cAAc,CAAC,KAAK,EAAE,YAAY,GAAG,SAAS,GAAG,OAAO,CAEvE;AAED;2EAC2E;AAC3E,MAAM,WAAW,eAAe;IAC5B,mEAAmE;IACnE,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,2CAA2C;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAA;CAChB"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/license/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,yEAAyE;AACzE,MAAM,MAAM,aAAa,GACnB,OAAO,GACP,OAAO,GACP,OAAO,GACP,SAAS,GACT,SAAS,GACT,SAAS;AACX,4EAA4E;GAC1E,SAAS,CAAA;AAEf,oFAAoF;AACpF,MAAM,WAAW,aAAa;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,GAAG,CAAC,EAAE,MAAM,CAAA;CACf;AAED;mFACmF;AACnF,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,OAAO,CAAA;AAEnD,MAAM,WAAW,YAAY;IACzB;yDACqD;IACrD,QAAQ,EAAE,OAAO,CAAA;IACjB,UAAU,EAAE,OAAO,CAAA;IACnB,KAAK,EAAE,OAAO,CAAA;IACd,MAAM,EAAE,aAAa,CAAA;IACrB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,YAAY,EAAE,MAAM,EAAE,CAAA;IACtB,QAAQ,EAAE,OAAO,CAAA;IACjB,oEAAoE;IACpE,KAAK,EAAE,OAAO,CAAA;IACd,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,OAAO,CAAA;IACjB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,cAAc,EAAE,MAAM,CAAA;IACtB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,sDAAsD;IACtD,MAAM,CAAC,EAAE,aAAa,CAAA;IACtB,mFAAmF;IACnF,SAAS,CAAC,EAAE,eAAe,CAAA;IAC3B,yFAAyF;IACzF,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CACrB;AAED;;;sDAGsD;AACtD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,YAAY,GAAG,SAAS,GAAG,OAAO,CAG1E;AAED;;mFAEmF;AACnF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,YAAY,GAAG,SAAS,GAAG,OAAO,CAK1E;AAED;;;;;qDAKqD;AACrD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,YAAY,GAAG,SAAS,GAAG,OAAO,CAI1E;AAED;wDACwD;AACxD,wBAAgB,gBAAgB,CAC5B,KAAK,EAAE,YAAY,GAAG,SAAS,EAC/B,SAAS,EAAE,MAAM,GAClB,OAAO,CAIT;AAED,0EAA0E;AAC1E,wBAAgB,cAAc,CAAC,KAAK,EAAE,YAAY,GAAG,SAAS,GAAG,OAAO,CAEvE;AAED;2EAC2E;AAC3E,MAAM,WAAW,eAAe;IAC5B,mEAAmE;IACnE,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,2CAA2C;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAA;CAChB"}
@@ -13,21 +13,35 @@
13
13
  */
14
14
  /** La licencia es OPERABLE cuando permite operar (aunque sea degradada):
15
15
  * valid, la postura `stale` del lease, o dentro de la ventana de gracia.
16
- * missing/invalid/expired no son operables. Sin enforcement → siempre operable.
17
- * Espeja `State.Operable()` del backend. */
16
+ * missing/invalid/expired/revoked no son operables. Sin enforcement → siempre
17
+ * operable. Espeja `State.Operable()` del backend. */
18
18
  export function isLicenseOperable(state) {
19
19
  if (!state || !state.enforced)
20
20
  return true;
21
21
  return state.valid || state.in_grace;
22
22
  }
23
+ /** Vencida con política de solo lectura: la app sigue abierta para consultar y
24
+ * exportar, y el backend rechaza las escrituras. Solo aplica si el hub informó
25
+ * `on_expiry: 'read_only'`; sin él, vencida = bloqueo (comportamiento clásico). */
26
+ export function isLicenseReadOnly(state) {
27
+ if (!state || !state.enforced)
28
+ return false;
29
+ if (state.on_expiry === 'read_only' && state.status === 'expired')
30
+ return true;
31
+ // Revocada dentro de su plazo corto de aviso: se puede consultar y exportar.
32
+ return state.status === 'revoked' && state.in_grace;
33
+ }
23
34
  /** La instancia debe BLOQUEARSE tras el modal de activación cuando hay
24
- * enforcement y la licencia es missing/invalid/expired (pasada la gracia).
25
- * grace/stale degradan con banner en vez de bloquear. Espeja `State.Blocking()`.
26
- * Mientras el estado aún carga (undefined) NO bloquea: fail-open en la UI para
27
- * que un check lento/fallido nunca destelle un candado sobre la app. */
35
+ * enforcement y la licencia es missing/invalid/revoked/expired (pasada la
36
+ * gracia), salvo que la política sea de solo lectura. grace/stale degradan con
37
+ * banner en vez de bloquear. Espeja `State.Blocking()`. Mientras el estado aún
38
+ * carga (undefined) NO bloquea: fail-open en la UI para que un check lento o
39
+ * fallido nunca destelle un candado sobre la app. */
28
40
  export function isLicenseBlocking(state) {
29
41
  if (!state || !state.enforced)
30
42
  return false;
43
+ if (isLicenseReadOnly(state))
44
+ return false;
31
45
  return !isLicenseOperable(state);
32
46
  }
33
47
  /** Un preset/vertical está habilitado si la licencia otorga wildcard o lo lista
@@ -0,0 +1,11 @@
1
+ import { type LicenseLang } from './messages';
2
+ /**
3
+ * `t` de licencia: pide la clave a i18next y, si el host no la define, cae al
4
+ * texto es/en del SDK según el idioma activo (español por omisión). Un host con
5
+ * su propio bundle gana siempre.
6
+ */
7
+ export declare function useLicenseT(): {
8
+ t: (key: string, vars?: Record<string, unknown>) => string;
9
+ lang: LicenseLang;
10
+ };
11
+ //# sourceMappingURL=use-license-t.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-license-t.d.ts","sourceRoot":"","sources":["../../src/license/use-license-t.ts"],"names":[],"mappings":"AACA,OAAO,EAAiC,KAAK,WAAW,EAAE,MAAM,YAAY,CAAA;AAE5E;;;;GAIG;AACH,wBAAgB,WAAW,IAAI;IAC3B,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,MAAM,CAAA;IAC1D,IAAI,EAAE,WAAW,CAAA;CACpB,CAWA"}
@@ -0,0 +1,18 @@
1
+ import { useTranslation } from 'react-i18next';
2
+ import { LICENSE_MESSAGES, licenseLang } from './messages';
3
+ /**
4
+ * `t` de licencia: pide la clave a i18next y, si el host no la define, cae al
5
+ * texto es/en del SDK según el idioma activo (español por omisión). Un host con
6
+ * su propio bundle gana siempre.
7
+ */
8
+ export function useLicenseT() {
9
+ const { t, i18n } = useTranslation();
10
+ const lang = licenseLang(i18n?.language);
11
+ return {
12
+ lang,
13
+ t: (key, vars) => t(key, {
14
+ defaultValue: LICENSE_MESSAGES[lang][key] ?? LICENSE_MESSAGES.es[key] ?? key,
15
+ ...vars,
16
+ }),
17
+ };
18
+ }