bkper-js 2.31.1 → 2.31.2
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/CHANGELOG.md +5 -0
- package/README.md +61 -32
- package/dist/bkper.min.js +1 -1
- package/dist/bkper.min.js.map +2 -2
- package/lib/model/Book.js +20 -2
- package/package.json +1 -1
package/lib/model/Book.js
CHANGED
|
@@ -989,9 +989,27 @@ export class Book extends ResourceProperty {
|
|
|
989
989
|
}
|
|
990
990
|
}
|
|
991
991
|
}
|
|
992
|
-
/**
|
|
992
|
+
/**
|
|
993
|
+
* Ensures every group has a cached `.accounts` Map after accounts are loaded.
|
|
994
|
+
*
|
|
995
|
+
* `linkAccountsAndGroups()` populates `.accounts` on groups that have accounts
|
|
996
|
+
* linked to them. Groups with zero accounts keep `.accounts = undefined`. This
|
|
997
|
+
* method fills that gap by initializing an empty Map on those groups.
|
|
998
|
+
*
|
|
999
|
+
* Without this, `Group.getAccounts()` sees `undefined`, skips the cache check,
|
|
1000
|
+
* and falls through to a network request per group — causing hundreds of
|
|
1001
|
+
* redundant `/groups/{id}/accounts` calls on books with many groups.
|
|
1002
|
+
*
|
|
1003
|
+
* IMPORTANT: This method must NOT be guarded by `allGroupsLoaded` or any
|
|
1004
|
+
* similar flag. It runs inside `mapAccounts()`, which is always called after
|
|
1005
|
+
* `mapGroups()` sets `allGroupsLoaded = true`. A guard like
|
|
1006
|
+
* `if (!this.allGroupsLoaded)` would make this method dead code, silently
|
|
1007
|
+
* reintroducing the redundant network requests.
|
|
1008
|
+
*
|
|
1009
|
+
* @internal
|
|
1010
|
+
*/
|
|
993
1011
|
ensureGroupsAccountMapsLoaded() {
|
|
994
|
-
if (this.idGroupMap
|
|
1012
|
+
if (this.idGroupMap) {
|
|
995
1013
|
for (const group of this.idGroupMap.values()) {
|
|
996
1014
|
if (group.accounts == null) {
|
|
997
1015
|
group.accounts = new Map();
|