@rdlabo/ionic-angular-kit 21.5.7 → 21.5.8

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/README.md CHANGED
@@ -523,6 +523,31 @@ The write lifecycle is: update the replica immediately → append an outbox comm
523
523
  the optimistic value → replay in the background → validate the server revision → store the confirmed value and
524
524
  revision. The server remains authoritative; SQLite is the durable local working database, not an HTTP response cache.
525
525
 
526
+ For a DB row whose deletion is represented by absence, enqueue the same full row values with
527
+ `replicaMutation: 'delete'`. The runtime stores a library-owned durable tombstone: normal `getReplicaRow()` and
528
+ `getReplicaRows()` reads stop returning the row immediately, while synchronization retains its immutable `localId`,
529
+ remote identity, confirmed baseline, and Outbox command. A successful tombstone acknowledgement removes the row
530
+ physically; retry, authorization failure, and conflict keep it hidden; discarding restores the latest confirmed
531
+ baseline unless the server has also deleted it.
532
+
533
+ Custom `OfflineRepository` implementations must implement `getReplicaRowIncludingPendingDelete()` before they can
534
+ accept `replicaMutation: 'delete'`; the runtime rejects that enqueue otherwise. This is intentional: ordinary product
535
+ reads stay hidden, while the library's remote-identity lookup and synchronization path must still resolve the durable
536
+ tombstone for replay, lost-ACK reconciliation, conflict handling, and discard.
537
+
538
+ ```ts
539
+ await offlineSync.enqueue({
540
+ scopeId,
541
+ aggregateType: 'favorites',
542
+ aggregateLocalId: favorite.localId,
543
+ operation: 'favorite.delete',
544
+ payload: { favTo: favorite.values.favTo },
545
+ optimisticValue: favorite.values,
546
+ baseRevision: favorite.serverRevision,
547
+ replicaMutation: 'delete',
548
+ });
549
+ ```
550
+
526
551
  The runtime retains pending, rejected, and conflicted commands until synchronization or an explicit user discard;
527
552
  it never evicts an unconfirmed mutation because of age or storage pressure. To keep a device that remains offline for
528
553
  months from exhausting SQLite, enqueue applies backpressure at 1,000 commands or 10 MiB per user by default. Products
@@ -674,7 +674,7 @@ const OFFLINE_COMMAND_EXECUTOR = new InjectionToken('OFFLINE_COMMAND_EXECUTOR');
674
674
  const OFFLINE_SYNC_CONTEXT = new InjectionToken('OFFLINE_SYNC_CONTEXT');
675
675
 
676
676
  /** Current durable storage schema used by both web and native repositories. */
677
- const OFFLINE_SCHEMA_VERSION = 4;
677
+ const OFFLINE_SCHEMA_VERSION = 5;
678
678
  /** DI token for the selected platform repository. */
679
679
  const OFFLINE_REPOSITORY = new InjectionToken('OFFLINE_REPOSITORY');
680
680
  /** Selects encrypted SQLite on native platforms and Ionic Storage on web. */
@@ -728,6 +728,16 @@ class IonicOfflineRepository {
728
728
  });
729
729
  }
