@neetru/sdk 3.4.7 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/ai.cjs +17 -13
  3. package/dist/ai.cjs.map +1 -1
  4. package/dist/ai.d.cts +1 -1
  5. package/dist/ai.d.ts +1 -1
  6. package/dist/ai.mjs +17 -13
  7. package/dist/ai.mjs.map +1 -1
  8. package/dist/auth.cjs +57 -23
  9. package/dist/auth.cjs.map +1 -1
  10. package/dist/auth.d.cts +2 -2
  11. package/dist/auth.d.ts +2 -2
  12. package/dist/auth.mjs +57 -23
  13. package/dist/auth.mjs.map +1 -1
  14. package/dist/catalog.cjs +19 -4
  15. package/dist/catalog.cjs.map +1 -1
  16. package/dist/catalog.d.cts +1 -1
  17. package/dist/catalog.d.ts +1 -1
  18. package/dist/catalog.mjs +19 -4
  19. package/dist/catalog.mjs.map +1 -1
  20. package/dist/checkout.cjs +11 -3
  21. package/dist/checkout.cjs.map +1 -1
  22. package/dist/checkout.d.cts +1 -1
  23. package/dist/checkout.d.ts +1 -1
  24. package/dist/checkout.mjs +11 -3
  25. package/dist/checkout.mjs.map +1 -1
  26. package/dist/db-react.d.cts +1 -1
  27. package/dist/db-react.d.ts +1 -1
  28. package/dist/db.cjs +17 -7
  29. package/dist/db.cjs.map +1 -1
  30. package/dist/db.d.cts +1 -1
  31. package/dist/db.d.ts +1 -1
  32. package/dist/db.mjs +17 -7
  33. package/dist/db.mjs.map +1 -1
  34. package/dist/entitlements.d.cts +1 -1
  35. package/dist/entitlements.d.ts +1 -1
  36. package/dist/firestore-compat.d.cts +1 -1
  37. package/dist/firestore-compat.d.ts +1 -1
  38. package/dist/index.cjs +58 -24
  39. package/dist/index.cjs.map +1 -1
  40. package/dist/index.d.cts +30 -2
  41. package/dist/index.d.ts +30 -2
  42. package/dist/index.mjs +58 -24
  43. package/dist/index.mjs.map +1 -1
  44. package/dist/mocks.cjs +17 -0
  45. package/dist/mocks.cjs.map +1 -1
  46. package/dist/mocks.d.cts +5 -1
  47. package/dist/mocks.d.ts +5 -1
  48. package/dist/mocks.mjs +17 -0
  49. package/dist/mocks.mjs.map +1 -1
  50. package/dist/notifications.cjs +11 -3
  51. package/dist/notifications.cjs.map +1 -1
  52. package/dist/notifications.d.cts +1 -1
  53. package/dist/notifications.d.ts +1 -1
  54. package/dist/notifications.mjs +11 -3
  55. package/dist/notifications.mjs.map +1 -1
  56. package/dist/react.cjs +36 -2
  57. package/dist/react.cjs.map +1 -1
  58. package/dist/react.d.cts +1 -1
  59. package/dist/react.d.ts +1 -1
  60. package/dist/react.mjs +36 -2
  61. package/dist/react.mjs.map +1 -1
  62. package/dist/support.cjs +15 -4
  63. package/dist/support.cjs.map +1 -1
  64. package/dist/support.d.cts +1 -1
  65. package/dist/support.d.ts +1 -1
  66. package/dist/support.mjs +15 -4
  67. package/dist/support.mjs.map +1 -1
  68. package/dist/telemetry.cjs +11 -3
  69. package/dist/telemetry.cjs.map +1 -1
  70. package/dist/telemetry.d.cts +1 -1
  71. package/dist/telemetry.d.ts +1 -1
  72. package/dist/telemetry.mjs +11 -3
  73. package/dist/telemetry.mjs.map +1 -1
  74. package/dist/{types-nnztVk7G.d.ts → types-BPATkXYu.d.ts} +35 -7
  75. package/dist/{types-DIVZl7nO.d.cts → types-Du_iioJ7.d.cts} +35 -7
  76. package/dist/usage.cjs +11 -3
  77. package/dist/usage.cjs.map +1 -1
  78. package/dist/usage.d.cts +1 -1
  79. package/dist/usage.d.ts +1 -1
  80. package/dist/usage.mjs +11 -3
  81. package/dist/usage.mjs.map +1 -1
  82. package/dist/webhooks.cjs +17 -4
  83. package/dist/webhooks.cjs.map +1 -1
  84. package/dist/webhooks.d.cts +1 -1
  85. package/dist/webhooks.d.ts +1 -1
  86. package/dist/webhooks.mjs +17 -4
  87. package/dist/webhooks.mjs.map +1 -1
  88. package/package.json +4 -1
