@neetru/sdk 3.7.0 → 3.8.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.
Files changed (73) hide show
  1. package/CHANGELOG.md +75 -0
  2. package/README.md +66 -1
  3. package/dist/ai.cjs +221 -177
  4. package/dist/ai.d.cts +1 -1
  5. package/dist/ai.d.ts +1 -1
  6. package/dist/ai.mjs +221 -177
  7. package/dist/auth.cjs +1051 -868
  8. package/dist/auth.d.cts +1 -1
  9. package/dist/auth.d.ts +1 -1
  10. package/dist/auth.mjs +1048 -865
  11. package/dist/catalog.cjs +164 -97
  12. package/dist/catalog.d.cts +1 -1
  13. package/dist/catalog.d.ts +1 -1
  14. package/dist/catalog.mjs +164 -97
  15. package/dist/checkout.cjs +182 -115
  16. package/dist/checkout.d.cts +1 -1
  17. package/dist/checkout.d.ts +1 -1
  18. package/dist/checkout.mjs +181 -114
  19. package/dist/db-react.d.cts +1 -1
  20. package/dist/db-react.d.ts +1 -1
  21. package/dist/db.cjs +437 -345
  22. package/dist/db.d.cts +1 -1
  23. package/dist/db.d.ts +1 -1
  24. package/dist/db.mjs +455 -363
  25. package/dist/entitlements.cjs +17 -10
  26. package/dist/entitlements.d.cts +1 -1
  27. package/dist/entitlements.d.ts +1 -1
  28. package/dist/entitlements.mjs +17 -10
  29. package/dist/errors.cjs +15 -8
  30. package/dist/errors.d.cts +24 -3
  31. package/dist/errors.d.ts +24 -3
  32. package/dist/errors.mjs +14 -7
  33. package/dist/firestore-compat.d.cts +1 -1
  34. package/dist/firestore-compat.d.ts +1 -1
  35. package/dist/index.cjs +1544 -1190
  36. package/dist/index.d.cts +177 -3
  37. package/dist/index.d.ts +177 -3
  38. package/dist/index.mjs +1676 -1329
  39. package/dist/mobile.cjs +400 -181
  40. package/dist/mobile.d.cts +59 -4
  41. package/dist/mobile.d.ts +59 -4
  42. package/dist/mobile.mjs +400 -181
  43. package/dist/mocks.cjs +9 -2
  44. package/dist/mocks.d.cts +1 -1
  45. package/dist/mocks.d.ts +1 -1
  46. package/dist/mocks.mjs +9 -2
  47. package/dist/notifications.cjs +197 -130
  48. package/dist/notifications.d.cts +1 -1
  49. package/dist/notifications.d.ts +1 -1
  50. package/dist/notifications.mjs +196 -129
  51. package/dist/react.cjs +303 -282
  52. package/dist/react.d.cts +1 -1
  53. package/dist/react.d.ts +1 -1
  54. package/dist/react.mjs +295 -274
  55. package/dist/support.cjs +299 -229
  56. package/dist/support.d.cts +8 -4
  57. package/dist/support.d.ts +8 -4
  58. package/dist/support.mjs +298 -228
  59. package/dist/telemetry.cjs +234 -167
  60. package/dist/telemetry.d.cts +1 -1
  61. package/dist/telemetry.d.ts +1 -1
  62. package/dist/telemetry.mjs +234 -167
  63. package/dist/{types-Dx0IrOSF.d.ts → types-BYPk_3HR.d.ts} +104 -17
  64. package/dist/{types-Bx4kTLmk.d.cts → types-yv3EDKg2.d.cts} +104 -17
  65. package/dist/usage.cjs +183 -116
  66. package/dist/usage.d.cts +1 -1
  67. package/dist/usage.d.ts +1 -1
  68. package/dist/usage.mjs +183 -116
  69. package/dist/webhooks.cjs +215 -148
  70. package/dist/webhooks.d.cts +1 -1
  71. package/dist/webhooks.d.ts +1 -1
  72. package/dist/webhooks.mjs +212 -145
  73. package/package.json +2 -1
