@neetru/sdk 3.6.0 → 3.7.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 (116) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/dist/ai.cjs +254 -391
  3. package/dist/ai.d.cts +1 -1
  4. package/dist/ai.d.ts +1 -1
  5. package/dist/ai.mjs +254 -391
  6. package/dist/auth.cjs +3547 -4998
  7. package/dist/auth.d.cts +1 -1
  8. package/dist/auth.d.ts +1 -1
  9. package/dist/auth.mjs +3544 -4995
  10. package/dist/build-guard.cjs +101 -119
  11. package/dist/build-guard.mjs +91 -109
  12. package/dist/catalog.cjs +152 -224
  13. package/dist/catalog.d.cts +1 -1
  14. package/dist/catalog.d.ts +1 -1
  15. package/dist/catalog.mjs +152 -224
  16. package/dist/checkout.cjs +237 -320
  17. package/dist/checkout.d.cts +1 -1
  18. package/dist/checkout.d.ts +1 -1
  19. package/dist/checkout.mjs +236 -319
  20. package/dist/db-react.cjs +59 -87
  21. package/dist/db-react.d.cts +1 -1
  22. package/dist/db-react.d.ts +1 -1
  23. package/dist/db-react.mjs +56 -84
  24. package/dist/db.cjs +2055 -3013
  25. package/dist/db.d.cts +1 -1
  26. package/dist/db.d.ts +1 -1
  27. package/dist/db.mjs +2068 -3026
  28. package/dist/entitlements.cjs +12 -20
  29. package/dist/entitlements.d.cts +1 -1
  30. package/dist/entitlements.d.ts +1 -1
  31. package/dist/entitlements.mjs +12 -20
  32. package/dist/errors.cjs +9 -12
  33. package/dist/errors.d.cts +37 -2
  34. package/dist/errors.d.ts +37 -2
  35. package/dist/errors.mjs +8 -12
  36. package/dist/firestore-compat.cjs +241 -297
  37. package/dist/firestore-compat.d.cts +1 -1
  38. package/dist/firestore-compat.d.ts +1 -1
  39. package/dist/firestore-compat.mjs +215 -271
  40. package/dist/index.cjs +3605 -5131
  41. package/dist/index.d.cts +6 -4
  42. package/dist/index.d.ts +6 -4
  43. package/dist/index.mjs +3710 -5236
  44. package/dist/mobile.cjs +238 -342
  45. package/dist/mobile.d.cts +1 -1
  46. package/dist/mobile.d.ts +1 -1
  47. package/dist/mobile.mjs +238 -342
  48. package/dist/mocks.cjs +312 -447
  49. package/dist/mocks.d.cts +1 -1
  50. package/dist/mocks.d.ts +1 -1
  51. package/dist/mocks.mjs +306 -441
  52. package/dist/notifications.cjs +226 -314
  53. package/dist/notifications.d.cts +1 -1
  54. package/dist/notifications.d.ts +1 -1
  55. package/dist/notifications.mjs +225 -313
  56. package/dist/react.cjs +522 -693
  57. package/dist/react.d.cts +1 -1
  58. package/dist/react.d.ts +1 -1
  59. package/dist/react.mjs +512 -683
  60. package/dist/support.cjs +329 -325
  61. package/dist/support.d.cts +25 -3
  62. package/dist/support.d.ts +25 -3
  63. package/dist/support.mjs +328 -325
  64. package/dist/telemetry.cjs +197 -301
  65. package/dist/telemetry.d.cts +1 -1
  66. package/dist/telemetry.d.ts +1 -1
  67. package/dist/telemetry.mjs +197 -301
  68. package/dist/{types-Du_iioJ7.d.cts → types-Bx4kTLmk.d.cts} +26 -0
  69. package/dist/{types-BPATkXYu.d.ts → types-Dx0IrOSF.d.ts} +26 -0
  70. package/dist/usage.cjs +163 -227
  71. package/dist/usage.d.cts +1 -1
  72. package/dist/usage.d.ts +1 -1
  73. package/dist/usage.mjs +163 -227
  74. package/dist/webhooks.cjs +258 -359
  75. package/dist/webhooks.d.cts +1 -1
  76. package/dist/webhooks.d.ts +1 -1
  77. package/dist/webhooks.mjs +255 -356
  78. package/package.json +4 -3
  79. package/dist/ai.cjs.map +0 -1
  80. package/dist/ai.mjs.map +0 -1
  81. package/dist/auth.cjs.map +0 -1
  82. package/dist/auth.mjs.map +0 -1
  83. package/dist/build-guard.cjs.map +0 -1
  84. package/dist/build-guard.mjs.map +0 -1
  85. package/dist/catalog.cjs.map +0 -1
  86. package/dist/catalog.mjs.map +0 -1
  87. package/dist/checkout.cjs.map +0 -1
  88. package/dist/checkout.mjs.map +0 -1
  89. package/dist/db-react.cjs.map +0 -1
  90. package/dist/db-react.mjs.map +0 -1
  91. package/dist/db.cjs.map +0 -1
  92. package/dist/db.mjs.map +0 -1
  93. package/dist/entitlements.cjs.map +0 -1
  94. package/dist/entitlements.mjs.map +0 -1
  95. package/dist/errors.cjs.map +0 -1
  96. package/dist/errors.mjs.map +0 -1
  97. package/dist/firestore-compat.cjs.map +0 -1
  98. package/dist/firestore-compat.mjs.map +0 -1
  99. package/dist/index.cjs.map +0 -1
  100. package/dist/index.mjs.map +0 -1
  101. package/dist/mobile.cjs.map +0 -1
  102. package/dist/mobile.mjs.map +0 -1
  103. package/dist/mocks.cjs.map +0 -1
  104. package/dist/mocks.mjs.map +0 -1
  105. package/dist/notifications.cjs.map +0 -1
  106. package/dist/notifications.mjs.map +0 -1
  107. package/dist/react.cjs.map +0 -1
  108. package/dist/react.mjs.map +0 -1
  109. package/dist/support.cjs.map +0 -1
  110. package/dist/support.mjs.map +0 -1
  111. package/dist/telemetry.cjs.map +0 -1
  112. package/dist/telemetry.mjs.map +0 -1
  113. package/dist/usage.cjs.map +0 -1
  114. package/dist/usage.mjs.map +0 -1
  115. package/dist/webhooks.cjs.map +0 -1
  116. package/dist/webhooks.mjs.map +0 -1
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var fs = require('fs');
4
- var path = require('path');
3
+ var u = require('fs');
4
+ var a = require('path');
5
5
 
