@neetru/sdk 3.2.3 → 3.4.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.
- package/CHANGELOG.md +45 -0
- package/dist/ai.cjs +229 -7
- package/dist/ai.cjs.map +1 -1
- package/dist/ai.d.cts +1 -1
- package/dist/ai.d.ts +1 -1
- package/dist/ai.mjs +229 -7
- package/dist/ai.mjs.map +1 -1
- package/dist/auth.cjs +581 -18
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +1 -1
- package/dist/auth.d.ts +1 -1
- package/dist/auth.mjs +581 -18
- package/dist/auth.mjs.map +1 -1
- package/dist/catalog.cjs +19 -3
- package/dist/catalog.cjs.map +1 -1
- package/dist/catalog.d.cts +1 -1
- package/dist/catalog.d.ts +1 -1
- package/dist/catalog.mjs +19 -3
- package/dist/catalog.mjs.map +1 -1
- package/dist/checkout.cjs +19 -3
- package/dist/checkout.cjs.map +1 -1
- package/dist/checkout.d.cts +1 -1
- package/dist/checkout.d.ts +1 -1
- package/dist/checkout.mjs +19 -3
- package/dist/checkout.mjs.map +1 -1
- package/dist/db-react.d.cts +1 -1
- package/dist/db-react.d.ts +1 -1
- package/dist/db.cjs +193 -8
- package/dist/db.cjs.map +1 -1
- package/dist/db.d.cts +1 -1
- package/dist/db.d.ts +1 -1
- package/dist/db.mjs +193 -9
- package/dist/db.mjs.map +1 -1
- package/dist/entitlements.cjs +19 -3
- package/dist/entitlements.cjs.map +1 -1
- package/dist/entitlements.d.cts +1 -1
- package/dist/entitlements.d.ts +1 -1
- package/dist/entitlements.mjs +19 -3
- package/dist/entitlements.mjs.map +1 -1
- package/dist/errors.cjs +11 -1
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.cts +10 -1
- package/dist/errors.d.ts +10 -1
- package/dist/errors.mjs +11 -1
- package/dist/errors.mjs.map +1 -1
- package/dist/firestore-compat.d.cts +1 -1
- package/dist/firestore-compat.d.ts +1 -1
- package/dist/index.cjs +582 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +582 -19
- package/dist/index.mjs.map +1 -1
- package/dist/mocks.cjs +87 -4
- package/dist/mocks.cjs.map +1 -1
- package/dist/mocks.d.cts +19 -1
- package/dist/mocks.d.ts +19 -1
- package/dist/mocks.mjs +87 -4
- package/dist/mocks.mjs.map +1 -1
- package/dist/notifications.cjs +19 -3
- package/dist/notifications.cjs.map +1 -1
- package/dist/notifications.d.cts +1 -1
- package/dist/notifications.d.ts +1 -1
- package/dist/notifications.mjs +19 -3
- package/dist/notifications.mjs.map +1 -1
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/support.cjs +117 -4
- package/dist/support.cjs.map +1 -1
- package/dist/support.d.cts +1 -1
- package/dist/support.d.ts +1 -1
- package/dist/support.mjs +117 -4
- package/dist/support.mjs.map +1 -1
- package/dist/telemetry.cjs +19 -3
- package/dist/telemetry.cjs.map +1 -1
- package/dist/telemetry.d.cts +1 -1
- package/dist/telemetry.d.ts +1 -1
- package/dist/telemetry.mjs +19 -3
- package/dist/telemetry.mjs.map +1 -1
- package/dist/{types-PzHvWMbV.d.cts → types-BoFSCHF_.d.cts} +185 -6
- package/dist/{types-iLDjiqqk.d.ts → types-DdJyqBy-.d.ts} +185 -6
- package/dist/usage.cjs +19 -3
- package/dist/usage.cjs.map +1 -1
- package/dist/usage.d.cts +1 -1
- package/dist/usage.d.ts +1 -1
- package/dist/usage.mjs +19 -3
- package/dist/usage.mjs.map +1 -1
- package/dist/webhooks.cjs +19 -3
- package/dist/webhooks.cjs.map +1 -1
- package/dist/webhooks.d.cts +1 -1
- package/dist/webhooks.d.ts +1 -1
- package/dist/webhooks.mjs +19 -3
- package/dist/webhooks.mjs.map +1 -1
- package/package.json +1 -1
package/dist/db.cjs
CHANGED
|
@@ -20,12 +20,22 @@ var init_errors = __esm({
|
|
|
20
20
|
code;
|
|
21
21
|
status;
|
|
22
22
|
requestId;
|
|
23
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Motivo semântico opcional propagado pelo Core no corpo do erro (campo
|
|
25
|
+
* `reason` no TOPO do body, fora de `error`). Usado principalmente pelo 503
|
|
26
|
+
* de lease de DB, onde `reason` discrimina o estado do ambiente
|
|
27
|
+
* (`suspended` | `archived` | `revoked` | `provisioning` | `degraded` |
|
|
28
|
+
* `no_route` | `expired`). Camadas superiores (ex.: `db/sql`) mapeiam isso
|
|
29
|
+
* para um `NeetruDbErrorCode` mais específico (recuperável vs não).
|
|
30
|
+
*/
|
|
31
|
+
reason;
|
|
32
|
+
constructor(code, message, status, requestId, reason) {
|
|
24
33
|
super(message);
|
|
25
34
|
this.name = "NeetruError";
|
|
26
35
|
this.code = code;
|
|
27
36
|
this.status = status;
|
|
28
37
|
this.requestId = requestId;
|
|
38
|
+
this.reason = reason;
|
|
29
39
|
Object.setPrototypeOf(this, _NeetruError.prototype);
|
|
30
40
|
}
|
|
31
41
|
};
|
|
@@ -231,16 +241,22 @@ async function httpRequest(config, opts) {
|
|
|
231
241
|
const body = await safeJson(res);
|
|
232
242
|
let code = statusToCode(res.status);
|
|
233
243
|
let message = `HTTP ${res.status}`;
|
|
234
|
-
|
|
244
|
+
let reason;
|
|
245
|
+
if (body && typeof body === "object") {
|
|
235
246
|
const errField = body.error;
|
|
236
247
|
if (typeof errField === "string") {
|
|
237
248
|
message = errField;
|
|
238
249
|
} else if (errField && typeof errField === "object") {
|
|
239
250
|
if (typeof errField.code === "string") code = errField.code;
|
|
240
251
|
if (typeof errField.message === "string") message = errField.message;
|
|
252
|
+
if (typeof errField.reason === "string") reason = errField.reason;
|
|
253
|
+
} else {
|
|
254
|
+
if (typeof body.code === "string") code = body.code;
|
|
255
|
+
if (typeof body.message === "string") message = body.message;
|
|
241
256
|
}
|
|
257
|
+
if (typeof body.reason === "string") reason = body.reason;
|
|
242
258
|
}
|
|
243
|
-
const err = new NeetruError(code, message, res.status, requestId);
|
|
259
|
+
const err = new NeetruError(code, message, res.status, requestId, reason);
|
|
244
260
|
lastError = err;
|
|
245
261
|
const isRetryable = RETRYABLE_CODES2.has(code);
|
|
246
262
|
if (isRetryable && attempt < maxRetries) {
|
|
@@ -367,6 +383,7 @@ var init_resilient_pool = __esm({
|
|
|
367
383
|
|
|
368
384
|
// src/db/sql/lease.ts
|
|
369
385
|
function hasConnectionChanged(oldLease, newLease) {
|
|
386
|
+
if (!oldLease) return true;
|
|
370
387
|
return oldLease.leaseId !== newLease.leaseId || oldLease.credentialVersion !== newLease.credentialVersion || oldLease.host !== newLease.host || oldLease.port !== newLease.port || oldLease.dbName !== newLease.dbName || oldLease.user !== newLease.user || oldLease.password !== newLease.password || oldLease.sslca !== newLease.sslca || oldLease.clientCert !== newLease.clientCert || oldLease.clientKey !== newLease.clientKey;
|
|
371
388
|
}
|
|
372
389
|
function mapPoolError(err) {
|
|
@@ -398,6 +415,10 @@ var init_lease = __esm({
|
|
|
398
415
|
RENEWAL_THRESHOLD = 0.8;
|
|
399
416
|
MIN_RENEWAL_DELAY_MS = 3e4;
|
|
400
417
|
SqlLeaseManager = class {
|
|
418
|
+
/**
|
|
419
|
+
* Lease atual. `null` no modo LAZY antes da 1ª query (o 1º lease é adiado —
|
|
420
|
+
* ver `_ensureInitialLease`). Após a 1ª aquisição, sempre não-nulo.
|
|
421
|
+
*/
|
|
401
422
|
_lease;
|
|
402
423
|
_pool;
|
|
403
424
|
_orm;
|
|
@@ -409,6 +430,12 @@ var init_lease = __esm({
|
|
|
409
430
|
* `_reactiveReLease`.
|
|
410
431
|
*/
|
|
411
432
|
_reLeaseInFlight = null;
|
|
433
|
+
/**
|
|
434
|
+
* Promessa da aquisição do LEASE INICIAL em voo (modo lazy) — coalesce as
|
|
435
|
+
* N primeiras queries concorrentes num único fetch. `null` quando não há
|
|
436
|
+
* aquisição inicial pendente. Ver `_ensureInitialLease`.
|
|
437
|
+
*/
|
|
438
|
+
_initInFlight = null;
|
|
412
439
|
_deps;
|
|
413
440
|
constructor(lease, pool, orm, deps) {
|
|
414
441
|
this._lease = lease;
|
|
@@ -418,7 +445,7 @@ var init_lease = __esm({
|
|
|
418
445
|
...deps,
|
|
419
446
|
now: deps.now ?? (() => Date.now())
|
|
420
447
|
};
|
|
421
|
-
this._scheduleRenewal();
|
|
448
|
+
if (this._lease) this._scheduleRenewal();
|
|
422
449
|
}
|
|
423
450
|
// ─── Superfície pública (NeetruSqlClient) ──────────────────────────────────
|
|
424
451
|
get orm() {
|
|
@@ -456,6 +483,7 @@ var init_lease = __esm({
|
|
|
456
483
|
* usa `MIN_RENEWAL_DELAY_MS` como fallback seguro.
|
|
457
484
|
*/
|
|
458
485
|
_calcRenewalDelayMs() {
|
|
486
|
+
if (!this._lease) return MIN_RENEWAL_DELAY_MS;
|
|
459
487
|
const expiresAtMs = Date.parse(this._lease.expiresAt);
|
|
460
488
|
if (!Number.isFinite(expiresAtMs)) return MIN_RENEWAL_DELAY_MS;
|
|
461
489
|
const now = this._deps.now();
|
|
@@ -479,6 +507,8 @@ var init_lease = __esm({
|
|
|
479
507
|
}
|
|
480
508
|
async _doRenew() {
|
|
481
509
|
if (this._closed) return;
|
|
510
|
+
const currentLease = this._lease;
|
|
511
|
+
if (!currentLease) return;
|
|
482
512
|
try {
|
|
483
513
|
const withDb = (o) => {
|
|
484
514
|
if (this._deps.database !== void 0) o.database = this._deps.database;
|
|
@@ -486,7 +516,7 @@ var init_lease = __esm({
|
|
|
486
516
|
};
|
|
487
517
|
let newLease;
|
|
488
518
|
try {
|
|
489
|
-
newLease = await this._deps.fetchLease(withDb({ leaseId:
|
|
519
|
+
newLease = await this._deps.fetchLease(withDb({ leaseId: currentLease.leaseId }));
|
|
490
520
|
} catch (renewErr) {
|
|
491
521
|
newLease = await this._deps.fetchLease(withDb({}));
|
|
492
522
|
}
|
|
@@ -546,6 +576,71 @@ var init_lease = __esm({
|
|
|
546
576
|
this._reLeaseInFlight = null;
|
|
547
577
|
}
|
|
548
578
|
}
|
|
579
|
+
// ─── Lease INICIAL lazy (motor de ambientes suspenso) ──────────────────────
|
|
580
|
+
/**
|
|
581
|
+
* Adquire o LEASE INICIAL sob demanda (modo lazy). Chamado pelo pool "adiado"
|
|
582
|
+
* (`createDeferredPool`) na 1ª query/transação — nunca no boot do módulo.
|
|
583
|
+
*
|
|
584
|
+
* Fluxo:
|
|
585
|
+
* 1. Se já há lease (`_lease != null`), devolve o pool REAL interno vigente
|
|
586
|
+
* (idempotente — chamadas após a 1ª aquisição são no-op de fetch).
|
|
587
|
+
* 2. Busca o 1º lease no Core (com `database` se houver — contrato C-H).
|
|
588
|
+
* 3. Cria o pool REAL e faz o swap no wrapper resiliente (`__neetruSwapInner`)
|
|
589
|
+
* pra que as queries seguintes passem direto pelo pool real.
|
|
590
|
+
* 4. Agenda a renovação proativa (só a partir daqui — antes não havia lease).
|
|
591
|
+
*
|
|
592
|
+
* Coalesce concorrência: N primeiras queries compartilham UM único fetch
|
|
593
|
+
* (`_initInFlight`). Se a aquisição FALHA (ex.: ambiente suspenso →
|
|
594
|
+
* `db_suspended`, ou Core fora → `db_unavailable`), o erro propaga pra query
|
|
595
|
+
* que a disparou e `_initInFlight` é limpo — a PRÓXIMA query re-tenta (o
|
|
596
|
+
* ambiente pode ter voltado). NÃO derruba o processo nem o import do módulo.
|
|
597
|
+
*/
|
|
598
|
+
async _ensureInitialLease() {
|
|
599
|
+
if (this._closed) {
|
|
600
|
+
throw new exports.NeetruDbError(
|
|
601
|
+
"db_unavailable",
|
|
602
|
+
"SqlLeaseManager foi fechado \u2014 aquisi\xE7\xE3o de lease inicial abortada."
|
|
603
|
+
);
|
|
604
|
+
}
|
|
605
|
+
if (this._lease) {
|
|
606
|
+
return isResilientPool(this._pool) ? this._pool.__neetruGetInner() : this._pool;
|
|
607
|
+
}
|
|
608
|
+
if (this._initInFlight !== null) return this._initInFlight;
|
|
609
|
+
const run = (async () => {
|
|
610
|
+
let lease;
|
|
611
|
+
try {
|
|
612
|
+
lease = this._deps.database !== void 0 ? await this._deps.fetchLease({ database: this._deps.database }) : await this._deps.fetchLease();
|
|
613
|
+
} catch (err) {
|
|
614
|
+
if (err instanceof exports.NeetruDbError) throw err;
|
|
615
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
616
|
+
throw new exports.NeetruDbError("db_unavailable", `Falha ao obter lease inicial: ${msg}`);
|
|
617
|
+
}
|
|
618
|
+
let realPool;
|
|
619
|
+
try {
|
|
620
|
+
realPool = this._deps.createPool(lease);
|
|
621
|
+
} catch (err) {
|
|
622
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
623
|
+
throw new exports.NeetruDbError("db_unavailable", `Falha ao abrir pool: ${msg}`);
|
|
624
|
+
}
|
|
625
|
+
if (isResilientPool(this._pool)) {
|
|
626
|
+
const old = this._pool.__neetruSwapInner(realPool);
|
|
627
|
+
void old.end().catch(() => {
|
|
628
|
+
});
|
|
629
|
+
} else {
|
|
630
|
+
this._pool = realPool;
|
|
631
|
+
}
|
|
632
|
+
this._lease = lease;
|
|
633
|
+
this._scheduleRenewal();
|
|
634
|
+
return realPool;
|
|
635
|
+
})();
|
|
636
|
+
this._initInFlight = run;
|
|
637
|
+
try {
|
|
638
|
+
return await run;
|
|
639
|
+
} catch (err) {
|
|
640
|
+
this._initInFlight = null;
|
|
641
|
+
throw err;
|
|
642
|
+
}
|
|
643
|
+
}
|
|
549
644
|
/**
|
|
550
645
|
* Hot-swap do pool: cria pool novo, atualiza ponteiros, drena pool antigo.
|
|
551
646
|
*
|
|
@@ -629,10 +724,19 @@ function createHttpLeaseFetcher(config) {
|
|
|
629
724
|
retries: 2
|
|
630
725
|
});
|
|
631
726
|
} catch (err) {
|
|
727
|
+
const verb = isRenewal ? "renovar" : "obter";
|
|
632
728
|
const msg = err instanceof Error ? err.message : String(err);
|
|
729
|
+
const reason = err instanceof NeetruError ? err.reason : void 0;
|
|
730
|
+
if (reason === "suspended" || reason === "archived" || reason === "revoked") {
|
|
731
|
+
const human = reason === "suspended" ? "ambiente suspenso \u2014 a m\xE1quina que o servia parou; ser\xE1 religado quando o ambiente voltar" : reason === "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";
|
|
732
|
+
throw new exports.NeetruDbError(
|
|
733
|
+
"db_suspended",
|
|
734
|
+
`Falha ao ${verb} lease SQL: ${human} (reason=${reason}).`
|
|
735
|
+
);
|
|
736
|
+
}
|
|
633
737
|
throw new exports.NeetruDbError(
|
|
634
738
|
"db_unavailable",
|
|
635
|
-
`Falha ao ${
|
|
739
|
+
`Falha ao ${verb} lease SQL: ${msg}`
|
|
636
740
|
);
|
|
637
741
|
}
|
|
638
742
|
return parseLease(raw);
|
|
@@ -704,8 +808,64 @@ async function createDrizzleHandle(pool, schema) {
|
|
|
704
808
|
);
|
|
705
809
|
return drizzle(pool, { schema });
|
|
706
810
|
}
|
|
811
|
+
function createDeferredPool(poolPrototype, ensureRealPool) {
|
|
812
|
+
let real = null;
|
|
813
|
+
let inflight = null;
|
|
814
|
+
const getReal = () => {
|
|
815
|
+
if (real) return Promise.resolve(real);
|
|
816
|
+
if (!inflight) {
|
|
817
|
+
inflight = ensureRealPool().then((p) => {
|
|
818
|
+
real = p;
|
|
819
|
+
inflight = null;
|
|
820
|
+
return p;
|
|
821
|
+
}).catch((e) => {
|
|
822
|
+
inflight = null;
|
|
823
|
+
throw e;
|
|
824
|
+
});
|
|
825
|
+
}
|
|
826
|
+
return inflight;
|
|
827
|
+
};
|
|
828
|
+
const deferred = {
|
|
829
|
+
async query(...args) {
|
|
830
|
+
const p = await getReal();
|
|
831
|
+
return p.query(...args);
|
|
832
|
+
},
|
|
833
|
+
async connect(...args) {
|
|
834
|
+
const p = await getReal();
|
|
835
|
+
return p.connect(...args);
|
|
836
|
+
},
|
|
837
|
+
async end() {
|
|
838
|
+
if (real) await real.end();
|
|
839
|
+
}
|
|
840
|
+
};
|
|
841
|
+
if (poolPrototype) {
|
|
842
|
+
Object.setPrototypeOf(deferred, poolPrototype);
|
|
843
|
+
}
|
|
844
|
+
return deferred;
|
|
845
|
+
}
|
|
707
846
|
async function createSqlClientWithDeps(deps, options) {
|
|
708
847
|
const depsWithDb = options?.database !== void 0 ? { ...deps, database: options.database } : deps;
|
|
848
|
+
if (depsWithDb.lazy) {
|
|
849
|
+
let managerRef = null;
|
|
850
|
+
const deferred = createDeferredPool(depsWithDb.poolPrototype ?? null, () => {
|
|
851
|
+
if (!managerRef) {
|
|
852
|
+
throw new exports.NeetruDbError("db_unavailable", "SQL client n\xE3o inicializado (manager ausente).");
|
|
853
|
+
}
|
|
854
|
+
return managerRef._ensureInitialLease();
|
|
855
|
+
});
|
|
856
|
+
const pool2 = createResilientPool(deferred);
|
|
857
|
+
let orm2;
|
|
858
|
+
try {
|
|
859
|
+
orm2 = depsWithDb.createDrizzle(pool2, depsWithDb.schema);
|
|
860
|
+
} catch (err) {
|
|
861
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
862
|
+
throw new exports.NeetruDbError("db_unavailable", `Falha ao criar handle Drizzle: ${msg}`);
|
|
863
|
+
}
|
|
864
|
+
const manager2 = new SqlLeaseManager(null, pool2, orm2, depsWithDb);
|
|
865
|
+
managerRef = manager2;
|
|
866
|
+
pool2.__neetruSetReLease(() => manager2._reactiveReLease());
|
|
867
|
+
return manager2;
|
|
868
|
+
}
|
|
709
869
|
let lease;
|
|
710
870
|
try {
|
|
711
871
|
if (options?.database !== void 0) {
|
|
@@ -758,8 +918,8 @@ async function createSqlClientFromConfig(config, schema, options) {
|
|
|
758
918
|
`[client.db.sql] requer pg + drizzle-orm como peerDependencies do servidor. Instale: npm install pg drizzle-orm. (${err.message})`
|
|
759
919
|
);
|
|
760
920
|
}
|
|
921
|
+
const Pool = pgMod.Pool ?? pgMod.default?.Pool;
|
|
761
922
|
const createPool = (lease) => {
|
|
762
|
-
const Pool = pgMod.Pool ?? pgMod.default?.Pool;
|
|
763
923
|
const ssl = lease.sslca ? {
|
|
764
924
|
ca: lease.sslca,
|
|
765
925
|
cert: lease.clientCert ?? void 0,
|
|
@@ -786,7 +946,14 @@ async function createSqlClientFromConfig(config, schema, options) {
|
|
|
786
946
|
fetchLease,
|
|
787
947
|
createPool,
|
|
788
948
|
createDrizzle,
|
|
789
|
-
schema
|
|
949
|
+
schema,
|
|
950
|
+
// Lease inicial LAZY (motor de ambientes suspenso): `client.db.sql()` não
|
|
951
|
+
// pode explodir o `import` do módulo do produto quando o ambiente está
|
|
952
|
+
// suspenso/arquivado no boot. O 1º lease é adiado pra 1ª query.
|
|
953
|
+
lazy: true,
|
|
954
|
+
// Placeholder pré-1ª-query herda `pg.Pool.prototype` pra `instanceof Pool`
|
|
955
|
+
// valer no wrapper resiliente (transações Drizzle PASS-THROUGH seguras).
|
|
956
|
+
poolPrototype: Pool?.prototype ?? null
|
|
790
957
|
},
|
|
791
958
|
options
|
|
792
959
|
);
|
|
@@ -795,6 +962,7 @@ var LEASE_ENDPOINT, LEASE_RENEW_ENDPOINT;
|
|
|
795
962
|
var init_sql_client = __esm({
|
|
796
963
|
"src/db/sql/sql-client.ts"() {
|
|
797
964
|
init_db_errors();
|
|
965
|
+
init_errors();
|
|
798
966
|
init_lease();
|
|
799
967
|
init_resilient_pool();
|
|
800
968
|
LEASE_ENDPOINT = "/api/sdk/v1/db/lease";
|
|
@@ -4233,7 +4401,23 @@ function buildTicketProvider(config, opts) {
|
|
|
4233
4401
|
function getWebSocketRealtimeClient(gatewayUrl, ticketProvider, dbId, wsFactory) {
|
|
4234
4402
|
return new NeetruRealtimeClient({ gatewayUrl, ticketProvider, dbId, webSocketFactory: wsFactory });
|
|
4235
4403
|
}
|
|
4404
|
+
var _hasWarnedMissingDbId = false;
|
|
4405
|
+
function __resetDbIdWarningForTests() {
|
|
4406
|
+
_hasWarnedMissingDbId = false;
|
|
4407
|
+
}
|
|
4408
|
+
function warnMissingDbIdOnce(config, dbOpts) {
|
|
4409
|
+
if (_hasWarnedMissingDbId) return;
|
|
4410
|
+
if (dbOpts.dbId) return;
|
|
4411
|
+
if (config.env === "prod") return;
|
|
4412
|
+
if (typeof window === "undefined") return;
|
|
4413
|
+
if (typeof console === "undefined" || typeof console.warn !== "function") return;
|
|
4414
|
+
_hasWarnedMissingDbId = true;
|
|
4415
|
+
console.warn(
|
|
4416
|
+
"[neetru/sdk] client.db sem `dbId` expl\xEDcito: escritas client-side (add/set/update/remove/list) caem no datastore gen\xE9rico do Core, escopado por tenant/produto (header x-neetru-tenant) \u2014 `dbId` s\xF3 nomeia o cache offline LOCAL (IndexedDB), n\xE3o roteia nem escopa nada no servidor. Veja o JSDoc de NeetruDbOptions.dbId."
|
|
4417
|
+
);
|
|
4418
|
+
}
|
|
4236
4419
|
function createNeetruDb(config, dbOpts = {}) {
|
|
4420
|
+
warnMissingDbIdOnce(config, dbOpts);
|
|
4237
4421
|
let resolvedTransport;
|
|
4238
4422
|
if (dbOpts.transport !== void 0) {
|
|
4239
4423
|
resolvedTransport = dbOpts.transport;
|
|
@@ -4409,6 +4593,7 @@ function createLazyCollectionRef(name, getDocsPromise) {
|
|
|
4409
4593
|
}
|
|
4410
4594
|
|
|
4411
4595
|
exports.NEETRU_SENTINEL_KEY = NEETRU_SENTINEL_KEY;
|
|
4596
|
+
exports.__resetDbIdWarningForTests = __resetDbIdWarningForTests;
|
|
4412
4597
|
exports.createNeetruDb = createNeetruDb;
|
|
4413
4598
|
exports.createRestSyncTransport = createRestSyncTransport;
|
|
4414
4599
|
exports.getWebSocketRealtimeClient = getWebSocketRealtimeClient;
|