730
730
  async getReplicaRow(scope, sourceKey, localId) {
731
+ await this.initialize();
732
+ await this.#writes;
733
+ const schema = this.#resolveReplicaEntitySchema(sourceKey);
734
+ const rows = await this.#readRecord(ROWS_KEY);
735
+ const row = rows[this.#rowKey(scope, sourceKey, localId)];
736
+ if (!row || (row.visibility ?? 'present') === 'pending_delete')
737
+ return null;
738
+ return this.#rowForScope(row, schema, scope);
739
+ }
740
+ async getReplicaRowIncludingPendingDelete(scope, sourceKey, localId) {
731
741
  await this.initialize();
732
742
  await this.#writes;
733
743
  const schema = this.#resolveReplicaEntitySchema(sourceKey);
@@ -744,6 +754,8 @@ class IonicOfflineRepository {
744
754
  .filter((row) => {
745
755
  if (row.sourceKey !== sourceKey || row.userId !== scope.userId)
746
756
  return false;
757
+ if ((row.visibility ?? 'present') === 'pending_delete')
758
+ return false;
747
759
  return schema.scope === 'partition' ? row.scopeId === scope.scopeId : true;
748
760
  })
749
761
  .map((row) => this.#rowForScope(row, schema, scope))
@@ -855,7 +867,18 @@ class IonicOfflineRepository {
855
867
  return write;
856
868
  }
857
869
  async #migrate() {
858
- const metadata = await this.#storage.get(METADATA_KEY);
870
+ let metadata = await this.#storage.get(METADATA_KEY);
871
+ if (metadata?.schemaVersion === 4) {
872
+ const rows = await this.#readRecord(ROWS_KEY);
873
+ const commands = await this.#readRecord(OUTBOX_KEY);
874
+ await this.#storage.set(ROWS_KEY, Object.fromEntries(Object.entries(rows).map(([key, row]) => [key, { ...row, visibility: row.visibility ?? 'present' }])));
875
+ await this.#storage.set(OUTBOX_KEY, Object.fromEntries(Object.entries(commands).map(([key, command]) => [
876
+ key,
877
+ { ...command, replicaMutation: command.replicaMutation ?? 'upsert' },
878
+ ])));
879
+ metadata = { ...metadata, schemaVersion: OFFLINE_SCHEMA_VERSION };
880
+ await this.#storage.set(METADATA_KEY, metadata);
881
+ }
859
882
  if (metadata?.schemaVersion !== undefined && metadata.schemaVersion !== OFFLINE_SCHEMA_VERSION) {
860
883
  throw new Error(`Unsupported offline storage schema version ${metadata.schemaVersion}; expected ${OFFLINE_SCHEMA_VERSION}. ` +
861
884
  'A lossless core schema migration is required before this database can be opened.');
@@ -1077,7 +1100,8 @@ class IonicOfflineRepository {
1077
1100
  return `${scope.userId}:${partition}:${sourceKey}:${localId}`;
1078
1101
  }
1079
1102
  #rowForScope(row, schema, scope) {
1080
- return schema.scope === 'user' ? { ...row, scopeId: scope.scopeId } : row;
1103
+ const normalized = { ...row, visibility: row.visibility ?? 'present' };
1104
+ return schema.scope === 'user' ? { ...normalized, scopeId: scope.scopeId } : normalized;
1081
1105
  }
1082
1106
  #cursorKey(scope) {
1083
1107
  return `${scope.userId}:${scope.scopeId}`;
