@neetru/sdk 3.0.1 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/CHANGELOG.md +554 -492
  2. package/dist/auth.cjs +84 -15
  3. package/dist/auth.cjs.map +1 -1
  4. package/dist/auth.d.cts +1 -2
  5. package/dist/auth.d.ts +1 -2
  6. package/dist/auth.mjs +84 -15
  7. package/dist/auth.mjs.map +1 -1
  8. package/dist/catalog.d.cts +1 -2
  9. package/dist/catalog.d.ts +1 -2
  10. package/dist/checkout.d.cts +1 -2
  11. package/dist/checkout.d.ts +1 -2
  12. package/dist/db-react.cjs +15 -5
  13. package/dist/db-react.cjs.map +1 -1
  14. package/dist/db-react.d.cts +35 -13
  15. package/dist/db-react.d.ts +35 -13
  16. package/dist/db-react.mjs +15 -5
  17. package/dist/db-react.mjs.map +1 -1
  18. package/dist/db.cjs +104 -18
  19. package/dist/db.cjs.map +1 -1
  20. package/dist/db.d.cts +1 -2
  21. package/dist/db.d.ts +1 -2
  22. package/dist/db.mjs +99 -19
  23. package/dist/db.mjs.map +1 -1
  24. package/dist/entitlements.d.cts +1 -2
  25. package/dist/entitlements.d.ts +1 -2
  26. package/dist/firestore-compat.cjs +399 -0
  27. package/dist/firestore-compat.cjs.map +1 -0
  28. package/dist/firestore-compat.d.cts +294 -0
  29. package/dist/firestore-compat.d.ts +294 -0
  30. package/dist/firestore-compat.mjs +371 -0
  31. package/dist/firestore-compat.mjs.map +1 -0
  32. package/dist/index.cjs +105 -19
  33. package/dist/index.cjs.map +1 -1
  34. package/dist/index.d.cts +2 -3
  35. package/dist/index.d.ts +2 -3
  36. package/dist/index.mjs +100 -20
  37. package/dist/index.mjs.map +1 -1
  38. package/dist/mocks.d.cts +1 -2
  39. package/dist/mocks.d.ts +1 -2
  40. package/dist/notifications.d.cts +1 -2
  41. package/dist/notifications.d.ts +1 -2
  42. package/dist/react.cjs +267 -0
  43. package/dist/react.cjs.map +1 -1
  44. package/dist/react.d.cts +117 -3
  45. package/dist/react.d.ts +117 -3
  46. package/dist/react.mjs +265 -1
  47. package/dist/react.mjs.map +1 -1
  48. package/dist/support.d.cts +1 -2
  49. package/dist/support.d.ts +1 -2
  50. package/dist/telemetry.d.cts +1 -2
  51. package/dist/telemetry.d.ts +1 -2
  52. package/dist/{types-DALIhcbq.d.ts → types-BRv8wBxX.d.ts} +581 -2
  53. package/dist/{types-Lfd3LiAF.d.cts → types-nwErcRX8.d.cts} +581 -2
  54. package/dist/usage.d.cts +1 -2
  55. package/dist/usage.d.ts +1 -2
  56. package/dist/webhooks.d.cts +1 -2
  57. package/dist/webhooks.d.ts +1 -2
  58. package/package.json +156 -151
  59. package/dist/collection-ref-DqAAhuhX.d.cts +0 -472
  60. package/dist/collection-ref-DqAAhuhX.d.ts +0 -472
package/dist/index.d.cts CHANGED
@@ -1,7 +1,6 @@
1
1
  export { createNeetruClient } from './auth.cjs';
2
2
  export { NeetruError, NeetruErrorCode } from './errors.cjs';
