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