bruce-models 4.8.0 → 4.8.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/dist/bruce-models.es5.js +135 -10
- package/dist/bruce-models.es5.js.map +1 -1
- package/dist/bruce-models.umd.js +135 -10
- package/dist/bruce-models.umd.js.map +1 -1
- package/dist/lib/bruce-models.js +1 -1
- package/dist/lib/entity/entity-type.js +12 -9
- package/dist/lib/entity/entity-type.js.map +1 -1
- package/dist/lib/server/pending-action.js +122 -0
- package/dist/lib/server/pending-action.js.map +1 -1
- package/dist/types/bruce-models.d.ts +1 -1
- package/dist/types/entity/entity-type.d.ts +5 -3
- package/dist/types/server/pending-action.d.ts +35 -0
- package/package.json +1 -1
package/dist/bruce-models.umd.js
CHANGED
|
@@ -2559,21 +2559,24 @@
|
|
|
2559
2559
|
*/
|
|
2560
2560
|
function ReIndex(params) {
|
|
2561
2561
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2562
|
-
let { api, entityTypeId: typeId, req } = params;
|
|
2563
|
-
if (!typeId) {
|
|
2564
|
-
throw ("Type ID is required.");
|
|
2565
|
-
}
|
|
2562
|
+
let { api, entityTypeId: typeId, req, dataTransformId, reSaveAll } = params;
|
|
2566
2563
|
if (!api) {
|
|
2567
2564
|
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
2568
2565
|
}
|
|
2569
2566
|
const urlParams = new URLSearchParams();
|
|
2570
|
-
if (
|
|
2571
|
-
urlParams.append("dataTransformID", String(
|
|
2567
|
+
if (dataTransformId) {
|
|
2568
|
+
urlParams.append("dataTransformID", String(dataTransformId));
|
|
2572
2569
|
}
|
|
2573
|
-
|
|
2570
|
+
if (reSaveAll) {
|
|
2571
|
+
urlParams.append("reSaveAll", "true");
|
|
2572
|
+
}
|
|
2573
|
+
let url = typeId ? `entityType/${typeId}/reindex` : "entities/reindex";
|
|
2574
|
+
url += "?" + urlParams.toString();
|
|
2574
2575
|
req = exports.Api.PrepReqParams(req);
|
|
2575
|
-
const
|
|
2576
|
-
return
|
|
2576
|
+
const res = yield api.POST(url, {}, req);
|
|
2577
|
+
return {
|
|
2578
|
+
pendingActionId: res.PendingActionID
|
|
2579
|
+
};
|
|
2577
2580
|
});
|
|
2578
2581
|
}
|
|
2579
2582
|
EntityType.ReIndex = ReIndex;
|
|
@@ -10548,6 +10551,128 @@
|
|
|
10548
10551
|
});
|
|
10549
10552
|
}
|
|
10550
10553
|
PendingAction.Cancel = Cancel;
|
|
10554
|
+
/**
|
|
10555
|
+
* Resolves when the Pending Action is no longer running.
|
|
10556
|
+
* @param params
|
|
10557
|
+
*
|
|
10558
|
+
* @example
|
|
10559
|
+
* try {
|
|
10560
|
+
* const { action } = await PendingAction.OnCompletion({ actionId: 123 });
|
|
10561
|
+
* }
|
|
10562
|
+
* catch (e) {
|
|
10563
|
+
* // Threw because the action failed to be found.
|
|
10564
|
+
* // Most likely scenarios are invalid actionId or server connection issues.
|
|
10565
|
+
* // If it's related to server connection issues then wait a bit and relaunch.
|
|
10566
|
+
* }
|
|
10567
|
+
*
|
|
10568
|
+
* // Here is how you can stop the loop on early disposal.
|
|
10569
|
+
* let disposed = false;
|
|
10570
|
+
* const { action } = await PendingAction.OnCompletion({
|
|
10571
|
+
* actionId: 123,
|
|
10572
|
+
* isDisposed: () => {
|
|
10573
|
+
* return disposed;
|
|
10574
|
+
* }
|
|
10575
|
+
* });
|
|
10576
|
+
* // Action will resolve as null if it was disposed early.
|
|
10577
|
+
*/
|
|
10578
|
+
function OnCompletion(params) {
|
|
10579
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
10580
|
+
let { api, actionId, req: reqParams, interval: intMs, isDisposed, onMessage } = params;
|
|
10581
|
+
if (!actionId) {
|
|
10582
|
+
throw ("Action ID is required.");
|
|
10583
|
+
}
|
|
10584
|
+
if (!api) {
|
|
10585
|
+
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
10586
|
+
}
|
|
10587
|
+
if (!intMs || intMs <= 0) {
|
|
10588
|
+
intMs = 3000;
|
|
10589
|
+
}
|
|
10590
|
+
// Map of found messages.
|
|
10591
|
+
const returnedMsgs = new Map();
|
|
10592
|
+
const returnedMsgsArr = [];
|
|
10593
|
+
const res = yield new Promise((res, rej) => {
|
|
10594
|
+
let msgInterval = null;
|
|
10595
|
+
if (onMessage != null) {
|
|
10596
|
+
msgInterval = setInterval(() => __awaiter(this, void 0, void 0, function* () {
|
|
10597
|
+
try {
|
|
10598
|
+
const { messages } = yield GetMessages({
|
|
10599
|
+
api,
|
|
10600
|
+
actionId,
|
|
10601
|
+
order: exports.Api.ESortOrder.Desc,
|
|
10602
|
+
startIndex: 0,
|
|
10603
|
+
amount: 5
|
|
10604
|
+
});
|
|
10605
|
+
for (let i = 0; i < messages.length; i++) {
|
|
10606
|
+
const message = messages[i];
|
|
10607
|
+
// If this is a new message we'll notify the callback.
|
|
10608
|
+
// We'll also add it to the map so we don't notify it again, and to return it later.
|
|
10609
|
+
if (!returnedMsgs.has(message.ID)) {
|
|
10610
|
+
returnedMsgs.set(message.ID, true);
|
|
10611
|
+
returnedMsgsArr.push(message);
|
|
10612
|
+
onMessage(message);
|
|
10613
|
+
}
|
|
10614
|
+
}
|
|
10615
|
+
}
|
|
10616
|
+
catch (e) {
|
|
10617
|
+
clearInterval(msgInterval);
|
|
10618
|
+
}
|
|
10619
|
+
}), 1000);
|
|
10620
|
+
}
|
|
10621
|
+
let interval = setInterval(() => __awaiter(this, void 0, void 0, function* () {
|
|
10622
|
+
if (isDisposed && isDisposed()) {
|
|
10623
|
+
clearInterval(interval);
|
|
10624
|
+
if (msgInterval) {
|
|
10625
|
+
clearInterval(msgInterval);
|
|
10626
|
+
}
|
|
10627
|
+
res(null);
|
|
10628
|
+
}
|
|
10629
|
+
try {
|
|
10630
|
+
const { action } = yield Get({
|
|
10631
|
+
api,
|
|
10632
|
+
actionId,
|
|
10633
|
+
req: reqParams
|
|
10634
|
+
});
|
|
10635
|
+
if (action.Status !== EStatus.InProgress) {
|
|
10636
|
+
clearInterval(interval);
|
|
10637
|
+
if (msgInterval) {
|
|
10638
|
+
clearInterval(msgInterval);
|
|
10639
|
+
}
|
|
10640
|
+
res(action);
|
|
10641
|
+
}
|
|
10642
|
+
}
|
|
10643
|
+
catch (e) {
|
|
10644
|
+
clearInterval(interval);
|
|
10645
|
+
if (msgInterval) {
|
|
10646
|
+
clearInterval(msgInterval);
|
|
10647
|
+
}
|
|
10648
|
+
rej(e);
|
|
10649
|
+
}
|
|
10650
|
+
}), intMs);
|
|
10651
|
+
});
|
|
10652
|
+
// Gather latest 30 messages.
|
|
10653
|
+
if (!isDisposed || !isDisposed()) {
|
|
10654
|
+
const { messages } = yield GetMessages({
|
|
10655
|
+
api,
|
|
10656
|
+
actionId,
|
|
10657
|
+
order: exports.Api.ESortOrder.Desc,
|
|
10658
|
+
startIndex: 0,
|
|
10659
|
+
amount: 30
|
|
10660
|
+
});
|
|
10661
|
+
for (let i = 0; i < messages.length; i++) {
|
|
10662
|
+
const message = messages[i];
|
|
10663
|
+
if (!returnedMsgs.has(message.ID)) {
|
|
10664
|
+
returnedMsgs.set(message.ID, true);
|
|
10665
|
+
returnedMsgsArr.push(message);
|
|
10666
|
+
}
|
|
10667
|
+
}
|
|
10668
|
+
}
|
|
10669
|
+
return {
|
|
10670
|
+
action: res,
|
|
10671
|
+
messages: returnedMsgsArr
|
|
10672
|
+
};
|
|
10673
|
+
});
|
|
10674
|
+
}
|
|
10675
|
+
PendingAction.OnCompletion = OnCompletion;
|
|
10551
10676
|
})(exports.PendingAction || (exports.PendingAction = {}));
|
|
10552
10677
|
|
|
10553
10678
|
// Some dead accounts that we don't want to show in the UI.
|
|
@@ -13916,7 +14041,7 @@
|
|
|
13916
14041
|
})(exports.DataSource || (exports.DataSource = {}));
|
|
13917
14042
|
|
|
13918
14043
|
// This is updated with the package.json version on build.
|
|
13919
|
-
const VERSION = "4.8.
|
|
14044
|
+
const VERSION = "4.8.2";
|
|
13920
14045
|
|
|
13921
14046
|
exports.VERSION = VERSION;
|
|
13922
14047
|
exports.AbstractApi = AbstractApi;
|