@neetru/sdk 3.4.0 → 3.4.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 +18 -0
- package/dist/ai.d.cts +1 -1
- package/dist/ai.d.ts +1 -1
- package/dist/auth.cjs +193 -30
- 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 +193 -30
- package/dist/auth.mjs.map +1 -1
- package/dist/catalog.d.cts +1 -1
- package/dist/catalog.d.ts +1 -1
- package/dist/checkout.d.cts +1 -1
- package/dist/checkout.d.ts +1 -1
- package/dist/db-react.d.cts +1 -1
- package/dist/db-react.d.ts +1 -1
- package/dist/db.cjs +193 -30
- 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 -30
- package/dist/db.mjs.map +1 -1
- 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 +194 -31
- 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 +194 -31
- package/dist/index.mjs.map +1 -1
- package/dist/mocks.d.cts +1 -1
- package/dist/mocks.d.ts +1 -1
- package/dist/notifications.d.cts +1 -1
- package/dist/notifications.d.ts +1 -1
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/support.d.cts +1 -1
- package/dist/support.d.ts +1 -1
- package/dist/telemetry.d.cts +1 -1
- package/dist/telemetry.d.ts +1 -1
- package/dist/{types-DdJyqBy-.d.ts → types-BlOLDMR0.d.ts} +79 -6
- package/dist/{types-BoFSCHF_.d.cts → types-D-QdG502.d.cts} +79 -6
- package/dist/usage.d.cts +1 -1
- package/dist/usage.d.ts +1 -1
- package/dist/webhooks.d.cts +1 -1
- package/dist/webhooks.d.ts +1 -1
- package/package.json +1 -1
package/dist/mocks.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a5 as NeetruUser, g as AiNamespace, b as AiChatOptions, c as AiChatResult, i as AiStreamHandle, l as AuthNamespace, aj as SignInOptions, m as AuthStateListener, ae as RedirectCallbackResult, v as CompleteSignInResult, Y as NeetruDb, E as DbCollectionRef, a4 as NeetruSqlClient,
|
|
1
|
+
import { a5 as NeetruUser, g as AiNamespace, b as AiChatOptions, c as AiChatResult, i as AiStreamHandle, l as AuthNamespace, aj as SignInOptions, m as AuthStateListener, ae as RedirectCallbackResult, v as CompleteSignInResult, Y as NeetruDb, E as DbCollectionRef, a4 as NeetruSqlClient, aq as SyncState, av as Unsubscribe, w as ConflictRecord, O as EntitlementCheck, al as SupportNamespace, y as CreateTicketInput, ao as SupportTicket, ax as UsageNamespace, ay as UsageQuota } from './types-D-QdG502.cjs';
|
|
2
2
|
import 'drizzle-orm/node-postgres';
|
|
3
3
|
import './errors.cjs';
|
|
4
4
|
|
package/dist/mocks.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a5 as NeetruUser, g as AiNamespace, b as AiChatOptions, c as AiChatResult, i as AiStreamHandle, l as AuthNamespace, aj as SignInOptions, m as AuthStateListener, ae as RedirectCallbackResult, v as CompleteSignInResult, Y as NeetruDb, E as DbCollectionRef, a4 as NeetruSqlClient,
|
|
1
|
+
import { a5 as NeetruUser, g as AiNamespace, b as AiChatOptions, c as AiChatResult, i as AiStreamHandle, l as AuthNamespace, aj as SignInOptions, m as AuthStateListener, ae as RedirectCallbackResult, v as CompleteSignInResult, Y as NeetruDb, E as DbCollectionRef, a4 as NeetruSqlClient, aq as SyncState, av as Unsubscribe, w as ConflictRecord, O as EntitlementCheck, al as SupportNamespace, y as CreateTicketInput, ao as SupportTicket, ax as UsageNamespace, ay as UsageQuota } from './types-BlOLDMR0.js';
|
|
2
2
|
import 'drizzle-orm/node-postgres';
|
|
3
3
|
import './errors.js';
|
|
4
4
|
|
package/dist/notifications.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { R as ListNotificationsOptions, T as MockNotifications, a6 as NotificationScopeOptions, a7 as NotificationsNamespace, a9 as ProductNotification, aa as ProductNotificationSeverity, ah as SendNotificationInput,
|
|
1
|
+
export { R as ListNotificationsOptions, T as MockNotifications, a6 as NotificationScopeOptions, a7 as NotificationsNamespace, a9 as ProductNotification, aa as ProductNotificationSeverity, ah as SendNotificationInput, aM as createNotificationsNamespace } from './types-D-QdG502.cjs';
|
|
2
2
|
import 'drizzle-orm/node-postgres';
|
|
3
3
|
import './errors.cjs';
|
package/dist/notifications.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { R as ListNotificationsOptions, T as MockNotifications, a6 as NotificationScopeOptions, a7 as NotificationsNamespace, a9 as ProductNotification, aa as ProductNotificationSeverity, ah as SendNotificationInput,
|
|
1
|
+
export { R as ListNotificationsOptions, T as MockNotifications, a6 as NotificationScopeOptions, a7 as NotificationsNamespace, a9 as ProductNotification, aa as ProductNotificationSeverity, ah as SendNotificationInput, aM as createNotificationsNamespace } from './types-BlOLDMR0.js';
|
|
2
2
|
import 'drizzle-orm/node-postgres';
|
|
3
3
|
import './errors.js';
|
package/dist/react.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { W as NeetruClient, t as CheckoutStartResult, l as AuthNamespace, a5 as NeetruUser } from './types-
|
|
2
|
+
import { W as NeetruClient, t as CheckoutStartResult, l as AuthNamespace, a5 as NeetruUser } from './types-D-QdG502.cjs';
|
|
3
3
|
import { CollectionReference, Query, DocumentReference } from './firestore-compat.cjs';
|
|
4
4
|
import 'drizzle-orm/node-postgres';
|
|
5
5
|
import './errors.cjs';
|
package/dist/react.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { W as NeetruClient, t as CheckoutStartResult, l as AuthNamespace, a5 as NeetruUser } from './types-
|
|
2
|
+
import { W as NeetruClient, t as CheckoutStartResult, l as AuthNamespace, a5 as NeetruUser } from './types-BlOLDMR0.js';
|
|
3
3
|
import { CollectionReference, Query, DocumentReference } from './firestore-compat.js';
|
|
4
4
|
import 'drizzle-orm/node-postgres';
|
|
5
5
|
import './errors.js';
|
package/dist/support.d.cts
CHANGED
package/dist/support.d.ts
CHANGED
package/dist/telemetry.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ag as ResolvedConfig,
|
|
1
|
+
import { ag as ResolvedConfig, as as TelemetryEventInput, ar as TelemetryEventAck, au as TelemetryLogInput, at as TelemetryLogAck } from './types-D-QdG502.cjs';
|
|
2
2
|
import 'drizzle-orm/node-postgres';
|
|
3
3
|
import './errors.cjs';
|
|
4
4
|
|
package/dist/telemetry.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ag as ResolvedConfig,
|
|
1
|
+
import { ag as ResolvedConfig, as as TelemetryEventInput, ar as TelemetryEventAck, au as TelemetryLogInput, at as TelemetryLogAck } from './types-BlOLDMR0.js';
|
|
2
2
|
import 'drizzle-orm/node-postgres';
|
|
3
3
|
import './errors.js';
|
|
4
4
|
|
|
@@ -531,6 +531,12 @@ interface Mutation {
|
|
|
531
531
|
attempts: number;
|
|
532
532
|
/** Último erro de replay (string). `null` se nenhuma tentativa ainda. */
|
|
533
533
|
lastError: string | null;
|
|
534
|
+
/**
|
|
535
|
+
* Epoch ms da ÚLTIMA tentativa real de envio (falha transiente).
|
|
536
|
+
* `undefined` se nunca foi tentada. Base do backoff exponencial keyed em
|
|
537
|
+
* `attempts` do SyncEngine — evita marretar o Core com uma mutação-veneno.
|
|
538
|
+
*/
|
|
539
|
+
lastAttemptAt?: number;
|
|
534
540
|
/** Estado de envio desta mutação. */
|
|
535
541
|
status: 'queued' | 'inflight' | 'failed';
|
|
536
542
|
/** Agrupa mutações de um `batch()` atômico. `null` se mutação individual. */
|
|
@@ -546,7 +552,14 @@ interface Mutation {
|
|
|
546
552
|
/**
|
|
547
553
|
* Razão pela qual uma escrita foi descartada no LWW (I3 §3.3 `conflict_log`).
|
|
548
554
|
*/
|
|
549
|
-
type ConflictReason = 'lww_server_newer' | 'rejected_permission' | 'rejected_validation'
|
|
555
|
+
type ConflictReason = 'lww_server_newer' | 'rejected_permission' | 'rejected_validation'
|
|
556
|
+
/**
|
|
557
|
+
* Dead-letter: a mutação esgotou o teto de tentativas de replay (5xx/timeout
|
|
558
|
+
* persistente) e foi descartada da fila para não travar o FIFO de todas as
|
|
559
|
+
* coleções (head-of-line block). `winningData` fica vazio — o servidor nunca
|
|
560
|
+
* aceitou a escrita. A escrita LOCAL otimista pode ter sido revertida.
|
|
561
|
+
*/
|
|
562
|
+
| 'failed_max_attempts';
|
|
550
563
|
/**
|
|
551
564
|
* Registro de uma escrita perdedora — gravado no `conflict_log` (I3 §3.3).
|
|
552
565
|
* Entregue ao produto via `onWriteResult` (status: `'superseded'`).
|
|
@@ -577,6 +590,13 @@ interface SyncState {
|
|
|
577
590
|
pendingWrites: number;
|
|
578
591
|
lastSyncedAt: number | null;
|
|
579
592
|
isLeaderTab: boolean;
|
|
593
|
+
/**
|
|
594
|
+
* Diagnóstico do ÚLTIMO ciclo de sync que falhou (push/pull/resync ou
|
|
595
|
+
* dead-letter de uma mutação-veneno). `null`/`undefined` = último ciclo OK.
|
|
596
|
+
* Reset a cada ciclo bem-sucedido. Antes disso a falha era engolida em
|
|
597
|
+
* silêncio — agora o produto pode reagir via `onSyncStateChanged`/`onError`.
|
|
598
|
+
*/
|
|
599
|
+
lastError?: string | null;
|
|
580
600
|
}
|
|
581
601
|
/** Função para cancelar uma subscrição (onSnapshot, onDoc, onSyncStateChanged). */
|
|
582
602
|
type Unsubscribe = () => void;
|
|
@@ -616,6 +636,15 @@ type Unsubscribe = () => void;
|
|
|
616
636
|
* de adaptação, não aqui. Isso torna o SyncEngine 100% testável com fake.
|
|
617
637
|
*/
|
|
618
638
|
|
|
639
|
+
/** Diagnóstico entregue ao hook `onError` do SyncEngine. */
|
|
640
|
+
interface SyncErrorEvent {
|
|
641
|
+
/** Fase onde o ciclo falhou. */
|
|
642
|
+
phase: 'push' | 'pull' | 'resync' | 'cycle';
|
|
643
|
+
/** Mensagem legível. */
|
|
644
|
+
message: string;
|
|
645
|
+
/** Epoch ms. */
|
|
646
|
+
at: number;
|
|
647
|
+
}
|
|
619
648
|
/**
|
|
620
649
|
* Documento retornado pelo servidor em push/pull/resync.
|
|
621
650
|
*/
|
|
@@ -664,6 +693,15 @@ interface PullChangesResult {
|
|
|
664
693
|
interface FullResyncResult {
|
|
665
694
|
docs: ServerDoc[];
|
|
666
695
|
newWatermark: number | null;
|
|
696
|
+
/**
|
|
697
|
+
* Coleções cujo resultado bateu no teto de paginação do transporte (o REST
|
|
698
|
+
* Documentos devolve no MÁXIMO 200 docs/coleção — paginação por cursor é
|
|
699
|
+
* tarefa Core, gated). Para essas coleções o conjunto veio TRUNCADO: o
|
|
700
|
+
* SyncEngine (a) NÃO roda detecção-de-deleção-por-ausência (senão docs além
|
|
701
|
+
* do teto virariam tombstone por engano) e (b) persiste o sinal para
|
|
702
|
+
* `DbListResult.truncated`. Transportes sem teto (realtime) omitem o campo.
|
|
703
|
+
*/
|
|
704
|
+
truncatedCollections?: string[];
|
|
667
705
|
}
|
|
668
706
|
/**
|
|
669
707
|
* Contrato do transporte de sync — injetado no SyncEngine.
|
|
@@ -949,6 +987,15 @@ interface DbListResult<T = Record<string, unknown>> {
|
|
|
949
987
|
type: 'added' | 'modified' | 'removed';
|
|
950
988
|
doc: DbDoc<T>;
|
|
951
989
|
}>;
|
|
990
|
+
/**
|
|
991
|
+
* `true` quando o último full-resync desta coleção bateu no TETO de 200 docs
|
|
992
|
+
* do transporte REST Documentos (ver `list()`): o cache local pode estar
|
|
993
|
+
* INCOMPLETO — existem mais docs no servidor além dos 200 baixados. Também
|
|
994
|
+
* força `stale: true`. Paginação por cursor > 200 exige mudança no Core
|
|
995
|
+
* (gated), então por ora o SDK apenas SINALIZA. `undefined`/`false` = sem
|
|
996
|
+
* truncamento conhecido (ou transporte sem teto, ex.: realtime).
|
|
997
|
+
*/
|
|
998
|
+
truncated?: boolean;
|
|
952
999
|
}
|
|
953
1000
|
interface DbGetResult<T = Record<string, unknown>> {
|
|
954
1001
|
docs: Array<DbDoc<T>>;
|
|
@@ -1053,7 +1100,18 @@ interface DbDocRef<T = Record<string, unknown>> {
|
|
|
1053
1100
|
interface DbCollectionRef$1<T = Record<string, unknown>> {
|
|
1054
1101
|
/** Retorna snapshot de um documento. `null` se não existir (nem no cache). */
|
|
1055
1102
|
get(id: string): Promise<DbGetResult<T> | null>;
|
|
1056
|
-
/**
|
|
1103
|
+
/**
|
|
1104
|
+
* Lista documentos com query opcional.
|
|
1105
|
+
*
|
|
1106
|
+
* **TETO DE 200 DOCS (transporte REST Documentos).** O reconciliador offline
|
|
1107
|
+
* baixa NO MÁXIMO 200 docs por coleção do Core em cada full-resync — o
|
|
1108
|
+
* endpoint REST não expõe paginação por cursor server-side (é tarefa Core,
|
|
1109
|
+
* gated). Se a coleção tem mais de 200 docs no servidor, o cache local fica
|
|
1110
|
+
* INCOMPLETO e `DbListResult.truncated === true` (+ `stale: true`). O
|
|
1111
|
+
* `q.limit`/`nextCursor` paginam apenas sobre o que já está no CACHE LOCAL,
|
|
1112
|
+
* não sobre o servidor. Para coleções grandes, filtre por `where` no Core ou
|
|
1113
|
+
* modele os dados para caber sob o teto até a paginação server-side existir.
|
|
1114
|
+
*/
|
|
1057
1115
|
list(q?: DbQuery$1): Promise<DbListResult<T>>;
|
|
1058
1116
|
/** Adiciona doc com id gerado pelo cliente (UUID v4). Durável localmente. */
|
|
1059
1117
|
add(data: WithFieldSentinels<Omit<T, 'id'>>): Promise<{
|
|
@@ -1112,6 +1170,13 @@ interface NeetruDbDocuments {
|
|
|
1112
1170
|
* já avançou a versão do documento (Last-Write-Wins).
|
|
1113
1171
|
*/
|
|
1114
1172
|
getConflicts(): Promise<ConflictRecord[]>;
|
|
1173
|
+
/**
|
|
1174
|
+
* Subscreve a erros de ciclo de sync (P2-C) — falha inesperada nas fases ou
|
|
1175
|
+
* dead-letter de uma mutação-veneno que antes eram engolidos em silêncio. O
|
|
1176
|
+
* mesmo diagnóstico também aparece em `syncState.lastError`. Retorna
|
|
1177
|
+
* uma função de unsubscribe.
|
|
1178
|
+
*/
|
|
1179
|
+
onError(cb: (err: SyncErrorEvent) => void): Unsubscribe;
|
|
1115
1180
|
}
|
|
1116
1181
|
interface CreateOfflineDocumentsOptions {
|
|
1117
1182
|
/**
|
|
@@ -1649,8 +1714,9 @@ interface NeetruDbOptions {
|
|
|
1649
1714
|
*
|
|
1650
1715
|
* Se o produto precisa de bancos logicamente separados no **servidor**,
|
|
1651
1716
|
* isso é uma decisão server-side (tenant/produto ou schema do Core), não
|
|
1652
|
-
* `dbId`.
|
|
1653
|
-
* console (dev-only)
|
|
1717
|
+
* `dbId`. PASSAR `dbId` em contexto browser dispara um aviso único no
|
|
1718
|
+
* console (dev-only): usar dbIds distintos no mesmo tenant/produto NÃO isola
|
|
1719
|
+
* os dados no servidor (co-mingling) — a falsa sensação de isolamento é a mina.
|
|
1654
1720
|
*/
|
|
1655
1721
|
dbId?: string;
|
|
1656
1722
|
/**
|
|
@@ -1790,6 +1856,13 @@ interface NeetruDb {
|
|
|
1790
1856
|
* Permite ao produto inspecionar escritas perdidas.
|
|
1791
1857
|
*/
|
|
1792
1858
|
getConflicts(): Promise<ConflictRecord[]>;
|
|
1859
|
+
/**
|
|
1860
|
+
* (Opcional) Subscreve a erros de ciclo de sync (P2-C) — falha inesperada nas
|
|
1861
|
+
* fases ou dead-letter de uma mutação-veneno que antes eram engolidos em
|
|
1862
|
+
* silêncio. O mesmo diagnóstico também aparece em `syncState.lastError`.
|
|
1863
|
+
* Retorna uma função de unsubscribe. Ausente em implementações mock.
|
|
1864
|
+
*/
|
|
1865
|
+
onError?(cb: (err: SyncErrorEvent) => void): Unsubscribe;
|
|
1793
1866
|
}
|
|
1794
1867
|
/**
|
|
1795
1868
|
* Transporte REST puro — usa os endpoints `/api/sdk/v1/datastore/*` do Core.
|
|
@@ -1818,7 +1891,7 @@ declare function createRestSyncTransport(config?: ResolvedConfig): RealtimeTrans
|
|
|
1818
1891
|
* @param wsFactory Factory de WebSocket injetável (testes).
|
|
1819
1892
|
*/
|
|
1820
1893
|
declare function getWebSocketRealtimeClient(gatewayUrl: string, ticketProvider: TicketProvider, dbId?: string, wsFactory?: WebSocketFactory): NeetruRealtimeClient;
|
|
1821
|
-
/** @internal Reseta o guard one-time do aviso de `dbId`
|
|
1894
|
+
/** @internal Reseta o guard one-time do aviso de `dbId` — uso exclusivo de testes. */
|
|
1822
1895
|
declare function __resetDbIdWarningForTests(): void;
|
|
1823
1896
|
/**
|
|
1824
1897
|
* Cria o namespace `client.db` completo.
|
|
@@ -2573,4 +2646,4 @@ interface CatalogListOptions {
|
|
|
2573
2646
|
includeDrafts?: boolean;
|
|
2574
2647
|
}
|
|
2575
2648
|
|
|
2576
|
-
export { NeetruDbError as $, type AiChatChoice as A, type DbChangeType as B, type CatalogListOptions as C, DEFAULT_BASE_URL as D, type DbCollectionRef$1 as E, type DbDoc as F, type DbDocRef as G, type DbGetResult as H, type DbListResult as I, type DbNamespace as J, type DbQuery$1 as K, type DbSqlLease as L, type DbWhereFilter as M, type DbWhereFilter$1 as N, type EntitlementCheck as O, type FieldSentinel as P, type IncrementSentinel as Q, type ListNotificationsOptions as R, MockCheckout as S, MockNotifications as T, MockWebhooks as U, NEETRU_SENTINEL_KEY as V, type NeetruClient as W, type NeetruClientConfig as X, type NeetruDb as Y, type NeetruDbDocuments as Z, type NeetruDbEngine as _, type AiChatMessage as a, type NeetruDbErrorCode as a0, type NeetruDbOptions as a1, type NeetruDbTransport as a2, type NeetruEnv as a3, type NeetruSqlClient as a4, type NeetruUser as a5, type NotificationScopeOptions as a6, type NotificationsNamespace as a7, type Product as a8, type ProductNotification as a9, type
|
|
2649
|
+
export { NeetruDbError as $, type AiChatChoice as A, type DbChangeType as B, type CatalogListOptions as C, DEFAULT_BASE_URL as D, type DbCollectionRef$1 as E, type DbDoc as F, type DbDocRef as G, type DbGetResult as H, type DbListResult as I, type DbNamespace as J, type DbQuery$1 as K, type DbSqlLease as L, type DbWhereFilter as M, type DbWhereFilter$1 as N, type EntitlementCheck as O, type FieldSentinel as P, type IncrementSentinel as Q, type ListNotificationsOptions as R, MockCheckout as S, MockNotifications as T, MockWebhooks as U, NEETRU_SENTINEL_KEY as V, type NeetruClient as W, type NeetruClientConfig as X, type NeetruDb as Y, type NeetruDbDocuments as Z, type NeetruDbEngine as _, type AiChatMessage as a, type NeetruDbErrorCode as a0, type NeetruDbOptions as a1, type NeetruDbTransport as a2, type NeetruEnv as a3, type NeetruSqlClient as a4, type NeetruUser as a5, type NotificationScopeOptions as a6, type NotificationsNamespace as a7, type Product as a8, type ProductNotification as a9, type VerifyWebhookRequestOptions as aA, type VerifyWebhookRequestResult as aB, type WebhookEndpoint as aC, type WebhookEvent as aD, type WebhookScopeOptions as aE, type WebhookTestResult as aF, type WebhooksNamespace as aG, type WithFieldSentinels as aH, __resetDbIdWarningForTests as aI, createAiNamespace as aJ, createCheckoutNamespace as aK, createNeetruDb as aL, createNotificationsNamespace as aM, createRestSyncTransport as aN, createWebhooksNamespace as aO, getWebSocketRealtimeClient as aP, increment as aQ, isFieldSentinel as aR, isIncrementSentinel as aS, isServerTimestampSentinel as aT, serverTimestamp as aU, verifyWebhookRequest as aV, verifyWebhookSignature as aW, type ProductNotificationSeverity as aa, type ProductPlan as ab, type ProductStatus as ac, type RealtimeTransport as ad, type RedirectCallbackResult as ae, type RegisterWebhookInput as af, type ResolvedConfig as ag, type SendNotificationInput as ah, type ServerTimestampSentinel as ai, type SignInOptions as aj, type SqlOptions as ak, type SupportNamespace as al, type SupportSeverity as am, type SupportStatus as an, type SupportTicket as ao, type SyncErrorEvent as ap, type SyncState as aq, type TelemetryEventAck as ar, type TelemetryEventInput as as, type TelemetryLogAck as at, type TelemetryLogInput as au, type Unsubscribe as av, type UsageEventInput as aw, type UsageNamespace as ax, type UsageQuota as ay, type VerifyTokenOptions as az, type AiChatOptions as b, type AiChatResult as c, type AiChatUsage as d, type AiContentPart as e, type AiImageUrlPart as f, type AiNamespace as g, type AiResponseFormat as h, type AiStreamHandle as i, type AiStreamMeta as j, type AiTextPart as k, type AuthNamespace as l, type AuthStateListener as m, type CatalogListResponse as n, type CheckoutAuthOpts as o, type CheckoutIntentInfo as p, type CheckoutIntentStatus as q, type CheckoutNamespace as r, type CheckoutStartInput as s, type CheckoutStartResult as t, type CheckoutTenantType as u, type CompleteSignInResult as v, type ConflictRecord as w, type CreateOfflineDocumentsOptions as x, type CreateTicketInput as y, type DbBatchOp as z };
|
|
@@ -531,6 +531,12 @@ interface Mutation {
|
|
|
531
531
|
attempts: number;
|
|
532
532
|
/** Último erro de replay (string). `null` se nenhuma tentativa ainda. */
|
|
533
533
|
lastError: string | null;
|
|
534
|
+
/**
|
|
535
|
+
* Epoch ms da ÚLTIMA tentativa real de envio (falha transiente).
|
|
536
|
+
* `undefined` se nunca foi tentada. Base do backoff exponencial keyed em
|
|
537
|
+
* `attempts` do SyncEngine — evita marretar o Core com uma mutação-veneno.
|
|
538
|
+
*/
|
|
539
|
+
lastAttemptAt?: number;
|
|
534
540
|
/** Estado de envio desta mutação. */
|
|
535
541
|
status: 'queued' | 'inflight' | 'failed';
|
|
536
542
|
/** Agrupa mutações de um `batch()` atômico. `null` se mutação individual. */
|
|
@@ -546,7 +552,14 @@ interface Mutation {
|
|
|
546
552
|
/**
|
|
547
553
|
* Razão pela qual uma escrita foi descartada no LWW (I3 §3.3 `conflict_log`).
|
|
548
554
|
*/
|
|
549
|
-
type ConflictReason = 'lww_server_newer' | 'rejected_permission' | 'rejected_validation'
|
|
555
|
+
type ConflictReason = 'lww_server_newer' | 'rejected_permission' | 'rejected_validation'
|
|
556
|
+
/**
|
|
557
|
+
* Dead-letter: a mutação esgotou o teto de tentativas de replay (5xx/timeout
|
|
558
|
+
* persistente) e foi descartada da fila para não travar o FIFO de todas as
|
|
559
|
+
* coleções (head-of-line block). `winningData` fica vazio — o servidor nunca
|
|
560
|
+
* aceitou a escrita. A escrita LOCAL otimista pode ter sido revertida.
|
|
561
|
+
*/
|
|
562
|
+
| 'failed_max_attempts';
|
|
550
563
|
/**
|
|
551
564
|
* Registro de uma escrita perdedora — gravado no `conflict_log` (I3 §3.3).
|
|
552
565
|
* Entregue ao produto via `onWriteResult` (status: `'superseded'`).
|
|
@@ -577,6 +590,13 @@ interface SyncState {
|
|
|
577
590
|
pendingWrites: number;
|
|
578
591
|
lastSyncedAt: number | null;
|
|
579
592
|
isLeaderTab: boolean;
|
|
593
|
+
/**
|
|
594
|
+
* Diagnóstico do ÚLTIMO ciclo de sync que falhou (push/pull/resync ou
|
|
595
|
+
* dead-letter de uma mutação-veneno). `null`/`undefined` = último ciclo OK.
|
|
596
|
+
* Reset a cada ciclo bem-sucedido. Antes disso a falha era engolida em
|
|
597
|
+
* silêncio — agora o produto pode reagir via `onSyncStateChanged`/`onError`.
|
|
598
|
+
*/
|
|
599
|
+
lastError?: string | null;
|
|
580
600
|
}
|
|
581
601
|
/** Função para cancelar uma subscrição (onSnapshot, onDoc, onSyncStateChanged). */
|
|
582
602
|
type Unsubscribe = () => void;
|
|
@@ -616,6 +636,15 @@ type Unsubscribe = () => void;
|
|
|
616
636
|
* de adaptação, não aqui. Isso torna o SyncEngine 100% testável com fake.
|
|
617
637
|
*/
|
|
618
638
|
|
|
639
|
+
/** Diagnóstico entregue ao hook `onError` do SyncEngine. */
|
|
640
|
+
interface SyncErrorEvent {
|
|
641
|
+
/** Fase onde o ciclo falhou. */
|
|
642
|
+
phase: 'push' | 'pull' | 'resync' | 'cycle';
|
|
643
|
+
/** Mensagem legível. */
|
|
644
|
+
message: string;
|
|
645
|
+
/** Epoch ms. */
|
|
646
|
+
at: number;
|
|
647
|
+
}
|
|
619
648
|
/**
|
|
620
649
|
* Documento retornado pelo servidor em push/pull/resync.
|
|
621
650
|
*/
|
|
@@ -664,6 +693,15 @@ interface PullChangesResult {
|
|
|
664
693
|
interface FullResyncResult {
|
|
665
694
|
docs: ServerDoc[];
|
|
666
695
|
newWatermark: number | null;
|
|
696
|
+
/**
|
|
697
|
+
* Coleções cujo resultado bateu no teto de paginação do transporte (o REST
|
|
698
|
+
* Documentos devolve no MÁXIMO 200 docs/coleção — paginação por cursor é
|
|
699
|
+
* tarefa Core, gated). Para essas coleções o conjunto veio TRUNCADO: o
|
|
700
|
+
* SyncEngine (a) NÃO roda detecção-de-deleção-por-ausência (senão docs além
|
|
701
|
+
* do teto virariam tombstone por engano) e (b) persiste o sinal para
|
|
702
|
+
* `DbListResult.truncated`. Transportes sem teto (realtime) omitem o campo.
|
|
703
|
+
*/
|
|
704
|
+
truncatedCollections?: string[];
|
|
667
705
|
}
|
|
668
706
|
/**
|
|
669
707
|
* Contrato do transporte de sync — injetado no SyncEngine.
|
|
@@ -949,6 +987,15 @@ interface DbListResult<T = Record<string, unknown>> {
|
|
|
949
987
|
type: 'added' | 'modified' | 'removed';
|
|
950
988
|
doc: DbDoc<T>;
|
|
951
989
|
}>;
|
|
990
|
+
/**
|
|
991
|
+
* `true` quando o último full-resync desta coleção bateu no TETO de 200 docs
|
|
992
|
+
* do transporte REST Documentos (ver `list()`): o cache local pode estar
|
|
993
|
+
* INCOMPLETO — existem mais docs no servidor além dos 200 baixados. Também
|
|
994
|
+
* força `stale: true`. Paginação por cursor > 200 exige mudança no Core
|
|
995
|
+
* (gated), então por ora o SDK apenas SINALIZA. `undefined`/`false` = sem
|
|
996
|
+
* truncamento conhecido (ou transporte sem teto, ex.: realtime).
|
|
997
|
+
*/
|
|
998
|
+
truncated?: boolean;
|
|
952
999
|
}
|
|
953
1000
|
interface DbGetResult<T = Record<string, unknown>> {
|
|
954
1001
|
docs: Array<DbDoc<T>>;
|
|
@@ -1053,7 +1100,18 @@ interface DbDocRef<T = Record<string, unknown>> {
|
|
|
1053
1100
|
interface DbCollectionRef$1<T = Record<string, unknown>> {
|
|
1054
1101
|
/** Retorna snapshot de um documento. `null` se não existir (nem no cache). */
|
|
1055
1102
|
get(id: string): Promise<DbGetResult<T> | null>;
|
|
1056
|
-
/**
|
|
1103
|
+
/**
|
|
1104
|
+
* Lista documentos com query opcional.
|
|
1105
|
+
*
|
|
1106
|
+
* **TETO DE 200 DOCS (transporte REST Documentos).** O reconciliador offline
|
|
1107
|
+
* baixa NO MÁXIMO 200 docs por coleção do Core em cada full-resync — o
|
|
1108
|
+
* endpoint REST não expõe paginação por cursor server-side (é tarefa Core,
|
|
1109
|
+
* gated). Se a coleção tem mais de 200 docs no servidor, o cache local fica
|
|
1110
|
+
* INCOMPLETO e `DbListResult.truncated === true` (+ `stale: true`). O
|
|
1111
|
+
* `q.limit`/`nextCursor` paginam apenas sobre o que já está no CACHE LOCAL,
|
|
1112
|
+
* não sobre o servidor. Para coleções grandes, filtre por `where` no Core ou
|
|
1113
|
+
* modele os dados para caber sob o teto até a paginação server-side existir.
|
|
1114
|
+
*/
|
|
1057
1115
|
list(q?: DbQuery$1): Promise<DbListResult<T>>;
|
|
1058
1116
|
/** Adiciona doc com id gerado pelo cliente (UUID v4). Durável localmente. */
|
|
1059
1117
|
add(data: WithFieldSentinels<Omit<T, 'id'>>): Promise<{
|
|
@@ -1112,6 +1170,13 @@ interface NeetruDbDocuments {
|
|
|
1112
1170
|
* já avançou a versão do documento (Last-Write-Wins).
|
|
1113
1171
|
*/
|
|
1114
1172
|
getConflicts(): Promise<ConflictRecord[]>;
|
|
1173
|
+
/**
|
|
1174
|
+
* Subscreve a erros de ciclo de sync (P2-C) — falha inesperada nas fases ou
|
|
1175
|
+
* dead-letter de uma mutação-veneno que antes eram engolidos em silêncio. O
|
|
1176
|
+
* mesmo diagnóstico também aparece em `syncState.lastError`. Retorna
|
|
1177
|
+
* uma função de unsubscribe.
|
|
1178
|
+
*/
|
|
1179
|
+
onError(cb: (err: SyncErrorEvent) => void): Unsubscribe;
|
|
1115
1180
|
}
|
|
1116
1181
|
interface CreateOfflineDocumentsOptions {
|
|
1117
1182
|
/**
|
|
@@ -1649,8 +1714,9 @@ interface NeetruDbOptions {
|
|
|
1649
1714
|
*
|
|
1650
1715
|
* Se o produto precisa de bancos logicamente separados no **servidor**,
|
|
1651
1716
|
* isso é uma decisão server-side (tenant/produto ou schema do Core), não
|
|
1652
|
-
* `dbId`.
|
|
1653
|
-
* console (dev-only)
|
|
1717
|
+
* `dbId`. PASSAR `dbId` em contexto browser dispara um aviso único no
|
|
1718
|
+
* console (dev-only): usar dbIds distintos no mesmo tenant/produto NÃO isola
|
|
1719
|
+
* os dados no servidor (co-mingling) — a falsa sensação de isolamento é a mina.
|
|
1654
1720
|
*/
|
|
1655
1721
|
dbId?: string;
|
|
1656
1722
|
/**
|
|
@@ -1790,6 +1856,13 @@ interface NeetruDb {
|
|
|
1790
1856
|
* Permite ao produto inspecionar escritas perdidas.
|
|
1791
1857
|
*/
|
|
1792
1858
|
getConflicts(): Promise<ConflictRecord[]>;
|
|
1859
|
+
/**
|
|
1860
|
+
* (Opcional) Subscreve a erros de ciclo de sync (P2-C) — falha inesperada nas
|
|
1861
|
+
* fases ou dead-letter de uma mutação-veneno que antes eram engolidos em
|
|
1862
|
+
* silêncio. O mesmo diagnóstico também aparece em `syncState.lastError`.
|
|
1863
|
+
* Retorna uma função de unsubscribe. Ausente em implementações mock.
|
|
1864
|
+
*/
|
|
1865
|
+
onError?(cb: (err: SyncErrorEvent) => void): Unsubscribe;
|
|
1793
1866
|
}
|
|
1794
1867
|
/**
|
|
1795
1868
|
* Transporte REST puro — usa os endpoints `/api/sdk/v1/datastore/*` do Core.
|
|
@@ -1818,7 +1891,7 @@ declare function createRestSyncTransport(config?: ResolvedConfig): RealtimeTrans
|
|
|
1818
1891
|
* @param wsFactory Factory de WebSocket injetável (testes).
|
|
1819
1892
|
*/
|
|
1820
1893
|
declare function getWebSocketRealtimeClient(gatewayUrl: string, ticketProvider: TicketProvider, dbId?: string, wsFactory?: WebSocketFactory): NeetruRealtimeClient;
|
|
1821
|
-
/** @internal Reseta o guard one-time do aviso de `dbId`
|
|
1894
|
+
/** @internal Reseta o guard one-time do aviso de `dbId` — uso exclusivo de testes. */
|
|
1822
1895
|
declare function __resetDbIdWarningForTests(): void;
|
|
1823
1896
|
/**
|
|
1824
1897
|
* Cria o namespace `client.db` completo.
|
|
@@ -2573,4 +2646,4 @@ interface CatalogListOptions {
|
|
|
2573
2646
|
includeDrafts?: boolean;
|
|
2574
2647
|
}
|
|
2575
2648
|
|
|
2576
|
-
export { NeetruDbError as $, type AiChatChoice as A, type DbChangeType as B, type CatalogListOptions as C, DEFAULT_BASE_URL as D, type DbCollectionRef$1 as E, type DbDoc as F, type DbDocRef as G, type DbGetResult as H, type DbListResult as I, type DbNamespace as J, type DbQuery$1 as K, type DbSqlLease as L, type DbWhereFilter as M, type DbWhereFilter$1 as N, type EntitlementCheck as O, type FieldSentinel as P, type IncrementSentinel as Q, type ListNotificationsOptions as R, MockCheckout as S, MockNotifications as T, MockWebhooks as U, NEETRU_SENTINEL_KEY as V, type NeetruClient as W, type NeetruClientConfig as X, type NeetruDb as Y, type NeetruDbDocuments as Z, type NeetruDbEngine as _, type AiChatMessage as a, type NeetruDbErrorCode as a0, type NeetruDbOptions as a1, type NeetruDbTransport as a2, type NeetruEnv as a3, type NeetruSqlClient as a4, type NeetruUser as a5, type NotificationScopeOptions as a6, type NotificationsNamespace as a7, type Product as a8, type ProductNotification as a9, type
|
|
2649
|
+
export { NeetruDbError as $, type AiChatChoice as A, type DbChangeType as B, type CatalogListOptions as C, DEFAULT_BASE_URL as D, type DbCollectionRef$1 as E, type DbDoc as F, type DbDocRef as G, type DbGetResult as H, type DbListResult as I, type DbNamespace as J, type DbQuery$1 as K, type DbSqlLease as L, type DbWhereFilter as M, type DbWhereFilter$1 as N, type EntitlementCheck as O, type FieldSentinel as P, type IncrementSentinel as Q, type ListNotificationsOptions as R, MockCheckout as S, MockNotifications as T, MockWebhooks as U, NEETRU_SENTINEL_KEY as V, type NeetruClient as W, type NeetruClientConfig as X, type NeetruDb as Y, type NeetruDbDocuments as Z, type NeetruDbEngine as _, type AiChatMessage as a, type NeetruDbErrorCode as a0, type NeetruDbOptions as a1, type NeetruDbTransport as a2, type NeetruEnv as a3, type NeetruSqlClient as a4, type NeetruUser as a5, type NotificationScopeOptions as a6, type NotificationsNamespace as a7, type Product as a8, type ProductNotification as a9, type VerifyWebhookRequestOptions as aA, type VerifyWebhookRequestResult as aB, type WebhookEndpoint as aC, type WebhookEvent as aD, type WebhookScopeOptions as aE, type WebhookTestResult as aF, type WebhooksNamespace as aG, type WithFieldSentinels as aH, __resetDbIdWarningForTests as aI, createAiNamespace as aJ, createCheckoutNamespace as aK, createNeetruDb as aL, createNotificationsNamespace as aM, createRestSyncTransport as aN, createWebhooksNamespace as aO, getWebSocketRealtimeClient as aP, increment as aQ, isFieldSentinel as aR, isIncrementSentinel as aS, isServerTimestampSentinel as aT, serverTimestamp as aU, verifyWebhookRequest as aV, verifyWebhookSignature as aW, type ProductNotificationSeverity as aa, type ProductPlan as ab, type ProductStatus as ac, type RealtimeTransport as ad, type RedirectCallbackResult as ae, type RegisterWebhookInput as af, type ResolvedConfig as ag, type SendNotificationInput as ah, type ServerTimestampSentinel as ai, type SignInOptions as aj, type SqlOptions as ak, type SupportNamespace as al, type SupportSeverity as am, type SupportStatus as an, type SupportTicket as ao, type SyncErrorEvent as ap, type SyncState as aq, type TelemetryEventAck as ar, type TelemetryEventInput as as, type TelemetryLogAck as at, type TelemetryLogInput as au, type Unsubscribe as av, type UsageEventInput as aw, type UsageNamespace as ax, type UsageQuota as ay, type VerifyTokenOptions as az, type AiChatOptions as b, type AiChatResult as c, type AiChatUsage as d, type AiContentPart as e, type AiImageUrlPart as f, type AiNamespace as g, type AiResponseFormat as h, type AiStreamHandle as i, type AiStreamMeta as j, type AiTextPart as k, type AuthNamespace as l, type AuthStateListener as m, type CatalogListResponse as n, type CheckoutAuthOpts as o, type CheckoutIntentInfo as p, type CheckoutIntentStatus as q, type CheckoutNamespace as r, type CheckoutStartInput as s, type CheckoutStartResult as t, type CheckoutTenantType as u, type CompleteSignInResult as v, type ConflictRecord as w, type CreateOfflineDocumentsOptions as x, type CreateTicketInput as y, type DbBatchOp as z };
|
package/dist/usage.d.cts
CHANGED
package/dist/usage.d.ts
CHANGED
package/dist/webhooks.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { U as MockWebhooks, af as RegisterWebhookInput,
|
|
1
|
+
export { U as MockWebhooks, af as RegisterWebhookInput, aA as VerifyWebhookRequestOptions, aB as VerifyWebhookRequestResult, aC as WebhookEndpoint, aD as WebhookEvent, aE as WebhookScopeOptions, aF as WebhookTestResult, aG as WebhooksNamespace, aO as createWebhooksNamespace, aV as verifyWebhookRequest, aW as verifyWebhookSignature } from './types-D-QdG502.cjs';
|
|
2
2
|
import 'drizzle-orm/node-postgres';
|
|
3
3
|
import './errors.cjs';
|
package/dist/webhooks.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { U as MockWebhooks, af as RegisterWebhookInput,
|
|
1
|
+
export { U as MockWebhooks, af as RegisterWebhookInput, aA as VerifyWebhookRequestOptions, aB as VerifyWebhookRequestResult, aC as WebhookEndpoint, aD as WebhookEvent, aE as WebhookScopeOptions, aF as WebhookTestResult, aG as WebhooksNamespace, aO as createWebhooksNamespace, aV as verifyWebhookRequest, aW as verifyWebhookSignature } from './types-BlOLDMR0.js';
|
|
2
2
|
import 'drizzle-orm/node-postgres';
|
|
3
3
|
import './errors.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neetru/sdk",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.1",
|
|
4
4
|
"description": "Neetru SDK 3.0 — biblioteca runtime universal (browser/Node/Edge) para consumir o ecossistema Neetru. Paths canonical /api/sdk/v1/*, productId obrigatório, Idempotency-Key em mutations, WebCrypto signatures, baseUrl allowlist fail-closed.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|