package/dist/checkout.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/errors.ts
2
- var o = class t extends Error {
2
+ var i = class t extends Error {
3
3
  code;
4
4
  status;
5
5
  requestId;
@@ -12,8 +12,15 @@ var o = class t extends Error {
12
12
  * para um `NeetruDbErrorCode` mais específico (recuperável vs não).
13
13
  */
14
14
  reason;
15
- constructor(e, n, r, s, a) {
16
- super(n), this.name = "NeetruError", this.code = e, this.status = r, this.requestId = s, this.reason = a, Object.setPrototypeOf(this, t.prototype);
15
+ /**
16
+ * 3.8.0: `x-correlation-id` da requisição que falhou. O SDK gera um UUID por
17
+ * chamada (ou usa o que o chamador passou) e manda no header; o Core grava o
18
+ * mesmo id nos logs/auditoria — cite-o ao abrir um ticket de suporte.
19
+ * `undefined` em erros que acontecem antes de qualquer requisição.
20
+ */
21
+ correlationId;
22
+ constructor(e, n, r, o, a, c) {
23
+ super(n), this.name = "NeetruError", this.code = e, this.status = r, this.requestId = o, this.reason = a, this.correlationId = c, Object.setPrototypeOf(this, t.prototype);
17
24
  }
18
25
  };
19
26
 
@@ -22,14 +29,66 @@ function E() {
22
29
  let t = typeof globalThis < "u" && "crypto" in globalThis ? globalThis.crypto : void 0;
23
30
  if (t && typeof t.randomUUID == "function")
24
31
  return t.randomUUID();
25
- throw new o(
32
+ throw new i(
26
33
  "runtime_unsupported",
27
34
  "crypto.randomUUID not available in this runtime. SDK 3.0 requires Node \u226520 or modern browser/Edge."
28
35
  );
29
36
  }
30
37
 
38
+ // src/correlation.ts
39
+ var A = "x-correlation-id";
40
+ var L = /^[A-Za-z0-9._:\-]+$/;
41
+ function x(t) {
42
+ return typeof t == "string" && t.length > 0 && t.length <= 128 && L.test(t);
43
+ }
44
+ function H() {
45
+ let t = globalThis.crypto;
46
+ try {
47
+ if (t && typeof t.randomUUID == "function") return t.randomUUID();
48
+ } catch {
49
+ }
50
+ let e = new Uint8Array(16), n = false;
51
+ try {
52
+ t && typeof t.getRandomValues == "function" && (t.getRandomValues(e), n = !0);
53
+ } catch {
54
+ n = false;
55
+ }
56
+ if (!n)
57
+ for (let o = 0; o < e.length; o++) e[o] = Math.floor(Math.random() * 256);
58
+ e[6] = e[6] & 15 | 64, e[8] = e[8] & 63 | 128;
59
+ let r = Array.from(e, (o) => o.toString(16).padStart(2, "0")).join("");
60
+ return `${r.slice(0, 8)}-${r.slice(8, 12)}-${r.slice(12, 16)}-${r.slice(16, 20)}-${r.slice(20)}`;
61
+ }
62
+ function N(t, e) {
63
+ let n, r = {};
64
+ for (let [a, c] of Object.entries(t)) {
65
+ if (a.toLowerCase() === A) {
66
+ x(c) && (n = c);
67
+ continue;
68
+ }
69
+ r[a] = c;
70
+ }
71
+ let o = n ?? (x(e) ? e : void 0) ?? H();
72
+ return r[A] = o, { headers: r, correlationId: o };
73
+ }
74
+
75
+ // src/server-only-key.ts
76
+ function D() {
77
+ try {
78
+ let t = globalThis.navigator;
79
+ if (t && t.product === "ReactNative") return "react-native";
80
+ } catch {
81
+ }
82
+ try {
83
+ let t = globalThis;
84
+ if (typeof t.window < "u" && typeof t.document < "u") return "browser";
85
+ } catch {
86
+ }
87
+ return null;
88
+ }
89
+
31
90
  // src/http.ts
32
- var P = {
91
+ var B = {
33
92
  // SDK major 3.x requer Core ≥ 2026.05.1 (suporte a X-Neetru-Version header,
34
93
  // runTransaction write-after-read, verifyWebhookRequest, webhooks 3.0+)
35
94
  3: "2026.05.1"
@@ -37,73 +96,77 @@ var P = {
37
96
  function b(t) {
38
97
  return t.split("+")[0] ?? t;
39
98
  }
40
- function M(t, e) {
41
- let n = b(t).split(".").map(Number), r = b(e).split(".").map(Number), s = Math.max(n.length, r.length);
42
- for (let a = 0; a < s; a++) {
43
- let d = n[a] ?? 0, u = r[a] ?? 0;
44
- if (d !== u) return d - u;
99
+ function G(t, e) {
100
+ let n = b(t).split(".").map(Number), r = b(e).split(".").map(Number), o = Math.max(n.length, r.length);
101
+ for (let a = 0; a < o; a++) {
102
+ let c = n[a] ?? 0, u = r[a] ?? 0;
103
+ if (c !== u) return c - u;
45
104
  }
46
105
  return 0;
47
106
  }
48
- function D() {
107
+ function M() {
49
108
  try {
50
- return "3.7.0";
109
+ return "3.8.1";
51
110
  } catch {
52
111
  return;
53
112
  }
54
113
  }
55
- function $() {
56
- let t = D();
114
+ function F() {
115
+ let t = M();
57
116
  return t ? parseInt(t.split(".")[0] ?? "3", 10) : 3;
58
117
  }
59
- var v = /* @__PURE__ */ new Set();
60
- function K(t) {
118
+ var U = /* @__PURE__ */ new Set();
119
+ function V(t) {
61
120
  if (!t) return;
62
- let e = $(), n = P[e];
121
+ let e = F(), n = B[e];
63
122
  if (!n) return;
64
123
  let r = b(t);
65
- if (M(r, n) < 0) {
66
- let s = `${e}:${r}`;
67
- v.has(s) || (v.add(s), console.warn(
124
+ if (G(r, n) < 0) {
125
+ let o = `${e}:${r}`;
126
+ U.has(o) || (U.add(o), console.warn(
68
127
  `[Neetru SDK] Aten\xE7\xE3o: Core vers\xE3o "${t}" \xE9 anterior ao m\xEDnimo recomendado "${n}" para SDK major ${e}. Alguns recursos podem n\xE3o funcionar corretamente. Atualize o Core para a vers\xE3o mais recente.`
69
128
  ));
70
129
  }
71
130
  }
72
- var j = 2, G = 0, H = /* @__PURE__ */ new Set(["GET", "HEAD"]), F = /* @__PURE__ */ new Set([
131
+ function z() {
132
+ let t = "This operation requires an apiKey. Pass it to createNeetruClient({ apiKey }) or set NEETRU_API_KEY env var.";
133
+ return D() ? "Esta opera\xE7\xE3o exige a credencial nrt_ do produto, que \xE9 S\xD3 DE SERVIDOR. No navegador/app, chame a API do seu produto (ex.: https://<produto>.neetru.com/api/v1) com o token do usu\xE1rio \u2014 o backend do produto faz esta chamada com o SDK e a chave. (" + t + ")" : t;
134
+ }
135
+ var X = 2, Y = 0, J = /* @__PURE__ */ new Set(["GET", "HEAD"]), W = /* @__PURE__ */ new Set([
73
136
  "rate_limited",
74
137
  "server_error",
75
138
  "network_error"
76
139
  ]);
77
- function x(t) {
140
+ function O(t) {
78
141
  let e = 200 * Math.pow(4, t), n = e * 0.2 * (Math.random() * 2 - 1);
79
142
  return Math.max(50, Math.round(e + n));
80
143
  }
81
- var A = 6e4;
82
- function B(t) {
144
+ var q = 6e4;
145
+ function Z(t) {
83
146
  if (!t) return null;
84
147
  let e = Number(t);
85
- if (Number.isFinite(e) && e >= 0) return Math.min(Math.round(e * 1e3), A);
148
+ if (Number.isFinite(e) && e >= 0) return Math.min(Math.round(e * 1e3), q);
86
149
  let n = Date.parse(t);
87
150
  if (Number.isFinite(n)) {
88
151
  let r = n - Date.now();
89
- if (r > 0) return Math.min(r, A);
152
+ if (r > 0) return Math.min(r, q);
90
153
  }
91
154
  return null;
92
155
  }
93
- function U(t) {
156
+ function K(t) {
94
157
  return new Promise((e) => setTimeout(e, t));
95
158
  }
96
- function L(t) {
159
+ function Q(t) {
97
160
  return t === 401 ? "unauthorized" : t === 403 ? "forbidden" : t === 404 ? "not_found" : t === 409 ? "conflict" : t === 410 ? "gone" : t === 422 || t === 400 ? "validation_failed" : t === 429 ? "rate_limited" : t >= 500 ? "server_error" : "unknown";
98
161
  }
99
- function z(t, e, n) {
100
- let r = t.replace(/\/+$/, ""), s = e.startsWith("/") ? e : `/${e}`, a = new URL(`${r}${s}`);
162
+ function ee(t, e, n) {
163
+ let r = t.replace(/\/+$/, ""), o = e.startsWith("/") ? e : `/${e}`, a = new URL(`${r}${o}`);
101
164
  if (n)
102
- for (let [d, u] of Object.entries(n))
103
- u !== void 0 && a.searchParams.set(d, String(u));
165
+ for (let [c, u] of Object.entries(n))
166
+ u !== void 0 && a.searchParams.set(c, String(u));
104
167
  return a.toString();
105
168
  }
106
- async function q(t) {
169
+ async function P(t) {
107
170
  let e = await t.text();
108
171
  if (e)
109
172
  try {
@@ -113,91 +176,95 @@ async function q(t) {
113
176
  }
114
177
  }
115
178
  async function y(t, e) {
116
- let n = e.method ?? "GET", r = z(t.baseUrl, e.path, e.query), s = H.has(n) ? j : G, a = e.retries ?? s, d = {
117
- accept: "application/json",
118
- ...e.headers
119
- }, u = D();
120
- if (u && (d["x-neetru-sdk-version"] = u), e.requireAuth) {
179
+ let n = e.method ?? "GET", r = ee(t.baseUrl, e.path, e.query), o = J.has(n) ? X : Y, a = e.retries ?? o, { headers: c, correlationId: u } = N(
180
+ { accept: "application/json", ...e.headers },
181
+ e.correlationId
182
+ ), C = M();
183
+ if (C && (c["x-neetru-sdk-version"] = C), e.requireAuth) {
121
184
  if (!t.apiKey)
122
- throw new o(
123
- "missing_api_key",
124
- "This operation requires an apiKey. Pass it to createNeetruClient({ apiKey }) or set NEETRU_API_KEY env var."
125
- );
126
- d.authorization = `Bearer ${t.apiKey}`;
185
+ throw new i("missing_api_key", z());
186
+ c.authorization = `Bearer ${t.apiKey}`;
127
187
  }
128
188
  if (e.idempotencyKey) {
129
189
  let f = typeof e.idempotencyKey == "string" ? e.idempotencyKey : E();
130
- d["idempotency-key"] = f;
190
+ c["idempotency-key"] = f;
131
191
  }
132
192
  let I = e.body !== void 0 && n !== "GET" && n !== "DELETE" ? JSON.stringify(e.body) : void 0;
133
- I !== void 0 && (d["content-type"] = "application/json");
193
+ I !== void 0 && (c["content-type"] = "application/json");
134
194
  let g = null, p = e.deadlineMs != null ? Date.now() + e.deadlineMs : null;
135
195
  for (let f = 0; f <= a; f++) {
136
196
  if (p != null && Date.now() >= p)
137
- throw g ?? new o("network_error", "Deadline excedido antes de completar a request");
138
- let w = { method: n, headers: d };
139
- I !== void 0 && (w.body = I);
140
- let N = p != null ? Math.max(1, Math.min(3e4, p - Date.now())) : 3e4;
141
- w.signal = AbortSignal.timeout(N);
142
- let c;
197
+ throw g ?? new i(
198
+ "network_error",
199
+ "Deadline excedido antes de completar a request",
200
+ void 0,
201
+ void 0,
202
+ void 0,
203
+ u
204
+ );
205
+ let _ = { method: n, headers: c };
206
+ I !== void 0 && (_.body = I);
207
+ let $ = p != null ? Math.max(1, Math.min(3e4, p - Date.now())) : 3e4;
208
+ _.signal = AbortSignal.timeout($);
209
+ let d;
143
210
  try {
144
- c = await t.fetch(r, w);
145
- } catch (i) {
146
- let k = i instanceof DOMException && i.name === "TimeoutError" ? "Network error: timeout after 30s" : `Network error: ${i instanceof Error ? i.message : "fetch failed"}`;
147
- if (g = new o("network_error", k), f < a) {
148
- let S = x(f);
211
+ d = await t.fetch(r, _);
212
+ } catch (s) {
213
+ let m = s instanceof DOMException && s.name === "TimeoutError" ? "Network error: timeout after 30s" : `Network error: ${s instanceof Error ? s.message : "fetch failed"}`;
214
+ if (g = new i("network_error", m, void 0, void 0, void 0, u), f < a) {
215
+ let S = O(f);
149
216
  if (p == null || Date.now() + S < p) {
150
- await U(S);
217
+ await K(S);
151
218
  continue;
152
219
  }
153
220
  }
154
221
  throw g;
155
222
  }
156
- let O = c.headers.get("x-request-id") ?? c.headers.get("x-correlation-id") ?? void 0;
157
- if (c.ok) {
158
- let i = c.headers.get("x-neetru-version");
159
- return i && K(i), await q(c);
223
+ let j = d.headers.get("x-request-id") ?? d.headers.get("x-correlation-id") ?? void 0;
224
+ if (d.ok) {
225
+ let s = d.headers.get("x-neetru-version");
226
+ return s && V(s), await P(d);
160
227
  }
161
- let l = await q(c), m = L(c.status), h = `HTTP ${c.status}`, T;
228
+ let l = await P(d), k = Q(d.status), h = `HTTP ${d.status}`, w;
162
229
  if (l && typeof l == "object") {
163
- let i = l.error;
164
- typeof i == "string" ? h = i : i && typeof i == "object" ? (typeof i.code == "string" && (m = i.code), typeof i.message == "string" && (h = i.message), typeof i.reason == "string" && (T = i.reason)) : (typeof l.code == "string" && (m = l.code), typeof l.message == "string" && (h = l.message)), typeof l.reason == "string" && (T = l.reason);
230
+ let s = l.error;
231
+ typeof s == "string" ? h = s : s && typeof s == "object" ? (typeof s.code == "string" && (k = s.code), typeof s.message == "string" && (h = s.message), typeof s.reason == "string" && (w = s.reason)) : (typeof l.code == "string" && (k = l.code), typeof l.message == "string" && (h = l.message)), typeof l.reason == "string" && (w = l.reason);
165
232
  }
166
- if (c.status === 410) {
167
- let i = c.headers.get("x-neetru-replacement");
168
- h === `HTTP ${c.status}` && (h = `Endpoint ${e.path} foi removido do Core (HTTP 410 Gone) \u2014 atualize o @neetru/sdk e migre para a API substituta.`), i && !h.includes(i) && (h += ` Substituto: ${i}.`);
233
+ if (d.status === 410) {
234
+ let s = d.headers.get("x-neetru-replacement");
235
+ h === `HTTP ${d.status}` && (h = `Endpoint ${e.path} foi removido do Core (HTTP 410 Gone) \u2014 atualize o @neetru/sdk e migre para a API substituta.`), s && !h.includes(s) && (h += ` Substituto: ${s}.`);
169
236
  }
170
- let R = new o(m, h, c.status, O, T);
171
- if (g = R, F.has(m) && f < a) {
172
- let k = B(c.headers.get("retry-after")) ?? x(f);
173
- if (p == null || Date.now() + k < p) {
174
- await U(k);
237
+ let v = new i(k, h, d.status, j, w, u);
238
+ if (g = v, W.has(k) && f < a) {
239
+ let m = Z(d.headers.get("retry-after")) ?? O(f);
240
+ if (p == null || Date.now() + m < p) {
241
+ await K(m);
175
242
  continue;
176
243
  }
177
244
  }
178
- throw R;
245
+ throw v;
179
246
  }
180
- throw g ?? new o("unknown", "unexpected httpRequest exit");
247
+ throw g ?? new i("unknown", "unexpected httpRequest exit", void 0, void 0, void 0, u);
181
248
  }
182
249
 
183
250
  // src/checkout.ts
184
- function _(t, e) {
251
+ function T(t, e) {
185
252
  let n = t?.accessToken || t?.idToken;
186
253
  if (!n || typeof n != "string")
187
- throw new o(
254
+ throw new i(
188
255
  "validation_failed",
189
256
  `checkout.${e} requer o access_token OU o id_token OIDC do usu\xE1rio final (passe \`accessToken\` ou \`idToken\`). A chave de API do SDK (nrt_*) N\xC3O \xE9 aceita pelo endpoint de checkout \u2014 ele autentica a identidade do cliente que est\xE1 assinando (Bearer access_token/id_token OIDC ou cookie de sess\xE3o). No padr\xE3o BFF/cookie, passe o \`idToken\` que seu servidor guardou no cookie httpOnly.`
190
257
  );
191
258
  return { requireAuth: false, headers: { authorization: `Bearer ${n}` } };
192
259
  }
193
- function V(t) {
260
+ function te(t) {
194
261
  if (!t || typeof t != "object")
195
- throw new o("invalid_response", "checkout.start response is not an object");
262
+ throw new i("invalid_response", "checkout.start response is not an object");
196
263
  let e = t;
197
264
  if (typeof e.intentId != "string" || !e.intentId)
198
- throw new o("invalid_response", "checkout.start response missing intentId");
265
+ throw new i("invalid_response", "checkout.start response missing intentId");
199
266
  if (typeof e.redirectUrl != "string" || !e.redirectUrl)
200
- throw new o("invalid_response", "checkout.start response missing redirectUrl");
267
+ throw new i("invalid_response", "checkout.start response missing redirectUrl");
201
268
  return {
202
269
  intentId: e.intentId,
203
270
  redirectUrl: e.redirectUrl,
@@ -206,14 +273,14 @@ function V(t) {
206
273
  requiresKyc: e.requiresKyc === true
207
274
  };
208
275
  }
209
- function J(t) {
276
+ function ne(t) {
210
277
  if (!t || typeof t != "object")
211
- throw new o("invalid_response", "checkout.get response is not an object");
278
+ throw new i("invalid_response", "checkout.get response is not an object");
212
279
  let e = t, n = e.intent;
213
280
  if (!n || typeof n != "object")
214
- throw new o("invalid_response", "checkout.get response missing intent");
281
+ throw new i("invalid_response", "checkout.get response missing intent");
215
282
  if (typeof n.intentId != "string")
216
- throw new o("invalid_response", "checkout.get response missing intentId");
283
+ throw new i("invalid_response", "checkout.get response missing intentId");
217
284
  return {
218
285
  intentId: n.intentId,
219
286
  uid: n.uid ?? "",
@@ -228,35 +295,35 @@ function J(t) {
228
295
  isStale: e.isStale === true
229
296
  };
230
297
  }
231
- function Y() {
298
+ function re() {
232
299
  try {
233
300
  return typeof globalThis < "u" && typeof globalThis.window < "u" && typeof globalThis.location < "u" && typeof globalThis.location.assign == "function";
234
301
  } catch {
235
302
  return false;
236
303
  }
237
304
  }
238
- function W(t) {
305
+ function oe(t) {
239
306
  try {
240
307
  globalThis.location.assign(t);
241
308
  } catch {
242
309
  }
243
310
  }
244
- function X(t) {
311
+ function ie(t) {
245
312
  return {
246
313
  async start(e) {
247
314
  if (!e?.productId)
248
- throw new o("validation_failed", "checkout.start: productId is required");
315
+ throw new i("validation_failed", "checkout.start: productId is required");
249
316
  if (!e?.planId)
250
- throw new o("validation_failed", "checkout.start: planId is required");
317
+ throw new i("validation_failed", "checkout.start: planId is required");
251
318
  if (!e?.callbackUrl)
252
- throw new o("validation_failed", "checkout.start: callbackUrl is required");
319
+ throw new i("validation_failed", "checkout.start: callbackUrl is required");
253
320
  let n = {
254
321
  productId: e.productId,
255
322
  planId: e.planId,
256
323
  callbackUrl: e.callbackUrl
257
324
  };
258
325
  e.tenantType && (n.targetTenantType = e.tenantType), e.tenantId && (n.targetTenantId = e.tenantId);
259
- let { requireAuth: r, headers: s } = _(
326
+ let { requireAuth: r, headers: o } = T(
260
327
  { accessToken: e.accessToken, idToken: e.idToken },
261
328
  "start"
262
329
  ), a = await y(t, {
@@ -264,29 +331,29 @@ function X(t) {
264
331
  path: "/api/v1/checkout/intents",
265
332
  body: n,
266
333
  requireAuth: r,
267
- headers: s,
334
+ headers: o,
268
335
  idempotencyKey: true
269
- }), d = V(a);
270
- return e.autoRedirect !== false && Y() && W(d.redirectUrl), d;
336
+ }), c = te(a);
337
+ return e.autoRedirect !== false && re() && oe(c.redirectUrl), c;
271
338
  },
272
339
  async get(e, n) {
273
340
  if (!e || typeof e != "string")
274
- throw new o("validation_failed", "checkout.get: intentId is required");
275
- let { requireAuth: r, headers: s } = _(
341
+ throw new i("validation_failed", "checkout.get: intentId is required");
342
+ let { requireAuth: r, headers: o } = T(
276
343
  { accessToken: n?.accessToken, idToken: n?.idToken },
277
344
  "get"
278
345
  ), a = await y(t, {
279
346
  method: "GET",
280
347
  path: `/api/v1/checkout/intents/${encodeURIComponent(e)}`,
281
348
  requireAuth: r,
282
- headers: s
349
+ headers: o
283
350
  });
284
- return J(a);
351
+ return ne(a);
285
352
  },
286
353
  async cancel(e, n) {
287
354
  if (!e || typeof e != "string")
288
- throw new o("validation_failed", "checkout.cancel: intentId is required");
289
- let { requireAuth: r, headers: s } = _(
355
+ throw new i("validation_failed", "checkout.cancel: intentId is required");
356
+ let { requireAuth: r, headers: o } = T(
290
357
  { accessToken: n?.accessToken, idToken: n?.idToken },
291
358
  "cancel"
292
359
  );
@@ -296,22 +363,22 @@ function X(t) {
296
363
  method: "DELETE",
297
364
  path: `/api/v1/checkout/intents/${encodeURIComponent(e)}`,
298
365
  requireAuth: r,
299
- headers: s
366
+ headers: o
300
367
  }))?.alreadyCancelled === true
301
368
  };
302
369
  }
303
370
  };
304
371
  }
305
- var C = class {
372
+ var R = class {
306
373
  intents = /* @__PURE__ */ new Map();
307
374
  async start(e) {
308
375
  if (!e?.productId)
309
- throw new o("validation_failed", "checkout.start: productId is required");
376
+ throw new i("validation_failed", "checkout.start: productId is required");
310
377
  if (!e?.planId)
311
- throw new o("validation_failed", "checkout.start: planId is required");
378
+ throw new i("validation_failed", "checkout.start: planId is required");
312
379
  if (!e?.callbackUrl)
313
- throw new o("validation_failed", "checkout.start: callbackUrl is required");
314
- let n = `chk_mock_${Math.random().toString(36).slice(2, 10)}`, r = new Date(Date.now() + 900 * 1e3).toISOString(), s = `https://localhost:9003/portal/checkout/${n}`;
380
+ throw new i("validation_failed", "checkout.start: callbackUrl is required");
381
+ let n = `chk_mock_${Math.random().toString(36).slice(2, 10)}`, r = new Date(Date.now() + 900 * 1e3).toISOString(), o = `https://localhost:9003/portal/checkout/${n}`;
315
382
  return this.intents.set(n, {
316
383
  intentId: n,
317
384
  uid: "dev-fixture-uid",
@@ -325,7 +392,7 @@ var C = class {
325
392
  expiresAt: r
326
393
  }), {
327
394
  intentId: n,
328
- redirectUrl: s,
395
+ redirectUrl: o,
329
396
  status: "pending",
330
397
  expiresAt: r,
331
398
  requiresKyc: false
@@ -334,19 +401,19 @@ var C = class {
334
401
  async get(e, n) {
335
402
  let r = this.intents.get(e);
336
403
  if (!r)
337
- throw new o("not_found", `Mock intent ${e} not found`);
404
+ throw new i("not_found", `Mock intent ${e} not found`);
338
405
  return { ...r };
339
406
  }
340
407
  async cancel(e, n) {
341
408
  let r = this.intents.get(e);
342
409
  if (!r)
343
- throw new o("not_found", `Mock intent ${e} not found`);
344
- let s = r.status === "cancelled";
345
- return this.intents.set(e, { ...r, status: "cancelled" }), { ok: true, alreadyCancelled: s };
410
+ throw new i("not_found", `Mock intent ${e} not found`);
411
+ let o = r.status === "cancelled";
412
+ return this.intents.set(e, { ...r, status: "cancelled" }), { ok: true, alreadyCancelled: o };
346
413
  }
347
414
  };
348
- function ae(t) {
349
- return t.env === "dev" ? new C() : X(t);
415
+ function Ie(t) {
416
+ return t.env === "dev" ? new R() : ie(t);
350
417
  }
351
418
 
352
- export { C as MockCheckout, ae as createCheckoutNamespace };
419
+ export { R as MockCheckout, Ie as createCheckoutNamespace };
@@ -1,4 +1,4 @@
1
- import { aq as SyncState, av as Unsubscribe, F as DbDoc, W as NeetruClient, E as DbCollectionRef, K as DbQuery } from './types-Bx4kTLmk.cjs';
1
+ import { ar as SyncState, aw as Unsubscribe, F as DbDoc, X as NeetruClient, E as DbCollectionRef, K as DbQuery } from './types-yv3EDKg2.cjs';
2
2
  import 'drizzle-orm/node-postgres';
3
3
  import './errors.cjs';
4
4
 
@@ -1,4 +1,4 @@
1
- import { aq as SyncState, av as Unsubscribe, F as DbDoc, W as NeetruClient, E as DbCollectionRef, K as DbQuery } from './types-Dx0IrOSF.js';
1
+ import { ar as SyncState, aw as Unsubscribe, F as DbDoc, X as NeetruClient, E as DbCollectionRef, K as DbQuery } from './types-BYPk_3HR.js';
2
2
  import 'drizzle-orm/node-postgres';
3
3
  import './errors.js';
4
4