@neetru/sdk 3.8.1 → 3.9.1
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 +46 -0
- package/README.md +14 -1
- package/dist/ai.cjs +1 -1
- package/dist/ai.d.cts +1 -1
- package/dist/ai.d.ts +1 -1
- package/dist/ai.mjs +1 -1
- package/dist/auth.cjs +844 -803
- package/dist/auth.d.cts +1 -1
- package/dist/auth.d.ts +1 -1
- package/dist/auth.mjs +841 -800
- package/dist/build-guard.cjs +186 -82
- package/dist/build-guard.d.cts +53 -1
- package/dist/build-guard.d.ts +53 -1
- package/dist/build-guard.mjs +175 -74
- package/dist/catalog.cjs +1 -1
- package/dist/catalog.d.cts +1 -1
- package/dist/catalog.d.ts +1 -1
- package/dist/catalog.mjs +1 -1
- package/dist/checkout.cjs +62 -49
- package/dist/checkout.d.cts +1 -1
- package/dist/checkout.d.ts +1 -1
- package/dist/checkout.mjs +62 -49
- package/dist/db-react.d.cts +1 -1
- package/dist/db-react.d.ts +1 -1
- package/dist/db.cjs +200 -187
- package/dist/db.d.cts +1 -1
- package/dist/db.d.ts +1 -1
- package/dist/db.mjs +193 -180
- 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 +880 -839
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +847 -806
- package/dist/mobile.cjs +328 -276
- package/dist/mobile.d.cts +12 -2
- package/dist/mobile.d.ts +12 -2
- package/dist/mobile.mjs +328 -276
- package/dist/mocks.cjs +5 -5
- package/dist/mocks.d.cts +2 -2
- package/dist/mocks.d.ts +2 -2
- package/dist/mocks.mjs +4 -4
- package/dist/notifications.cjs +1 -1
- package/dist/notifications.d.cts +1 -1
- package/dist/notifications.d.ts +1 -1
- package/dist/notifications.mjs +1 -1
- package/dist/react.cjs +119 -119
- package/dist/react.d.cts +8 -2
- package/dist/react.d.ts +8 -2
- package/dist/react.mjs +119 -119
- package/dist/support.cjs +1 -1
- package/dist/support.d.cts +1 -1
- package/dist/support.d.ts +1 -1
- package/dist/support.mjs +1 -1
- package/dist/telemetry.cjs +62 -49
- package/dist/telemetry.d.cts +1 -1
- package/dist/telemetry.d.ts +1 -1
- package/dist/telemetry.mjs +62 -49
- package/dist/{types-yv3EDKg2.d.cts → types-Bl_4HROd.d.cts} +62 -3
- package/dist/{types-BYPk_3HR.d.ts → types-Bqnsqvow.d.ts} +62 -3
- package/dist/usage.cjs +1 -1
- package/dist/usage.d.cts +1 -1
- package/dist/usage.d.ts +1 -1
- package/dist/usage.mjs +1 -1
- package/dist/webhooks.cjs +1 -1
- package/dist/webhooks.d.cts +1 -1
- package/dist/webhooks.d.ts +1 -1
- package/dist/webhooks.mjs +1 -1
- package/package.json +9 -1
package/dist/react.mjs
CHANGED
|
@@ -23,13 +23,13 @@ var E = class e extends Error {
|
|
|
23
23
|
* `undefined` em erros que acontecem antes de qualquer requisição.
|
|
24
24
|
*/
|
|
25
25
|
correlationId;
|
|
26
|
-
constructor(t, i, n,
|
|
27
|
-
super(i), this.name = "NeetruError", this.code = t, this.status = n, this.requestId =
|
|
26
|
+
constructor(t, i, n, a, c, o) {
|
|
27
|
+
super(i), this.name = "NeetruError", this.code = t, this.status = n, this.requestId = a, this.reason = c, this.correlationId = o, Object.setPrototypeOf(this, e.prototype);
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
// src/types.ts
|
|
32
|
-
var
|
|
32
|
+
var F = "https://api.neetru.com";
|
|
33
33
|
|
|
34
34
|
// src/end-user-token.ts
|
|
35
35
|
var ee = /* @__PURE__ */ new WeakMap();
|
|
@@ -59,9 +59,9 @@ var y = l.createElement, ne = {
|
|
|
59
59
|
async function W(e) {
|
|
60
60
|
let t = await M(e);
|
|
61
61
|
if (!t) return null;
|
|
62
|
-
let i = e.config, n = (i.baseUrl ??
|
|
62
|
+
let i = e.config, n = (i.baseUrl ?? F).replace(/\/+$/, ""), a = i.fetch ?? globalThis.fetch, c = `${n}/api/sdk/v1/account/bar`;
|
|
63
63
|
try {
|
|
64
|
-
let o = await
|
|
64
|
+
let o = await a(c, {
|
|
65
65
|
headers: { authorization: `Bearer ${t}`, accept: "application/json" }
|
|
66
66
|
});
|
|
67
67
|
if (!o.ok) return null;
|
|
@@ -96,17 +96,17 @@ var h = {
|
|
|
96
96
|
borderSoft: "#e5e5e5"
|
|
97
97
|
}, H = 0;
|
|
98
98
|
function re({ size: e = 18, color: t = h.fg }) {
|
|
99
|
-
let i = [0, 1, 2].flatMap((c) => [0, 1, 2].map((o) => ({ r: c, c: o }))), n = e / 3,
|
|
99
|
+
let i = [0, 1, 2].flatMap((c) => [0, 1, 2].map((o) => ({ r: c, c: o }))), n = e / 3, a = Math.max(2, e / 7);
|
|
100
100
|
return y(
|
|
101
101
|
"svg",
|
|
102
102
|
{ width: e, height: e, viewBox: `0 0 ${e} ${e}`, "aria-hidden": true, style: { display: "block" } },
|
|
103
103
|
i.map(
|
|
104
104
|
({ r: c, c: o }) => y("rect", {
|
|
105
105
|
key: `${c}-${o}`,
|
|
106
|
-
x: o * n + (n -
|
|
107
|
-
y: c * n + (n -
|
|
108
|
-
width:
|
|
109
|
-
height:
|
|
106
|
+
x: o * n + (n - a) / 2,
|
|
107
|
+
y: c * n + (n - a) / 2,
|
|
108
|
+
width: a,
|
|
109
|
+
height: a,
|
|
110
110
|
fill: t
|
|
111
111
|
})
|
|
112
112
|
)
|
|
@@ -124,63 +124,63 @@ function oe({
|
|
|
124
124
|
currentProductSlug: t,
|
|
125
125
|
settingsUrl: i,
|
|
126
126
|
onSignOut: n,
|
|
127
|
-
fetchBar:
|
|
127
|
+
fetchBar: a,
|
|
128
128
|
labels: c,
|
|
129
129
|
className: o
|
|
130
130
|
}) {
|
|
131
131
|
let r = { ...ne, ...c }, b = l.useMemo(() => {
|
|
132
132
|
try {
|
|
133
|
-
let
|
|
134
|
-
return
|
|
135
|
-
displayName:
|
|
136
|
-
email:
|
|
137
|
-
photoUrl:
|
|
133
|
+
let s = e.auth.getUser();
|
|
134
|
+
return s ? {
|
|
135
|
+
displayName: s.displayName || s.email || "",
|
|
136
|
+
email: s.email || "",
|
|
137
|
+
photoUrl: s.photoURL ?? null
|
|
138
138
|
} : null;
|
|
139
139
|
} catch {
|
|
140
140
|
return null;
|
|
141
141
|
}
|
|
142
|
-
}, [e]), [u, f] = l.useState(null), [m,
|
|
142
|
+
}, [e]), [u, f] = l.useState(null), [m, x] = l.useState(null), [T, R] = l.useState(false), p = l.useRef(null), d = l.useRef(null), g = l.useRef(null), S = l.useRef(null);
|
|
143
143
|
l.useEffect(() => {
|
|
144
|
-
let
|
|
145
|
-
return Promise.resolve(k(e)).then((
|
|
146
|
-
!
|
|
144
|
+
let s = false, k = a ?? W;
|
|
145
|
+
return Promise.resolve(k(e)).then((C) => {
|
|
146
|
+
!s && C && f(C);
|
|
147
147
|
}).catch(() => {
|
|
148
148
|
}), () => {
|
|
149
|
-
|
|
149
|
+
s = true;
|
|
150
150
|
};
|
|
151
|
-
}, [e,
|
|
152
|
-
let v = u?.account ?? b, G = u?.accountUrl ?? "https://minhaconta.neetru.com", A = u?.products ?? [], L = l.useCallback((
|
|
153
|
-
|
|
151
|
+
}, [e, a]);
|
|
152
|
+
let v = u?.account ?? b, G = u?.accountUrl ?? "https://minhaconta.neetru.com", A = u?.products ?? [], L = l.useCallback((s) => {
|
|
153
|
+
x(null), (s === "apps" ? g.current : d.current)?.focus();
|
|
154
154
|
}, []);
|
|
155
155
|
l.useEffect(() => {
|
|
156
156
|
if (!m) return;
|
|
157
|
-
Q(
|
|
158
|
-
let k = (
|
|
159
|
-
p.current && !p.current.contains(
|
|
157
|
+
Q(S.current)[0]?.focus();
|
|
158
|
+
let k = (C) => {
|
|
159
|
+
p.current && !p.current.contains(C.target) && x(null);
|
|
160
160
|
};
|
|
161
161
|
return document.addEventListener("mousedown", k), () => document.removeEventListener("mousedown", k);
|
|
162
162
|
}, [m]);
|
|
163
163
|
let P = l.useCallback(
|
|
164
|
-
(
|
|
165
|
-
if (
|
|
166
|
-
|
|
164
|
+
(s) => {
|
|
165
|
+
if (s.key === "Escape") {
|
|
166
|
+
s.stopPropagation(), L(m);
|
|
167
167
|
return;
|
|
168
168
|
}
|
|
169
|
-
let k = Q(
|
|
169
|
+
let k = Q(S.current);
|
|
170
170
|
if (k.length === 0) return;
|
|
171
|
-
let
|
|
172
|
-
|
|
171
|
+
let C = k.indexOf(document.activeElement);
|
|
172
|
+
s.key === "Tab" ? s.shiftKey && C <= 0 ? (s.preventDefault(), k[k.length - 1].focus()) : !s.shiftKey && C === k.length - 1 && (s.preventDefault(), k[0].focus()) : s.key === "ArrowDown" ? (s.preventDefault(), k[(C + 1) % k.length].focus()) : s.key === "ArrowUp" && (s.preventDefault(), k[(C - 1 + k.length) % k.length].focus());
|
|
173
173
|
},
|
|
174
174
|
[m, L]
|
|
175
175
|
), K = l.useCallback(async () => {
|
|
176
|
-
if (
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
176
|
+
if (T) return;
|
|
177
|
+
R(true);
|
|
178
|
+
let s;
|
|
179
|
+
try {
|
|
180
|
+
s = await e.auth.signOut();
|
|
181
|
+
} catch {
|
|
182
|
+
} finally {
|
|
183
|
+
R(false), x(null), n?.(s);
|
|
184
184
|
}
|
|
185
185
|
}, [e, T, n]);
|
|
186
186
|
if (!v) return null;
|
|
@@ -208,7 +208,7 @@ function oe({
|
|
|
208
208
|
}
|
|
209
209
|
},
|
|
210
210
|
I
|
|
211
|
-
), B = (
|
|
211
|
+
), B = (s) => ({
|
|
212
212
|
display: "inline-flex",
|
|
213
213
|
alignItems: "center",
|
|
214
214
|
justifyContent: "center",
|
|
@@ -216,8 +216,8 @@ function oe({
|
|
|
216
216
|
height: 36,
|
|
217
217
|
padding: 0,
|
|
218
218
|
borderRadius: H,
|
|
219
|
-
border: `1px solid ${
|
|
220
|
-
backgroundColor:
|
|
219
|
+
border: `1px solid ${s ? h.border : h.borderSoft}`,
|
|
220
|
+
backgroundColor: s ? h.bgHover : h.bg,
|
|
221
221
|
color: h.fg,
|
|
222
222
|
cursor: "pointer",
|
|
223
223
|
boxSizing: "border-box",
|
|
@@ -232,7 +232,7 @@ function oe({
|
|
|
232
232
|
"aria-haspopup": "menu",
|
|
233
233
|
"aria-expanded": m === "apps",
|
|
234
234
|
"data-neetru-appswitcher-button": "true",
|
|
235
|
-
onClick: () =>
|
|
235
|
+
onClick: () => x((s) => s === "apps" ? null : "apps"),
|
|
236
236
|
style: B(m === "apps")
|
|
237
237
|
},
|
|
238
238
|
y(re, {})
|
|
@@ -245,11 +245,11 @@ function oe({
|
|
|
245
245
|
"aria-haspopup": "menu",
|
|
246
246
|
"aria-expanded": m === "account",
|
|
247
247
|
"data-neetru-account-button": "true",
|
|
248
|
-
onClick: () =>
|
|
248
|
+
onClick: () => x((s) => s === "account" ? null : "account"),
|
|
249
249
|
style: { ...B(m === "account"), width: 36, height: 36 }
|
|
250
250
|
},
|
|
251
251
|
V
|
|
252
|
-
),
|
|
252
|
+
), O = {
|
|
253
253
|
position: "absolute",
|
|
254
254
|
top: "calc(100% + 6px)",
|
|
255
255
|
right: 0,
|
|
@@ -280,21 +280,21 @@ function oe({
|
|
|
280
280
|
boxSizing: "border-box",
|
|
281
281
|
fontFamily: "inherit"
|
|
282
282
|
}, _ = {
|
|
283
|
-
onMouseEnter: (
|
|
284
|
-
|
|
283
|
+
onMouseEnter: (s) => {
|
|
284
|
+
s.currentTarget.style.backgroundColor = h.bgHover;
|
|
285
285
|
},
|
|
286
|
-
onMouseLeave: (
|
|
287
|
-
|
|
286
|
+
onMouseLeave: (s) => {
|
|
287
|
+
s.currentTarget.style.backgroundColor = "transparent";
|
|
288
288
|
}
|
|
289
289
|
}, Y = m === "account" ? y(
|
|
290
290
|
"div",
|
|
291
291
|
{
|
|
292
|
-
ref:
|
|
292
|
+
ref: S,
|
|
293
293
|
role: "menu",
|
|
294
294
|
"aria-label": r.accountButton,
|
|
295
295
|
"data-neetru-account-menu": "true",
|
|
296
296
|
onKeyDown: P,
|
|
297
|
-
style:
|
|
297
|
+
style: O
|
|
298
298
|
},
|
|
299
299
|
// Header identidade
|
|
300
300
|
y(
|
|
@@ -393,12 +393,12 @@ function oe({
|
|
|
393
393
|
) : null, Z = m === "apps" ? y(
|
|
394
394
|
"div",
|
|
395
395
|
{
|
|
396
|
-
ref:
|
|
396
|
+
ref: S,
|
|
397
397
|
role: "menu",
|
|
398
398
|
"aria-label": r.appsTitle,
|
|
399
399
|
"data-neetru-appswitcher-menu": "true",
|
|
400
400
|
onKeyDown: P,
|
|
401
|
-
style: { ...
|
|
401
|
+
style: { ...O, minWidth: 280 }
|
|
402
402
|
},
|
|
403
403
|
y(
|
|
404
404
|
"div",
|
|
@@ -429,18 +429,18 @@ function oe({
|
|
|
429
429
|
backgroundColor: h.borderSoft
|
|
430
430
|
}
|
|
431
431
|
},
|
|
432
|
-
A.map((
|
|
433
|
-
let k = !!t &&
|
|
432
|
+
A.map((s) => {
|
|
433
|
+
let k = !!t && s.slug === t;
|
|
434
434
|
return y(
|
|
435
435
|
"a",
|
|
436
436
|
{
|
|
437
|
-
key:
|
|
437
|
+
key: s.slug,
|
|
438
438
|
role: "menuitem",
|
|
439
|
-
href:
|
|
439
|
+
href: s.url,
|
|
440
440
|
"aria-current": k ? "true" : void 0,
|
|
441
|
-
"data-neetru-product":
|
|
441
|
+
"data-neetru-product": s.slug,
|
|
442
442
|
"data-current": k ? "true" : void 0,
|
|
443
|
-
title:
|
|
443
|
+
title: s.name,
|
|
444
444
|
style: {
|
|
445
445
|
display: "flex",
|
|
446
446
|
flexDirection: "column",
|
|
@@ -453,16 +453,16 @@ function oe({
|
|
|
453
453
|
cursor: "pointer",
|
|
454
454
|
boxSizing: "border-box"
|
|
455
455
|
},
|
|
456
|
-
onMouseEnter: (
|
|
457
|
-
|
|
456
|
+
onMouseEnter: (C) => {
|
|
457
|
+
C.currentTarget.style.backgroundColor = h.bgHover;
|
|
458
458
|
},
|
|
459
|
-
onMouseLeave: (
|
|
460
|
-
|
|
459
|
+
onMouseLeave: (C) => {
|
|
460
|
+
C.currentTarget.style.backgroundColor = k ? h.bgHover : h.bg;
|
|
461
461
|
}
|
|
462
462
|
},
|
|
463
463
|
// Tile/ícone
|
|
464
|
-
|
|
465
|
-
src:
|
|
464
|
+
s.iconUrl ? y("img", {
|
|
465
|
+
src: s.iconUrl,
|
|
466
466
|
alt: "",
|
|
467
467
|
width: 32,
|
|
468
468
|
height: 32,
|
|
@@ -483,7 +483,7 @@ function oe({
|
|
|
483
483
|
fontWeight: 700
|
|
484
484
|
}
|
|
485
485
|
},
|
|
486
|
-
N(
|
|
486
|
+
N(s.name)
|
|
487
487
|
),
|
|
488
488
|
y(
|
|
489
489
|
"span",
|
|
@@ -500,7 +500,7 @@ function oe({
|
|
|
500
500
|
width: "100%"
|
|
501
501
|
}
|
|
502
502
|
},
|
|
503
|
-
|
|
503
|
+
s.name
|
|
504
504
|
),
|
|
505
505
|
k ? y(
|
|
506
506
|
"span",
|
|
@@ -553,8 +553,8 @@ function U(e) {
|
|
|
553
553
|
let o = c;
|
|
554
554
|
i = { field: o.field, direction: o.direction };
|
|
555
555
|
} else c.__constraint === "limit" && (n = c.value);
|
|
556
|
-
let
|
|
557
|
-
return t.length > 0 && (
|
|
556
|
+
let a = {};
|
|
557
|
+
return t.length > 0 && (a.where = t), i && (a.orderBy = i), n !== void 0 && (a.limit = n), a;
|
|
558
558
|
}
|
|
559
559
|
|
|
560
560
|
// src/react.ts
|
|
@@ -578,18 +578,18 @@ async function ie(e, t) {
|
|
|
578
578
|
i.status
|
|
579
579
|
);
|
|
580
580
|
}
|
|
581
|
-
let
|
|
581
|
+
let a = n?.intent ?? n ?? {}, c = n?.redirectUrl ?? a.redirectUrl;
|
|
582
582
|
if (!c || typeof c != "string")
|
|
583
583
|
throw new E(
|
|
584
584
|
"invalid_response",
|
|
585
585
|
"Resposta do route BFF de checkout sem `redirectUrl`."
|
|
586
586
|
);
|
|
587
587
|
return {
|
|
588
|
-
intentId: String(n?.intentId ??
|
|
588
|
+
intentId: String(n?.intentId ?? a.intentId ?? ""),
|
|
589
589
|
redirectUrl: c,
|
|
590
|
-
status: n?.status ??
|
|
591
|
-
expiresAt: typeof n?.expiresAt == "string" ? n.expiresAt : typeof
|
|
592
|
-
requiresKyc: n?.requiresKyc === true ||
|
|
590
|
+
status: n?.status ?? a.status ?? "pending",
|
|
591
|
+
expiresAt: typeof n?.expiresAt == "string" ? n.expiresAt : typeof a.expiresAt == "string" ? a.expiresAt : "",
|
|
592
|
+
requiresKyc: n?.requiresKyc === true || a.requiresKyc === true
|
|
593
593
|
};
|
|
594
594
|
}
|
|
595
595
|
function se(e) {
|
|
@@ -601,7 +601,7 @@ function Ee({
|
|
|
601
601
|
startPath: t,
|
|
602
602
|
productId: i,
|
|
603
603
|
planId: n,
|
|
604
|
-
callbackUrl:
|
|
604
|
+
callbackUrl: a,
|
|
605
605
|
tenantType: c,
|
|
606
606
|
tenantId: o,
|
|
607
607
|
children: r,
|
|
@@ -610,16 +610,16 @@ function Ee({
|
|
|
610
610
|
noAutoRedirect: f,
|
|
611
611
|
...m
|
|
612
612
|
}) {
|
|
613
|
-
let [
|
|
613
|
+
let [x, T] = l.useState(false), R = e?.checkout, p = l.useCallback(
|
|
614
614
|
async (d) => {
|
|
615
|
-
if (d.preventDefault(), !
|
|
615
|
+
if (d.preventDefault(), !x) {
|
|
616
616
|
if (t) {
|
|
617
617
|
T(true);
|
|
618
618
|
try {
|
|
619
619
|
let g = await ie(t, {
|
|
620
620
|
productId: i,
|
|
621
621
|
planId: n,
|
|
622
|
-
callbackUrl:
|
|
622
|
+
callbackUrl: a,
|
|
623
623
|
tenantType: c,
|
|
624
624
|
tenantId: o
|
|
625
625
|
});
|
|
@@ -644,7 +644,7 @@ function Ee({
|
|
|
644
644
|
let g = await R.start({
|
|
645
645
|
productId: i,
|
|
646
646
|
planId: n,
|
|
647
|
-
callbackUrl:
|
|
647
|
+
callbackUrl: a,
|
|
648
648
|
tenantType: c,
|
|
649
649
|
tenantId: o,
|
|
650
650
|
autoRedirect: !f
|
|
@@ -657,7 +657,7 @@ function Ee({
|
|
|
657
657
|
}
|
|
658
658
|
}
|
|
659
659
|
},
|
|
660
|
-
[
|
|
660
|
+
[x, R, t, i, n, a, c, o, f, b, u]
|
|
661
661
|
);
|
|
662
662
|
return l.createElement(
|
|
663
663
|
"a",
|
|
@@ -665,7 +665,7 @@ function Ee({
|
|
|
665
665
|
...m,
|
|
666
666
|
href: m.href ?? "#",
|
|
667
667
|
onClick: p,
|
|
668
|
-
"aria-busy":
|
|
668
|
+
"aria-busy": x || void 0,
|
|
669
669
|
"data-neetru-checkout-link": "true"
|
|
670
670
|
},
|
|
671
671
|
r
|
|
@@ -699,14 +699,14 @@ function De({
|
|
|
699
699
|
redirectUri: t,
|
|
700
700
|
scope: i,
|
|
701
701
|
postLoginRedirect: n,
|
|
702
|
-
theme:
|
|
702
|
+
theme: a = "dark",
|
|
703
703
|
label: c = "Entrar com Neetru",
|
|
704
704
|
onError: o,
|
|
705
705
|
style: r,
|
|
706
706
|
disabled: b,
|
|
707
707
|
...u
|
|
708
708
|
}) {
|
|
709
|
-
let [f, m] = l.useState(false), [
|
|
709
|
+
let [f, m] = l.useState(false), [x, T] = l.useState(false), R = de[a], p = !!b || f;
|
|
710
710
|
l.useEffect(() => {
|
|
711
711
|
ge();
|
|
712
712
|
}, []);
|
|
@@ -745,7 +745,7 @@ function De({
|
|
|
745
745
|
padding: "0 20px",
|
|
746
746
|
borderRadius: 0,
|
|
747
747
|
border: `1px solid ${R.border}`,
|
|
748
|
-
backgroundColor:
|
|
748
|
+
backgroundColor: x && !p ? R.bgHover : R.bg,
|
|
749
749
|
color: R.fg,
|
|
750
750
|
fontSize: "14px",
|
|
751
751
|
fontWeight: 700,
|
|
@@ -778,7 +778,7 @@ function Ne({
|
|
|
778
778
|
feature: t,
|
|
779
779
|
productSlug: i,
|
|
780
780
|
mode: n = "block",
|
|
781
|
-
fallback:
|
|
781
|
+
fallback: a,
|
|
782
782
|
loading: c,
|
|
783
783
|
children: o
|
|
784
784
|
}) {
|
|
@@ -791,16 +791,16 @@ function Ne({
|
|
|
791
791
|
try {
|
|
792
792
|
let d, g = e.usage;
|
|
793
793
|
if (g && typeof g.check == "function" && f) {
|
|
794
|
-
let
|
|
794
|
+
let S = await g.check(t, {
|
|
795
795
|
productId: u,
|
|
796
796
|
tenantId: f
|
|
797
797
|
});
|
|
798
798
|
d = {
|
|
799
|
-
allowed:
|
|
800
|
-
reason:
|
|
801
|
-
limit:
|
|
802
|
-
currentUsage:
|
|
803
|
-
behavior:
|
|
799
|
+
allowed: S.allowed === !0,
|
|
800
|
+
reason: S.reason,
|
|
801
|
+
limit: S.limit,
|
|
802
|
+
currentUsage: S.currentUsage,
|
|
803
|
+
behavior: S.behavior
|
|
804
804
|
};
|
|
805
805
|
} else
|
|
806
806
|
typeof console < "u" && console.warn(
|
|
@@ -815,8 +815,8 @@ function Ne({
|
|
|
815
815
|
};
|
|
816
816
|
}, [e, t, u, f]), r.status === "loading")
|
|
817
817
|
return l.createElement(l.Fragment, null, c ?? null);
|
|
818
|
-
let m = r.result,
|
|
819
|
-
return !
|
|
818
|
+
let m = r.result, x = m?.allowed === true, T = !x && (n === "readonly" || m?.behavior === "readonly");
|
|
819
|
+
return !x && n === "block" && !T ? l.createElement(l.Fragment, null, a ?? null) : l.createElement(
|
|
820
820
|
$.Provider,
|
|
821
821
|
{
|
|
822
822
|
value: {
|
|
@@ -842,22 +842,22 @@ function fe(e) {
|
|
|
842
842
|
}
|
|
843
843
|
function me(e) {
|
|
844
844
|
return e.docs.map((t) => {
|
|
845
|
-
let i = t.data, { id: n, ...
|
|
846
|
-
return { ...
|
|
845
|
+
let i = t.data, { id: n, ...a } = i;
|
|
846
|
+
return { ...a, id: t.id };
|
|
847
847
|
});
|
|
848
848
|
}
|
|
849
849
|
function ye(e, t) {
|
|
850
850
|
let i = e?.docs[0];
|
|
851
851
|
if (!i) return null;
|
|
852
|
-
let n = i.data, { id:
|
|
852
|
+
let n = i.data, { id: a, ...c } = n;
|
|
853
853
|
return { ...c, id: t };
|
|
854
854
|
}
|
|
855
855
|
function Ue(e, t) {
|
|
856
|
-
let i = t?.intervalMs ?? q, n = t?.poll ?? false,
|
|
856
|
+
let i = t?.intervalMs ?? q, n = t?.poll ?? false, a = fe(
|
|
857
857
|
e
|
|
858
858
|
), [c, o] = l.useState({
|
|
859
859
|
data: null,
|
|
860
|
-
isLoading:
|
|
860
|
+
isLoading: a !== null,
|
|
861
861
|
error: null,
|
|
862
862
|
isStale: false,
|
|
863
863
|
lastUpdated: null
|
|
@@ -865,12 +865,12 @@ function Ue(e, t) {
|
|
|
865
865
|
return b.current = e, l.useEffect(() => {
|
|
866
866
|
r.current = true;
|
|
867
867
|
let u = b.current;
|
|
868
|
-
if (!u ||
|
|
868
|
+
if (!u || a === null)
|
|
869
869
|
return o({ data: null, isLoading: false, error: null, isStale: false, lastUpdated: null }), () => {
|
|
870
870
|
r.current = false;
|
|
871
871
|
};
|
|
872
872
|
o((d) => ({ ...d, isLoading: d.data === null }));
|
|
873
|
-
let f = u.__kind === "query" ? u.collection : u.id, m = u.__kind === "query" ? U(u.constraints) : void 0,
|
|
873
|
+
let f = u.__kind === "query" ? u.collection : u.id, m = u.__kind === "query" ? U(u.constraints) : void 0, x = u.db.collection(f), T = (d) => {
|
|
874
874
|
r.current && o({
|
|
875
875
|
data: me(d),
|
|
876
876
|
isLoading: false,
|
|
@@ -891,33 +891,33 @@ function Ue(e, t) {
|
|
|
891
891
|
let d = false, g = async () => {
|
|
892
892
|
if (!(d || z()))
|
|
893
893
|
try {
|
|
894
|
-
let v = await
|
|
894
|
+
let v = await x.list(m);
|
|
895
895
|
d || T(v);
|
|
896
896
|
} catch (v) {
|
|
897
897
|
d || R(v);
|
|
898
898
|
}
|
|
899
899
|
};
|
|
900
900
|
g();
|
|
901
|
-
let
|
|
901
|
+
let S = setInterval(g, i);
|
|
902
902
|
return () => {
|
|
903
|
-
d = true, clearInterval(
|
|
903
|
+
d = true, clearInterval(S), r.current = false;
|
|
904
904
|
};
|
|
905
905
|
}
|
|
906
906
|
let p;
|
|
907
907
|
try {
|
|
908
|
-
p =
|
|
908
|
+
p = x.onSnapshot(m, T);
|
|
909
909
|
} catch (d) {
|
|
910
910
|
R(d);
|
|
911
911
|
}
|
|
912
912
|
return () => {
|
|
913
913
|
r.current = false, p?.();
|
|
914
914
|
};
|
|
915
|
-
}, [
|
|
915
|
+
}, [a, i, n]), c;
|
|
916
916
|
}
|
|
917
917
|
function Ae(e, t) {
|
|
918
|
-
let i = t?.intervalMs ?? q, n = t?.poll ?? false,
|
|
918
|
+
let i = t?.intervalMs ?? q, n = t?.poll ?? false, a = e && e.id ? `${e.collection}/${e.id}` : null, [c, o] = l.useState({
|
|
919
919
|
data: null,
|
|
920
|
-
isLoading:
|
|
920
|
+
isLoading: a !== null,
|
|
921
921
|
error: null,
|
|
922
922
|
isStale: false,
|
|
923
923
|
lastUpdated: null
|
|
@@ -925,12 +925,12 @@ function Ae(e, t) {
|
|
|
925
925
|
return b.current = e, l.useEffect(() => {
|
|
926
926
|
r.current = true;
|
|
927
927
|
let u = b.current;
|
|
928
|
-
if (!u ||
|
|
928
|
+
if (!u || a === null)
|
|
929
929
|
return o({ data: null, isLoading: false, error: null, isStale: false, lastUpdated: null }), () => {
|
|
930
930
|
r.current = false;
|
|
931
931
|
};
|
|
932
932
|
o((p) => ({ ...p, isLoading: p.data === null }));
|
|
933
|
-
let f = u.db.collection(u.collection).doc(u.id), m = u.id,
|
|
933
|
+
let f = u.db.collection(u.collection).doc(u.id), m = u.id, x = (p) => {
|
|
934
934
|
r.current && o({
|
|
935
935
|
data: ye(p, m),
|
|
936
936
|
isLoading: false,
|
|
@@ -950,10 +950,10 @@ function Ae(e, t) {
|
|
|
950
950
|
let p = false, d = async () => {
|
|
951
951
|
if (!(p || z()))
|
|
952
952
|
try {
|
|
953
|
-
let
|
|
954
|
-
p ||
|
|
955
|
-
} catch (
|
|
956
|
-
p || T(
|
|
953
|
+
let S = await f.get();
|
|
954
|
+
p || x(S);
|
|
955
|
+
} catch (S) {
|
|
956
|
+
p || T(S);
|
|
957
957
|
}
|
|
958
958
|
};
|
|
959
959
|
d();
|
|
@@ -964,21 +964,21 @@ function Ae(e, t) {
|
|
|
964
964
|
}
|
|
965
965
|
let R;
|
|
966
966
|
try {
|
|
967
|
-
R = f.onSnapshot(
|
|
967
|
+
R = f.onSnapshot(x);
|
|
968
968
|
} catch (p) {
|
|
969
969
|
T(p);
|
|
970
970
|
}
|
|
971
971
|
return () => {
|
|
972
972
|
r.current = false, R?.();
|
|
973
973
|
};
|
|
974
|
-
}, [
|
|
974
|
+
}, [a, i, n]), c;
|
|
975
975
|
}
|
|
976
976
|
function he(e) {
|
|
977
977
|
let t = e;
|
|
978
978
|
return t.auth && typeof t.auth.onAuthStateChanged == "function" ? t.auth : e;
|
|
979
979
|
}
|
|
980
980
|
function Le(e, t) {
|
|
981
|
-
let i = t?.timeoutMs ?? 8e3, n = he(e), [
|
|
981
|
+
let i = t?.timeoutMs ?? 8e3, n = he(e), [a, c] = l.useState(() => {
|
|
982
982
|
let r = null;
|
|
983
983
|
try {
|
|
984
984
|
r = n.getUser();
|
|
@@ -1006,7 +1006,7 @@ function Le(e, t) {
|
|
|
1006
1006
|
return () => {
|
|
1007
1007
|
o.current = false, clearTimeout(b), u?.();
|
|
1008
1008
|
};
|
|
1009
|
-
}, [n, i]),
|
|
1009
|
+
}, [n, i]), a;
|
|
1010
1010
|
}
|
|
1011
1011
|
|
|
1012
1012
|
export { Ee as CheckoutLink, Ne as EntitlementGate, oe as NeetruAccountBar, De as NeetruLoginButton, W as fetchNeetruAccountBar, N as initialsFrom, Ue as useCollection, Ae as useDoc, _e as useEntitlementContext, Le as useUser };
|
package/dist/support.cjs
CHANGED
package/dist/support.d.cts
CHANGED
package/dist/support.d.ts
CHANGED