6
6
  function _interopNamespace(e) {
7
7
  if (e && e.__esModule) return e;
@@ -21,178 +21,160 @@ function _interopNamespace(e) {
21
21
  return Object.freeze(n);
22
22
  }
23
23
 
24
- var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
25
- var path__namespace = /*#__PURE__*/_interopNamespace(path);
24
+ var u__namespace = /*#__PURE__*/_interopNamespace(u);
25
+ var a__namespace = /*#__PURE__*/_interopNamespace(a);
26
26
 
27
27
  // src/build-guard.ts
28
- var NeetruBuildGuardError = class extends Error {
29
- constructor(message) {
30
- super(message);
31
- this.name = "NeetruBuildGuardError";
28
+ var l = class extends Error {
29
+ constructor(n) {
30
+ super(n), this.name = "NeetruBuildGuardError";
32
31
  }
33
32
  };
34
- function isBlankEnvValue(v) {
35
- return v == null || v.trim() === "";
33
+ function p(e) {
34
+ return e == null || e.trim() === "";
36
35
  }
37
- function assertNeetruProdBuildEnv(resolved) {
38
- if (resolved.builtEnv !== "prod") return;
39
- const missing = [];
40
- if (isBlankEnvValue(resolved.oidcClientId)) missing.push("NEXT_PUBLIC_NEETRU_OIDC_CLIENT_ID");
41
- if (isBlankEnvValue(resolved.productId)) missing.push("NEXT_PUBLIC_NEETRU_PRODUCT_ID");
42
- if (missing.length === 0) return;
43
- const plural = missing.length > 1;
44
- throw new NeetruBuildGuardError(
36
+ function k(e) {
37
+ if (e.builtEnv !== "prod") return;
38
+ let n = [];
39
+ if (p(e.oidcClientId) && n.push("NEXT_PUBLIC_NEETRU_OIDC_CLIENT_ID"), p(e.productId) && n.push("NEXT_PUBLIC_NEETRU_PRODUCT_ID"), n.length === 0) return;
40
+ let t = n.length > 1;
41
+ throw new l(
45
42
  [
46
43
  "[neetru-sdk] BUILD DE PRODU\xC7\xC3O ABORTADO (withNeetruBuildGuard).",
47
44
  "",
48
- `Vari\xE1ve${plural ? "is" : "l"} de ambiente obrigat\xF3ri${plural ? "as" : "a"} ausente${plural ? "s" : ""}/vazia${plural ? "s" : ""} no build de produ\xE7\xE3o (NEXT_PUBLIC_NEETRU_ENV=prod):`,
49
- ...missing.map((v) => ` \u2022 ${v}`),
45
+ `Vari\xE1ve${t ? "is" : "l"} de ambiente obrigat\xF3ri${t ? "as" : "a"} ausente${t ? "s" : ""}/vazia${t ? "s" : ""} no build de produ\xE7\xE3o (NEXT_PUBLIC_NEETRU_ENV=prod):`,
46
+ ...n.map((r) => ` \u2022 ${r}`),
50
47
  "",
51
- `Sem ${plural ? "essas vari\xE1veis" : "essa vari\xE1vel"} o SDK n\xE3o consegue montar o client_id do login OIDC \u2014 o bot\xE3o "Entrar com Neetru" (NeetruLoginButton) N\xC3O redireciona e o login do produto quebra EM SIL\xCANCIO em produ\xE7\xE3o (incidente gestovendas 2026-09-06: workspace recriado perdeu a env var e shippou um build de prod com o client_id vazio).`,
48
+ `Sem ${t ? "essas vari\xE1veis" : "essa vari\xE1vel"} o SDK n\xE3o consegue montar o client_id do login OIDC \u2014 o bot\xE3o "Entrar com Neetru" (NeetruLoginButton) N\xC3O redireciona e o login do produto quebra EM SIL\xCANCIO em produ\xE7\xE3o (incidente gestovendas 2026-09-06: workspace recriado perdeu a env var e shippou um build de prod com o client_id vazio).`,
52
49
  "",
53
50
  "Como corrigir \u2014 defina no .env.production do produto (ou no ambiente do build de deploy):",
54
- ...missing.map((v) => ` ${v}=<valor real vindo do cat\xE1logo do produto no Core>`),
51
+ ...n.map((r) => ` ${r}=<valor real vindo do cat\xE1logo do produto no Core>`),
55
52
  "",
56
53
  "dev/workspace N\xC3O exigem essas vari\xE1veis (usam MockAuth/sandbox) \u2014 s\xF3 o build de produ\xE7\xE3o enfor\xE7a."
57
- ].join("\n")
54
+ ].join(`
55
+ `)
58
56
  );
59
57
  }
60
- var NEETRU_SQL_SERVER_EXTERNAL_PACKAGES = ["pg", "drizzle-orm"];
61
- var NEETRU_SQL_TRACE_INCLUDE_KEY = "*";
62
- function toStringArray(value) {
63
- return Array.isArray(value) ? value.filter((v) => typeof v === "string") : [];
58
+ var f = ["pg", "drizzle-orm"], g = "*";
59
+ function E(e) {
60
+ return Array.isArray(e) ? e.filter((n) => typeof n == "string") : [];
64
61
  }
65
- function findPackageJsonPath(pkgName, parentDir, fromDir) {
66
- const bases = [];
67
- let dir = parentDir;
62
+ function _(e, n, t) {
63
+ let r = [], o = n;
68
64
  for (; ; ) {
69
- bases.push(dir);
70
- const parent = path__namespace.dirname(dir);
71
- if (parent === dir) break;
72
- dir = parent;
65
+ r.push(o);
66
+ let i = a__namespace.dirname(o);
67
+ if (i === o) break;
68
+ o = i;
73
69
  }
74
- if (!bases.includes(fromDir)) bases.push(fromDir);
75
- for (const base of bases) {
76
- const candidate = path__namespace.join(base, "node_modules", pkgName, "package.json");
70
+ r.includes(t) || r.push(t);
71
+ for (let i of r) {
72
+ let s = a__namespace.join(i, "node_modules", e, "package.json");
77
73
  try {
78
- if (fs__namespace.existsSync(candidate)) return candidate;
74
+ if (u__namespace.existsSync(s)) return s;
79
75
  } catch {
80
76
  }
81
77
  }
82
78
  return null;
83
79
  }
84
- function resolveSqlRuntimeClosure(fromDir) {
85
- if (typeof fromDir !== "string" || fromDir.trim() === "") return [];
86
- const visited = /* @__PURE__ */ new Set();
87
- const closure = /* @__PURE__ */ new Set();
88
- const walk = (pkgName, parentDir) => {
89
- if (visited.has(pkgName)) return;
90
- visited.add(pkgName);
91
- const pkgJsonPath = findPackageJsonPath(pkgName, parentDir, fromDir);
92
- if (!pkgJsonPath) return;
93
- closure.add(pkgName);
94
- let manifest;
80
+ function m(e) {
81
+ if (typeof e != "string" || e.trim() === "") return [];
82
+ let n = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Set(), r = (o, i) => {
83
+ if (n.has(o)) return;
84
+ n.add(o);
85
+ let s = _(o, i, e);
86
+ if (!s) return;
87
+ t.add(o);
88
+ let d;
95
89
  try {
96
- manifest = JSON.parse(fs__namespace.readFileSync(pkgJsonPath, "utf8"));
90
+ d = JSON.parse(u__namespace.readFileSync(s, "utf8"));
97
91
  } catch {
98
92
  return;
99
93
  }
100
- const deps = {
101
- ...manifest.dependencies ?? {},
102
- ...manifest.optionalDependencies ?? {}
103
- };
104
- const pkgDir = path__namespace.dirname(pkgJsonPath);
105
- for (const dep of Object.keys(deps)) walk(dep, pkgDir);
94
+ let c = {
95
+ ...d.dependencies ?? {},
96
+ ...d.optionalDependencies ?? {}
97
+ }, b = a__namespace.dirname(s);
98
+ for (let v of Object.keys(c)) r(v, b);
106
99
  };
107
100
  try {
108
- for (const seed of NEETRU_SQL_SERVER_EXTERNAL_PACKAGES) walk(seed, fromDir);
101
+ for (let o of f) r(o, e);
109
102
  } catch {
110
103
  return [];
111
104
  }
112
- return [...closure].sort();
105
+ return [...t].sort();
113
106
  }
114
- function sqlClosureToTraceGlobs(closure) {
115
- return closure.map((pkg) => `./node_modules/${pkg}/**`);
107
+ function N(e) {
108
+ return e.map((n) => `./node_modules/${n}/**`);
116
109
  }
117
- function mergeServerExternalPackages(existing) {
118
- const out = toStringArray(existing);
119
- for (const pkg of NEETRU_SQL_SERVER_EXTERNAL_PACKAGES) {
120
- if (!out.includes(pkg)) out.push(pkg);
121
- }
122
- return out;
110
+ function h(e) {
111
+ let n = E(e);
112
+ for (let t of f)
113
+ n.includes(t) || n.push(t);
114
+ return n;
123
115
  }
124
- function mergeOutputFileTracingIncludes(existing, globs) {
125
- const merged = {};
126
- if (existing && typeof existing === "object" && !Array.isArray(existing)) {
127
- for (const [key, value] of Object.entries(existing)) {
128
- merged[key] = toStringArray(value);
129
- }
130
- }
131
- if (globs.length === 0) return merged;
132
- const combined = [...merged[NEETRU_SQL_TRACE_INCLUDE_KEY] ?? []];
133
- for (const glob of globs) {
134
- if (!combined.includes(glob)) combined.push(glob);
135
- }
136
- merged[NEETRU_SQL_TRACE_INCLUDE_KEY] = combined;
137
- return merged;
116
+ function I(e, n) {
117
+ let t = {};
118
+ if (e && typeof e == "object" && !Array.isArray(e))
119
+ for (let [o, i] of Object.entries(e))
120
+ t[o] = E(i);
121
+ if (n.length === 0) return t;
122
+ let r = [...t[g] ?? []];
123
+ for (let o of n)
124
+ r.includes(o) || r.push(o);
125
+ return t[g] = r, t;
138
126
  }
139
- function withNeetruBuildGuard(nextConfig, options = {}) {
140
- const prevWebpack = nextConfig.webpack;
141
- let sqlTraceGlobs = [];
127
+ function T(e, n = {}) {
128
+ let t = e.webpack, r = [];
142
129
  try {
143
- sqlTraceGlobs = sqlClosureToTraceGlobs(resolveSqlRuntimeClosure(process.cwd()));
130
+ r = N(m(process.cwd()));
144
131
  } catch {
145
- sqlTraceGlobs = [];
132
+ r = [];
146
133
  }
147
134
  return {
148
- ...nextConfig,
135
+ ...e,
149
136
  // `serverExternalPackages` é reforço (não o conserto do caso webpackIgnore);
150
137
  // o `outputFileTracingIncludes` computado é o que realmente inclui o closure.
151
- serverExternalPackages: mergeServerExternalPackages(nextConfig.serverExternalPackages),
152
- outputFileTracingIncludes: mergeOutputFileTracingIncludes(
153
- nextConfig.outputFileTracingIncludes,
154
- sqlTraceGlobs
138
+ serverExternalPackages: h(e.serverExternalPackages),
139
+ outputFileTracingIncludes: I(
140
+ e.outputFileTracingIncludes,
141
+ r
155
142
  ),
156
- webpack(config, context) {
157
- const result = typeof prevWebpack === "function" ? prevWebpack(config, context) : config;
158
- if (!context.dev && context.isServer) {
159
- const manifest = {
143
+ webpack(o, i) {
144
+ let s = typeof t == "function" ? t(o, i) : o;
145
+ if (!i.dev && i.isServer) {
146
+ let d = {
160
147
  builtEnv: process.env.NEXT_PUBLIC_NEETRU_ENV ?? null,
161
148
  productId: process.env.NEXT_PUBLIC_NEETRU_PRODUCT_ID ?? null,
162
149
  oidcClientId: process.env.NEXT_PUBLIC_NEETRU_OIDC_CLIENT_ID ?? null,
163
150
  builtAt: (/* @__PURE__ */ new Date()).toISOString()
164
151
  };
165
152
  try {
166
- const outDir = path__namespace.resolve(process.cwd(), options.outputDir ?? ".next");
167
- fs__namespace.mkdirSync(outDir, { recursive: true });
168
- fs__namespace.writeFileSync(
169
- path__namespace.join(outDir, "neetru-build-manifest.json"),
170
- JSON.stringify(manifest, null, 2),
153
+ let c = a__namespace.resolve(process.cwd(), n.outputDir ?? ".next");
154
+ u__namespace.mkdirSync(c, { recursive: !0 }), u__namespace.writeFileSync(
155
+ a__namespace.join(c, "neetru-build-manifest.json"),
156
+ JSON.stringify(d, null, 2),
171
157
  "utf8"
172
158
  );
173
- } catch (err) {
174
- if (typeof console !== "undefined") {
175
- console.warn(
176
- "[neetru-sdk] withNeetruBuildGuard: falha ao gravar neetru-build-manifest.json (ignorado, build segue):",
177
- err
178
- );
179
- }
159
+ } catch (c) {
160
+ typeof console < "u" && console.warn(
161
+ "[neetru-sdk] withNeetruBuildGuard: falha ao gravar neetru-build-manifest.json (ignorado, build segue):",
162
+ c
163
+ );
180
164
  }
181
- assertNeetruProdBuildEnv(manifest);
165
+ k(d);
182
166
  }
183
- return result;
167
+ return s;
184
168
  }
185
169
  };
186
170
  }
187
171
 
188
- exports.NEETRU_SQL_SERVER_EXTERNAL_PACKAGES = NEETRU_SQL_SERVER_EXTERNAL_PACKAGES;
189
- exports.NEETRU_SQL_TRACE_INCLUDE_KEY = NEETRU_SQL_TRACE_INCLUDE_KEY;
190
- exports.NeetruBuildGuardError = NeetruBuildGuardError;
191
- exports.assertNeetruProdBuildEnv = assertNeetruProdBuildEnv;
192
- exports.mergeOutputFileTracingIncludes = mergeOutputFileTracingIncludes;
193
- exports.mergeServerExternalPackages = mergeServerExternalPackages;
194
- exports.resolveSqlRuntimeClosure = resolveSqlRuntimeClosure;
195
- exports.sqlClosureToTraceGlobs = sqlClosureToTraceGlobs;
196
- exports.withNeetruBuildGuard = withNeetruBuildGuard;
197
- //# sourceMappingURL=build-guard.cjs.map
198
- //# sourceMappingURL=build-guard.cjs.map
172
+ exports.NEETRU_SQL_SERVER_EXTERNAL_PACKAGES = f;
173
+ exports.NEETRU_SQL_TRACE_INCLUDE_KEY = g;
174
+ exports.NeetruBuildGuardError = l;
175
+ exports.assertNeetruProdBuildEnv = k;
176
+ exports.mergeOutputFileTracingIncludes = I;
177
+ exports.mergeServerExternalPackages = h;
178
+ exports.resolveSqlRuntimeClosure = m;
179
+ exports.sqlClosureToTraceGlobs = N;
180
+ exports.withNeetruBuildGuard = T;
@@ -1,167 +1,149 @@
1
- import * as fs from 'fs';
2
- import * as path from 'path';
1
+ import * as u from 'fs';
2
+ import * as a from 'path';
3
3
 
4
4
  // src/build-guard.ts
5
- var NeetruBuildGuardError = class extends Error {
6
- constructor(message) {
7
- super(message);
8
- this.name = "NeetruBuildGuardError";
5
+ var l = class extends Error {
6
+ constructor(n) {
7
+ super(n), this.name = "NeetruBuildGuardError";
9
8
  }
10
9
  };
11
- function isBlankEnvValue(v) {
12
- return v == null || v.trim() === "";
10
+ function p(e) {
11
+ return e == null || e.trim() === "";
13
12
  }
14
- function assertNeetruProdBuildEnv(resolved) {
15
- if (resolved.builtEnv !== "prod") return;
16
- const missing = [];
17
- if (isBlankEnvValue(resolved.oidcClientId)) missing.push("NEXT_PUBLIC_NEETRU_OIDC_CLIENT_ID");
18
- if (isBlankEnvValue(resolved.productId)) missing.push("NEXT_PUBLIC_NEETRU_PRODUCT_ID");
19
- if (missing.length === 0) return;
20
- const plural = missing.length > 1;
21
- throw new NeetruBuildGuardError(
13
+ function k(e) {
14
+ if (e.builtEnv !== "prod") return;
15
+ let n = [];
16
+ if (p(e.oidcClientId) && n.push("NEXT_PUBLIC_NEETRU_OIDC_CLIENT_ID"), p(e.productId) && n.push("NEXT_PUBLIC_NEETRU_PRODUCT_ID"), n.length === 0) return;
17
+ let t = n.length > 1;
18
+ throw new l(
22
19
  [
23
20
  "[neetru-sdk] BUILD DE PRODU\xC7\xC3O ABORTADO (withNeetruBuildGuard).",
24
21
  "",
25
- `Vari\xE1ve${plural ? "is" : "l"} de ambiente obrigat\xF3ri${plural ? "as" : "a"} ausente${plural ? "s" : ""}/vazia${plural ? "s" : ""} no build de produ\xE7\xE3o (NEXT_PUBLIC_NEETRU_ENV=prod):`,
26
- ...missing.map((v) => ` \u2022 ${v}`),
22
+ `Vari\xE1ve${t ? "is" : "l"} de ambiente obrigat\xF3ri${t ? "as" : "a"} ausente${t ? "s" : ""}/vazia${t ? "s" : ""} no build de produ\xE7\xE3o (NEXT_PUBLIC_NEETRU_ENV=prod):`,
23
+ ...n.map((r) => ` \u2022 ${r}`),
27
24
  "",
28
- `Sem ${plural ? "essas vari\xE1veis" : "essa vari\xE1vel"} o SDK n\xE3o consegue montar o client_id do login OIDC \u2014 o bot\xE3o "Entrar com Neetru" (NeetruLoginButton) N\xC3O redireciona e o login do produto quebra EM SIL\xCANCIO em produ\xE7\xE3o (incidente gestovendas 2026-09-06: workspace recriado perdeu a env var e shippou um build de prod com o client_id vazio).`,
25
+ `Sem ${t ? "essas vari\xE1veis" : "essa vari\xE1vel"} o SDK n\xE3o consegue montar o client_id do login OIDC \u2014 o bot\xE3o "Entrar com Neetru" (NeetruLoginButton) N\xC3O redireciona e o login do produto quebra EM SIL\xCANCIO em produ\xE7\xE3o (incidente gestovendas 2026-09-06: workspace recriado perdeu a env var e shippou um build de prod com o client_id vazio).`,
29
26
  "",
30
27
  "Como corrigir \u2014 defina no .env.production do produto (ou no ambiente do build de deploy):",
31
- ...missing.map((v) => ` ${v}=<valor real vindo do cat\xE1logo do produto no Core>`),
28
+ ...n.map((r) => ` ${r}=<valor real vindo do cat\xE1logo do produto no Core>`),
32
29
  "",
33
30
  "dev/workspace N\xC3O exigem essas vari\xE1veis (usam MockAuth/sandbox) \u2014 s\xF3 o build de produ\xE7\xE3o enfor\xE7a."
34
- ].join("\n")
31
+ ].join(`
32
+ `)
35
33
  );
36
34
  }
37
- var NEETRU_SQL_SERVER_EXTERNAL_PACKAGES = ["pg", "drizzle-orm"];
38
- var NEETRU_SQL_TRACE_INCLUDE_KEY = "*";
39
- function toStringArray(value) {
40
- return Array.isArray(value) ? value.filter((v) => typeof v === "string") : [];
35
+ var f = ["pg", "drizzle-orm"], g = "*";
36
+ function E(e) {
37
+ return Array.isArray(e) ? e.filter((n) => typeof n == "string") : [];
41
38
  }
42
- function findPackageJsonPath(pkgName, parentDir, fromDir) {
43
- const bases = [];
44
- let dir = parentDir;
39
+ function _(e, n, t) {
40
+ let r = [], o = n;
45
41
  for (; ; ) {
46
- bases.push(dir);
47
- const parent = path.dirname(dir);
48
- if (parent === dir) break;
49
- dir = parent;
42
+ r.push(o);
43
+ let i = a.dirname(o);
44
+ if (i === o) break;
45
+ o = i;
50
46
  }
51
- if (!bases.includes(fromDir)) bases.push(fromDir);
52
- for (const base of bases) {
53
- const candidate = path.join(base, "node_modules", pkgName, "package.json");
47
+ r.includes(t) || r.push(t);
48
+ for (let i of r) {
49
+ let s = a.join(i, "node_modules", e, "package.json");
54
50
  try {
55
- if (fs.existsSync(candidate)) return candidate;
51
+ if (u.existsSync(s)) return s;
56
52
  } catch {
57
53
  }
58
54
  }
59
55
  return null;
60
56
  }
61
- function resolveSqlRuntimeClosure(fromDir) {
62
- if (typeof fromDir !== "string" || fromDir.trim() === "") return [];
63
- const visited = /* @__PURE__ */ new Set();
64
- const closure = /* @__PURE__ */ new Set();
65
- const walk = (pkgName, parentDir) => {
66
- if (visited.has(pkgName)) return;
67
- visited.add(pkgName);
68
- const pkgJsonPath = findPackageJsonPath(pkgName, parentDir, fromDir);
69
- if (!pkgJsonPath) return;
70
- closure.add(pkgName);
71
- let manifest;
57
+ function m(e) {
58
+ if (typeof e != "string" || e.trim() === "") return [];
59
+ let n = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Set(), r = (o, i) => {
60
+ if (n.has(o)) return;
61
+ n.add(o);
62
+ let s = _(o, i, e);
63
+ if (!s) return;
64
+ t.add(o);
65
+ let d;
72
66
  try {
73
- manifest = JSON.parse(fs.readFileSync(pkgJsonPath, "utf8"));
67
+ d = JSON.parse(u.readFileSync(s, "utf8"));
74
68
  } catch {
75
69
  return;
76
70
  }
77
- const deps = {
78
- ...manifest.dependencies ?? {},
79
- ...manifest.optionalDependencies ?? {}
80
- };
81
- const pkgDir = path.dirname(pkgJsonPath);
82
- for (const dep of Object.keys(deps)) walk(dep, pkgDir);
71
+ let c = {
72
+ ...d.dependencies ?? {},
73
+ ...d.optionalDependencies ?? {}
74
+ }, b = a.dirname(s);
75
+ for (let v of Object.keys(c)) r(v, b);
83
76
  };
84
77
  try {
85
- for (const seed of NEETRU_SQL_SERVER_EXTERNAL_PACKAGES) walk(seed, fromDir);
78
+ for (let o of f) r(o, e);
86
79
  } catch {
87
80
  return [];
88
81
  }
89
- return [...closure].sort();
82
+ return [...t].sort();
90
83
  }
91
- function sqlClosureToTraceGlobs(closure) {
92
- return closure.map((pkg) => `./node_modules/${pkg}/**`);
84
+ function N(e) {
85
+ return e.map((n) => `./node_modules/${n}/**`);
93
86
  }
94
- function mergeServerExternalPackages(existing) {
95
- const out = toStringArray(existing);
96
- for (const pkg of NEETRU_SQL_SERVER_EXTERNAL_PACKAGES) {
97
- if (!out.includes(pkg)) out.push(pkg);
98
- }
99
- return out;
87
+ function h(e) {
88
+ let n = E(e);
89
+ for (let t of f)
90
+ n.includes(t) || n.push(t);
91
+ return n;
100
92
  }
101
- function mergeOutputFileTracingIncludes(existing, globs) {
102
- const merged = {};
103
- if (existing && typeof existing === "object" && !Array.isArray(existing)) {
104
- for (const [key, value] of Object.entries(existing)) {
105
- merged[key] = toStringArray(value);
106
- }
107
- }
108
- if (globs.length === 0) return merged;
109
- const combined = [...merged[NEETRU_SQL_TRACE_INCLUDE_KEY] ?? []];
110
- for (const glob of globs) {
111
- if (!combined.includes(glob)) combined.push(glob);
112
- }
113
- merged[NEETRU_SQL_TRACE_INCLUDE_KEY] = combined;
114
- return merged;
93
+ function I(e, n) {
94
+ let t = {};
95
+ if (e && typeof e == "object" && !Array.isArray(e))
96
+ for (let [o, i] of Object.entries(e))
97
+ t[o] = E(i);
98
+ if (n.length === 0) return t;
99
+ let r = [...t[g] ?? []];
100
+ for (let o of n)
101
+ r.includes(o) || r.push(o);
102
+ return t[g] = r, t;
115
103
  }
116
- function withNeetruBuildGuard(nextConfig, options = {}) {
117
- const prevWebpack = nextConfig.webpack;
118
- let sqlTraceGlobs = [];
104
+ function T(e, n = {}) {
105
+ let t = e.webpack, r = [];
119
106
  try {
120
- sqlTraceGlobs = sqlClosureToTraceGlobs(resolveSqlRuntimeClosure(process.cwd()));
107
+ r = N(m(process.cwd()));
121
108
  } catch {
122
- sqlTraceGlobs = [];
109
+ r = [];
123
110
  }
124
111
  return {
125
- ...nextConfig,
112
+ ...e,
126
113
  // `serverExternalPackages` é reforço (não o conserto do caso webpackIgnore);
127
114
  // o `outputFileTracingIncludes` computado é o que realmente inclui o closure.
128
- serverExternalPackages: mergeServerExternalPackages(nextConfig.serverExternalPackages),
129
- outputFileTracingIncludes: mergeOutputFileTracingIncludes(
130
- nextConfig.outputFileTracingIncludes,
131
- sqlTraceGlobs
115
+ serverExternalPackages: h(e.serverExternalPackages),
116
+ outputFileTracingIncludes: I(
117
+ e.outputFileTracingIncludes,
118
+ r
132
119
  ),
133
- webpack(config, context) {
134
- const result = typeof prevWebpack === "function" ? prevWebpack(config, context) : config;
135
- if (!context.dev && context.isServer) {
136
- const manifest = {
120
+ webpack(o, i) {
121
+ let s = typeof t == "function" ? t(o, i) : o;
122
+ if (!i.dev && i.isServer) {
123
+ let d = {
137
124
  builtEnv: process.env.NEXT_PUBLIC_NEETRU_ENV ?? null,
138
125
  productId: process.env.NEXT_PUBLIC_NEETRU_PRODUCT_ID ?? null,
139
126
  oidcClientId: process.env.NEXT_PUBLIC_NEETRU_OIDC_CLIENT_ID ?? null,
140
127
  builtAt: (/* @__PURE__ */ new Date()).toISOString()
141
128
  };
142
129
  try {
143
- const outDir = path.resolve(process.cwd(), options.outputDir ?? ".next");
144
- fs.mkdirSync(outDir, { recursive: true });
145
- fs.writeFileSync(
146
- path.join(outDir, "neetru-build-manifest.json"),
147
- JSON.stringify(manifest, null, 2),
130
+ let c = a.resolve(process.cwd(), n.outputDir ?? ".next");
131
+ u.mkdirSync(c, { recursive: !0 }), u.writeFileSync(
132
+ a.join(c, "neetru-build-manifest.json"),
133
+ JSON.stringify(d, null, 2),
148
134
  "utf8"
149
135
  );
150
- } catch (err) {
151
- if (typeof console !== "undefined") {
152
- console.warn(
153
- "[neetru-sdk] withNeetruBuildGuard: falha ao gravar neetru-build-manifest.json (ignorado, build segue):",
154
- err
155
- );
156
- }
136
+ } catch (c) {
137
+ typeof console < "u" && console.warn(
138
+ "[neetru-sdk] withNeetruBuildGuard: falha ao gravar neetru-build-manifest.json (ignorado, build segue):",
139
+ c
140
+ );
157
141
  }
158
- assertNeetruProdBuildEnv(manifest);
142
+ k(d);
159
143
  }
160
- return result;
144
+ return s;
161
145
  }
162
146
  };
163
147
  }
164
148
 
165
- export { NEETRU_SQL_SERVER_EXTERNAL_PACKAGES, NEETRU_SQL_TRACE_INCLUDE_KEY, NeetruBuildGuardError, assertNeetruProdBuildEnv, mergeOutputFileTracingIncludes, mergeServerExternalPackages, resolveSqlRuntimeClosure, sqlClosureToTraceGlobs, withNeetruBuildGuard };
166
- //# sourceMappingURL=build-guard.mjs.map
167
- //# sourceMappingURL=build-guard.mjs.map
149
+ export { f as NEETRU_SQL_SERVER_EXTERNAL_PACKAGES, g as NEETRU_SQL_TRACE_INCLUDE_KEY, l as NeetruBuildGuardError, k as assertNeetruProdBuildEnv, I as mergeOutputFileTracingIncludes, h as mergeServerExternalPackages, m as resolveSqlRuntimeClosure, N as sqlClosureToTraceGlobs, T as withNeetruBuildGuard };