@@ -1210,7 +1234,8 @@ class OfflineReplicaPullService {
1210
1234
  ? { userId: acknowledgedCommand.userId, scopeId: acknowledgedCommand.scopeId }
1211
1235
  : scope;
1212
1236
  const acknowledgedRow = acknowledgedCommand
1213
- ? await this.#repository.getReplicaRow(acknowledgedScope, change.sourceKey, acknowledgedCommand.aggregateLocalId)
1237
+ ? await (this.#repository.getReplicaRowIncludingPendingDelete?.(acknowledgedScope, change.sourceKey, acknowledgedCommand.aggregateLocalId) ??
1238
+ this.#repository.getReplicaRow(acknowledgedScope, change.sourceKey, acknowledgedCommand.aggregateLocalId))
1214
1239
  : null;
1215
1240
  if (acknowledgedCommand && !acknowledgedRow) {
1216
1241
  throw new Error(`Acknowledged command "${acknowledgedCommand.commandId}" has no local replica row.`);
@@ -1229,6 +1254,7 @@ class OfflineReplicaPullService {
1229
1254
  : [];
1230
1255
  const hasPending = related.length > 0;
1231
1256
  if (acknowledgedCommand) {
1257
+ this.#assertIdentityAssignment(schema, existing, identity);
1232
1258
  this.#applyAcknowledgement(change, existing, related, putRows, removeRows, putCommands, removeCommandIds);
1233
1259
  continue;
1234
1260
  }
@@ -1239,7 +1265,13 @@ class OfflineReplicaPullService {
1239
1265
  removeRows.push(existing);
1240
1266
  continue;
1241
1267
  }
1242
- putRows.push({ ...existing, serverRevision: change.serverRevision, syncState: 'conflict', fetchedAt: Date.now() });
1268
+ putRows.push({
1269
+ ...existing,
1270
+ confirmedValues: null,
1271
+ serverRevision: change.serverRevision,
1272
+ syncState: 'conflict',
1273
+ fetchedAt: Date.now(),
1274
+ });
1243
1275
  for (const command of related) {
1244
1276
  putCommands.set(command.commandId, { ...command, state: 'conflict', retryAt: null, lastErrorCode: 'remote_deleted' });
1245
1277
  }
@@ -1420,9 +1452,28 @@ class OfflineReplicaPullService {
1420
1452
  }
1421
1453
  if (change.deleted) {
1422
1454
  if (following.length > 0) {
1423
- putRows.push({ ...row, serverRevision: change.serverRevision, syncState: 'conflict', fetchedAt: Date.now() });
1424
- for (const command of following) {
1425
- putCommands.set(command.commandId, { ...command, state: 'conflict', lastErrorCode: 'remote_deleted' });
1455
+ if (acknowledgementSuperseded) {
1456
+ putRows.push({
1457
+ ...row,
1458
+ confirmedValues: null,
1459
+ serverRevision: change.serverRevision,
1460
+ syncState: 'conflict',
1461
+ fetchedAt: Date.now(),
1462
+ });
1463
+ for (const command of following) {
1464
+ putCommands.set(command.commandId, { ...command, state: 'conflict', lastErrorCode: 'remote_deleted' });
1465
+ }
1466
+ }
1467
+ else {
1468
+ putRows.push({
1469
+ ...row,
1470
+ values: following.at(-1).optimisticValue,
1471
+ confirmedValues: null,
1472
+ serverRevision: change.serverRevision,
1473
+ syncState: 'pending',
1474
+ visibility: following.at(-1).replicaMutation === 'delete' ? 'pending_delete' : 'present',
1475
+ fetchedAt: Date.now(),
1476
+ });
1426
1477
  }
1427
1478
  }
1428
1479
  else {
@@ -1441,6 +1492,7 @@ class OfflineReplicaPullService {
1441
1492
  serverRevision: change.serverRevision,
1442
1493
  fetchedAt: Date.now(),
1443
1494
  syncState: following.length > 0 ? (acknowledgementSuperseded ? 'conflict' : 'pending') : 'confirmed',
1495
+ visibility: following.at(-1)?.replicaMutation === 'delete' ? 'pending_delete' : 'present',
1444
1496
  });
1445
1497
  }
1446
1498
  #identity(change) {
@@ -1835,6 +1887,7 @@ class OfflineSyncService {
1835
1887
  operation: request.operation,
1836
1888
  payload: normalized.payload,
1837
1889
  optimisticValue,
1890
+ replicaMutation: request.replicaMutation ?? 'upsert',
1838
1891
  payloadHash: await this.#payloadHash(normalized.payload),
1839
1892
  baseRevision: normalized.baseRevision,
1840
1893
  state: 'pending',
@@ -1846,7 +1899,10 @@ class OfflineSyncService {
1846
1899
  await this.#assertOutboxCapacity(userId, command);
1847
1900
  const entityType = this.#entityType(command);
1848
1901
  const schema = this.#entitySchema(entityType);
1849
- const existing = await this.#repository.getReplicaRow(scope, entityType, aggregateLocalId);
1902
+ if (request.replicaMutation === 'delete' && !this.#repository.getReplicaRowIncludingPendingDelete) {
1903
+ throw new Error('Offline repository does not support durable replica delete tombstones.');
1904
+ }
1905
+ const existing = await this.#getReplicaRowForSync(scope, entityType, aggregateLocalId);
1850
1906
  const initialServerId = this.#initialServerId(existing?.serverId ?? null, request.serverId);
1851
1907
  const naturalKey = offlineNaturalKeyFromValues(schema, optimisticValue);
1852
1908
  const remoteIdentity = schema.identity.kind === 'serverId'
@@ -1885,6 +1941,7 @@ class OfflineSyncService {
1885
1941
  serverRevision: existing?.serverRevision ?? normalized.baseRevision,
1886
1942
  fetchedAt: Date.now(),
1887
1943
  syncState: 'pending',
1944
+ visibility: request.replicaMutation === 'delete' ? 'pending_delete' : 'present',
1888
1945
  };
1889
1946
  if (generation !== this.#generation) {
1890
1947
  throw new Error('Offline session changed before the command could be persisted');
@@ -2056,7 +2113,7 @@ class OfflineSyncService {
2056
2113
  let baseRevision = request.baseRevision ?? null;
2057
2114
  let payload = request.payload;
2058
2115
  const aggregateLocalId = request.aggregateLocalId;
2059
- const row = await this.#repository.getReplicaRow(scope, this.#entityType(request), aggregateLocalId);
2116
+ const row = await this.#getReplicaRowForSync(scope, this.#entityType(request), aggregateLocalId);
2060
2117
  if (row?.serverRevision != null && row.serverRevision !== baseRevision) {
2061
2118
  const rebased = this.#executor.withServerRevision({ ...scope, ...request, aggregateLocalId, payload, baseRevision }, row.serverRevision);
2062
2119
  baseRevision = row.serverRevision;
@@ -2077,7 +2134,8 @@ class OfflineSyncService {
2077
2134
  throw new Error(`Offline replica row disappeared while completing command ${command.commandId}.`);
2078
2135
  }
2079
2136
  this.#assertServerRevision(result.serverRevision);
2080
- const confirmedValues = result.confirmedValues ?? command.optimisticValue;
2137
+ const removesReplica = result.removeReplica === true || command.replicaMutation === 'delete';
2138
+ const confirmedValues = removesReplica ? null : (result.confirmedValues ?? command.optimisticValue);
2081
2139
  const schema = this.#entitySchema(current.sourceKey);
2082
2140
  this.#assertCommandResultIdentity(schema, current, result);
2083
2141
  const serverId = this.#resolvedServerId(current.serverId, result.serverId);
@@ -2089,12 +2147,13 @@ class OfflineSyncService {
2089
2147
  serverRevision: revision ?? current.serverRevision,
2090
2148
  fetchedAt: Date.now(),
2091
2149
  syncState: rebased.length > 0 ? 'pending' : 'confirmed',
2150
+ visibility: rebased.at(-1)?.replicaMutation === 'delete' ? 'pending_delete' : 'present',
2092
2151
  };
2093
2152
  if (!this.#isCurrent(generation))
2094
2153
  return;
2095
2154
  await this.#repository.transactReplica({
2096
- putRows: result.removeReplica ? undefined : [row],
2097
- removeRows: result.removeReplica ? [current] : undefined,
2155
+ putRows: removesReplica && rebased.length === 0 ? undefined : [row],
2156
+ removeRows: removesReplica && rebased.length === 0 ? [current] : undefined,
2098
2157
  putCommands: rebased,
2099
2158
  removeCommandIds: [command.commandId],
2100
2159
  });
@@ -2102,7 +2161,11 @@ class OfflineSyncService {
2102
2161
  async #rowForCommand(command) {
2103
2162
  const scope = { userId: command.userId, scopeId: command.scopeId };
2104
2163
  const entityType = this.#entityType(command);
2105
- return this.#repository.getReplicaRow(scope, entityType, command.aggregateLocalId);
2164
+ return this.#getReplicaRowForSync(scope, entityType, command.aggregateLocalId);
2165
+ }
2166
+ #getReplicaRowForSync(scope, sourceKey, localId) {
2167
+ return (this.#repository.getReplicaRowIncludingPendingDelete?.(scope, sourceKey, localId) ??
2168
+ this.#repository.getReplicaRow(scope, sourceKey, localId));
2106
2169
  }
2107
2170
  #replicaState(state) {
2108
2171
  if (state === 'blocked_auth' || state === 'rejected' || state === 'conflict')
@@ -2139,6 +2202,7 @@ class OfflineSyncService {
2139
2202
  ...row,
2140
2203
  values: remaining.length > 0 ? remaining.at(-1).optimisticValue : row.confirmedValues,
2141
2204
  syncState: remaining.length > 0 ? 'pending' : 'confirmed',
2205
+ visibility: remaining.at(-1)?.replicaMutation === 'delete' ? 'pending_delete' : 'present',
2142
2206
  });
2143
2207
  }
2144
2208
  }
@@ -2657,6 +2721,7 @@ const SCHEMA = [
2657
2721
  operation TEXT NOT NULL,
2658
2722
  payload_json TEXT NOT NULL,
2659
2723
  optimistic_value_json TEXT NOT NULL,
2724
+ replica_mutation TEXT NOT NULL DEFAULT 'upsert',
2660
2725
  payload_hash TEXT NOT NULL,
2661
2726
  base_revision_json TEXT,
2662
2727
  state TEXT NOT NULL,
@@ -2717,10 +2782,22 @@ class SqliteOfflineRepository {
2717
2782
  }
2718
2783
  const rows = await this.#query(`SELECT * FROM ${schema.tableName} WHERE ${predicates.join(' AND ')}`, values);
2719
2784
  const row = rows[0];
2720
- if (!row)
2785
+ if (!row || (row['_offline_visibility'] ?? 'present') === 'pending_delete')
2721
2786
  return null;
2722
2787
  return this.#replicaRowFromSqliteRow(schema, scope, sourceKey, localId, row);
2723
2788
  }
2789
+ async getReplicaRowIncludingPendingDelete(scope, sourceKey, localId) {
2790
+ const schema = this.#resolveReplicaEntitySchema(sourceKey);
2791
+ const predicates = ['local_id = ?', '_offline_user_id = ?'];
2792
+ const values = [localId, scope.userId];
2793
+ if (schema.scope === 'partition') {
2794
+ predicates.push('_offline_scope_id = ?');
2795
+ values.push(scope.scopeId);
2796
+ }
2797
+ const rows = await this.#query(`SELECT * FROM ${schema.tableName} WHERE ${predicates.join(' AND ')}`, values);
2798
+ const row = rows[0];
2799
+ return row ? this.#replicaRowFromSqliteRow(schema, scope, sourceKey, localId, row) : null;
2800
+ }
2724
2801
  async getReplicaRows(scope, sourceKey) {
2725
2802
  const schema = this.#resolveReplicaEntitySchema(sourceKey);
2726
2803
  const predicates = ['_offline_user_id = ?'];
@@ -2730,7 +2807,9 @@ class SqliteOfflineRepository {
2730
2807
  values.push(scope.scopeId);
2731
2808
  }
2732
2809
  const rows = await this.#query(`SELECT * FROM ${schema.tableName} WHERE ${predicates.join(' AND ')} ORDER BY local_id ASC`, values);
2733
- return rows.map((row) => this.#replicaRowFromSqliteRow(schema, scope, sourceKey, this.#string(row['local_id']), row));
2810
+ return rows
2811
+ .filter((row) => (row['_offline_visibility'] ?? 'present') !== 'pending_delete')
2812
+ .map((row) => this.#replicaRowFromSqliteRow(schema, scope, sourceKey, this.#string(row['local_id']), row));
2734
2813
  }
2735
2814
  async getReplicaRowByServerId(scope, sourceKey, serverId) {
2736
2815
  const schema = this.#resolveReplicaEntitySchema(sourceKey);
@@ -2857,12 +2936,21 @@ class SqliteOfflineRepository {
2857
2936
  if (!commandColumns.some((column) => column['name'] === 'optimistic_value_json')) {
2858
2937
  await this.#execute(databaseId, 'ALTER TABLE offline_sync_commands ADD COLUMN optimistic_value_json TEXT');
2859
2938
  }
2939
+ if (!commandColumns.some((column) => column['name'] === 'replica_mutation')) {
2940
+ await this.#execute(databaseId, "ALTER TABLE offline_sync_commands ADD COLUMN replica_mutation TEXT NOT NULL DEFAULT 'upsert'");
2941
+ }
2860
2942
  // Keep this repair outside the ADD-column branch so a process/database
2861
2943
  // failure after ALTER but before backfill is retried on every open.
2862
2944
  await this.#execute(databaseId, 'UPDATE offline_sync_commands SET optimistic_value_json = payload_json WHERE optimistic_value_json IS NULL');
2863
2945
  await this.#execute(databaseId, `INSERT INTO offline_metadata (id, schema_version, last_user_id) VALUES (1, ?, NULL)
2864
2946
  ON CONFLICT(id) DO UPDATE SET schema_version = excluded.schema_version`, [OFFLINE_SCHEMA_VERSION]);
2865
2947
  await this.#initializeReplicaSchema(databaseId);
2948
+ for (const entity of this.#options.replicaSchema.entities) {
2949
+ const columns = await this.#queryDatabase(databaseId, `PRAGMA table_info(${entity.tableName})`);
2950
+ if (!columns.some((column) => column['name'] === '_offline_visibility')) {
2951
+ await this.#execute(databaseId, `ALTER TABLE ${entity.tableName} ADD COLUMN _offline_visibility TEXT NOT NULL DEFAULT 'present'`);
2952
+ }
2953
+ }
2866
2954
  }
2867
2955
  async #initializeReplicaSchema(databaseId) {
2868
2956
  const bundle = this.#options.replicaSchema;
@@ -2966,6 +3054,7 @@ class SqliteOfflineRepository {
2966
3054
  operation: this.#string(row['operation']),
2967
3055
  payload: this.#parse(row['payload_json']),
2968
3056
  optimisticValue: this.#parse(row['optimistic_value_json']),
3057
+ replicaMutation: this.#string(row['replica_mutation']),
2969
3058
  payloadHash: this.#string(row['payload_hash']),
2970
3059
  baseRevision: this.#parseNullable(row['base_revision_json']),
2971
3060
  state: this.#string(row['state']),
@@ -2978,12 +3067,13 @@ class SqliteOfflineRepository {
2978
3067
  #putCommand(databaseId, command) {
2979
3068
  return this.#execute(databaseId, `INSERT INTO offline_sync_commands
2980
3069
  (command_id, user_id, scope_id, aggregate_type, aggregate_local_id, operation, payload_json, optimistic_value_json,
2981
- payload_hash, base_revision_json, state, attempts, retry_at, created_at, last_error_code)
2982
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
3070
+ replica_mutation, payload_hash, base_revision_json, state, attempts, retry_at, created_at, last_error_code)
3071
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
2983
3072
  ON CONFLICT(command_id) DO UPDATE SET
2984
3073
  user_id = excluded.user_id, scope_id = excluded.scope_id, aggregate_type = excluded.aggregate_type,
2985
3074
  aggregate_local_id = excluded.aggregate_local_id, operation = excluded.operation, payload_json = excluded.payload_json,
2986
- optimistic_value_json = excluded.optimistic_value_json, payload_hash = excluded.payload_hash,
3075
+ optimistic_value_json = excluded.optimistic_value_json, replica_mutation = excluded.replica_mutation,
3076
+ payload_hash = excluded.payload_hash,
2987
3077
  base_revision_json = excluded.base_revision_json, state = excluded.state, attempts = excluded.attempts,
2988
3078
  retry_at = excluded.retry_at, created_at = excluded.created_at, last_error_code = excluded.last_error_code`, [
2989
3079
  command.commandId,
@@ -2994,6 +3084,7 @@ class SqliteOfflineRepository {
2994
3084
  command.operation,
2995
3085
  JSON.stringify(command.payload),
2996
3086
  JSON.stringify(command.optimisticValue),
3087
+ command.replicaMutation ?? 'upsert',
2997
3088
  command.payloadHash,
2998
3089
  this.#stringifyNullable(command.baseRevision),
2999
3090
  command.state,
@@ -3010,7 +3101,7 @@ class SqliteOfflineRepository {
3010
3101
  if (row.confirmedValues !== null)
3011
3102
  encodeOfflineReplicaValues(schema, row.confirmedValues);
3012
3103
  assertOfflineReplicaNaturalKeyBaseline(schema, row.values, row.confirmedValues);
3013
- const existing = await this.getReplicaRow(row, row.sourceKey, row.localId);
3104
+ const existing = await this.getReplicaRowIncludingPendingDelete(row, row.sourceKey, row.localId);
3014
3105
  if (existing)
3015
3106
  this.#assertReplicaIdentityAssignment(schema, existing, row);
3016
3107
  const confirmedValues = row.confirmedValues === null ? null : projectOfflineReplicaValues(schema, row.confirmedValues);
@@ -3023,6 +3114,7 @@ class SqliteOfflineRepository {
3023
3114
  confirmedValues === null ? null : JSON.stringify(confirmedValues),
3024
3115
  row.serverRevision == null ? null : JSON.stringify(row.serverRevision),
3025
3116
  row.syncState,
3117
+ row.visibility ?? 'present',
3026
3118
  row.fetchedAt,
3027
3119
  ...domainColumns.map((column) => encoded[column] ?? null),
3028
3120
  ];
@@ -3053,8 +3145,8 @@ class SqliteOfflineRepository {
3053
3145
  insertColumns.push('server_id');
3054
3146
  updateSets.push('server_id = excluded.server_id');
3055
3147
  }
3056
- insertColumns.push('_offline_confirmed_json', '_offline_server_revision_json', '_offline_sync_state', '_offline_fetched_at');
3057
- updateSets.push('_offline_confirmed_json = excluded._offline_confirmed_json', '_offline_server_revision_json = excluded._offline_server_revision_json', '_offline_sync_state = excluded._offline_sync_state', '_offline_fetched_at = excluded._offline_fetched_at');
3148
+ insertColumns.push('_offline_confirmed_json', '_offline_server_revision_json', '_offline_sync_state', '_offline_visibility', '_offline_fetched_at');
3149
+ updateSets.push('_offline_confirmed_json = excluded._offline_confirmed_json', '_offline_server_revision_json = excluded._offline_server_revision_json', '_offline_sync_state = excluded._offline_sync_state', '_offline_visibility = excluded._offline_visibility', '_offline_fetched_at = excluded._offline_fetched_at');
3058
3150
  const domainColumns = [];
3059
3151
  for (const field of schema.fields) {
3060
3152
  if (field.policy !== 'column' || field.sqliteColumnName === null)
@@ -3082,6 +3174,7 @@ class SqliteOfflineRepository {
3082
3174
  serverRevision: this.#parseNullable(row['_offline_server_revision_json']),
3083
3175
  fetchedAt: this.#number(row['_offline_fetched_at']),
3084
3176
  syncState: this.#string(row['_offline_sync_state']),
3177
+ visibility: (row['_offline_visibility'] ?? 'present'),
3085
3178
  };
3086
3179
  }
3087
3180
  #resolveReplicaEntitySchema(sourceKey) {