@jcbuisson/express-x-client 3.1.26 → 3.1.27

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 +10 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jcbuisson/express-x-client",
3
- "version": "3.1.26",
3
+ "version": "3.1.27",
4
4
  "type": "module",
5
5
  "description": "Client library for ExpressX framework",
6
6
  "main": "src/client.mts",
package/src/client.mts CHANGED
@@ -288,6 +288,11 @@ export function offlinePlugin(app) {
288
288
  const currentMetadata = await db.metadata.get(uid)
289
289
  if (!currentMetadata || !sameTimestamp(currentMetadata.updated_at, requestUpdatedAt)) return
290
290
  const [value, meta] = Array.isArray(result) ? result : []
291
+ if (!value?.uid && meta?.deleted_at) {
292
+ await db.values.delete(uid)
293
+ await db.metadata.delete(uid)
294
+ return
295
+ }
291
296
  if (value?.uid) await db.values.put(value)
292
297
  if (meta?.uid)
293
298
  await db.metadata.put({ ...meta, __dirty__: false })
@@ -612,6 +617,11 @@ export function offlinePlugin(app) {
612
617
  const serverMeta = Array.isArray(result) ? result[1] : null
613
618
  currentMetadata = await idbMetadata.get(elt.uid)
614
619
  if (!metadataUnchangedSinceRequest(currentMetadata, elt)) continue
620
+ if (Array.isArray(result) && !result[0]?.uid && serverMeta?.deleted_at) {
621
+ await idbValues.delete(elt.uid)
622
+ await idbMetadata.delete(elt.uid)
623
+ continue
624
+ }
615
625
  if (serverMeta?.uid) await idbMetadata.put({ ...serverMeta, __dirty__: false })
616
626
  else await idbMetadata.update(elt.uid, { __dirty__: false })
617
627
  } catch(err) {