@neetru/sdk 3.8.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.
- package/CHANGELOG.md +20 -0
- package/dist/ai.cjs +1 -1
- package/dist/ai.d.cts +1 -1
- package/dist/ai.d.ts +1 -1
- package/dist/ai.mjs +1 -1
- package/dist/auth.cjs +708 -688
- package/dist/auth.d.cts +1 -1
- package/dist/auth.d.ts +1 -1
- package/dist/auth.mjs +705 -685
- package/dist/catalog.cjs +1 -1
- package/dist/catalog.d.cts +1 -1
- package/dist/catalog.d.ts +1 -1
- package/dist/catalog.mjs +1 -1
- package/dist/checkout.cjs +1 -1
- package/dist/checkout.d.cts +1 -1
- package/dist/checkout.d.ts +1 -1
- package/dist/checkout.mjs +1 -1
- package/dist/db-react.d.cts +1 -1
- package/dist/db-react.d.ts +1 -1
- package/dist/db.cjs +242 -222
- package/dist/db.d.cts +1 -1
- package/dist/db.d.ts +1 -1
- package/dist/db.mjs +263 -243
- package/dist/entitlements.d.cts +1 -1
- package/dist/entitlements.d.ts +1 -1
- package/dist/firestore-compat.d.cts +1 -1
- package/dist/firestore-compat.d.ts +1 -1
- package/dist/index.cjs +730 -710
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +874 -854
- package/dist/mobile.d.cts +1 -1
- package/dist/mobile.d.ts +1 -1
- package/dist/mocks.d.cts +1 -1
- package/dist/mocks.d.ts +1 -1
- package/dist/notifications.cjs +1 -1
- package/dist/notifications.d.cts +1 -1
- package/dist/notifications.d.ts +1 -1
- package/dist/notifications.mjs +1 -1
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/support.cjs +1 -1
- package/dist/support.d.cts +1 -1
- package/dist/support.d.ts +1 -1
- package/dist/support.mjs +1 -1
- package/dist/telemetry.cjs +1 -1
- package/dist/telemetry.d.cts +1 -1
- package/dist/telemetry.d.ts +1 -1
- package/dist/telemetry.mjs +1 -1
- package/dist/{types-bVztFQTI.d.ts → types-BYPk_3HR.d.ts} +56 -16
- package/dist/{types-D-9bjlM0.d.cts → types-yv3EDKg2.d.cts} +56 -16
- package/dist/usage.cjs +1 -1
- package/dist/usage.d.cts +1 -1
- package/dist/usage.d.ts +1 -1
- package/dist/usage.mjs +1 -1
- package/dist/webhooks.cjs +1 -1
- package/dist/webhooks.d.cts +1 -1
- package/dist/webhooks.d.ts +1 -1
- package/dist/webhooks.mjs +1 -1
- package/package.json +1 -1
package/dist/db.cjs
CHANGED
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
var idb = require('idb');
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var Ye = Object.defineProperty;
|
|
6
6
|
var S = (r, e) => () => (r && (e = r(r = 0)), e);
|
|
7
7
|
var me = (r, e) => {
|
|
8
8
|
for (var t in e)
|
|
9
|
-
|
|
9
|
+
Ye(r, t, { get: e[t], enumerable: true });
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
// src/errors.ts
|
|
13
|
-
var
|
|
14
|
-
|
|
13
|
+
var b, x = S(() => {
|
|
14
|
+
b = class r extends Error {
|
|
15
15
|
code;
|
|
16
16
|
status;
|
|
17
17
|
requestId;
|
|
@@ -38,13 +38,13 @@ var g, x = S(() => {
|
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
// src/db-errors.ts
|
|
41
|
-
var
|
|
41
|
+
var Ze; exports.NeetruDbError = void 0; var I = S(() => {
|
|
42
42
|
x();
|
|
43
|
-
|
|
43
|
+
Ze = /* @__PURE__ */ new Set([
|
|
44
44
|
"db_unavailable",
|
|
45
45
|
"db_conflict",
|
|
46
46
|
"db_timeout"
|
|
47
|
-
]), exports.NeetruDbError = class r extends
|
|
47
|
+
]), exports.NeetruDbError = class r extends b {
|
|
48
48
|
/** Código de erro fechado — específico de DB. */
|
|
49
49
|
code;
|
|
50
50
|
/**
|
|
@@ -58,7 +58,7 @@ var Ye; exports.NeetruDbError = void 0; var I = S(() => {
|
|
|
58
58
|
*/
|
|
59
59
|
dbId;
|
|
60
60
|
constructor(e, t, n) {
|
|
61
|
-
super(e, t), this.name = "NeetruDbError", this.code = e, this.retryable =
|
|
61
|
+
super(e, t), this.name = "NeetruDbError", this.code = e, this.retryable = Ze.has(e), this.dbId = n, Object.setPrototypeOf(this, r.prototype);
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
64
|
});
|
|
@@ -68,7 +68,7 @@ function Te() {
|
|
|
68
68
|
let r = typeof globalThis < "u" && "crypto" in globalThis ? globalThis.crypto : void 0;
|
|
69
69
|
if (r && typeof r.randomUUID == "function")
|
|
70
70
|
return r.randomUUID();
|
|
71
|
-
throw new
|
|
71
|
+
throw new b(
|
|
72
72
|
"runtime_unsupported",
|
|
73
73
|
"crypto.randomUUID not available in this runtime. SDK 3.0 requires Node \u226520 or modern browser/Edge."
|
|
74
74
|
);
|
|
@@ -79,9 +79,9 @@ var Re = S(() => {
|
|
|
79
79
|
|
|
80
80
|
// src/correlation.ts
|
|
81
81
|
function ke(r) {
|
|
82
|
-
return typeof r == "string" && r.length > 0 && r.length <= 128 &&
|
|
82
|
+
return typeof r == "string" && r.length > 0 && r.length <= 128 && wt.test(r);
|
|
83
83
|
}
|
|
84
|
-
function
|
|
84
|
+
function St() {
|
|
85
85
|
let r = globalThis.crypto;
|
|
86
86
|
try {
|
|
87
87
|
if (r && typeof r.randomUUID == "function") return r.randomUUID();
|
|
@@ -108,11 +108,11 @@ function Ce(r, e) {
|
|
|
108
108
|
}
|
|
109
109
|
n[i] = s;
|
|
110
110
|
}
|
|
111
|
-
let o = t ?? (ke(e) ? e : void 0) ??
|
|
111
|
+
let o = t ?? (ke(e) ? e : void 0) ?? St();
|
|
112
112
|
return n[De] = o, { headers: n, correlationId: o };
|
|
113
113
|
}
|
|
114
|
-
var De,
|
|
115
|
-
De = "x-correlation-id",
|
|
114
|
+
var De, wt, Ie = S(() => {
|
|
115
|
+
De = "x-correlation-id", wt = /^[A-Za-z0-9._:\-]+$/;
|
|
116
116
|
});
|
|
117
117
|
|
|
118
118
|
// src/server-only-key.ts
|
|
@@ -136,13 +136,13 @@ var Ee = S(() => {
|
|
|
136
136
|
var U = {};
|
|
137
137
|
me(U, {
|
|
138
138
|
checkCoreVersionCompat: () => qe,
|
|
139
|
-
httpRequest: () =>
|
|
139
|
+
httpRequest: () => Ot,
|
|
140
140
|
statusToCode: () => Fe
|
|
141
141
|
});
|
|
142
142
|
function se(r) {
|
|
143
143
|
return r.split("+")[0] ?? r;
|
|
144
144
|
}
|
|
145
|
-
function
|
|
145
|
+
function Rt(r, e) {
|
|
146
146
|
let t = se(r).split(".").map(Number), n = se(e).split(".").map(Number), o = Math.max(t.length, n.length);
|
|
147
147
|
for (let i = 0; i < o; i++) {
|
|
148
148
|
let s = t[i] ?? 0, a = n[i] ?? 0;
|
|
@@ -152,28 +152,28 @@ function Tt(r, e) {
|
|
|
152
152
|
}
|
|
153
153
|
function Ne() {
|
|
154
154
|
try {
|
|
155
|
-
return "3.8.
|
|
155
|
+
return "3.8.1";
|
|
156
156
|
} catch {
|
|
157
157
|
return;
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
|
-
function
|
|
160
|
+
function Dt() {
|
|
161
161
|
let r = Ne();
|
|
162
162
|
return r ? parseInt(r.split(".")[0] ?? "3", 10) : 3;
|
|
163
163
|
}
|
|
164
164
|
function qe(r) {
|
|
165
165
|
if (!r) return;
|
|
166
|
-
let e =
|
|
166
|
+
let e = Dt(), t = Tt[e];
|
|
167
167
|
if (!t) return;
|
|
168
168
|
let n = se(r);
|
|
169
|
-
if (
|
|
169
|
+
if (Rt(n, t) < 0) {
|
|
170
170
|
let o = `${e}:${n}`;
|
|
171
171
|
Le.has(o) || (Le.add(o), console.warn(
|
|
172
172
|
`[Neetru SDK] Aten\xE7\xE3o: Core vers\xE3o "${r}" \xE9 anterior ao m\xEDnimo recomendado "${t}" para SDK major ${e}. Alguns recursos podem n\xE3o funcionar corretamente. Atualize o Core para a vers\xE3o mais recente.`
|
|
173
173
|
));
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
|
-
function
|
|
176
|
+
function kt() {
|
|
177
177
|
let r = "This operation requires an apiKey. Pass it to createNeetruClient({ apiKey }) or set NEETRU_API_KEY env var.";
|
|
178
178
|
return Pe() ? "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. (" + r + ")" : r;
|
|
179
179
|
}
|
|
@@ -181,7 +181,7 @@ function Me(r) {
|
|
|
181
181
|
let e = 200 * Math.pow(4, r), t = e * 0.2 * (Math.random() * 2 - 1);
|
|
182
182
|
return Math.max(50, Math.round(e + t));
|
|
183
183
|
}
|
|
184
|
-
function
|
|
184
|
+
function Lt(r) {
|
|
185
185
|
if (!r) return null;
|
|
186
186
|
let e = Number(r);
|
|
187
187
|
if (Number.isFinite(e) && e >= 0) return Math.min(Math.round(e * 1e3), Oe);
|
|
@@ -198,7 +198,7 @@ function xe(r) {
|
|
|
198
198
|
function Fe(r) {
|
|
199
199
|
return r === 401 ? "unauthorized" : r === 403 ? "forbidden" : r === 404 ? "not_found" : r === 409 ? "conflict" : r === 410 ? "gone" : r === 422 || r === 400 ? "validation_failed" : r === 429 ? "rate_limited" : r >= 500 ? "server_error" : "unknown";
|
|
200
200
|
}
|
|
201
|
-
function
|
|
201
|
+
function Mt(r, e, t) {
|
|
202
202
|
let n = r.replace(/\/+$/, ""), o = e.startsWith("/") ? e : `/${e}`, i = new URL(`${n}${o}`);
|
|
203
203
|
if (t)
|
|
204
204
|
for (let [s, a] of Object.entries(t))
|
|
@@ -214,26 +214,26 @@ async function Ae(r) {
|
|
|
214
214
|
return;
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
|
-
async function
|
|
218
|
-
let t = e.method ?? "GET", n =
|
|
217
|
+
async function Ot(r, e) {
|
|
218
|
+
let t = e.method ?? "GET", n = Mt(r.baseUrl, e.path, e.query), o = Pt.has(t) ? Ct : It, i = e.retries ?? o, { headers: s, correlationId: a } = Ce(
|
|
219
219
|
{ accept: "application/json", ...e.headers },
|
|
220
220
|
e.correlationId
|
|
221
221
|
), c = Ne();
|
|
222
222
|
if (c && (s["x-neetru-sdk-version"] = c), e.requireAuth) {
|
|
223
223
|
if (!r.apiKey)
|
|
224
|
-
throw new
|
|
224
|
+
throw new b("missing_api_key", kt());
|
|
225
225
|
s.authorization = `Bearer ${r.apiKey}`;
|
|
226
226
|
}
|
|
227
227
|
if (e.idempotencyKey) {
|
|
228
|
-
let
|
|
229
|
-
s["idempotency-key"] =
|
|
228
|
+
let p = typeof e.idempotencyKey == "string" ? e.idempotencyKey : Te();
|
|
229
|
+
s["idempotency-key"] = p;
|
|
230
230
|
}
|
|
231
231
|
let l = e.body !== void 0 && t !== "GET" && t !== "DELETE" ? JSON.stringify(e.body) : void 0;
|
|
232
232
|
l !== void 0 && (s["content-type"] = "application/json");
|
|
233
233
|
let d = null, u = e.deadlineMs != null ? Date.now() + e.deadlineMs : null;
|
|
234
|
-
for (let
|
|
234
|
+
for (let p = 0; p <= i; p++) {
|
|
235
235
|
if (u != null && Date.now() >= u)
|
|
236
|
-
throw d ?? new
|
|
236
|
+
throw d ?? new b(
|
|
237
237
|
"network_error",
|
|
238
238
|
"Deadline excedido antes de completar a request",
|
|
239
239
|
void 0,
|
|
@@ -243,15 +243,15 @@ async function Mt(r, e) {
|
|
|
243
243
|
);
|
|
244
244
|
let h = { method: t, headers: s };
|
|
245
245
|
l !== void 0 && (h.body = l);
|
|
246
|
-
let
|
|
247
|
-
h.signal = AbortSignal.timeout(
|
|
248
|
-
let
|
|
246
|
+
let _ = u != null ? Math.max(1, Math.min(3e4, u - Date.now())) : 3e4;
|
|
247
|
+
h.signal = AbortSignal.timeout(_);
|
|
248
|
+
let y;
|
|
249
249
|
try {
|
|
250
|
-
|
|
250
|
+
y = await r.fetch(n, h);
|
|
251
251
|
} catch (m) {
|
|
252
252
|
let O = m instanceof DOMException && m.name === "TimeoutError" ? "Network error: timeout after 30s" : `Network error: ${m instanceof Error ? m.message : "fetch failed"}`;
|
|
253
|
-
if (d = new
|
|
254
|
-
let he = Me(
|
|
253
|
+
if (d = new b("network_error", O, void 0, void 0, void 0, a), p < i) {
|
|
254
|
+
let he = Me(p);
|
|
255
255
|
if (u == null || Date.now() + he < u) {
|
|
256
256
|
await xe(he);
|
|
257
257
|
continue;
|
|
@@ -259,23 +259,23 @@ async function Mt(r, e) {
|
|
|
259
259
|
}
|
|
260
260
|
throw d;
|
|
261
261
|
}
|
|
262
|
-
let B =
|
|
263
|
-
if (
|
|
264
|
-
let m =
|
|
265
|
-
return m && qe(m), await Ae(
|
|
262
|
+
let B = y.headers.get("x-request-id") ?? y.headers.get("x-correlation-id") ?? void 0;
|
|
263
|
+
if (y.ok) {
|
|
264
|
+
let m = y.headers.get("x-neetru-version");
|
|
265
|
+
return m && qe(m), await Ae(y);
|
|
266
266
|
}
|
|
267
|
-
let
|
|
268
|
-
if (
|
|
269
|
-
let m =
|
|
270
|
-
typeof m == "string" ? w = m : m && typeof m == "object" ? (typeof m.code == "string" && (
|
|
267
|
+
let g = await Ae(y), v = Fe(y.status), w = `HTTP ${y.status}`, C;
|
|
268
|
+
if (g && typeof g == "object") {
|
|
269
|
+
let m = g.error;
|
|
270
|
+
typeof m == "string" ? w = m : m && typeof m == "object" ? (typeof m.code == "string" && (v = m.code), typeof m.message == "string" && (w = m.message), typeof m.reason == "string" && (C = m.reason)) : (typeof g.code == "string" && (v = g.code), typeof g.message == "string" && (w = g.message)), typeof g.reason == "string" && (C = g.reason);
|
|
271
271
|
}
|
|
272
|
-
if (
|
|
273
|
-
let m =
|
|
274
|
-
w === `HTTP ${
|
|
272
|
+
if (y.status === 410) {
|
|
273
|
+
let m = y.headers.get("x-neetru-replacement");
|
|
274
|
+
w === `HTTP ${y.status}` && (w = `Endpoint ${e.path} foi removido do Core (HTTP 410 Gone) \u2014 atualize o @neetru/sdk e migre para a API substituta.`), m && !w.includes(m) && (w += ` Substituto: ${m}.`);
|
|
275
275
|
}
|
|
276
|
-
let fe = new
|
|
277
|
-
if (d = fe,
|
|
278
|
-
let O =
|
|
276
|
+
let fe = new b(v, w, y.status, B, C, a);
|
|
277
|
+
if (d = fe, Et.has(v) && p < i) {
|
|
278
|
+
let O = Lt(y.headers.get("retry-after")) ?? Me(p);
|
|
279
279
|
if (u == null || Date.now() + O < u) {
|
|
280
280
|
await xe(O);
|
|
281
281
|
continue;
|
|
@@ -283,20 +283,20 @@ async function Mt(r, e) {
|
|
|
283
283
|
}
|
|
284
284
|
throw fe;
|
|
285
285
|
}
|
|
286
|
-
throw d ?? new
|
|
286
|
+
throw d ?? new b("unknown", "unexpected httpRequest exit", void 0, void 0, void 0, a);
|
|
287
287
|
}
|
|
288
|
-
var
|
|
288
|
+
var Tt, Le, Ct, It, Pt, Et, Oe, W = S(() => {
|
|
289
289
|
x();
|
|
290
290
|
Re();
|
|
291
291
|
Ie();
|
|
292
292
|
Ee();
|
|
293
|
-
|
|
293
|
+
Tt = {
|
|
294
294
|
// SDK major 3.x requer Core ≥ 2026.05.1 (suporte a X-Neetru-Version header,
|
|
295
295
|
// runTransaction write-after-read, verifyWebhookRequest, webhooks 3.0+)
|
|
296
296
|
3: "2026.05.1"
|
|
297
297
|
};
|
|
298
298
|
Le = /* @__PURE__ */ new Set();
|
|
299
|
-
|
|
299
|
+
Ct = 2, It = 0, Pt = /* @__PURE__ */ new Set(["GET", "HEAD"]), Et = /* @__PURE__ */ new Set([
|
|
300
300
|
"rate_limited",
|
|
301
301
|
"server_error",
|
|
302
302
|
"network_error"
|
|
@@ -308,7 +308,7 @@ var St, Le, kt, Ct, It, Pt, Oe, W = S(() => {
|
|
|
308
308
|
function J(r) {
|
|
309
309
|
return typeof r == "object" && r !== null && r[ae] === true;
|
|
310
310
|
}
|
|
311
|
-
function
|
|
311
|
+
function xt(r) {
|
|
312
312
|
let e = r && typeof r == "object" && "code" in r ? r.code : void 0;
|
|
313
313
|
if (e === "ECONNREFUSED" || e === "ETIMEDOUT" || e === "ENOTFOUND" || e === "EHOSTUNREACH" || e === "EAI_AGAIN")
|
|
314
314
|
return true;
|
|
@@ -320,56 +320,73 @@ function Ot(r) {
|
|
|
320
320
|
let n = (r instanceof Error ? r.message : typeof r == "string" ? r : "").toLowerCase();
|
|
321
321
|
return n.length === 0 ? false : !!(n.includes("certificate expired") || n.includes("certificate has expired") || n.includes("cert_has_expired") || n.includes("alert certificate expired") || n.includes("err_ssl") || n.includes("sslv3 alert") || n.includes("tlsv1 alert") || n.includes("econnrefused") || n.includes("etimedout") || n.includes("enotfound") || n.includes("ehostunreach") || n.includes("getaddrinfo"));
|
|
322
322
|
}
|
|
323
|
+
function Ue(r) {
|
|
324
|
+
let e = r && typeof r == "object" && "code" in r ? r.code : void 0;
|
|
325
|
+
if (typeof e == "string" && At.has(e.toUpperCase()))
|
|
326
|
+
return true;
|
|
327
|
+
let n = (r instanceof Error ? r.message : typeof r == "string" ? r : "").toLowerCase();
|
|
328
|
+
return n.length === 0 ? false : n.includes("password authentication failed") || n.includes("sasl authentication failed");
|
|
329
|
+
}
|
|
330
|
+
function Nt(r) {
|
|
331
|
+
return xt(r) || Ue(r);
|
|
332
|
+
}
|
|
323
333
|
function ce(r) {
|
|
324
334
|
let e = { current: r }, t = null, n = {
|
|
325
|
-
__neetruSwapInner(
|
|
326
|
-
let
|
|
327
|
-
return e.current =
|
|
335
|
+
__neetruSwapInner(d) {
|
|
336
|
+
let u = e.current;
|
|
337
|
+
return e.current = d, u;
|
|
328
338
|
},
|
|
329
339
|
__neetruGetInner() {
|
|
330
340
|
return e.current;
|
|
331
341
|
},
|
|
332
|
-
__neetruSetReLease(
|
|
333
|
-
t =
|
|
342
|
+
__neetruSetReLease(d) {
|
|
343
|
+
t = d;
|
|
334
344
|
}
|
|
335
|
-
}, o = (
|
|
345
|
+
}, o = (d, u, p) => u[d](
|
|
346
|
+
...p
|
|
347
|
+
), i = (d, u) => (...p) => p.length > 0 && typeof p[p.length - 1] == "function" ? o(d, e.current, p) : (async () => {
|
|
336
348
|
try {
|
|
337
|
-
return await o(e.current,
|
|
338
|
-
} catch (
|
|
339
|
-
let
|
|
340
|
-
if (
|
|
341
|
-
throw
|
|
349
|
+
return await o(d, e.current, p);
|
|
350
|
+
} catch (h) {
|
|
351
|
+
let _ = t;
|
|
352
|
+
if (_ === null || !u(h))
|
|
353
|
+
throw h;
|
|
342
354
|
try {
|
|
343
|
-
await
|
|
355
|
+
await _();
|
|
344
356
|
} catch {
|
|
345
|
-
throw
|
|
357
|
+
throw h;
|
|
346
358
|
}
|
|
347
|
-
return await o(e.current,
|
|
359
|
+
return await o(d, e.current, p);
|
|
348
360
|
}
|
|
349
|
-
})(), s = Object.create(Object.getPrototypeOf(r));
|
|
350
|
-
return new Proxy(
|
|
351
|
-
get(
|
|
352
|
-
if (
|
|
353
|
-
if (
|
|
354
|
-
if (
|
|
355
|
-
if (
|
|
356
|
-
if (
|
|
357
|
-
if (
|
|
361
|
+
})(), s = i("query", Nt), a = i("connect", Ue), c = Object.create(Object.getPrototypeOf(r));
|
|
362
|
+
return new Proxy(c, {
|
|
363
|
+
get(d, u) {
|
|
364
|
+
if (u === ae) return true;
|
|
365
|
+
if (u === "__neetruSwapInner") return n.__neetruSwapInner;
|
|
366
|
+
if (u === "__neetruGetInner") return n.__neetruGetInner;
|
|
367
|
+
if (u === "__neetruSetReLease") return n.__neetruSetReLease;
|
|
368
|
+
if (u === "query") return s;
|
|
369
|
+
if (u === "connect") {
|
|
370
|
+
let _ = e.current;
|
|
371
|
+
return typeof _.connect == "function" ? a : _.connect;
|
|
372
|
+
}
|
|
373
|
+
if (u === "constructor")
|
|
358
374
|
return e.current.constructor;
|
|
359
|
-
let
|
|
360
|
-
return typeof
|
|
375
|
+
let p = e.current, h = Reflect.get(p, u, p);
|
|
376
|
+
return typeof h == "function" ? h.bind(p) : h;
|
|
361
377
|
}
|
|
362
378
|
});
|
|
363
379
|
}
|
|
364
|
-
var ae, le = S(() => {
|
|
380
|
+
var ae, At, le = S(() => {
|
|
365
381
|
ae = /* @__PURE__ */ Symbol.for("neetru.sdk.resilientPool");
|
|
382
|
+
At = /* @__PURE__ */ new Set(["28P01", "28000"]);
|
|
366
383
|
});
|
|
367
384
|
|
|
368
385
|
// src/db/sql/lease.ts
|
|
369
|
-
function
|
|
386
|
+
function Ft(r, e) {
|
|
370
387
|
return r ? r.leaseId !== e.leaseId || r.credentialVersion !== e.credentialVersion || r.host !== e.host || r.port !== e.port || r.dbName !== e.dbName || r.user !== e.user || r.password !== e.password || r.sslca !== e.sslca || r.clientCert !== e.clientCert || r.clientKey !== e.clientKey : true;
|
|
371
388
|
}
|
|
372
|
-
function
|
|
389
|
+
function Ut(r) {
|
|
373
390
|
if (r instanceof exports.NeetruDbError) return r;
|
|
374
391
|
let e = r instanceof Error ? r.message : String(r), t = r instanceof Error ? r.code : void 0;
|
|
375
392
|
return typeof t == "string" && (t === "ECONNREFUSED" || t === "ENOTFOUND" || t === "ETIMEDOUT") ? new exports.NeetruDbError(
|
|
@@ -377,10 +394,10 @@ function Nt(r) {
|
|
|
377
394
|
`Pool connection failed (${t}): ${e}`
|
|
378
395
|
) : e.includes("statement timeout") || e.includes("lock timeout") ? new exports.NeetruDbError("db_timeout", `Query timeout: ${e}`) : e.includes("40001") || e.includes("40P01") || e.includes("deadlock") ? new exports.NeetruDbError("db_conflict", `Transaction conflict: ${e}`) : e.includes("42501") || e.toLowerCase().includes("permission denied") ? new exports.NeetruDbError("db_permission_denied", `Permission denied: ${e}`) : new exports.NeetruDbError("db_unavailable", `Database error: ${e}`);
|
|
379
396
|
}
|
|
380
|
-
var
|
|
397
|
+
var qt, M, $, We = S(() => {
|
|
381
398
|
I();
|
|
382
399
|
le();
|
|
383
|
-
|
|
400
|
+
qt = 0.8, M = 3e4, $ = class {
|
|
384
401
|
/**
|
|
385
402
|
* Lease atual. `null` no modo LAZY antes da 1ª query (o 1º lease é adiado —
|
|
386
403
|
* ver `_ensureInitialLease`). Após a 1ª aquisição, sempre não-nulo.
|
|
@@ -420,7 +437,7 @@ var xt, M, $, Ue = S(() => {
|
|
|
420
437
|
isolationLevel: t.isolationLevel
|
|
421
438
|
}) : await this._orm.transaction(e);
|
|
422
439
|
} catch (n) {
|
|
423
|
-
throw
|
|
440
|
+
throw Ut(n);
|
|
424
441
|
}
|
|
425
442
|
}
|
|
426
443
|
async close() {
|
|
@@ -443,7 +460,7 @@ var xt, M, $, Ue = S(() => {
|
|
|
443
460
|
if (!Number.isFinite(e)) return M;
|
|
444
461
|
let t = this._deps.now(), n = e - t;
|
|
445
462
|
if (n <= 0) return M;
|
|
446
|
-
let o = n * (1 -
|
|
463
|
+
let o = n * (1 - qt);
|
|
447
464
|
return Math.max(M, Math.round(o));
|
|
448
465
|
}
|
|
449
466
|
_scheduleRenewal() {
|
|
@@ -472,7 +489,7 @@ var xt, M, $, Ue = S(() => {
|
|
|
472
489
|
this._renewalTimer = setTimeout(() => {
|
|
473
490
|
this._doRenew();
|
|
474
491
|
}, M), console.warn(
|
|
475
|
-
`[SqlLeaseManager] renova\xE7\xE3o E emiss\xE3o de lease novo falharam; re-tentando em ${M}ms (cert
|
|
492
|
+
`[SqlLeaseManager] renova\xE7\xE3o E emiss\xE3o de lease novo falharam; re-tentando em ${M}ms (o cert de cliente mTLS do lease expira ~15min ap\xF3s o \xFAltimo swap):`,
|
|
476
493
|
t instanceof Error ? t.message : t
|
|
477
494
|
);
|
|
478
495
|
return;
|
|
@@ -484,10 +501,13 @@ var xt, M, $, Ue = S(() => {
|
|
|
484
501
|
/**
|
|
485
502
|
* Recuperação REATIVA: chamado pelo wrapper resiliente (`resilient-pool.ts`)
|
|
486
503
|
* quando uma query plana falha num erro de ESTABELECIMENTO de conexão (cert
|
|
487
|
-
* TLS
|
|
488
|
-
* renovação que não disparou)
|
|
489
|
-
* do
|
|
490
|
-
*
|
|
504
|
+
* TLS de cliente mTLS do lease expirado no meio de uma request, ou timer de
|
|
505
|
+
* renovação que não disparou) ou de AUTENTICAÇÃO (senha rotacionada por
|
|
506
|
+
* `rotate-credentials` antes do próximo renew — SQLSTATE 28P01/28000, ou o
|
|
507
|
+
* 08P01+SASL do PgBouncer; também no `connect()` de uma transação). Emite um
|
|
508
|
+
* lease NOVO e faz o swap do pool interno do wrapper com a credencial e o
|
|
509
|
+
* certificado frescos (o pool velho é drenado com `end()`); o wrapper então
|
|
510
|
+
* re-tenta a operação 1x no pool novo.
|
|
491
511
|
*
|
|
492
512
|
* Vai DIRETO ao lease novo (sem `leaseId`) — a conexão falhou porque o
|
|
493
513
|
* certificado do lease atual está ruim, então `renew` (que depende do lease
|
|
@@ -579,7 +599,7 @@ var xt, M, $, Ue = S(() => {
|
|
|
579
599
|
* Exposto como método protegido para testes.
|
|
580
600
|
*/
|
|
581
601
|
async _swapPool(e) {
|
|
582
|
-
if (!
|
|
602
|
+
if (!Ft(this._lease, e)) {
|
|
583
603
|
this._lease = e;
|
|
584
604
|
return;
|
|
585
605
|
}
|
|
@@ -606,29 +626,29 @@ var xt, M, $, Ue = S(() => {
|
|
|
606
626
|
});
|
|
607
627
|
|
|
608
628
|
// src/db/sql/sql-client.ts
|
|
609
|
-
var
|
|
610
|
-
me(
|
|
611
|
-
DEFAULT_POOL_CONNECT_TIMEOUT_MS: () =>
|
|
612
|
-
DEFAULT_POOL_IDLE_MS: () =>
|
|
629
|
+
var He = {};
|
|
630
|
+
me(He, {
|
|
631
|
+
DEFAULT_POOL_CONNECT_TIMEOUT_MS: () => ze,
|
|
632
|
+
DEFAULT_POOL_IDLE_MS: () => Qe,
|
|
613
633
|
DEFAULT_POOL_MAX: () => Ve,
|
|
614
|
-
LEASE_ENDPOINT: () =>
|
|
615
|
-
LEASE_RENEW_ENDPOINT: () =>
|
|
616
|
-
createDrizzleHandle: () =>
|
|
617
|
-
createHttpLeaseFetcher: () =>
|
|
618
|
-
createPgPool: () =>
|
|
619
|
-
createSqlClientFromConfig: () =>
|
|
620
|
-
createSqlClientWithDeps: () =>
|
|
634
|
+
LEASE_ENDPOINT: () => $e,
|
|
635
|
+
LEASE_RENEW_ENDPOINT: () => Be,
|
|
636
|
+
createDrizzleHandle: () => jt,
|
|
637
|
+
createHttpLeaseFetcher: () => je,
|
|
638
|
+
createPgPool: () => Bt,
|
|
639
|
+
createSqlClientFromConfig: () => Qt,
|
|
640
|
+
createSqlClientWithDeps: () => Ke,
|
|
621
641
|
resolvePoolTuning: () => ue
|
|
622
642
|
});
|
|
623
|
-
function
|
|
643
|
+
function Wt(r) {
|
|
624
644
|
return r === "workspace" ? "staging" : r === "prod" ? "production" : "dev-local";
|
|
625
645
|
}
|
|
626
|
-
function
|
|
646
|
+
function je(r) {
|
|
627
647
|
return async (e) => {
|
|
628
|
-
let { httpRequest: t } = await Promise.resolve().then(() => (W(), U)), n = !!e?.leaseId, o = n ?
|
|
648
|
+
let { httpRequest: t } = await Promise.resolve().then(() => (W(), U)), n = !!e?.leaseId, o = n ? Be : $e, i;
|
|
629
649
|
n ? i = { leaseId: e.leaseId } : (i = {
|
|
630
650
|
productId: r.productId ?? "",
|
|
631
|
-
environment:
|
|
651
|
+
environment: Wt(r.env ?? "prod")
|
|
632
652
|
}, e?.database !== void 0 && (i.database = e.database));
|
|
633
653
|
let s;
|
|
634
654
|
try {
|
|
@@ -641,7 +661,7 @@ function Be(r) {
|
|
|
641
661
|
retries: 2
|
|
642
662
|
});
|
|
643
663
|
} catch (a) {
|
|
644
|
-
let c = n ? "renovar" : "obter", l = a instanceof Error ? a.message : String(a), d = a instanceof
|
|
664
|
+
let c = n ? "renovar" : "obter", l = a instanceof Error ? a.message : String(a), d = a instanceof b ? a.reason : void 0;
|
|
645
665
|
if (d === "suspended" || d === "archived" || d === "revoked") {
|
|
646
666
|
let u = d === "suspended" ? "ambiente suspenso \u2014 a m\xE1quina que o servia parou; ser\xE1 religado quando o ambiente voltar" : d === "archived" ? "ambiente arquivado \u2014 este banco foi arquivado e n\xE3o aceita mais conex\xF5es" : "lease revogado \u2014 as credenciais deste ambiente foram revogadas pelo Core";
|
|
647
667
|
throw new exports.NeetruDbError(
|
|
@@ -654,10 +674,10 @@ function Be(r) {
|
|
|
654
674
|
`Falha ao ${c} lease SQL: ${l}`
|
|
655
675
|
);
|
|
656
676
|
}
|
|
657
|
-
return
|
|
677
|
+
return $t(s);
|
|
658
678
|
};
|
|
659
679
|
}
|
|
660
|
-
function
|
|
680
|
+
function $t(r) {
|
|
661
681
|
if (!r || typeof r != "object")
|
|
662
682
|
throw new exports.NeetruDbError("db_unavailable", "Resposta de lease inv\xE1lida (n\xE3o \xE9 objeto).");
|
|
663
683
|
let t = r.lease;
|
|
@@ -701,10 +721,10 @@ function ue() {
|
|
|
701
721
|
// para múltiplas instâncias do app dividirem o mesmo front-door.
|
|
702
722
|
max: de("NEETRU_DB_POOL_MAX", Ve, 1, 100),
|
|
703
723
|
// Teto 15min = janela do cert; piso 1s.
|
|
704
|
-
idleTimeoutMillis: de("NEETRU_DB_POOL_IDLE_MS",
|
|
724
|
+
idleTimeoutMillis: de("NEETRU_DB_POOL_IDLE_MS", Qe, 1e3, 9e5),
|
|
705
725
|
connectionTimeoutMillis: de(
|
|
706
726
|
"NEETRU_DB_POOL_CONNECT_TIMEOUT_MS",
|
|
707
|
-
|
|
727
|
+
ze,
|
|
708
728
|
1e3,
|
|
709
729
|
12e4
|
|
710
730
|
),
|
|
@@ -712,7 +732,7 @@ function ue() {
|
|
|
712
732
|
keepAliveInitialDelayMillis: 1e4
|
|
713
733
|
};
|
|
714
734
|
}
|
|
715
|
-
async function
|
|
735
|
+
async function Bt(r) {
|
|
716
736
|
let { Pool: e } = await import(
|
|
717
737
|
/* webpackIgnore: true */
|
|
718
738
|
'pg'
|
|
@@ -732,14 +752,14 @@ async function Ut(r) {
|
|
|
732
752
|
...ue()
|
|
733
753
|
});
|
|
734
754
|
}
|
|
735
|
-
async function
|
|
755
|
+
async function jt(r, e) {
|
|
736
756
|
let { drizzle: t } = await import(
|
|
737
757
|
/* webpackIgnore: true */
|
|
738
758
|
'drizzle-orm/node-postgres'
|
|
739
759
|
);
|
|
740
760
|
return t(r, { schema: e });
|
|
741
761
|
}
|
|
742
|
-
function
|
|
762
|
+
function Vt(r, e) {
|
|
743
763
|
let t = null, n = null, o = () => t ? Promise.resolve(t) : (n || (n = e().then((s) => (t = s, n = null, s)).catch((s) => {
|
|
744
764
|
throw n = null, s;
|
|
745
765
|
})), n), i = {
|
|
@@ -755,10 +775,10 @@ function $t(r, e) {
|
|
|
755
775
|
};
|
|
756
776
|
return r && Object.setPrototypeOf(i, r), i;
|
|
757
777
|
}
|
|
758
|
-
async function
|
|
778
|
+
async function Ke(r, e) {
|
|
759
779
|
let t = e?.database !== void 0 ? { ...r, database: e.database } : r;
|
|
760
780
|
if (t.lazy) {
|
|
761
|
-
let c = null, l =
|
|
781
|
+
let c = null, l = Vt(t.poolPrototype ?? null, () => {
|
|
762
782
|
if (!c)
|
|
763
783
|
throw new exports.NeetruDbError("db_unavailable", "SQL client n\xE3o inicializado (manager ausente).");
|
|
764
784
|
return c._ensureInitialLease();
|
|
@@ -766,11 +786,11 @@ async function ze(r, e) {
|
|
|
766
786
|
try {
|
|
767
787
|
u = t.createDrizzle(d, t.schema);
|
|
768
788
|
} catch (h) {
|
|
769
|
-
let
|
|
770
|
-
throw new exports.NeetruDbError("db_unavailable", `Falha ao criar handle Drizzle: ${
|
|
789
|
+
let _ = h instanceof Error ? h.message : String(h);
|
|
790
|
+
throw new exports.NeetruDbError("db_unavailable", `Falha ao criar handle Drizzle: ${_}`);
|
|
771
791
|
}
|
|
772
|
-
let
|
|
773
|
-
return c =
|
|
792
|
+
let p = new $(null, d, u, t);
|
|
793
|
+
return c = p, d.__neetruSetReLease(() => p._reactiveReLease()), p;
|
|
774
794
|
}
|
|
775
795
|
let n;
|
|
776
796
|
try {
|
|
@@ -799,8 +819,8 @@ async function ze(r, e) {
|
|
|
799
819
|
let a = new $(n, i, s, t);
|
|
800
820
|
return i.__neetruSetReLease(() => a._reactiveReLease()), a;
|
|
801
821
|
}
|
|
802
|
-
async function
|
|
803
|
-
let n =
|
|
822
|
+
async function Qt(r, e, t) {
|
|
823
|
+
let n = je(r), o, i;
|
|
804
824
|
try {
|
|
805
825
|
o = await import(
|
|
806
826
|
/* webpackIgnore: true */
|
|
@@ -816,7 +836,7 @@ async function Bt(r, e, t) {
|
|
|
816
836
|
);
|
|
817
837
|
}
|
|
818
838
|
let s = o.Pool ?? o.default?.Pool;
|
|
819
|
-
return
|
|
839
|
+
return Ke(
|
|
820
840
|
{
|
|
821
841
|
fetchLease: n,
|
|
822
842
|
createPool: (l) => {
|
|
@@ -851,13 +871,13 @@ async function Bt(r, e, t) {
|
|
|
851
871
|
t
|
|
852
872
|
);
|
|
853
873
|
}
|
|
854
|
-
var
|
|
874
|
+
var $e, Be, Ve, Qe, ze, Ge = S(() => {
|
|
855
875
|
I();
|
|
856
876
|
x();
|
|
857
|
-
|
|
877
|
+
We();
|
|
858
878
|
le();
|
|
859
|
-
|
|
860
|
-
Ve = 10,
|
|
879
|
+
$e = "/api/sdk/v1/db/lease", Be = "/api/sdk/v1/db/lease/renew";
|
|
880
|
+
Ve = 10, Qe = 6e4, ze = 1e4;
|
|
861
881
|
});
|
|
862
882
|
|
|
863
883
|
// src/db/client-db.ts
|
|
@@ -886,7 +906,7 @@ function Z(r, e) {
|
|
|
886
906
|
}
|
|
887
907
|
return n;
|
|
888
908
|
}
|
|
889
|
-
function
|
|
909
|
+
function et(r, e) {
|
|
890
910
|
let t = Z(r, e.field);
|
|
891
911
|
if (t === void 0) return false;
|
|
892
912
|
let { op: n, value: o } = e;
|
|
@@ -917,10 +937,10 @@ function Ze(r, e) {
|
|
|
917
937
|
);
|
|
918
938
|
}
|
|
919
939
|
}
|
|
920
|
-
function
|
|
921
|
-
return e.every((t) =>
|
|
940
|
+
function tt(r, e) {
|
|
941
|
+
return e.every((t) => et(r, t));
|
|
922
942
|
}
|
|
923
|
-
function
|
|
943
|
+
function nt(r) {
|
|
924
944
|
return (e, t) => {
|
|
925
945
|
if (r) {
|
|
926
946
|
let n = Z(e.data, r.field), o = Z(t.data, r.field), i = A(n, o);
|
|
@@ -930,7 +950,7 @@ function tt(r) {
|
|
|
930
950
|
return e.id < t.id ? -1 : e.id > t.id ? 1 : 0;
|
|
931
951
|
};
|
|
932
952
|
}
|
|
933
|
-
function
|
|
953
|
+
function rt(r, e) {
|
|
934
954
|
let t = r.findIndex((n) => n.id === e.docId);
|
|
935
955
|
return t === -1 ? r : e.type === "startAfter" ? r.slice(t + 1) : r.slice(0, t);
|
|
936
956
|
}
|
|
@@ -948,9 +968,9 @@ var P = class r {
|
|
|
948
968
|
evaluate(e, t) {
|
|
949
969
|
let n = e.filter((d) => !d.meta.deleted), o = t.where ?? [];
|
|
950
970
|
o.length > 0 && (n = n.filter(
|
|
951
|
-
(d) =>
|
|
971
|
+
(d) => tt(d.data, o)
|
|
952
972
|
));
|
|
953
|
-
let i =
|
|
973
|
+
let i = nt(t.orderBy), s = [...n].sort(i), a = t.cursor ? rt(s, t.cursor) : s, c = Math.min(t.limit ?? 20, 500);
|
|
954
974
|
return {
|
|
955
975
|
docs: a.slice(0, c).map((d) => ({ id: d.id, data: d.data })),
|
|
956
976
|
// `incomplete` é sempre true aqui — o QueryEngine não sabe se o cache
|
|
@@ -970,7 +990,7 @@ var P = class r {
|
|
|
970
990
|
};
|
|
971
991
|
|
|
972
992
|
// src/db/offline/local-store.ts
|
|
973
|
-
var
|
|
993
|
+
var it = 1, T = "documents", R = "mutations", N = "query_cache", j = "sync_meta", E = "conflict_log", V = class {
|
|
974
994
|
db = null;
|
|
975
995
|
dbName;
|
|
976
996
|
constructor(e) {
|
|
@@ -982,7 +1002,7 @@ var ot = 1, T = "documents", R = "mutations", N = "query_cache", V = "sync_meta"
|
|
|
982
1002
|
* Idempotente — chamadas subsequentes são no-ops se o banco já está aberto.
|
|
983
1003
|
*/
|
|
984
1004
|
async open() {
|
|
985
|
-
this.db === null && (this.db = await idb.openDB(this.dbName,
|
|
1005
|
+
this.db === null && (this.db = await idb.openDB(this.dbName, it, {
|
|
986
1006
|
upgrade(e) {
|
|
987
1007
|
if (!e.objectStoreNames.contains(T)) {
|
|
988
1008
|
let t = e.createObjectStore(T, {
|
|
@@ -996,7 +1016,7 @@ var ot = 1, T = "documents", R = "mutations", N = "query_cache", V = "sync_meta"
|
|
|
996
1016
|
});
|
|
997
1017
|
t.createIndex("by_seq", "seq"), t.createIndex("by_status", "status"), t.createIndex("by_doc", ["collection", "docId"]), t.createIndex("by_batch", "batchId");
|
|
998
1018
|
}
|
|
999
|
-
if (e.objectStoreNames.contains(N) || e.createObjectStore(N, { keyPath: "queryHash" }), e.objectStoreNames.contains(
|
|
1019
|
+
if (e.objectStoreNames.contains(N) || e.createObjectStore(N, { keyPath: "queryHash" }), e.objectStoreNames.contains(j) || e.createObjectStore(j, { keyPath: "key" }), !e.objectStoreNames.contains(E)) {
|
|
1000
1020
|
let t = e.createObjectStore(E, {
|
|
1001
1021
|
keyPath: "id",
|
|
1002
1022
|
autoIncrement: true
|
|
@@ -1083,14 +1103,14 @@ var ot = 1, T = "documents", R = "mutations", N = "query_cache", V = "sync_meta"
|
|
|
1083
1103
|
* 'lastFullResyncAt', 'leaderTabId'.
|
|
1084
1104
|
*/
|
|
1085
1105
|
async getMeta(e) {
|
|
1086
|
-
let n = await this.assertOpen().get(
|
|
1106
|
+
let n = await this.assertOpen().get(j, e);
|
|
1087
1107
|
return n ? n.value : null;
|
|
1088
1108
|
}
|
|
1089
1109
|
/**
|
|
1090
1110
|
* Armazena ou atualiza um valor na store `sync_meta`.
|
|
1091
1111
|
*/
|
|
1092
1112
|
async setMeta(e, t) {
|
|
1093
|
-
await this.assertOpen().put(
|
|
1113
|
+
await this.assertOpen().put(j, { key: e, value: t });
|
|
1094
1114
|
}
|
|
1095
1115
|
// ─── Conflict log ───────────────────────────────────────────────────────────
|
|
1096
1116
|
/**
|
|
@@ -1392,7 +1412,7 @@ var z = class {
|
|
|
1392
1412
|
async enqueue(e) {
|
|
1393
1413
|
let { collection: t, op: n, payload: o, baseVersion: i, batchId: s, upsert: a } = e, c = e.docId ?? (n === "add" ? ee() : "");
|
|
1394
1414
|
await this.syncSeq();
|
|
1395
|
-
let d = (await this.store.listMutations({ collection: t, docId: c })).filter((h) => h.status === "queued").sort((h,
|
|
1415
|
+
let d = (await this.store.listMutations({ collection: t, docId: c })).filter((h) => h.status === "queued").sort((h, _) => _.seq - h.seq)[0];
|
|
1396
1416
|
if (d !== void 0) {
|
|
1397
1417
|
let h = this.tryCoalesce(d, n, o, s, a);
|
|
1398
1418
|
if (h !== null) {
|
|
@@ -1411,11 +1431,11 @@ var z = class {
|
|
|
1411
1431
|
status: "queued",
|
|
1412
1432
|
batchId: s
|
|
1413
1433
|
};
|
|
1414
|
-
let { coalesced:
|
|
1415
|
-
return await this.store.putMutation(
|
|
1434
|
+
let { coalesced: _ } = h;
|
|
1435
|
+
return await this.store.putMutation(_), _;
|
|
1416
1436
|
}
|
|
1417
1437
|
}
|
|
1418
|
-
let
|
|
1438
|
+
let p = {
|
|
1419
1439
|
seq: this.nextSeq(),
|
|
1420
1440
|
mutationId: ee(),
|
|
1421
1441
|
collection: t,
|
|
@@ -1431,7 +1451,7 @@ var z = class {
|
|
|
1431
1451
|
// bug_0273e4dd: só persiste o flag quando verdadeiro (mantém o doc limpo).
|
|
1432
1452
|
...a ? { upsert: true } : {}
|
|
1433
1453
|
};
|
|
1434
|
-
return await this.store.putMutation(
|
|
1454
|
+
return await this.store.putMutation(p), p;
|
|
1435
1455
|
}
|
|
1436
1456
|
// ─── Leitura da fila ─────────────────────────────────────────────────────────
|
|
1437
1457
|
/**
|
|
@@ -1531,10 +1551,10 @@ var z = class {
|
|
|
1531
1551
|
|
|
1532
1552
|
// src/db/field-value.ts
|
|
1533
1553
|
var te = "__neetru__";
|
|
1534
|
-
function
|
|
1554
|
+
function st() {
|
|
1535
1555
|
return { __neetru__: "serverTimestamp" };
|
|
1536
1556
|
}
|
|
1537
|
-
function
|
|
1557
|
+
function at(r) {
|
|
1538
1558
|
if (typeof r != "number" || !Number.isFinite(r))
|
|
1539
1559
|
throw new TypeError(
|
|
1540
1560
|
`increment(n): n deve ser um n\xFAmero finito (recebido: ${String(r)}).`
|
|
@@ -1550,13 +1570,13 @@ function ye(r) {
|
|
|
1550
1570
|
function ge(r) {
|
|
1551
1571
|
return D(r) && r.__neetru__ === "increment" && typeof r.operand == "number" && Number.isFinite(r.operand);
|
|
1552
1572
|
}
|
|
1553
|
-
function
|
|
1573
|
+
function ct(r, e) {
|
|
1554
1574
|
return ye(r) ? Date.now() : ge(r) ? (typeof e == "number" && Number.isFinite(e) ? e : 0) + r.operand : r;
|
|
1555
1575
|
}
|
|
1556
1576
|
function k(r, e) {
|
|
1557
1577
|
let t = false, n = {};
|
|
1558
1578
|
for (let [o, i] of Object.entries(r))
|
|
1559
|
-
D(i) ? (t = true, n[o] =
|
|
1579
|
+
D(i) ? (t = true, n[o] = ct(i, e?.[o])) : n[o] = i;
|
|
1560
1580
|
return t ? n : r;
|
|
1561
1581
|
}
|
|
1562
1582
|
function ne(r) {
|
|
@@ -1566,11 +1586,11 @@ function ne(r) {
|
|
|
1566
1586
|
}
|
|
1567
1587
|
|
|
1568
1588
|
// src/db/offline/sync-engine.ts
|
|
1569
|
-
var
|
|
1570
|
-
function
|
|
1589
|
+
var lt = 8, dt = 1e3, ut = 300 * 1e3, re = "truncatedCollections";
|
|
1590
|
+
function pt(r) {
|
|
1571
1591
|
return r !== null && ne(r);
|
|
1572
1592
|
}
|
|
1573
|
-
function
|
|
1593
|
+
function ft(r) {
|
|
1574
1594
|
if (r === null) return null;
|
|
1575
1595
|
if (!ne(r)) return r;
|
|
1576
1596
|
let e = {};
|
|
@@ -1772,13 +1792,13 @@ var K = class {
|
|
|
1772
1792
|
}), s.push({ type: "removed", collection: e, doc: { id: t, data: a.data } }));
|
|
1773
1793
|
return;
|
|
1774
1794
|
}
|
|
1775
|
-
let l =
|
|
1795
|
+
let l = ft(i.payload) ?? a?.data ?? {}, d = {
|
|
1776
1796
|
collection: e,
|
|
1777
1797
|
id: t,
|
|
1778
1798
|
data: i.op === "update" ? { ...a?.data ?? {}, ...l } : (
|
|
1779
1799
|
// add/set: se o payload tinha sentinels, o cache otimista (existing.data)
|
|
1780
1800
|
// é a fonte de verdade até o pull; senão usa o payload literal.
|
|
1781
|
-
|
|
1801
|
+
pt(i.payload) ? { ...a?.data ?? {}, ...l } : l
|
|
1782
1802
|
),
|
|
1783
1803
|
meta: {
|
|
1784
1804
|
serverVersion: n,
|
|
@@ -1931,7 +1951,7 @@ var K = class {
|
|
|
1931
1951
|
* pending do doc no cache + registra `lastError`/dispara `onError`.
|
|
1932
1952
|
*/
|
|
1933
1953
|
async _retryOrDeadLetter(e, t, n) {
|
|
1934
|
-
if (e.attempts + 1 <
|
|
1954
|
+
if (e.attempts + 1 < lt) {
|
|
1935
1955
|
await this._queue.markRetry(e.mutationId, t);
|
|
1936
1956
|
return;
|
|
1937
1957
|
}
|
|
@@ -1972,7 +1992,7 @@ var K = class {
|
|
|
1972
1992
|
}
|
|
1973
1993
|
/** Backoff exponencial keyed em `attempts`, com teto `BACKOFF_CAP_MS`. */
|
|
1974
1994
|
_backoffDelayMs(e) {
|
|
1975
|
-
return Math.min(
|
|
1995
|
+
return Math.min(dt * 2 ** (e - 1), ut);
|
|
1976
1996
|
}
|
|
1977
1997
|
// ─── FASE 2 — pull (reconciliar o cache) ─────────────────────────────────────
|
|
1978
1998
|
/**
|
|
@@ -2386,7 +2406,7 @@ var H = class r {
|
|
|
2386
2406
|
};
|
|
2387
2407
|
|
|
2388
2408
|
// src/db/offline/change-bus.ts
|
|
2389
|
-
function
|
|
2409
|
+
function ht(r) {
|
|
2390
2410
|
return `${r.collection}::${r.doc.id}`;
|
|
2391
2411
|
}
|
|
2392
2412
|
var G = class {
|
|
@@ -2434,7 +2454,7 @@ var G = class {
|
|
|
2434
2454
|
if (e.length === 0) return;
|
|
2435
2455
|
let t = /* @__PURE__ */ new Map();
|
|
2436
2456
|
for (let i of e)
|
|
2437
|
-
t.set(
|
|
2457
|
+
t.set(ht(i), i);
|
|
2438
2458
|
let n = Array.from(t.values()), o = /* @__PURE__ */ new Map();
|
|
2439
2459
|
for (let i of n)
|
|
2440
2460
|
o.has(i.collection) || o.set(i.collection, []), o.get(i.collection).push(i);
|
|
@@ -2753,11 +2773,11 @@ var q = class {
|
|
|
2753
2773
|
|
|
2754
2774
|
// src/db/collection-ref.ts
|
|
2755
2775
|
I();
|
|
2756
|
-
function
|
|
2776
|
+
function mt() {
|
|
2757
2777
|
return typeof indexedDB > "u" || typeof window > "u";
|
|
2758
2778
|
}
|
|
2759
2779
|
var ve = /^[a-z0-9][a-z0-9_-]{0,62}$/;
|
|
2760
|
-
function
|
|
2780
|
+
function _t(r) {
|
|
2761
2781
|
if (!ve.test(r))
|
|
2762
2782
|
throw new exports.NeetruDbError(
|
|
2763
2783
|
"db_invalid_query",
|
|
@@ -2771,7 +2791,7 @@ function L(r, e = "id") {
|
|
|
2771
2791
|
`${e} \xE9 obrigat\xF3rio e deve ser uma string n\xE3o-vazia.`
|
|
2772
2792
|
);
|
|
2773
2793
|
}
|
|
2774
|
-
function
|
|
2794
|
+
function yt(r) {
|
|
2775
2795
|
let e = {};
|
|
2776
2796
|
if (r?.where && (e.where = r.where.map((t) => ({
|
|
2777
2797
|
field: t.field,
|
|
@@ -2788,7 +2808,7 @@ function _t(r) {
|
|
|
2788
2808
|
}
|
|
2789
2809
|
return e;
|
|
2790
2810
|
}
|
|
2791
|
-
function
|
|
2811
|
+
function gt(r, e) {
|
|
2792
2812
|
if (r.length < e) return null;
|
|
2793
2813
|
let t = r[r.length - 1];
|
|
2794
2814
|
return t ? btoa(JSON.stringify({ type: "startAfter", docId: t.id })) : null;
|
|
@@ -2835,11 +2855,11 @@ var oe = class {
|
|
|
2835
2855
|
}
|
|
2836
2856
|
/** Constrói um DbListResult para a coleção com query opcional. */
|
|
2837
2857
|
async _buildListResult(e) {
|
|
2838
|
-
let t =
|
|
2858
|
+
let t = yt(e), n = t.limit ?? 20, o = await this._store.listDocs(this._collection, t), i = await this._hasPendingWrites(), s = this._isOnline(), a = this._engine.getSyncState(), c = gt(o.docs, n), l = await this._store.getMeta(re), d = Array.isArray(l) && l.includes(this._collection), u = !s || a.status === "offline" || d, p = i || a.lastSyncedAt === null || u;
|
|
2839
2859
|
return {
|
|
2840
2860
|
docs: o.docs.map((h) => ({ id: h.id, data: h.data })),
|
|
2841
2861
|
nextCursor: c,
|
|
2842
|
-
fromCache:
|
|
2862
|
+
fromCache: p,
|
|
2843
2863
|
stale: u,
|
|
2844
2864
|
hasPendingWrites: i,
|
|
2845
2865
|
changes: [],
|
|
@@ -3013,7 +3033,7 @@ var oe = class {
|
|
|
3013
3033
|
doc: { id: s, data: l }
|
|
3014
3034
|
});
|
|
3015
3035
|
} else if (o.kind === "update") {
|
|
3016
|
-
let s = o.id, a = o.data, c = await this._store.getDoc(i, s), l = c?.meta.deleted ? void 0 : c?.data, d = k(a, l), u = { ...c?.data ?? {}, ...d },
|
|
3036
|
+
let s = o.id, a = o.data, c = await this._store.getDoc(i, s), l = c?.meta.deleted ? void 0 : c?.data, d = k(a, l), u = { ...c?.data ?? {}, ...d }, p = await this._queue.enqueue({
|
|
3017
3037
|
collection: i,
|
|
3018
3038
|
docId: s,
|
|
3019
3039
|
op: "update",
|
|
@@ -3034,7 +3054,7 @@ var oe = class {
|
|
|
3034
3054
|
state: "pending",
|
|
3035
3055
|
pendingMutationIds: [
|
|
3036
3056
|
...c?.meta.pendingMutationIds ?? [],
|
|
3037
|
-
|
|
3057
|
+
p.mutationId
|
|
3038
3058
|
],
|
|
3039
3059
|
deleted: false,
|
|
3040
3060
|
ownerId: c?.meta.ownerId ?? null
|
|
@@ -3178,7 +3198,7 @@ var oe = class {
|
|
|
3178
3198
|
this._store = e.store, this._queue = e.queue, this._bus = e.bus, this._engine = e.engine, this._connectivity = e.connectivity;
|
|
3179
3199
|
}
|
|
3180
3200
|
collection(e) {
|
|
3181
|
-
return
|
|
3201
|
+
return _t(e), new oe(
|
|
3182
3202
|
e,
|
|
3183
3203
|
this._store,
|
|
3184
3204
|
this._queue,
|
|
@@ -3208,7 +3228,7 @@ var oe = class {
|
|
|
3208
3228
|
}
|
|
3209
3229
|
};
|
|
3210
3230
|
async function we(r) {
|
|
3211
|
-
let e =
|
|
3231
|
+
let e = mt() ? new Q() : new V(r.dbName);
|
|
3212
3232
|
await e.open();
|
|
3213
3233
|
let t = new z(e), n = new H(), o = new G(), i = new X({
|
|
3214
3234
|
// Se startOnline=false, injeta um navigator falso
|
|
@@ -3243,9 +3263,9 @@ async function we(r) {
|
|
|
3243
3263
|
}
|
|
3244
3264
|
|
|
3245
3265
|
// src/db/realtime/realtime-client.ts
|
|
3246
|
-
var
|
|
3266
|
+
var bt = 0;
|
|
3247
3267
|
function Se() {
|
|
3248
|
-
return typeof globalThis.crypto?.randomUUID == "function" ? globalThis.crypto.randomUUID() : `nrt-sub-${Date.now()}-${++
|
|
3268
|
+
return typeof globalThis.crypto?.randomUUID == "function" ? globalThis.crypto.randomUUID() : `nrt-sub-${Date.now()}-${++bt}-${Math.random().toString(36).slice(2)}`;
|
|
3249
3269
|
}
|
|
3250
3270
|
var F = class {
|
|
3251
3271
|
// ── configuração ──────────────────────────────────────────────────────────
|
|
@@ -3285,7 +3305,7 @@ var F = class {
|
|
|
3285
3305
|
_pendingFrames = [];
|
|
3286
3306
|
// ── construtor ────────────────────────────────────────────────────────────
|
|
3287
3307
|
constructor(e) {
|
|
3288
|
-
this._gatewayUrl = e.gatewayUrl, this._wsFactory = e.webSocketFactory ??
|
|
3308
|
+
this._gatewayUrl = e.gatewayUrl, this._wsFactory = e.webSocketFactory ?? vt, this._setTimeout = e.setTimeoutFn ?? globalThis.setTimeout.bind(globalThis), this._clearTimeout = e.clearTimeoutFn ?? globalThis.clearTimeout.bind(globalThis), this._backoffBaseMs = e.backoffBaseMs ?? 1e3, this._backoffMaxMs = e.backoffMaxMs ?? 3e4, this._heartbeatIntervalMs = e.heartbeatIntervalMs ?? 25e3, this._ticketProvider = e.ticketProvider, this._dbId = e.dbId, this._connect();
|
|
3289
3309
|
}
|
|
3290
3310
|
// ── API pública ───────────────────────────────────────────────────────────
|
|
3291
3311
|
/**
|
|
@@ -3564,7 +3584,7 @@ var F = class {
|
|
|
3564
3584
|
_detachHandlers(e) {
|
|
3565
3585
|
e.onopen = null, e.onmessage = null, e.onclose = null, e.onerror = null;
|
|
3566
3586
|
}
|
|
3567
|
-
},
|
|
3587
|
+
}, vt = (r) => {
|
|
3568
3588
|
if (typeof WebSocket > "u")
|
|
3569
3589
|
throw new Error(
|
|
3570
3590
|
"[NeetruRealtimeClient] WebSocket n\xE3o dispon\xEDvel neste ambiente. Injete uma implementa\xE7\xE3o via `webSocketFactory` nas op\xE7\xF5es."
|
|
@@ -3574,11 +3594,11 @@ var F = class {
|
|
|
3574
3594
|
|
|
3575
3595
|
// src/db/client-db.ts
|
|
3576
3596
|
I();
|
|
3577
|
-
var
|
|
3578
|
-
function
|
|
3579
|
-
return e._transport ? e._transport : r === "firestore" && e.firestoreTransport ? e.firestoreTransport : r === "nosql-vm" && e.realtimeGatewayUrl ?
|
|
3597
|
+
var zt = (r) => `/api/sdk/v1/datastore/${encodeURIComponent(r)}`, Y = (r, e) => `/api/sdk/v1/datastore/${encodeURIComponent(r)}/${encodeURIComponent(e)}`, Xe = 200;
|
|
3598
|
+
function Kt(r, e, t) {
|
|
3599
|
+
return e._transport ? e._transport : r === "firestore" && e.firestoreTransport ? e.firestoreTransport : r === "nosql-vm" && e.realtimeGatewayUrl ? Ht(e.realtimeGatewayUrl, t, e) : Je(t);
|
|
3580
3600
|
}
|
|
3581
|
-
function
|
|
3601
|
+
function Je(r) {
|
|
3582
3602
|
return {
|
|
3583
3603
|
async pushMutations(e) {
|
|
3584
3604
|
if (!r)
|
|
@@ -3628,11 +3648,11 @@ function Xe(r) {
|
|
|
3628
3648
|
} catch (a) {
|
|
3629
3649
|
let c = a instanceof Error ? a.message : String(a), l = a?.code, d = a?.status;
|
|
3630
3650
|
if (l === "forbidden" || l === "unauthorized" || l === "not_found" || l === "conflict" || l === "validation_failed" || typeof d == "number" && d >= 400 && d < 500 && d !== 408 && d !== 429) {
|
|
3631
|
-
let
|
|
3651
|
+
let p = l === "forbidden" || l === "unauthorized" ? "rejected_permission" : "rejected_validation";
|
|
3632
3652
|
n.push({
|
|
3633
3653
|
mutationId: s.mutationId,
|
|
3634
3654
|
outcome: "rejected",
|
|
3635
|
-
reason:
|
|
3655
|
+
reason: p,
|
|
3636
3656
|
serverVersion: null,
|
|
3637
3657
|
serverData: null
|
|
3638
3658
|
});
|
|
@@ -3656,7 +3676,7 @@ function Xe(r) {
|
|
|
3656
3676
|
try {
|
|
3657
3677
|
l = await t(r, {
|
|
3658
3678
|
method: "GET",
|
|
3659
|
-
path:
|
|
3679
|
+
path: zt(c),
|
|
3660
3680
|
requireAuth: !0,
|
|
3661
3681
|
retries: 2,
|
|
3662
3682
|
headers: o,
|
|
@@ -3664,37 +3684,37 @@ function Xe(r) {
|
|
|
3664
3684
|
// TRUNCADAS — reportadas em `truncatedCollections` p/ o SyncEngine
|
|
3665
3685
|
// (a) NÃO rodar deleção-por-ausência e (b) sinalizar
|
|
3666
3686
|
// `DbListResult.truncated`. Paginação por cursor é tarefa Core (gated).
|
|
3667
|
-
query: { limit:
|
|
3687
|
+
query: { limit: Xe }
|
|
3668
3688
|
});
|
|
3669
|
-
} catch (
|
|
3670
|
-
let h =
|
|
3689
|
+
} catch (p) {
|
|
3690
|
+
let h = p instanceof Error ? p.message : String(p);
|
|
3671
3691
|
throw new exports.NeetruDbError(
|
|
3672
3692
|
"db_unavailable",
|
|
3673
3693
|
`[RestSyncTransport] fullResync falhou na cole\xE7\xE3o "${c}": ${h}`
|
|
3674
3694
|
);
|
|
3675
3695
|
}
|
|
3676
3696
|
let d = l, u = Array.isArray(d?.items) ? d.items : [];
|
|
3677
|
-
u.length >=
|
|
3678
|
-
for (let
|
|
3679
|
-
if (!
|
|
3680
|
-
let h =
|
|
3681
|
-
if (!
|
|
3682
|
-
let { id:
|
|
3683
|
-
if (typeof
|
|
3684
|
-
|
|
3685
|
-
else if (
|
|
3686
|
-
|
|
3687
|
-
else if (typeof
|
|
3688
|
-
let C = Date.parse(
|
|
3689
|
-
Number.isNaN(C) || (
|
|
3697
|
+
u.length >= Xe && a.push(c);
|
|
3698
|
+
for (let p of u) {
|
|
3699
|
+
if (!p || typeof p != "object") continue;
|
|
3700
|
+
let h = p, _ = typeof h.id == "string" ? h.id : null;
|
|
3701
|
+
if (!_) continue;
|
|
3702
|
+
let { id: y, ...B } = h, g = i, v = B._updatedAt;
|
|
3703
|
+
if (typeof v == "number")
|
|
3704
|
+
g = v;
|
|
3705
|
+
else if (v !== null && typeof v == "object" && typeof v._seconds == "number")
|
|
3706
|
+
g = v._seconds * 1e3;
|
|
3707
|
+
else if (typeof v == "string") {
|
|
3708
|
+
let C = Date.parse(v);
|
|
3709
|
+
Number.isNaN(C) || (g = C);
|
|
3690
3710
|
}
|
|
3691
|
-
let w = `rest_${
|
|
3711
|
+
let w = `rest_${_}_${g}`;
|
|
3692
3712
|
s.push({
|
|
3693
3713
|
collection: c,
|
|
3694
|
-
id:
|
|
3714
|
+
id: _,
|
|
3695
3715
|
data: B,
|
|
3696
3716
|
serverVersion: w,
|
|
3697
|
-
serverTimestamp:
|
|
3717
|
+
serverTimestamp: g,
|
|
3698
3718
|
deleted: false
|
|
3699
3719
|
});
|
|
3700
3720
|
}
|
|
@@ -3703,10 +3723,10 @@ function Xe(r) {
|
|
|
3703
3723
|
}
|
|
3704
3724
|
};
|
|
3705
3725
|
}
|
|
3706
|
-
function
|
|
3707
|
-
let n =
|
|
3726
|
+
function Ht(r, e, t) {
|
|
3727
|
+
let n = Je(e), o = new F({
|
|
3708
3728
|
gatewayUrl: r,
|
|
3709
|
-
ticketProvider:
|
|
3729
|
+
ticketProvider: Gt(e, t),
|
|
3710
3730
|
dbId: t.dbId,
|
|
3711
3731
|
webSocketFactory: t._wsFactory
|
|
3712
3732
|
});
|
|
@@ -3742,7 +3762,7 @@ function Qt(r, e, t) {
|
|
|
3742
3762
|
}
|
|
3743
3763
|
};
|
|
3744
3764
|
}
|
|
3745
|
-
function
|
|
3765
|
+
function Gt(r, e) {
|
|
3746
3766
|
return async () => {
|
|
3747
3767
|
let { httpRequest: t } = await Promise.resolve().then(() => (W(), U));
|
|
3748
3768
|
return await t(r, {
|
|
@@ -3757,25 +3777,25 @@ function zt(r, e) {
|
|
|
3757
3777
|
});
|
|
3758
3778
|
};
|
|
3759
3779
|
}
|
|
3760
|
-
function
|
|
3780
|
+
function Gn(r, e, t, n) {
|
|
3761
3781
|
return new F({ gatewayUrl: r, ticketProvider: e, dbId: t, webSocketFactory: n });
|
|
3762
3782
|
}
|
|
3763
3783
|
var pe = false;
|
|
3764
|
-
function
|
|
3784
|
+
function Xn() {
|
|
3765
3785
|
pe = false;
|
|
3766
3786
|
}
|
|
3767
|
-
function
|
|
3787
|
+
function Xt(r, e) {
|
|
3768
3788
|
pe || e.dbId && r.env !== "prod" && (typeof window > "u" || typeof console > "u" || typeof console.warn != "function" || (pe = true, console.warn(
|
|
3769
3789
|
'[neetru/sdk] client.db recebeu `dbId` ("' + e.dbId + '") mas ele N\xC3O roteia nem escopa nada no servidor: as escritas do mundo Documentos (add/set/update/remove/list) SEMPRE caem no datastore gen\xE9rico do Core, escopado s\xF3 por tenant/produto (header x-neetru-tenant). `dbId` apenas nomeia o cache offline LOCAL (IndexedDB). ATEN\xC7\xC3O: usar dbIds distintos no MESMO tenant/produto N\xC3O isola os dados no servidor \u2014 eles se misturam (co-mingling). Veja o JSDoc de NeetruDbOptions.dbId.'
|
|
3770
3790
|
)));
|
|
3771
3791
|
}
|
|
3772
|
-
function
|
|
3773
|
-
|
|
3792
|
+
function Jn(r, e = {}) {
|
|
3793
|
+
Xt(r, e);
|
|
3774
3794
|
let t;
|
|
3775
3795
|
e.transport !== void 0 ? t = e.transport : e.engine !== void 0 ? (console.warn(
|
|
3776
3796
|
'[neetru/sdk] NeetruDbOptions.engine est\xE1 depreciado e ser\xE1 removido em v3.0. Use NeetruDbOptions.transport em vez de engine. Valores v\xE1lidos: "rest" | "firestore" | "nosql-vm". Nota: "engine" no SDK configura o TRANSPORTE (REST/Firestore/WebSocket), n\xE3o o storage engine do admin database (firestore-instance, cloud-sql-postgres, \u2026).'
|
|
3777
3797
|
), t = e.engine) : t = "rest";
|
|
3778
|
-
let n =
|
|
3798
|
+
let n = Kt(t, e, r), o = e.dbId ?? "default", i = e.dbName ?? `neetru-db__${r.productId ?? "sdk"}__${o}__${r.env}`, s = null, a = null;
|
|
3779
3799
|
function c() {
|
|
3780
3800
|
return s || (s = we({
|
|
3781
3801
|
dbName: i,
|
|
@@ -3785,7 +3805,7 @@ function Hn(r, e = {}) {
|
|
|
3785
3805
|
}
|
|
3786
3806
|
return {
|
|
3787
3807
|
collection(l) {
|
|
3788
|
-
return a ? a.collection(l) :
|
|
3808
|
+
return a ? a.collection(l) : Jt(l, c);
|
|
3789
3809
|
},
|
|
3790
3810
|
async sql(l, d) {
|
|
3791
3811
|
if (r.env === "dev")
|
|
@@ -3793,7 +3813,7 @@ function Hn(r, e = {}) {
|
|
|
3793
3813
|
"db_unavailable",
|
|
3794
3814
|
"[SDK] db.sql() n\xE3o dispon\xEDvel em NEETRU_ENV=dev. Use `neetru dev` para subir o container Postgres local."
|
|
3795
3815
|
);
|
|
3796
|
-
return (await Promise.resolve().then(() => (
|
|
3816
|
+
return (await Promise.resolve().then(() => (Ge(), He))).createSqlClientFromConfig(r, l, d);
|
|
3797
3817
|
},
|
|
3798
3818
|
get syncState() {
|
|
3799
3819
|
return a?.syncState ?? {
|
|
@@ -3806,8 +3826,8 @@ function Hn(r, e = {}) {
|
|
|
3806
3826
|
onSyncStateChanged(l) {
|
|
3807
3827
|
if (a) return a.onSyncStateChanged(l);
|
|
3808
3828
|
let d = null, u = false;
|
|
3809
|
-
return c().then((
|
|
3810
|
-
u || (d =
|
|
3829
|
+
return c().then((p) => {
|
|
3830
|
+
u || (d = p.onSyncStateChanged(l));
|
|
3811
3831
|
}), () => {
|
|
3812
3832
|
u = true, d?.();
|
|
3813
3833
|
};
|
|
@@ -3824,15 +3844,15 @@ function Hn(r, e = {}) {
|
|
|
3824
3844
|
onError(l) {
|
|
3825
3845
|
if (a) return a.onError(l);
|
|
3826
3846
|
let d = null, u = false;
|
|
3827
|
-
return c().then((
|
|
3828
|
-
u || (d =
|
|
3847
|
+
return c().then((p) => {
|
|
3848
|
+
u || (d = p.onError(l));
|
|
3829
3849
|
}), () => {
|
|
3830
3850
|
u = true, d?.();
|
|
3831
3851
|
};
|
|
3832
3852
|
}
|
|
3833
3853
|
};
|
|
3834
3854
|
}
|
|
3835
|
-
function
|
|
3855
|
+
function Jt(r, e) {
|
|
3836
3856
|
async function t() {
|
|
3837
3857
|
return (await e()).collection(r);
|
|
3838
3858
|
}
|
|
@@ -3911,12 +3931,12 @@ function Ht(r, e) {
|
|
|
3911
3931
|
}
|
|
3912
3932
|
|
|
3913
3933
|
exports.NEETRU_SENTINEL_KEY = te;
|
|
3914
|
-
exports.__resetDbIdWarningForTests =
|
|
3915
|
-
exports.createNeetruDb =
|
|
3916
|
-
exports.createRestSyncTransport =
|
|
3917
|
-
exports.getWebSocketRealtimeClient =
|
|
3918
|
-
exports.increment =
|
|
3934
|
+
exports.__resetDbIdWarningForTests = Xn;
|
|
3935
|
+
exports.createNeetruDb = Jn;
|
|
3936
|
+
exports.createRestSyncTransport = Je;
|
|
3937
|
+
exports.getWebSocketRealtimeClient = Gn;
|
|
3938
|
+
exports.increment = at;
|
|
3919
3939
|
exports.isFieldSentinel = D;
|
|
3920
3940
|
exports.isIncrementSentinel = ge;
|
|
3921
3941
|
exports.isServerTimestampSentinel = ye;
|
|
3922
|
-
exports.serverTimestamp =
|
|
3942
|
+
exports.serverTimestamp = st;
|