3
- export { A as AuthNamespace, a as AuthStateListener, C as CatalogListOptions, b as CatalogListResponse, c as CheckoutIntentInfo, d as CheckoutIntentStatus, e as CheckoutNamespace, f as CheckoutStartInput, g as CheckoutStartResult, h as CheckoutTenantType, i as CreateTicketInput, D as DEFAULT_BASE_URL, j as DbNamespace, k as DbSqlLease, l as DbWhereFilter, E as EntitlementCheck, L as ListNotificationsOptions, M as MockCheckout, m as MockNotifications, n as MockWebhooks, N as NeetruClient, o as NeetruClientConfig, p as NeetruDb, q as NeetruDbEngine, r as NeetruDbError, s as NeetruDbErrorCode, t as NeetruDbOptions, u as NeetruDbTransport, v as NeetruEnv, w as NeetruSqlClient, x as NeetruUser, y as NotificationScopeOptions, z as NotificationsNamespace, P as Product, B as ProductNotification, F as ProductNotificationSeverity, G as ProductPlan, H as ProductStatus, R as RegisterWebhookInput, I as ResolvedConfig, S as SendNotificationInput, J as SignInOptions, O as SupportNamespace, Q as SupportSeverity, T as SupportStatus, U as SupportTicket, V as TelemetryEventAck, W as TelemetryEventInput, Z as UsageEventInput, _ as UsageNamespace, $ as UsageQuota, a0 as VerifyTokenOptions, a1 as WebhookEndpoint, a2 as WebhookEvent, a3 as WebhookScopeOptions, a4 as WebhookTestResult, a5 as WebhooksNamespace, a6 as createCheckoutNamespace, a7 as createNeetruDb, a8 as createNotificationsNamespace, aa as createWebhooksNamespace, ac as verifyWebhookSignature } from './types-Lfd3LiAF.cjs';
4
- export { D as DbBatchOp, b as DbChangeType, c as DbCollectionRef, d as DbDoc, e as DbDocRef, f as DbGetResult, g as DbListResult, h as DbQuery } from './collection-ref-DqAAhuhX.cjs';
3
+ export { A as AuthNamespace, a as AuthStateListener, C as CatalogListOptions, b as CatalogListResponse, c as CheckoutIntentInfo, d as CheckoutIntentStatus, e as CheckoutNamespace, f as CheckoutStartInput, g as CheckoutStartResult, h as CheckoutTenantType, k as CreateTicketInput, D as DEFAULT_BASE_URL, l as DbBatchOp, m as DbChangeType, n as DbCollectionRef, o as DbDoc, p as DbDocRef, q as DbGetResult, r as DbListResult, s as DbNamespace, t as DbQuery, u as DbSqlLease, v as DbWhereFilter, E as EntitlementCheck, F as FieldSentinel, I as IncrementSentinel, L as ListNotificationsOptions, M as MockCheckout, x as MockNotifications, y as MockWebhooks, N as NEETRU_SENTINEL_KEY, z as NeetruClient, B as NeetruClientConfig, G as NeetruDb, J as NeetruDbEngine, K as NeetruDbError, O as NeetruDbErrorCode, P as NeetruDbOptions, Q as NeetruDbTransport, R as NeetruEnv, S as NeetruSqlClient, T as NeetruUser, U as NotificationScopeOptions, V as NotificationsNamespace, W as Product, X as ProductNotification, Y as ProductNotificationSeverity, Z as ProductPlan, _ as ProductStatus, a0 as RegisterWebhookInput, a1 as ResolvedConfig, a2 as SendNotificationInput, a3 as ServerTimestampSentinel, a4 as SignInOptions, a6 as SupportNamespace, a7 as SupportSeverity, a8 as SupportStatus, a9 as SupportTicket, ab as TelemetryEventAck, ac as TelemetryEventInput, ag as UsageEventInput, ah as UsageNamespace, ai as UsageQuota, aj as VerifyTokenOptions, ak as WebhookEndpoint, al as WebhookEvent, am as WebhookScopeOptions, an as WebhookTestResult, ao as WebhooksNamespace, ap as WithFieldSentinels, aq as createCheckoutNamespace, ar as createNeetruDb, as as createNotificationsNamespace, au as createWebhooksNamespace, aw as increment, ax as isFieldSentinel, ay as isIncrementSentinel, az as isServerTimestampSentinel, aA as serverTimestamp, aB as verifyWebhookSignature } from './types-nwErcRX8.cjs';
5
4
  export { DEV_FIXTURE_USER, MockAuth, MockDb, MockEntitlements, MockSupport, MockUsage } from './mocks.cjs';
