@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/usage.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  // src/errors.ts
4
- var s = class e extends Error {
4
+ var d = class e extends Error {
5
5
  code;
6
6
  status;
7
7
  requestId;
@@ -14,98 +14,161 @@ var s = class e extends Error {
14
14
  * para um `NeetruDbErrorCode` mais específico (recuperável vs não).
15
15
  */
16
16
  reason;
17
- constructor(t, r, i, d, n) {
18
- super(r), this.name = "NeetruError", this.code = t, this.status = i, this.requestId = d, this.reason = n, Object.setPrototypeOf(this, e.prototype);
17
+ /**
18
+ * 3.8.0: `x-correlation-id` da requisição que falhou. O SDK gera um UUID por
19
+ * chamada (ou usa o que o chamador passou) e manda no header; o Core grava o
20
+ * mesmo id nos logs/auditoria — cite-o ao abrir um ticket de suporte.
21
+ * `undefined` em erros que acontecem antes de qualquer requisição.
22
+ */
23
+ correlationId;
24
+ constructor(t, r, n, i, o, a) {
25
+ super(r), this.name = "NeetruError", this.code = t, this.status = n, this.requestId = i, this.reason = o, this.correlationId = a, Object.setPrototypeOf(this, e.prototype);
19
26
  }
20
27
  };
21
28
 
22
29
  // src/idempotency.ts
23
- function k() {
30
+ function T() {
24
31
  let e = typeof globalThis < "u" && "crypto" in globalThis ? globalThis.crypto : void 0;
25
32
  if (e && typeof e.randomUUID == "function")
26
33
  return e.randomUUID();
27
- throw new s(
34
+ throw new d(
28
35
  "runtime_unsupported",
29
36
  "crypto.randomUUID not available in this runtime. SDK 3.0 requires Node \u226520 or modern browser/Edge."
30
37
  );
31
38
  }
32
39
 
40
+ // src/correlation.ts
41
+ var S = "x-correlation-id";
42
+ var j = /^[A-Za-z0-9._:\-]+$/;
43
+ function x(e) {
44
+ return typeof e == "string" && e.length > 0 && e.length <= 128 && j.test(e);
45
+ }
46
+ function F() {
47
+ let e = globalThis.crypto;
48
+ try {
49
+ if (e && typeof e.randomUUID == "function") return e.randomUUID();
50
+ } catch {
51
+ }
52
+ let t = new Uint8Array(16), r = false;
53
+ try {
54
+ e && typeof e.getRandomValues == "function" && (e.getRandomValues(t), r = !0);
55
+ } catch {
56
+ r = false;
57
+ }
58
+ if (!r)
59
+ for (let i = 0; i < t.length; i++) t[i] = Math.floor(Math.random() * 256);
60
+ t[6] = t[6] & 15 | 64, t[8] = t[8] & 63 | 128;
61
+ let n = Array.from(t, (i) => i.toString(16).padStart(2, "0")).join("");
62
+ return `${n.slice(0, 8)}-${n.slice(8, 12)}-${n.slice(12, 16)}-${n.slice(16, 20)}-${n.slice(20)}`;
63
+ }
64
+ function D(e, t) {
65
+ let r, n = {};
66
+ for (let [o, a] of Object.entries(e)) {
67
+ if (o.toLowerCase() === S) {
68
+ x(a) && (r = a);
69
+ continue;
70
+ }
71
+ n[o] = a;
72
+ }
73
+ let i = r ?? (x(t) ? t : void 0) ?? F();
74
+ return n[S] = i, { headers: n, correlationId: i };
75
+ }
76
+
77
+ // src/server-only-key.ts
78
+ function A() {
79
+ try {
80
+ let e = globalThis.navigator;
81
+ if (e && e.product === "ReactNative") return "react-native";
82
+ } catch {
83
+ }
84
+ try {
85
+ let e = globalThis;
86
+ if (typeof e.window < "u" && typeof e.document < "u") return "browser";
87
+ } catch {
88
+ }
89
+ return null;
90
+ }
91
+
33
92
  // src/http.ts
34
- var O = {
93
+ var H = {
35
94
  // SDK major 3.x requer Core ≥ 2026.05.1 (suporte a X-Neetru-Version header,
36
95
  // runTransaction write-after-read, verifyWebhookRequest, webhooks 3.0+)
37
96
  3: "2026.05.1"
38
97
  };
39
- function E(e) {
98
+ function v(e) {
40
99
  return e.split("+")[0] ?? e;
41
100
  }
42
- function $(e, t) {
43
- let r = E(e).split(".").map(Number), i = E(t).split(".").map(Number), d = Math.max(r.length, i.length);
44
- for (let n = 0; n < d; n++) {
45
- let a = r[n] ?? 0, l = i[n] ?? 0;
46
- if (a !== l) return a - l;
101
+ function V(e, t) {
102
+ let r = v(e).split(".").map(Number), n = v(t).split(".").map(Number), i = Math.max(r.length, n.length);
103
+ for (let o = 0; o < i; o++) {
104
+ let a = r[o] ?? 0, c = n[o] ?? 0;
105
+ if (a !== c) return a - c;
47
106
  }
48
107
  return 0;
49
108
  }
50
- function C() {
109
+ function q() {
51
110
  try {
52
- return "3.7.0";
111
+ return "3.8.1";
53
112
  } catch {
54
113
  return;
55
114
  }
56
115
  }
57
- function P() {
58
- let e = C();
116
+ function z() {
117
+ let e = q();
59
118
  return e ? parseInt(e.split(".")[0] ?? "3", 10) : 3;
60
119
  }
61
- var N = /* @__PURE__ */ new Set();
62
- function K(e) {
120
+ var C = /* @__PURE__ */ new Set();
121
+ function B(e) {
63
122
  if (!e) return;
64
- let t = P(), r = O[t];
123
+ let t = z(), r = H[t];
65
124
  if (!r) return;
66
- let i = E(e);
67
- if ($(i, r) < 0) {
68
- let d = `${t}:${i}`;
69
- N.has(d) || (N.add(d), console.warn(
125
+ let n = v(e);
126
+ if (V(n, r) < 0) {
127
+ let i = `${t}:${n}`;
128
+ C.has(i) || (C.add(i), console.warn(
70
129
  `[Neetru SDK] Aten\xE7\xE3o: Core vers\xE3o "${e}" \xE9 anterior ao m\xEDnimo recomendado "${r}" para SDK major ${t}. Alguns recursos podem n\xE3o funcionar corretamente. Atualize o Core para a vers\xE3o mais recente.`
71
130
  ));
72
131
  }
73
132
  }
74
- var j = 2, F = 0, H = /* @__PURE__ */ new Set(["GET", "HEAD"]), z = /* @__PURE__ */ new Set([
133
+ function G() {
134
+ let e = "This operation requires an apiKey. Pass it to createNeetruClient({ apiKey }) or set NEETRU_API_KEY env var.";
135
+ return A() ? "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. (" + e + ")" : e;
136
+ }
137
+ var X = 2, Y = 0, J = /* @__PURE__ */ new Set(["GET", "HEAD"]), W = /* @__PURE__ */ new Set([
75
138
  "rate_limited",
76
139
  "server_error",
77
140
  "network_error"
78
141
  ]);
79
- function x(e) {
142
+ function O(e) {
80
143
  let t = 200 * Math.pow(4, e), r = t * 0.2 * (Math.random() * 2 - 1);
81
144
  return Math.max(50, Math.round(t + r));
82
145
  }
83
- var D = 6e4;
84
- function V(e) {
146
+ var K = 6e4;
147
+ function Z(e) {
85
148
  if (!e) return null;
86
149
  let t = Number(e);
87
- if (Number.isFinite(t) && t >= 0) return Math.min(Math.round(t * 1e3), D);
150
+ if (Number.isFinite(t) && t >= 0) return Math.min(Math.round(t * 1e3), K);
88
151
  let r = Date.parse(e);
89
152
  if (Number.isFinite(r)) {
90
- let i = r - Date.now();
91
- if (i > 0) return Math.min(i, D);
153
+ let n = r - Date.now();
154
+ if (n > 0) return Math.min(n, K);
92
155
  }
93
156
  return null;
94
157
  }
95
- function q(e) {
158
+ function M(e) {
96
159
  return new Promise((t) => setTimeout(t, e));
97
160
  }
98
- function G(e) {
161
+ function Q(e) {
99
162
  return e === 401 ? "unauthorized" : e === 403 ? "forbidden" : e === 404 ? "not_found" : e === 409 ? "conflict" : e === 410 ? "gone" : e === 422 || e === 400 ? "validation_failed" : e === 429 ? "rate_limited" : e >= 500 ? "server_error" : "unknown";
100
163
  }
101
- function L(e, t, r) {
102
- let i = e.replace(/\/+$/, ""), d = t.startsWith("/") ? t : `/${t}`, n = new URL(`${i}${d}`);
164
+ function ee(e, t, r) {
165
+ let n = e.replace(/\/+$/, ""), i = t.startsWith("/") ? t : `/${t}`, o = new URL(`${n}${i}`);
103
166
  if (r)
104
- for (let [a, l] of Object.entries(r))
105
- l !== void 0 && n.searchParams.set(a, String(l));
106
- return n.toString();
167
+ for (let [a, c] of Object.entries(r))
168
+ c !== void 0 && o.searchParams.set(a, String(c));
169
+ return o.toString();
107
170
  }
108
- async function A(e) {
171
+ async function U(e) {
109
172
  let t = await e.text();
110
173
  if (t)
111
174
  try {
@@ -114,86 +177,90 @@ async function A(e) {
114
177
  return;
115
178
  }
116
179
  }
117
- async function v(e, t) {
118
- let r = t.method ?? "GET", i = L(e.baseUrl, t.path, t.query), d = H.has(r) ? j : F, n = t.retries ?? d, a = {
119
- accept: "application/json",
120
- ...t.headers
121
- }, l = C();
122
- if (l && (a["x-neetru-sdk-version"] = l), t.requireAuth) {
180
+ async function E(e, t) {
181
+ let r = t.method ?? "GET", n = ee(e.baseUrl, t.path, t.query), i = J.has(r) ? X : Y, o = t.retries ?? i, { headers: a, correlationId: c } = D(
182
+ { accept: "application/json", ...t.headers },
183
+ t.correlationId
184
+ ), R = q();
185
+ if (R && (a["x-neetru-sdk-version"] = R), t.requireAuth) {
123
186
  if (!e.apiKey)
124
- throw new s(
125
- "missing_api_key",
126
- "This operation requires an apiKey. Pass it to createNeetruClient({ apiKey }) or set NEETRU_API_KEY env var."
127
- );
187
+ throw new d("missing_api_key", G());
128
188
  a.authorization = `Bearer ${e.apiKey}`;
129
189
  }
130
190
  if (t.idempotencyKey) {
131
- let f = typeof t.idempotencyKey == "string" ? t.idempotencyKey : k();
132
- a["idempotency-key"] = f;
191
+ let p = typeof t.idempotencyKey == "string" ? t.idempotencyKey : T();
192
+ a["idempotency-key"] = p;
133
193
  }
134
- let _ = t.body !== void 0 && r !== "GET" && r !== "DELETE" ? JSON.stringify(t.body) : void 0;
135
- _ !== void 0 && (a["content-type"] = "application/json");
136
- let g = null, p = t.deadlineMs != null ? Date.now() + t.deadlineMs : null;
137
- for (let f = 0; f <= n; f++) {
138
- if (p != null && Date.now() >= p)
139
- throw g ?? new s("network_error", "Deadline excedido antes de completar a request");
194
+ let b = t.body !== void 0 && r !== "GET" && r !== "DELETE" ? JSON.stringify(t.body) : void 0;
195
+ b !== void 0 && (a["content-type"] = "application/json");
196
+ let g = null, f = t.deadlineMs != null ? Date.now() + t.deadlineMs : null;
197
+ for (let p = 0; p <= o; p++) {
198
+ if (f != null && Date.now() >= f)
199
+ throw g ?? new d(
200
+ "network_error",
201
+ "Deadline excedido antes de completar a request",
202
+ void 0,
203
+ void 0,
204
+ void 0,
205
+ c
206
+ );
140
207
  let w = { method: r, headers: a };
141
- _ !== void 0 && (w.body = _);
142
- let M = p != null ? Math.max(1, Math.min(3e4, p - Date.now())) : 3e4;
143
- w.signal = AbortSignal.timeout(M);
208
+ b !== void 0 && (w.body = b);
209
+ let $ = f != null ? Math.max(1, Math.min(3e4, f - Date.now())) : 3e4;
210
+ w.signal = AbortSignal.timeout($);
144
211
  let u;
145
212
  try {
146
- u = await e.fetch(i, w);
147
- } catch (o) {
148
- let h = o instanceof DOMException && o.name === "TimeoutError" ? "Network error: timeout after 30s" : `Network error: ${o instanceof Error ? o.message : "fetch failed"}`;
149
- if (g = new s("network_error", h), f < n) {
150
- let T = x(f);
151
- if (p == null || Date.now() + T < p) {
152
- await q(T);
213
+ u = await e.fetch(n, w);
214
+ } catch (s) {
215
+ let h = s instanceof DOMException && s.name === "TimeoutError" ? "Network error: timeout after 30s" : `Network error: ${s instanceof Error ? s.message : "fetch failed"}`;
216
+ if (g = new d("network_error", h, void 0, void 0, void 0, c), p < o) {
217
+ let k = O(p);
218
+ if (f == null || Date.now() + k < f) {
219
+ await M(k);
153
220
  continue;
154
221
  }
155
222
  }
156
223
  throw g;
157
224
  }
158
- let U = u.headers.get("x-request-id") ?? u.headers.get("x-correlation-id") ?? void 0;
225
+ let L = u.headers.get("x-request-id") ?? u.headers.get("x-correlation-id") ?? void 0;
159
226
  if (u.ok) {
160
- let o = u.headers.get("x-neetru-version");
161
- return o && K(o), await A(u);
227
+ let s = u.headers.get("x-neetru-version");
228
+ return s && B(s), await U(u);
162
229
  }
163
- let c = await A(u), b = G(u.status), m = `HTTP ${u.status}`, I;
164
- if (c && typeof c == "object") {
165
- let o = c.error;
166
- typeof o == "string" ? m = o : o && typeof o == "object" ? (typeof o.code == "string" && (b = o.code), typeof o.message == "string" && (m = o.message), typeof o.reason == "string" && (I = o.reason)) : (typeof c.code == "string" && (b = c.code), typeof c.message == "string" && (m = c.message)), typeof c.reason == "string" && (I = c.reason);
230
+ let l = await U(u), _ = Q(u.status), m = `HTTP ${u.status}`, I;
231
+ if (l && typeof l == "object") {
232
+ let s = l.error;
233
+ typeof s == "string" ? m = s : s && typeof s == "object" ? (typeof s.code == "string" && (_ = s.code), typeof s.message == "string" && (m = s.message), typeof s.reason == "string" && (I = s.reason)) : (typeof l.code == "string" && (_ = l.code), typeof l.message == "string" && (m = l.message)), typeof l.reason == "string" && (I = l.reason);
167
234
  }
168
235
  if (u.status === 410) {
169
- let o = u.headers.get("x-neetru-replacement");
170
- m === `HTTP ${u.status}` && (m = `Endpoint ${t.path} foi removido do Core (HTTP 410 Gone) \u2014 atualize o @neetru/sdk e migre para a API substituta.`), o && !m.includes(o) && (m += ` Substituto: ${o}.`);
236
+ let s = u.headers.get("x-neetru-replacement");
237
+ m === `HTTP ${u.status}` && (m = `Endpoint ${t.path} foi removido do Core (HTTP 410 Gone) \u2014 atualize o @neetru/sdk e migre para a API substituta.`), s && !m.includes(s) && (m += ` Substituto: ${s}.`);
171
238
  }
172
- let R = new s(b, m, u.status, U, I);
173
- if (g = R, z.has(b) && f < n) {
174
- let h = V(u.headers.get("retry-after")) ?? x(f);
175
- if (p == null || Date.now() + h < p) {
176
- await q(h);
239
+ let N = new d(_, m, u.status, L, I, c);
240
+ if (g = N, W.has(_) && p < o) {
241
+ let h = Z(u.headers.get("retry-after")) ?? O(p);
242
+ if (f == null || Date.now() + h < f) {
243
+ await M(h);
177
244
  continue;
178
245
  }
179
246
  }
180
- throw R;
247
+ throw N;
181
248
  }
182
- throw g ?? new s("unknown", "unexpected httpRequest exit");
249
+ throw g ?? new d("unknown", "unexpected httpRequest exit", void 0, void 0, void 0, c);
183
250
  }
184
251
 
185
252
  // src/validators.ts
186
- var S = /^[a-z0-9][a-z0-9_-]{0,62}$/i;
253
+ var P = /^[a-z0-9][a-z0-9_-]{0,62}$/i;
187
254
  function y(e, t) {
188
- if (typeof t != "string" || !S.test(t))
189
- throw new s(
255
+ if (typeof t != "string" || !P.test(t))
256
+ throw new d(
190
257
  "validation_failed",
191
- `${e} must match ${S.source} (lowercase alphanumeric, _, -; first char must be alphanumeric; max 63 chars)`
258
+ `${e} must match ${P.source} (lowercase alphanumeric, _, -; first char must be alphanumeric; max 63 chars)`
192
259
  );
193
260
  }
194
261
 
195
262
  // src/usage.ts
196
- function ie(e) {
263
+ function ye(e) {
197
264
  return {
198
265
  /**
199
266
  * Reporta consumo metered de um resource. Hit no endpoint canônico
@@ -207,32 +274,32 @@ function ie(e) {
207
274
  * await client.usage.report('api_call', 5, { productId: 'gestovendas', tenantId: 't-acme' });
208
275
  * ```
209
276
  */
210
- async report(t, r = 1, i) {
277
+ async report(t, r = 1, n) {
211
278
  if (!t || typeof t != "string")
212
- throw new s("validation_failed", "resource is required");
279
+ throw new d("validation_failed", "resource is required");
213
280
  if (!Number.isFinite(r) || r <= 0 || !Number.isInteger(r))
214
- throw new s("validation_failed", "qty must be a positive integer");
215
- let d = i?.productId ?? e.productId, n = i?.tenantId ?? e.tenantId;
216
- if (!d)
217
- throw new s(
281
+ throw new d("validation_failed", "qty must be a positive integer");
282
+ let i = n?.productId ?? e.productId, o = n?.tenantId ?? e.tenantId;
283
+ if (!i)
284
+ throw new d(
218
285
  "validation_failed",
219
286
  "productId required (pass to options or set on createNeetruClient)"
220
287
  );
221
- if (!n)
222
- throw new s(
288
+ if (!o)
289
+ throw new d(
223
290
  "validation_failed",
224
291
  "tenantId required (pass to options or set on createNeetruClient)"
225
292
  );
226
- y("productId", d), y("tenantId", n);
227
- let a = await v(e, {
293
+ y("productId", i), y("tenantId", o);
294
+ let a = await E(e, {
228
295
  method: "POST",
229
296
  path: "/api/sdk/v1/usage/record",
230
- body: { productId: d, tenantId: n, resource: t, qty: Math.floor(r) },
297
+ body: { productId: i, tenantId: o, resource: t, qty: Math.floor(r) },
231
298
  requireAuth: true,
232
299
  idempotencyKey: true
233
300
  });
234
301
  if (!a || a.ok !== true)
235
- throw new s("invalid_response", "usage.report response missing ok");
302
+ throw new d("invalid_response", "usage.report response missing ok");
236
303
  return {
237
304
  ok: true,
238
305
  counterId: a.counterId,
@@ -250,34 +317,34 @@ function ie(e) {
250
317
  */
251
318
  async check(t, r) {
252
319
  if (!t || typeof t != "string")
253
- throw new s("validation_failed", "resource is required");
254
- let i = r?.productId ?? e.productId, d = r?.tenantId ?? e.tenantId;
255
- if (!i || !d)
256
- throw new s(
320
+ throw new d("validation_failed", "resource is required");
321
+ let n = r?.productId ?? e.productId, i = r?.tenantId ?? e.tenantId;
322
+ if (!n || !i)
323
+ throw new d(
257
324
  "validation_failed",
258
325
  "productId and tenantId required (pass to options or set on createNeetruClient)"
259
326
  );
260
- y("productId", i), y("tenantId", d);
261
- let n = await v(e, {
327
+ y("productId", n), y("tenantId", i);
328
+ let o = await E(e, {
262
329
  method: "GET",
263
330
  path: "/api/sdk/v1/entitlements",
264
- query: { productId: i, tenantId: d, feature: t },
331
+ query: { productId: n, tenantId: i, feature: t },
265
332
  requireAuth: true
266
333
  });
267
- if (!n || typeof n.allowed != "boolean")
268
- throw new s("invalid_response", "usage.check response missing allowed");
269
- let a = n.behavior ?? (n.reason === "limit_exceeded" ? "readonly" : null);
334
+ if (!o || typeof o.allowed != "boolean")
335
+ throw new d("invalid_response", "usage.check response missing allowed");
336
+ let a = o.behavior ?? (o.reason === "limit_exceeded" ? "readonly" : null);
270
337
  return {
271
- allowed: n.allowed,
272
- reason: n.reason,
273
- remaining: n.remaining,
274
- limit: n.limit,
275
- planId: n.planId,
276
- planFeatures: n.planFeatures,
338
+ allowed: o.allowed,
339
+ reason: o.reason,
340
+ remaining: o.remaining,
341
+ limit: o.limit,
342
+ planId: o.planId,
343
+ planFeatures: o.planFeatures,
277
344
  behavior: a
278
345
  };
279
346
  }
280
347
  };
281
348
  }
282
349
 
283
- exports.createUsageNamespace = ie;
350
+ exports.createUsageNamespace = ye;
package/dist/usage.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { ag as ResolvedConfig, ax as UsageNamespace } from './types-Bx4kTLmk.cjs';
1
+ import { ah as ResolvedConfig, ay as UsageNamespace } from './types-yv3EDKg2.cjs';
2
2
  import 'drizzle-orm/node-postgres';
3
3
  import './errors.cjs';
4
4
 
package/dist/usage.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ag as ResolvedConfig, ax as UsageNamespace } from './types-Dx0IrOSF.js';
1
+ import { ah as ResolvedConfig, ay as UsageNamespace } from './types-BYPk_3HR.js';
2
2
  import 'drizzle-orm/node-postgres';
3
3
  import './errors.js';
4
4