bkper-js 1.45.0 → 1.46.1
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/lib/index.d.ts +26 -0
- package/lib/model/App.js +30 -0
- package/lib/model/Book.js +60 -10
- package/lib/model/Group.js +2 -2
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -417,6 +417,26 @@ export declare class App {
|
|
|
417
417
|
* @return The name of the owner of this App
|
|
418
418
|
*/
|
|
419
419
|
getOwnerName(): string | undefined;
|
|
420
|
+
/**
|
|
421
|
+
* @return The menu url of this App
|
|
422
|
+
*/
|
|
423
|
+
getMenuUrl(): string | undefined;
|
|
424
|
+
/**
|
|
425
|
+
* @return The menu development url of this App
|
|
426
|
+
*/
|
|
427
|
+
getMenuUrlDev(): string | undefined;
|
|
428
|
+
/**
|
|
429
|
+
* @return The menu text of this App
|
|
430
|
+
*/
|
|
431
|
+
getMenuText(): string | undefined;
|
|
432
|
+
/**
|
|
433
|
+
* @return The menu popup width of this App
|
|
434
|
+
*/
|
|
435
|
+
getMenuPopupWidth(): string | undefined;
|
|
436
|
+
/**
|
|
437
|
+
* @return The menu popup height of this App
|
|
438
|
+
*/
|
|
439
|
+
getMenuPopupHeight(): string | undefined;
|
|
420
440
|
/**
|
|
421
441
|
* @return The logo url of the owner of this App
|
|
422
442
|
*/
|
|
@@ -725,6 +745,8 @@ export declare class Book {
|
|
|
725
745
|
|
|
726
746
|
|
|
727
747
|
|
|
748
|
+
|
|
749
|
+
|
|
728
750
|
constructor(payload?: bkper.Book);
|
|
729
751
|
/**
|
|
730
752
|
* @returns An immutable copy of the json payload
|
|
@@ -1074,6 +1096,10 @@ export declare class Book {
|
|
|
1074
1096
|
|
|
1075
1097
|
|
|
1076
1098
|
|
|
1099
|
+
|
|
1100
|
+
|
|
1101
|
+
|
|
1102
|
+
|
|
1077
1103
|
/**
|
|
1078
1104
|
* Gets a [[Group]] object
|
|
1079
1105
|
*
|
package/lib/model/App.js
CHANGED
|
@@ -116,6 +116,36 @@ export class App {
|
|
|
116
116
|
getOwnerName() {
|
|
117
117
|
return this.payload.ownerName;
|
|
118
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* @return The menu url of this App
|
|
121
|
+
*/
|
|
122
|
+
getMenuUrl() {
|
|
123
|
+
return this.payload.menuUrl;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* @return The menu development url of this App
|
|
127
|
+
*/
|
|
128
|
+
getMenuUrlDev() {
|
|
129
|
+
return this.payload.menuUrlDev;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* @return The menu text of this App
|
|
133
|
+
*/
|
|
134
|
+
getMenuText() {
|
|
135
|
+
return this.payload.menuText;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* @return The menu popup width of this App
|
|
139
|
+
*/
|
|
140
|
+
getMenuPopupWidth() {
|
|
141
|
+
return this.payload.menuPopupWidth;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* @return The menu popup height of this App
|
|
145
|
+
*/
|
|
146
|
+
getMenuPopupHeight() {
|
|
147
|
+
return this.payload.menuPopupHeight;
|
|
148
|
+
}
|
|
119
149
|
/**
|
|
120
150
|
* @return The logo url of the owner of this App
|
|
121
151
|
*/
|
package/lib/model/Book.js
CHANGED
|
@@ -643,36 +643,75 @@ export class Book {
|
|
|
643
643
|
if (!idOrName || idOrName.trim() == '') {
|
|
644
644
|
return undefined;
|
|
645
645
|
}
|
|
646
|
+
let account;
|
|
647
|
+
// Try to get account by id
|
|
646
648
|
if (this.idAccountMap) {
|
|
647
|
-
|
|
649
|
+
account = this.idAccountMap.get(idOrName);
|
|
648
650
|
}
|
|
649
|
-
|
|
651
|
+
// Try to get account by name
|
|
652
|
+
if (!account && this.nameAccountMap) {
|
|
653
|
+
account = this.nameAccountMap.get(idOrName);
|
|
654
|
+
}
|
|
655
|
+
// Try to fetch account from server
|
|
656
|
+
if (!account) {
|
|
650
657
|
const accountPayload = yield AccountService.getAccount(this.getId(), idOrName);
|
|
651
658
|
if (accountPayload) {
|
|
652
|
-
|
|
659
|
+
account = new Account(this, accountPayload);
|
|
653
660
|
}
|
|
654
661
|
}
|
|
655
|
-
return
|
|
662
|
+
return account;
|
|
656
663
|
});
|
|
657
664
|
}
|
|
658
665
|
/** @internal */
|
|
659
666
|
updateGroupCache(group) {
|
|
667
|
+
this.updateGroupIdMap(group);
|
|
668
|
+
this.updateGroupNameMap(group);
|
|
669
|
+
if (this.idGroupMap) {
|
|
670
|
+
group.buildGroupTree(this.idGroupMap);
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
/** @internal */
|
|
674
|
+
updateGroupIdMap(group) {
|
|
660
675
|
if (this.idGroupMap) {
|
|
661
676
|
const id = group.getId();
|
|
662
677
|
if (id) {
|
|
663
678
|
this.idGroupMap.set(id, group);
|
|
664
679
|
}
|
|
665
|
-
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
/** @internal */
|
|
683
|
+
updateGroupNameMap(group) {
|
|
684
|
+
if (this.nameGroupMap) {
|
|
685
|
+
const normalizedName = group.getNormalizedName();
|
|
686
|
+
if (normalizedName) {
|
|
687
|
+
this.nameGroupMap.set(normalizedName, group);
|
|
688
|
+
}
|
|
666
689
|
}
|
|
667
690
|
}
|
|
668
691
|
/** @internal */
|
|
669
692
|
updateAccountCache(account) {
|
|
693
|
+
this.updateAccountIdMap(account);
|
|
694
|
+
this.updateAccountNameMap(account);
|
|
695
|
+
if (this.idAccountMap || this.nameAccountMap) {
|
|
696
|
+
this.linkAccountsAndGroups(account);
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
/** @internal */
|
|
700
|
+
updateAccountIdMap(account) {
|
|
670
701
|
if (this.idAccountMap) {
|
|
671
702
|
const id = account.getId();
|
|
672
703
|
if (id) {
|
|
673
704
|
this.idAccountMap.set(id, account);
|
|
674
705
|
}
|
|
675
|
-
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
/** @internal */
|
|
709
|
+
updateAccountNameMap(account) {
|
|
710
|
+
if (this.nameAccountMap) {
|
|
711
|
+
const normalizedName = account.getNormalizedName();
|
|
712
|
+
if (normalizedName) {
|
|
713
|
+
this.nameAccountMap.set(normalizedName, account);
|
|
714
|
+
}
|
|
676
715
|
}
|
|
677
716
|
}
|
|
678
717
|
/** @internal */
|
|
@@ -718,16 +757,23 @@ export class Book {
|
|
|
718
757
|
if (!idOrName || idOrName.trim() == '') {
|
|
719
758
|
return undefined;
|
|
720
759
|
}
|
|
760
|
+
let group;
|
|
761
|
+
// Try to get group by id
|
|
721
762
|
if (this.idGroupMap) {
|
|
722
|
-
|
|
763
|
+
group = this.idGroupMap.get(idOrName);
|
|
723
764
|
}
|
|
724
|
-
|
|
765
|
+
// Try to get group by name
|
|
766
|
+
if (!group && this.nameGroupMap) {
|
|
767
|
+
group = this.nameGroupMap.get(idOrName);
|
|
768
|
+
}
|
|
769
|
+
// Try to fetch group from server
|
|
770
|
+
if (!group) {
|
|
725
771
|
const groupPayload = yield GroupService.getGroup(this.getId(), idOrName);
|
|
726
772
|
if (groupPayload) {
|
|
727
|
-
|
|
773
|
+
group = new Group(this, groupPayload);
|
|
728
774
|
}
|
|
729
775
|
}
|
|
730
|
-
return
|
|
776
|
+
return group;
|
|
731
777
|
});
|
|
732
778
|
}
|
|
733
779
|
/**
|
|
@@ -751,6 +797,7 @@ export class Book {
|
|
|
751
797
|
}
|
|
752
798
|
let groupsObj = groups.map(group => new Group(this, group));
|
|
753
799
|
this.idGroupMap = new Map();
|
|
800
|
+
this.nameGroupMap = new Map();
|
|
754
801
|
for (const group of groupsObj) {
|
|
755
802
|
this.updateGroupCache(group);
|
|
756
803
|
}
|
|
@@ -780,6 +827,7 @@ export class Book {
|
|
|
780
827
|
}
|
|
781
828
|
let accountsObj = accounts.map(account => new Account(this, account));
|
|
782
829
|
this.idAccountMap = new Map();
|
|
830
|
+
this.nameAccountMap = new Map();
|
|
783
831
|
for (const account of accountsObj) {
|
|
784
832
|
this.updateAccountCache(account);
|
|
785
833
|
}
|
|
@@ -804,10 +852,12 @@ export class Book {
|
|
|
804
852
|
/** @internal */
|
|
805
853
|
clearGroupCache() {
|
|
806
854
|
this.idGroupMap = undefined;
|
|
855
|
+
this.nameGroupMap = undefined;
|
|
807
856
|
}
|
|
808
857
|
/** @internal */
|
|
809
858
|
clearAccountCache() {
|
|
810
859
|
this.idAccountMap = undefined;
|
|
860
|
+
this.nameAccountMap = undefined;
|
|
811
861
|
}
|
|
812
862
|
/** @internal */
|
|
813
863
|
setAccount(account, remove) {
|
package/lib/model/Group.js
CHANGED
|
@@ -343,12 +343,12 @@ export class Group {
|
|
|
343
343
|
}
|
|
344
344
|
}
|
|
345
345
|
/** @internal */
|
|
346
|
-
buildGroupTree(
|
|
346
|
+
buildGroupTree(idGroupMap) {
|
|
347
347
|
this.parent = undefined;
|
|
348
348
|
this.depth = undefined;
|
|
349
349
|
this.root = undefined;
|
|
350
350
|
if (this.payload.parent) {
|
|
351
|
-
const parentGroup =
|
|
351
|
+
const parentGroup = idGroupMap.get(this.payload.parent.id || "");
|
|
352
352
|
if (parentGroup) {
|
|
353
353
|
this.parent = parentGroup;
|
|
354
354
|
parentGroup.addChild(this);
|