6
5
  import 'drizzle-orm/node-postgres';
7
6
 
@@ -37,6 +36,6 @@ import 'drizzle-orm/node-postgres';
37
36
  */
38
37
 
39
38
  /** Versão do SDK — exportada explicitamente pra detecção em runtime. */
40
- declare const VERSION: "3.0.1";
39
+ declare const VERSION: "3.1.0";
41
40
 
42
41
  export { VERSION };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  export { createNeetruClient } from './auth.js';
2
2
  export { NeetruError, NeetruErrorCode } from './errors.js';
3
- export { A as AuthNamespace, a as AuthStateListener, C as CatalogListOptions, b as CatalogListResponse, c as CheckoutIntentInfo, d as CheckoutIntentStatus, e as CheckoutNamespace, f as CheckoutStartInput, g as CheckoutStartResult, h as CheckoutTenantType, i as CreateTicketInput, D as DEFAULT_BASE_URL, j as DbNamespace, k as DbSqlLease, l as DbWhereFilter, E as EntitlementCheck, L as ListNotificationsOptions, M as MockCheckout, m as MockNotifications, n as MockWebhooks, N as NeetruClient, o as NeetruClientConfig, p as NeetruDb, q as NeetruDbEngine, r as NeetruDbError, s as NeetruDbErrorCode, t as NeetruDbOptions, u as NeetruDbTransport, v as NeetruEnv, w as NeetruSqlClient, x as NeetruUser, y as NotificationScopeOptions, z as NotificationsNamespace, P as Product, B as ProductNotification, F as ProductNotificationSeverity, G as ProductPlan, H as ProductStatus, R as RegisterWebhookInput, I as ResolvedConfig, S as SendNotificationInput, J as SignInOptions, O as SupportNamespace, Q as SupportSeverity, T as SupportStatus, U as SupportTicket, V as TelemetryEventAck, W as TelemetryEventInput, Z as UsageEventInput, _ as UsageNamespace, $ as UsageQuota, a0 as VerifyTokenOptions, a1 as WebhookEndpoint, a2 as WebhookEvent, a3 as WebhookScopeOptions, a4 as WebhookTestResult, a5 as WebhooksNamespace, a6 as createCheckoutNamespace, a7 as createNeetruDb, a8 as createNotificationsNamespace, aa as createWebhooksNamespace, ac as verifyWebhookSignature } from './types-DALIhcbq.js';
4
- export { D as DbBatchOp, b as DbChangeType, c as DbCollectionRef, d as DbDoc, e as DbDocRef, f as DbGetResult, g as DbListResult, h as DbQuery } from './collection-ref-DqAAhuhX.js';
3
+ export { A as AuthNamespace, a as AuthStateListener, C as CatalogListOptions, b as CatalogListResponse, c as CheckoutIntentInfo, d as CheckoutIntentStatus, e as CheckoutNamespace, f as CheckoutStartInput, g as CheckoutStartResult, h as CheckoutTenantType, k as CreateTicketInput, D as DEFAULT_BASE_URL, l as DbBatchOp, m as DbChangeType, n as DbCollectionRef, o as DbDoc, p as DbDocRef, q as DbGetResult, r as DbListResult, s as DbNamespace, t as DbQuery, u as DbSqlLease, v as DbWhereFilter, E as EntitlementCheck, F as FieldSentinel, I as IncrementSentinel, L as ListNotificationsOptions, M as MockCheckout, x as MockNotifications, y as MockWebhooks, N as NEETRU_SENTINEL_KEY, z as NeetruClient, B as NeetruClientConfig, G as NeetruDb, J as NeetruDbEngine, K as NeetruDbError, O as NeetruDbErrorCode, P as NeetruDbOptions, Q as NeetruDbTransport, R as NeetruEnv, S as NeetruSqlClient, T as NeetruUser, U as NotificationScopeOptions, V as NotificationsNamespace, W as Product, X as ProductNotification, Y as ProductNotificationSeverity, Z as ProductPlan, _ as ProductStatus, a0 as RegisterWebhookInput, a1 as ResolvedConfig, a2 as SendNotificationInput, a3 as ServerTimestampSentinel, a4 as SignInOptions, a6 as SupportNamespace, a7 as SupportSeverity, a8 as SupportStatus, a9 as SupportTicket, ab as TelemetryEventAck, ac as TelemetryEventInput, ag as UsageEventInput, ah as UsageNamespace, ai as UsageQuota, aj as VerifyTokenOptions, ak as WebhookEndpoint, al as WebhookEvent, am as WebhookScopeOptions, an as WebhookTestResult, ao as WebhooksNamespace, ap as WithFieldSentinels, aq as createCheckoutNamespace, ar as createNeetruDb, as as createNotificationsNamespace, au as createWebhooksNamespace, aw as increment, ax as isFieldSentinel, ay as isIncrementSentinel, az as isServerTimestampSentinel, aA as serverTimestamp, aB as verifyWebhookSignature } from './types-BRv8wBxX.js';
5
4
  export { DEV_FIXTURE_USER, MockAuth, MockDb, MockEntitlements, MockSupport, MockUsage } from './mocks.js';