package/dist/react.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { W as NeetruClient, t as CheckoutStartResult, l as AuthNamespace, a5 as NeetruUser } from './types-DIVZl7nO.cjs';
2
+ import { W as NeetruClient, t as CheckoutStartResult, l as AuthNamespace, a5 as NeetruUser } from './types-Du_iioJ7.cjs';
3
3
  import { CollectionReference, Query, DocumentReference } from './firestore-compat.cjs';
4
4
  import 'drizzle-orm/node-postgres';
5
5
  import './errors.cjs';
package/dist/react.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { W as NeetruClient, t as CheckoutStartResult, l as AuthNamespace, a5 as NeetruUser } from './types-nnztVk7G.js';
2
+ import { W as NeetruClient, t as CheckoutStartResult, l as AuthNamespace, a5 as NeetruUser } from './types-BPATkXYu.js';
3
3
  import { CollectionReference, Query, DocumentReference } from './firestore-compat.js';
4
4
  import 'drizzle-orm/node-postgres';
5
5
  import './errors.js';
package/dist/react.mjs CHANGED
@@ -2,6 +2,31 @@ import * as React2 from 'react';
2
2
 
3
3
  // src/react.ts
4
4
 
5
+ // src/errors.ts
6
+ var NeetruError = class _NeetruError extends Error {
7
+ code;
8
+ status;
9
+ requestId;
10
+ /**
11
+ * Motivo semântico opcional propagado pelo Core no corpo do erro (campo
12
+ * `reason` no TOPO do body, fora de `error`). Usado principalmente pelo 503
13
+ * de lease de DB, onde `reason` discrimina o estado do ambiente
14
+ * (`suspended` | `archived` | `revoked` | `provisioning` | `degraded` |
15
+ * `no_route` | `expired`). Camadas superiores (ex.: `db/sql`) mapeiam isso
16
+ * para um `NeetruDbErrorCode` mais específico (recuperável vs não).
17
+ */
18
+ reason;
19
+ constructor(code, message, status, requestId, reason) {
20
+ super(message);
21
+ this.name = "NeetruError";
22
+ this.code = code;
23
+ this.status = status;
24
+ this.requestId = requestId;
25
+ this.reason = reason;
26
+ Object.setPrototypeOf(this, _NeetruError.prototype);
27
+ }
28
+ };
29
+
5
30
  // src/types.ts
6
31
  var DEFAULT_BASE_URL = "https://api.neetru.com";
7
32
 
@@ -603,13 +628,22 @@ async function startCheckoutViaBff(startPath, input) {
603
628
  }
604
629
  if (!res.ok) {
605
630
  const p = payload;
631
+ const errField = p?.error;
632
+ const code = (errField && typeof errField === "object" && typeof errField.code === "string" ? errField.code : void 0) ?? "server_error";
606
633
  const msg = p && (typeof p.error === "object" && p.error?.message || typeof p.error === "string" && p.error || typeof p.message === "string" && p.message) || `Checkout BFF respondeu HTTP ${res.status}`;
607
- throw new Error(typeof msg === "string" ? msg : `Checkout BFF respondeu HTTP ${res.status}`);
634
+ throw new NeetruError(
635
+ code,
636
+ typeof msg === "string" ? msg : `Checkout BFF respondeu HTTP ${res.status}`,
637
+ res.status
638
+ );
608
639
  }
609
640
  const intent = payload?.intent ?? payload ?? {};
610
641
  const redirectUrl = payload?.redirectUrl ?? intent.redirectUrl;
611
642
  if (!redirectUrl || typeof redirectUrl !== "string") {
612
- throw new Error("Resposta do route BFF de checkout sem `redirectUrl`.");
643
+ throw new NeetruError(
644
+ "invalid_response",
645
+ "Resposta do route BFF de checkout sem `redirectUrl`."
646
+ );
613
647
  }
614
648
  return {
615
649
  intentId: String(payload?.intentId ?? intent.intentId ?? ""),