@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.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { W as NeetruClient, t as CheckoutStartResult, l as AuthNamespace, a5 as NeetruUser } from './types-
|
|
2
|
+
import { W as NeetruClient, t as CheckoutStartResult, l as AuthNamespace, a5 as NeetruUser } from './types-Du_iioJ7.cjs';
|
|
3
3
|
import { CollectionReference, Query, DocumentReference } from './firestore-compat.cjs';
|
|
4
4
|
import 'drizzle-orm/node-postgres';
|
|
5
5
|
import './errors.cjs';
|
package/dist/react.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { W as NeetruClient, t as CheckoutStartResult, l as AuthNamespace, a5 as NeetruUser } from './types-
|
|
2
|
+
import { W as NeetruClient, t as CheckoutStartResult, l as AuthNamespace, a5 as NeetruUser } from './types-BPATkXYu.js';
|
|
3
3
|
import { CollectionReference, Query, DocumentReference } from './firestore-compat.js';
|
|
4
4
|
import 'drizzle-orm/node-postgres';
|
|
5
5
|
import './errors.js';
|
package/dist/react.mjs
CHANGED
|
@@ -2,6 +2,31 @@ import * as React2 from 'react';
|
|
|
2
2
|
|
|
3
3
|
// src/react.ts
|
|
4
4
|
|
|
5
|
+
// src/errors.ts
|
|
6
|
+
var NeetruError = class _NeetruError extends Error {
|
|
7
|
+
code;
|
|
8
|
+
status;
|
|
9
|
+
requestId;
|
|
10
|
+
/**
|
|
11
|
+
* Motivo semântico opcional propagado pelo Core no corpo do erro (campo
|
|
12
|
+
* `reason` no TOPO do body, fora de `error`). Usado principalmente pelo 503
|
|
13
|
+
* de lease de DB, onde `reason` discrimina o estado do ambiente
|
|
14
|
+
* (`suspended` | `archived` | `revoked` | `provisioning` | `degraded` |
|
|
15
|
+
* `no_route` | `expired`). Camadas superiores (ex.: `db/sql`) mapeiam isso
|
|
16
|
+
* para um `NeetruDbErrorCode` mais específico (recuperável vs não).
|
|
17
|
+
*/
|
|
18
|
+
reason;
|
|
19
|
+
constructor(code, message, status, requestId, reason) {
|
|
20
|
+
super(message);
|
|
21
|
+
this.name = "NeetruError";
|
|
22
|
+
this.code = code;
|
|
23
|
+
this.status = status;
|
|
24
|
+
this.requestId = requestId;
|
|
25
|
+
this.reason = reason;
|
|
26
|
+
Object.setPrototypeOf(this, _NeetruError.prototype);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
5
30
|
// src/types.ts
|
|
6
31
|
var DEFAULT_BASE_URL = "https://api.neetru.com";
|
|
7
32
|
|
|
@@ -603,13 +628,22 @@ async function startCheckoutViaBff(startPath, input) {
|
|
|
603
628
|
}
|
|
604
629
|
if (!res.ok) {
|
|
605
630
|
const p = payload;
|
|
631
|
+
const errField = p?.error;
|
|
632
|
+
const code = (errField && typeof errField === "object" && typeof errField.code === "string" ? errField.code : void 0) ?? "server_error";
|
|
606
633
|
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}`;
|
|
607
|
-
throw new
|
|
634
|
+
throw new NeetruError(
|
|
635
|
+
code,
|
|
636
|
+
typeof msg === "string" ? msg : `Checkout BFF respondeu HTTP ${res.status}`,
|
|
637
|
+
res.status
|
|
638
|
+
);
|
|
608
639
|
}
|
|
609
640
|
const intent = payload?.intent ?? payload ?? {};
|
|
610
641
|
const redirectUrl = payload?.redirectUrl ?? intent.redirectUrl;
|
|
611
642
|
if (!redirectUrl || typeof redirectUrl !== "string") {
|
|
612
|
-
throw new
|
|
643
|
+
throw new NeetruError(
|
|
644
|
+
"invalid_response",
|
|
645
|
+
"Resposta do route BFF de checkout sem `redirectUrl`."
|
|
646
|
+
);
|
|
613
647
|
}
|
|
614
648
|
return {
|
|
615
649
|
intentId: String(payload?.intentId ?? intent.intentId ?? ""),
|
|
@@ -721,6 +755,16 @@ var NEETRU_LOGIN_BUTTON_THEME = {
|
|
|
721
755
|
dark: { bg: "#0a0a0a", bgHover: "#1a1a1a", fg: "#ffffff", border: "#0a0a0a" },
|
|
722
756
|
light: { bg: "#ffffff", bgHover: "#f5f5f5", fg: "#0a0a0a", border: "#0a0a0a" }
|
|
723
757
|
};
|
|
758
|
+
var NEETRU_LOGIN_FOCUS_STYLE_ID = "neetru-login-button-focus-style";
|
|
759
|
+
var NEETRU_LOGIN_FOCUS_CSS = "button[data-neetru-login-button]:focus-visible{outline:2px solid var(--neetru-login-focus-ring,#ffffff);outline-offset:2px;}";
|
|
760
|
+
function ensureLoginFocusStyleInjected() {
|
|
761
|
+
if (typeof document === "undefined" || !document.head) return;
|
|
762
|
+
if (document.getElementById(NEETRU_LOGIN_FOCUS_STYLE_ID)) return;
|
|
763
|
+
const styleEl = document.createElement("style");
|
|
764
|
+
styleEl.id = NEETRU_LOGIN_FOCUS_STYLE_ID;
|
|
765
|
+
styleEl.textContent = NEETRU_LOGIN_FOCUS_CSS;
|
|
766
|
+
document.head.appendChild(styleEl);
|
|
767
|
+
}
|
|
724
768
|
function NeetruLoginButton({
|
|
725
769
|
client,
|
|
726
770
|
redirectUri,
|
|
@@ -737,6 +781,9 @@ function NeetruLoginButton({
|
|
|
737
781
|
const [isHover, setIsHover] = React2.useState(false);
|
|
738
782
|
const colors = NEETRU_LOGIN_BUTTON_THEME[theme];
|
|
739
783
|
const isDisabled = Boolean(disabled) || isLoading;
|
|
784
|
+
React2.useEffect(() => {
|
|
785
|
+
ensureLoginFocusStyleInjected();
|
|
786
|
+
}, []);
|
|
740
787
|
const handleClick = React2.useCallback(async () => {
|
|
741
788
|
if (isDisabled) return;
|
|
742
789
|
setIsLoading(true);
|
|
@@ -783,6 +830,9 @@ function NeetruLoginButton({
|
|
|
783
830
|
opacity: isDisabled && !isLoading ? 0.6 : 1,
|
|
784
831
|
transition: "background-color 150ms ease",
|
|
785
832
|
boxSizing: "border-box",
|
|
833
|
+
// Cor do ring de foco de teclado (:focus-visible) — ver
|
|
834
|
+
// NEETRU_LOGIN_FOCUS_CSS. Usa a cor do texto (contraste AA garantido).
|
|
835
|
+
"--neetru-login-focus-ring": colors.fg,
|
|
786
836
|
...style
|
|
787
837
|
}
|
|
788
838
|
},
|