pict-section-recordset 1.17.0 → 1.18.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pict-section-recordset",
3
- "version": "1.17.0",
3
+ "version": "1.18.0",
4
4
  "description": "Pict dynamic record set management views",
5
5
  "main": "source/Pict-Section-RecordSet.js",
6
6
  "files": [
@@ -38,6 +38,31 @@ class PictRecordSetAssociationManager extends libPictProvider
38
38
 
39
39
  /** @type {Record<string, any>} - Lazily-created EntityProviders scoped to a non-default URL prefix. */
40
40
  this._scopedEntityProviders = {};
41
+
42
+ /** @type {string} - EntityProvider cache scope for join-list reads; cleared on every join write so
43
+ * the editor and pickers never show a stale (cached) association list after an add or remove. */
44
+ this._cacheScope = 'RecordSetAssociation';
45
+ }
46
+
47
+ /**
48
+ * Invalidate the cached join-list reads after a write so the next list reflects it immediately
49
+ * (pict's EntityProvider caches getEntitySet by filter for ~10s; clearScope no-ops on the default
50
+ * empty scope, which is why join reads run under a dedicated scope).
51
+ * @param {Record<string, any>} pEntityProvider - the (scoped) EntityProvider used for the join.
52
+ */
53
+ _clearAssociationCache(pEntityProvider)
54
+ {
55
+ try
56
+ {
57
+ if (pEntityProvider && (typeof pEntityProvider.clearScope === 'function'))
58
+ {
59
+ pEntityProvider.clearScope(this._cacheScope);
60
+ }
61
+ }
62
+ catch (pError)
63
+ {
64
+ this.pict.log.warn(`AssociationManager: association cache clear failed: ${pError.message || pError}`);
65
+ }
41
66
  }
42
67
 
43
68
  /**
@@ -294,7 +319,7 @@ class PictRecordSetAssociationManager extends libPictProvider
294
319
  return resolve([]);
295
320
  }
296
321
  return resolve(Array.isArray(pRecords) ? pRecords : []);
297
- });
322
+ }, '', { Scope: this._cacheScope, NoCount: true });
298
323
  });
299
324
  }
300
325
 
@@ -326,7 +351,7 @@ class PictRecordSetAssociationManager extends libPictProvider
326
351
  return resolve([]);
327
352
  }
328
353
  return resolve(Array.isArray(pRecords) ? pRecords : []);
329
- });
354
+ }, '', { Scope: this._cacheScope, NoCount: true });
330
355
  });
331
356
  }
332
357
 
@@ -447,6 +472,7 @@ class PictRecordSetAssociationManager extends libPictProvider
447
472
  {
448
473
  return reject(pError);
449
474
  }
475
+ this._clearAssociationCache(tmpEntityProvider);
450
476
  return resolve(pBody);
451
477
  });
452
478
  });
@@ -476,6 +502,7 @@ class PictRecordSetAssociationManager extends libPictProvider
476
502
  {
477
503
  return reject(pError);
478
504
  }
505
+ this._clearAssociationCache(tmpEntityProvider);
479
506
  return resolve(pBody);
480
507
  });
481
508
  });