@neetru/sdk 3.4.6 → 3.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.
- package/CHANGELOG.md +38 -0
- package/dist/ai.cjs +17 -13
- package/dist/ai.cjs.map +1 -1
- package/dist/ai.d.cts +1 -1
- package/dist/ai.d.ts +1 -1
- package/dist/ai.mjs +17 -13
- package/dist/ai.mjs.map +1 -1
- package/dist/auth.cjs +57 -23
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +2 -2
- package/dist/auth.d.ts +2 -2
- package/dist/auth.mjs +57 -23
- package/dist/auth.mjs.map +1 -1
- package/dist/catalog.cjs +19 -4
- package/dist/catalog.cjs.map +1 -1
- package/dist/catalog.d.cts +1 -1
- package/dist/catalog.d.ts +1 -1
- package/dist/catalog.mjs +19 -4
- package/dist/catalog.mjs.map +1 -1
- package/dist/checkout.cjs +11 -3
- package/dist/checkout.cjs.map +1 -1
- package/dist/checkout.d.cts +1 -1
- package/dist/checkout.d.ts +1 -1
- package/dist/checkout.mjs +11 -3
- package/dist/checkout.mjs.map +1 -1
- package/dist/db-react.d.cts +1 -1
- package/dist/db-react.d.ts +1 -1
- package/dist/db.cjs +17 -7
- package/dist/db.cjs.map +1 -1
- package/dist/db.d.cts +1 -1
- package/dist/db.d.ts +1 -1
- package/dist/db.mjs +17 -7
- package/dist/db.mjs.map +1 -1
- package/dist/entitlements.d.cts +1 -1
- package/dist/entitlements.d.ts +1 -1
- package/dist/firestore-compat.d.cts +1 -1
- package/dist/firestore-compat.d.ts +1 -1
- package/dist/index.cjs +58 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +30 -2
- package/dist/index.d.ts +30 -2
- package/dist/index.mjs +58 -24
- package/dist/index.mjs.map +1 -1
- package/dist/mocks.cjs +17 -0
- package/dist/mocks.cjs.map +1 -1
- package/dist/mocks.d.cts +5 -1
- package/dist/mocks.d.ts +5 -1
- package/dist/mocks.mjs +17 -0
- package/dist/mocks.mjs.map +1 -1
- package/dist/notifications.cjs +11 -3
- package/dist/notifications.cjs.map +1 -1
- package/dist/notifications.d.cts +1 -1
- package/dist/notifications.d.ts +1 -1
- package/dist/notifications.mjs +11 -3
- package/dist/notifications.mjs.map +1 -1
- package/dist/react.cjs +52 -2
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.mjs +52 -2
- package/dist/react.mjs.map +1 -1
- package/dist/support.cjs +15 -4
- package/dist/support.cjs.map +1 -1
- package/dist/support.d.cts +1 -1
- package/dist/support.d.ts +1 -1
- package/dist/support.mjs +15 -4
- package/dist/support.mjs.map +1 -1
- package/dist/telemetry.cjs +11 -3
- package/dist/telemetry.cjs.map +1 -1
- package/dist/telemetry.d.cts +1 -1
- package/dist/telemetry.d.ts +1 -1
- package/dist/telemetry.mjs +11 -3
- package/dist/telemetry.mjs.map +1 -1
- package/dist/{types-nnztVk7G.d.ts → types-BPATkXYu.d.ts} +35 -7
- package/dist/{types-DIVZl7nO.d.cts → types-Du_iioJ7.d.cts} +35 -7
- package/dist/usage.cjs +11 -3
- package/dist/usage.cjs.map +1 -1
- package/dist/usage.d.cts +1 -1
- package/dist/usage.d.ts +1 -1
- package/dist/usage.mjs +11 -3
- package/dist/usage.mjs.map +1 -1
- package/dist/webhooks.cjs +17 -4
- package/dist/webhooks.cjs.map +1 -1
- package/dist/webhooks.d.cts +1 -1
- package/dist/webhooks.d.ts +1 -1
- package/dist/webhooks.mjs +17 -4
- package/dist/webhooks.mjs.map +1 -1
- package/package.json +4 -1
package/dist/react.cjs
CHANGED
|
@@ -24,6 +24,31 @@ var React2__namespace = /*#__PURE__*/_interopNamespace(React2);
|
|
|
24
24
|
|
|
25
25
|
// src/react.ts
|
|
26
26
|
|
|
27
|
+
// src/errors.ts
|
|
28
|
+
var NeetruError = class _NeetruError extends Error {
|
|
29
|
+
code;
|
|
30
|
+
status;
|
|
31
|
+
requestId;
|
|
32
|
+
/**
|
|
33
|
+
* Motivo semântico opcional propagado pelo Core no corpo do erro (campo
|
|
34
|
+
* `reason` no TOPO do body, fora de `error`). Usado principalmente pelo 503
|
|
35
|
+
* de lease de DB, onde `reason` discrimina o estado do ambiente
|
|
36
|
+
* (`suspended` | `archived` | `revoked` | `provisioning` | `degraded` |
|
|
37
|
+
* `no_route` | `expired`). Camadas superiores (ex.: `db/sql`) mapeiam isso
|
|
38
|
+
* para um `NeetruDbErrorCode` mais específico (recuperável vs não).
|
|
39
|
+
*/
|
|
40
|
+
reason;
|
|
41
|
+
constructor(code, message, status, requestId, reason) {
|
|
42
|
+
super(message);
|
|
43
|
+
this.name = "NeetruError";
|
|
44
|
+
this.code = code;
|
|
45
|
+
this.status = status;
|
|
46
|
+
this.requestId = requestId;
|
|
47
|
+
this.reason = reason;
|
|
48
|
+
Object.setPrototypeOf(this, _NeetruError.prototype);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
27
52
|
// src/types.ts
|
|
28
53
|
var DEFAULT_BASE_URL = "https://api.neetru.com";
|
|
29
54
|
|
|
@@ -625,13 +650,22 @@ async function startCheckoutViaBff(startPath, input) {
|
|
|
625
650
|
}
|
|
626
651
|
if (!res.ok) {
|
|
627
652
|
const p = payload;
|
|
653
|
+
const errField = p?.error;
|
|
654
|
+
const code = (errField && typeof errField === "object" && typeof errField.code === "string" ? errField.code : void 0) ?? "server_error";
|
|
628
655
|
const msg = p && (typeof p.error === "object" && p.error?.message || typeof p.error === "string" && p.error || typeof p.message === "string" && p.message) || `Checkout BFF respondeu HTTP ${res.status}`;
|
|
629
|
-
throw new
|
|
656
|
+
throw new NeetruError(
|
|
657
|
+
code,
|
|
658
|
+
typeof msg === "string" ? msg : `Checkout BFF respondeu HTTP ${res.status}`,
|
|
659
|
+
res.status
|
|
660
|
+
);
|
|
630
661
|
}
|
|
631
662
|
const intent = payload?.intent ?? payload ?? {};
|
|
632
663
|
const redirectUrl = payload?.redirectUrl ?? intent.redirectUrl;
|
|
633
664
|
if (!redirectUrl || typeof redirectUrl !== "string") {
|
|
634
|
-
throw new
|
|
665
|
+
throw new NeetruError(
|
|
666
|
+
"invalid_response",
|
|
667
|
+
"Resposta do route BFF de checkout sem `redirectUrl`."
|
|
668
|
+
);
|
|
635
669
|
}
|
|
636
670
|
return {
|
|
637
671
|
intentId: String(payload?.intentId ?? intent.intentId ?? ""),
|
|
@@ -743,6 +777,16 @@ var NEETRU_LOGIN_BUTTON_THEME = {
|
|
|
743
777
|
dark: { bg: "#0a0a0a", bgHover: "#1a1a1a", fg: "#ffffff", border: "#0a0a0a" },
|
|
744
778
|
light: { bg: "#ffffff", bgHover: "#f5f5f5", fg: "#0a0a0a", border: "#0a0a0a" }
|
|
745
779
|
};
|
|
780
|
+
var NEETRU_LOGIN_FOCUS_STYLE_ID = "neetru-login-button-focus-style";
|
|
781
|
+
var NEETRU_LOGIN_FOCUS_CSS = "button[data-neetru-login-button]:focus-visible{outline:2px solid var(--neetru-login-focus-ring,#ffffff);outline-offset:2px;}";
|
|
782
|
+
function ensureLoginFocusStyleInjected() {
|
|
783
|
+
if (typeof document === "undefined" || !document.head) return;
|
|
784
|
+
if (document.getElementById(NEETRU_LOGIN_FOCUS_STYLE_ID)) return;
|
|
785
|
+
const styleEl = document.createElement("style");
|
|
786
|
+
styleEl.id = NEETRU_LOGIN_FOCUS_STYLE_ID;
|
|
787
|
+
styleEl.textContent = NEETRU_LOGIN_FOCUS_CSS;
|
|
788
|
+
document.head.appendChild(styleEl);
|
|
789
|
+
}
|
|
746
790
|
function NeetruLoginButton({
|
|
747
791
|
client,
|
|
748
792
|
redirectUri,
|
|
@@ -759,6 +803,9 @@ function NeetruLoginButton({
|
|
|
759
803
|
const [isHover, setIsHover] = React2__namespace.useState(false);
|
|
760
804
|
const colors = NEETRU_LOGIN_BUTTON_THEME[theme];
|
|
761
805
|
const isDisabled = Boolean(disabled) || isLoading;
|
|
806
|
+
React2__namespace.useEffect(() => {
|
|
807
|
+
ensureLoginFocusStyleInjected();
|
|
808
|
+
}, []);
|
|
762
809
|
const handleClick = React2__namespace.useCallback(async () => {
|
|
763
810
|
if (isDisabled) return;
|
|
764
811
|
setIsLoading(true);
|
|
@@ -805,6 +852,9 @@ function NeetruLoginButton({
|
|
|
805
852
|
opacity: isDisabled && !isLoading ? 0.6 : 1,
|
|
806
853
|
transition: "background-color 150ms ease",
|
|
807
854
|
boxSizing: "border-box",
|
|
855
|
+
// Cor do ring de foco de teclado (:focus-visible) — ver
|
|
856
|
+
// NEETRU_LOGIN_FOCUS_CSS. Usa a cor do texto (contraste AA garantido).
|
|
857
|
+
"--neetru-login-focus-ring": colors.fg,
|
|
808
858
|
...style
|
|
809
859
|
}
|
|
810
860
|
},
|