@jcbuisson/express-x-client 3.1.20 → 3.1.23

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/client.mts +8 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jcbuisson/express-x-client",
3
- "version": "3.1.20",
3
+ "version": "3.1.23",
4
4
  "type": "module",
5
5
  "description": "Client library for ExpressX framework",
6
6
  "main": "src/client.mts",
package/src/client.mts CHANGED
@@ -293,7 +293,12 @@ export function offlinePlugin(app) {
293
293
  async function applyDeleteAcknowledgement(uid, requestDeletedAt, result) {
294
294
  const currentMetadata = await db.metadata.get(uid)
295
295
  if (!currentMetadata || !sameTimestamp(currentMetadata.deleted_at, requestDeletedAt)) return
296
- const [, meta] = Array.isArray(result) ? result : []
296
+ const [value, meta] = Array.isArray(result) ? result : []
297
+ if (value?.uid && !meta?.deleted_at) {
298
+ const restoredValue = { ...value }
299
+ delete restoredValue.__deleted__
300
+ await db.values.put(restoredValue)
301
+ }
297
302
  if (meta?.uid)
298
303
  await db.metadata.put({ ...meta, __dirty__: false })
299
304
  else
@@ -525,6 +530,8 @@ export function offlinePlugin(app) {
525
530
  // uid to Dexie between the idbValues.filter snapshot and this step,
526
531
  // add() would throw ConstraintError and abort the entire transaction,
527
532
  // silently dropping every other addClient record in the batch.
533
+ const currentMetadata = await idbMetadata.get(value.uid)
534
+ if (currentMetadata && compareMetadataTime(metaData, currentMetadata) <= 0) continue
528
535
  await idbValues.put(value)
529
536
  await idbMetadata.put({ ...metaData, __dirty__: false })
530
537
  }