6
5
  import 'drizzle-orm/node-postgres';
7
6
 
@@ -37,6 +36,6 @@ import 'drizzle-orm/node-postgres';
37
36
  */
38
37
 
39
38
  /** Versão do SDK — exportada explicitamente pra detecção em runtime. */
40
- declare const VERSION: "3.0.1";
39
+ declare const VERSION: "3.1.0";
41
40
 
42
41
  export { VERSION };
package/dist/index.mjs CHANGED
@@ -2041,7 +2041,71 @@ var MutationQueue = class {
2041
2041
  }
2042
2042
  };
2043
2043
 
2044
+ // src/db/field-value.ts
2045
+ var NEETRU_SENTINEL_KEY = "__neetru__";
2046
+ function serverTimestamp() {
2047
+ return { __neetru__: "serverTimestamp" };
2048
+ }
2049
+ function increment(n) {
2050
+ if (typeof n !== "number" || !Number.isFinite(n)) {
2051
+ throw new TypeError(
2052
+ `increment(n): n deve ser um n\xFAmero finito (recebido: ${String(n)}).`
2053
+ );
2054
+ }
2055
+ return { __neetru__: "increment", operand: n };
2056
+ }
2057
+ function isFieldSentinel(v) {
2058
+ return typeof v === "object" && v !== null && NEETRU_SENTINEL_KEY in v && typeof v[NEETRU_SENTINEL_KEY] === "string";
2059
+ }
2060
+ function isServerTimestampSentinel(v) {
2061
+ return isFieldSentinel(v) && v.__neetru__ === "serverTimestamp";
2062
+ }
2063
+ function isIncrementSentinel(v) {
2064
+ return isFieldSentinel(v) && v.__neetru__ === "increment" && typeof v.operand === "number" && Number.isFinite(v.operand);
2065
+ }
2066
+ function resolveSentinelLocally(value, baseValue) {
2067
+ if (isServerTimestampSentinel(value)) {
2068
+ return Date.now();
2069
+ }
2070
+ if (isIncrementSentinel(value)) {
2071
+ const base = typeof baseValue === "number" && Number.isFinite(baseValue) ? baseValue : 0;
2072
+ return base + value.operand;
2073
+ }
2074
+ return value;
2075
+ }
2076
+ function resolveSentinelsLocally(data, existing) {
2077
+ let touched = false;
2078
+ const out = {};
2079
+ for (const [k, v] of Object.entries(data)) {
2080
+ if (isFieldSentinel(v)) {
2081
+ touched = true;
2082
+ out[k] = resolveSentinelLocally(v, existing?.[k]);
2083
+ } else {
2084
+ out[k] = v;
2085
+ }
2086
+ }
2087
+ return touched ? out : data;
2088
+ }
2089
+ function hasFieldSentinel(data) {
2090
+ for (const v of Object.values(data)) {
2091
+ if (isFieldSentinel(v)) return true;
2092
+ }
2093
+ return false;
2094
+ }
2095
+
2044
2096
  // src/db/offline/sync-engine.ts
2097
+ function hasSentinels(payload) {
2098
+ return payload !== null && hasFieldSentinel(payload);
2099
+ }
2100
+ function sanitizeSentinelPayload(payload) {
2101
+ if (payload === null) return null;
2102
+ if (!hasFieldSentinel(payload)) return payload;
2103
+ const out = {};
2104
+ for (const [k, v] of Object.entries(payload)) {
2105
+ if (!isFieldSentinel(v)) out[k] = v;
2106
+ }
2107
+ return out;
2108
+ }
2045
2109
  var SyncEngine = class {
2046
2110
  _store;
2047
2111
  _queue;
@@ -2229,7 +2293,7 @@ var SyncEngine = class {
2229
2293
  return true;
2230
2294
  }
2231
2295
  /** Atualiza o cache após confirmação de escrita (outcome=confirmed). */
2232
- async _applySyncedDoc(collection, docId, serverVersion, serverTimestamp, mut, busChanges) {
2296
+ async _applySyncedDoc(collection, docId, serverVersion, serverTimestamp2, mut, busChanges) {
2233
2297
  const existing = await this._store.getDoc(collection, docId);
2234
2298
  if (mut.op === "remove") {
2235
2299
  if (existing) {
@@ -2238,7 +2302,7 @@ var SyncEngine = class {
2238
2302
  meta: {
2239
2303
  ...existing.meta,
2240
2304
  serverVersion,
2241
- updatedAtServer: serverTimestamp,
2305
+ updatedAtServer: serverTimestamp2,
2242
2306
  updatedAtLocal: Date.now(),
2243
2307
  state: "synced",
2244
2308
  deleted: true,
@@ -2249,14 +2313,19 @@ var SyncEngine = class {
2249
2313
  }
2250
2314
  return;
2251
2315
  }
2252
- const newData = mut.payload ?? (existing?.data ?? {});
2316
+ const literalPayload = sanitizeSentinelPayload(mut.payload);
2317
+ const newData = literalPayload ?? (existing?.data ?? {});
2253
2318
  const updatedDoc = {
2254
2319
  collection,
2255
2320
  id: docId,
2256
- data: mut.op === "update" ? { ...existing?.data ?? {}, ...newData } : newData,
2321
+ data: mut.op === "update" ? { ...existing?.data ?? {}, ...newData } : (
2322
+ // add/set: se o payload tinha sentinels, o cache otimista (existing.data)
2323
+ // é a fonte de verdade até o pull; senão usa o payload literal.
2324
+ hasSentinels(mut.payload) ? { ...existing?.data ?? {}, ...newData } : newData
2325
+ ),
2257
2326
  meta: {
2258
2327
  serverVersion,
2259
- updatedAtServer: serverTimestamp,
2328
+ updatedAtServer: serverTimestamp2,
2260
2329
  updatedAtLocal: Date.now(),
2261
2330
  state: "synced",
2262
2331
  pendingMutationIds: [],
@@ -3463,10 +3532,12 @@ var DbCollectionRefImpl = class {
3463
3532
  return this._buildListResult(q);
3464
3533
  }
3465
3534
  async add(data) {
3535
+ const rawData = data;
3536
+ const localData = resolveSentinelsLocally(rawData, void 0);
3466
3537
  const mutation = await this._queue.enqueue({
3467
3538
  collection: this._collection,
3468
3539
  op: "add",
3469
- payload: data,
3540
+ payload: rawData,
3470
3541
  baseVersion: null,
3471
3542
  batchId: null
3472
3543
  });
@@ -3474,7 +3545,7 @@ var DbCollectionRefImpl = class {
3474
3545
  await this._store.putDoc({
3475
3546
  collection: this._collection,
3476
3547
  id: docId,
3477
- data,
3548
+ data: localData,
3478
3549
  meta: {
3479
3550
  serverVersion: null,
3480
3551
  updatedAtServer: null,
@@ -3488,25 +3559,27 @@ var DbCollectionRefImpl = class {
3488
3559
  this._bus.emit([{
3489
3560
  type: "added",
3490
3561
  collection: this._collection,
3491
- doc: { id: docId, data }
3562
+ doc: { id: docId, data: localData }
3492
3563
  }]);
3493
3564
  return { ok: true, id: docId };
3494
3565
  }
3495
3566
  async set(id, data) {
3496
3567
  assertValidId(id);
3497
3568
  const existing = await this._store.getDoc(this._collection, id);
3569
+ const rawData = data;
3570
+ const localData = resolveSentinelsLocally(rawData, void 0);
3498
3571
  const mutation = await this._queue.enqueue({
3499
3572
  collection: this._collection,
3500
3573
  docId: id,
3501
3574
  op: "set",
3502
- payload: data,
3575
+ payload: rawData,
3503
3576
  baseVersion: existing?.meta.serverVersion ?? null,
3504
3577
  batchId: null
3505
3578
  });
3506
3579
  await this._store.putDoc({
3507
3580
  collection: this._collection,
3508
3581
  id,
3509
- data,
3582
+ data: localData,
3510
3583
  meta: {
3511
3584
  serverVersion: existing?.meta.serverVersion ?? null,
3512
3585
  updatedAtServer: existing?.meta.updatedAtServer ?? null,
@@ -3520,19 +3593,22 @@ var DbCollectionRefImpl = class {
3520
3593
  this._bus.emit([{
3521
3594
  type: existing && !existing.meta.deleted ? "modified" : "added",
3522
3595
  collection: this._collection,
3523
- doc: { id, data }
3596
+ doc: { id, data: localData }
3524
3597
  }]);
3525
3598
  return { ok: true };
3526
3599
  }
3527
3600
  async update(id, data) {
3528
3601
  assertValidId(id);
3529
3602
  const existing = await this._store.getDoc(this._collection, id);
3530
- const mergedData = existing?.meta.deleted ? { ...data } : { ...existing?.data ?? {}, ...data };
3603
+ const rawData = data;
3604
+ const existingBase = existing?.meta.deleted ? void 0 : existing?.data;
3605
+ const localData = resolveSentinelsLocally(rawData, existingBase);
3606
+ const mergedData = existing?.meta.deleted ? { ...localData } : { ...existing?.data ?? {}, ...localData };
3531
3607
  const mutation = await this._queue.enqueue({
3532
3608
  collection: this._collection,
3533
3609
  docId: id,
3534
3610
  op: "update",
3535
- payload: data,
3611
+ payload: rawData,
3536
3612
  baseVersion: existing?.meta.serverVersion ?? null,
3537
3613
  batchId: null
3538
3614
  });
@@ -3589,6 +3665,7 @@ var DbCollectionRefImpl = class {
3589
3665
  const collection = this._collection;
3590
3666
  if (op.kind === "add") {
3591
3667
  const data = op.data;
3668
+ const localData = resolveSentinelsLocally(data, void 0);
3592
3669
  const mutation = await this._queue.enqueue({
3593
3670
  collection,
3594
3671
  op: "add",
@@ -3600,7 +3677,7 @@ var DbCollectionRefImpl = class {
3600
3677
  await this._store.putDoc({
3601
3678
  collection,
3602
3679
  id: docId,
3603
- data,
3680
+ data: localData,
3604
3681
  meta: {
3605
3682
  serverVersion: null,
3606
3683
  updatedAtServer: null,
@@ -3611,11 +3688,12 @@ var DbCollectionRefImpl = class {
3611
3688
  ownerId: null
3612
3689
  }
3613
3690
  });
3614
- busChanges.push({ type: "added", collection, doc: { id: docId, data } });
3691
+ busChanges.push({ type: "added", collection, doc: { id: docId, data: localData } });
3615
3692
  } else if (op.kind === "set") {
3616
3693
  const id = op.id;
3617
3694
  const data = op.data;
3618
3695
  const existing = await this._store.getDoc(collection, id);
3696
+ const localData = resolveSentinelsLocally(data, void 0);
3619
3697
  const mutation = await this._queue.enqueue({
3620
3698
  collection,
3621
3699
  docId: id,
@@ -3627,7 +3705,7 @@ var DbCollectionRefImpl = class {
3627
3705
  await this._store.putDoc({
3628
3706
  collection,
3629
3707
  id,
3630
- data,
3708
+ data: localData,
3631
3709
  meta: {
3632
3710
  serverVersion: existing?.meta.serverVersion ?? null,
3633
3711
  updatedAtServer: existing?.meta.updatedAtServer ?? null,
@@ -3641,13 +3719,15 @@ var DbCollectionRefImpl = class {
3641
3719
  busChanges.push({
3642
3720
  type: existing && !existing.meta.deleted ? "modified" : "added",
3643
3721
  collection,
3644
- doc: { id, data }
3722
+ doc: { id, data: localData }
3645
3723
  });
3646
3724
  } else if (op.kind === "update") {
3647
3725
  const id = op.id;
3648
3726
  const data = op.data;
3649
3727
  const existing = await this._store.getDoc(collection, id);
3650
- const merged = { ...existing?.data ?? {}, ...data };
3728
+ const existingBase = existing?.meta.deleted ? void 0 : existing?.data;
3729
+ const localData = resolveSentinelsLocally(data, existingBase);
3730
+ const merged = { ...existing?.data ?? {}, ...localData };
3651
3731
  const mutation = await this._queue.enqueue({
3652
3732
  collection,
3653
3733
  docId: id,
@@ -6081,8 +6161,8 @@ function createNeetruClient(config = {}) {
6081
6161
  // src/index.ts
6082
6162
  init_errors();
6083
6163
  init_db_errors();
6084
- var VERSION = "3.0.1";
6164
+ var VERSION = "3.1.0";
6085
6165
 
6086
- export { DEFAULT_BASE_URL, DEV_FIXTURE_USER, MockAuth, MockCheckout, MockDb, MockEntitlements, MockNotifications, MockSupport, MockUsage, MockWebhooks, NeetruDbError, NeetruError, VERSION, createCheckoutNamespace, createNeetruClient, createNeetruDb, createNotificationsNamespace, createWebhooksNamespace, verifyWebhookSignature };
6166
+ export { DEFAULT_BASE_URL, DEV_FIXTURE_USER, MockAuth, MockCheckout, MockDb, MockEntitlements, MockNotifications, MockSupport, MockUsage, MockWebhooks, NEETRU_SENTINEL_KEY, NeetruDbError, NeetruError, VERSION, createCheckoutNamespace, createNeetruClient, createNeetruDb, createNotificationsNamespace, createWebhooksNamespace, increment, isFieldSentinel, isIncrementSentinel, isServerTimestampSentinel, serverTimestamp, verifyWebhookSignature };
6087
6167
  //# sourceMappingURL=index.mjs.map
6088
6168
  //# sourceMappingURL=index.mjs.map