bruce-models 7.1.98 → 7.1.99

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.
@@ -95,6 +95,7 @@
95
95
  ECacheKey["EntityHistoricDataAnalysis"] = "entityhistoricdataanalysis";
96
96
  ECacheKey["EntityHistoricDataPage"] = "entityhistoricdatapage";
97
97
  ECacheKey["AccountLimits"] = "accountlimits";
98
+ ECacheKey["WorkflowType"] = "workflowtype";
98
99
  })(ECacheKey = Api.ECacheKey || (Api.ECacheKey = {}));
99
100
  // 1 minute.
100
101
  Api.DEFAULT_CACHE_DURATION = 60 * 1000;
@@ -23277,8 +23278,313 @@
23277
23278
  UrlUtils.ConstructUrl = ConstructUrl;
23278
23279
  })(exports.UrlUtils || (exports.UrlUtils = {}));
23279
23280
 
23281
+ (function (WorkflowType) {
23282
+ /**
23283
+ * Gets a workflow type by ID.
23284
+ * @param params
23285
+ */
23286
+ function Get(params) {
23287
+ return __awaiter(this, void 0, void 0, function* () {
23288
+ let { api, workflowTypeId, req: reqParams } = params;
23289
+ if (isInvalidId(workflowTypeId)) {
23290
+ throw ("Workflow Type ID is required.");
23291
+ }
23292
+ if (!api) {
23293
+ api = exports.ENVIRONMENT.Api().GetBruceApi();
23294
+ }
23295
+ const key = GetCacheKey(workflowTypeId);
23296
+ const cache = api.GetCacheItem(key, reqParams);
23297
+ if (cache === null || cache === void 0 ? void 0 : cache.found) {
23298
+ return cache.data;
23299
+ }
23300
+ const req = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
23301
+ try {
23302
+ const data = yield api.GET(`workflow/type/${workflowTypeId}`, exports.Api.PrepReqParams(reqParams));
23303
+ res({
23304
+ workflowType: ParseResponse(data)
23305
+ });
23306
+ }
23307
+ catch (e) {
23308
+ rej(e);
23309
+ }
23310
+ }));
23311
+ api.SetCacheItem({
23312
+ key,
23313
+ value: req,
23314
+ req: reqParams
23315
+ });
23316
+ return req;
23317
+ });
23318
+ }
23319
+ WorkflowType.Get = Get;
23320
+ /**
23321
+ * Gets all workflow types.
23322
+ * @param params
23323
+ */
23324
+ function GetList(params) {
23325
+ return __awaiter(this, void 0, void 0, function* () {
23326
+ if (!params) {
23327
+ params = {};
23328
+ }
23329
+ let { api, req: reqParams } = params;
23330
+ if (!api) {
23331
+ api = exports.ENVIRONMENT.Api().GetBruceApi();
23332
+ }
23333
+ const key = GetListCacheKey();
23334
+ const cache = api.GetCacheItem(key, reqParams);
23335
+ if (cache === null || cache === void 0 ? void 0 : cache.found) {
23336
+ return cache.data;
23337
+ }
23338
+ const req = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
23339
+ try {
23340
+ const data = yield api.GET("workflow/types", exports.Api.PrepReqParams(reqParams));
23341
+ res({
23342
+ workflowTypes: ParseListResponse(data)
23343
+ });
23344
+ }
23345
+ catch (e) {
23346
+ rej(e);
23347
+ }
23348
+ }));
23349
+ api.SetCacheItem({
23350
+ key,
23351
+ value: req,
23352
+ req: reqParams
23353
+ });
23354
+ return req;
23355
+ });
23356
+ }
23357
+ WorkflowType.GetList = GetList;
23358
+ /**
23359
+ * Creates or updates a workflow type.
23360
+ * This calls: POST workflow/type/{workflow_type_id} where 0 creates new.
23361
+ * @param params
23362
+ */
23363
+ function Update(params) {
23364
+ return __awaiter(this, void 0, void 0, function* () {
23365
+ let { api, workflowType: data, req: reqParams } = params;
23366
+ if (!api) {
23367
+ api = exports.ENVIRONMENT.Api().GetBruceApi();
23368
+ }
23369
+ if (!data) {
23370
+ data = {};
23371
+ }
23372
+ const id = data.ID && data.ID > 0 ? data.ID : 0;
23373
+ const res = yield api.POST(`workflow/type/${id}`, data, exports.Api.PrepReqParams(reqParams));
23374
+ const parsed = ParseResponse(res);
23375
+ api.Cache.Remove(GetListCacheKey());
23376
+ if (id > 0) {
23377
+ api.Cache.Remove(GetCacheKey(id));
23378
+ }
23379
+ if (parsed === null || parsed === void 0 ? void 0 : parsed.ID) {
23380
+ api.Cache.Remove(GetCacheKey(parsed.ID));
23381
+ }
23382
+ return {
23383
+ workflowType: parsed
23384
+ };
23385
+ });
23386
+ }
23387
+ WorkflowType.Update = Update;
23388
+ /**
23389
+ * Deletes a workflow type by ID.
23390
+ * @param params
23391
+ */
23392
+ function Delete(params) {
23393
+ return __awaiter(this, void 0, void 0, function* () {
23394
+ let { api, workflowTypeId, req: reqParams } = params;
23395
+ if (isInvalidId(workflowTypeId)) {
23396
+ throw ("Workflow Type ID is required.");
23397
+ }
23398
+ if (!api) {
23399
+ api = exports.ENVIRONMENT.Api().GetBruceApi();
23400
+ }
23401
+ yield api.DELETE(`workflow/type/${workflowTypeId}`, exports.Api.PrepReqParams(reqParams));
23402
+ api.Cache.Remove(GetCacheKey(workflowTypeId));
23403
+ api.Cache.Remove(GetListCacheKey());
23404
+ api.Cache.RemoveByStartsWith(GetStatusesCacheKey(workflowTypeId));
23405
+ });
23406
+ }
23407
+ WorkflowType.Delete = Delete;
23408
+ /**
23409
+ * Gets the workflow statuses enabled for a workflow type.
23410
+ * @param params
23411
+ */
23412
+ function GetStatuses(params) {
23413
+ return __awaiter(this, void 0, void 0, function* () {
23414
+ let { api, workflowTypeId, req: reqParams } = params;
23415
+ if (isInvalidId(workflowTypeId)) {
23416
+ throw ("Workflow Type ID is required.");
23417
+ }
23418
+ if (!api) {
23419
+ api = exports.ENVIRONMENT.Api().GetBruceApi();
23420
+ }
23421
+ const key = GetStatusesCacheKey(workflowTypeId);
23422
+ const cache = api.GetCacheItem(key, reqParams);
23423
+ if (cache === null || cache === void 0 ? void 0 : cache.found) {
23424
+ return cache.data;
23425
+ }
23426
+ const req = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
23427
+ try {
23428
+ const data = yield api.GET(`workflow/type/${workflowTypeId}/statuses`, exports.Api.PrepReqParams(reqParams));
23429
+ res({
23430
+ statuses: ParseStatusListResponse(data)
23431
+ });
23432
+ }
23433
+ catch (e) {
23434
+ rej(e);
23435
+ }
23436
+ }));
23437
+ api.SetCacheItem({
23438
+ key,
23439
+ value: req,
23440
+ req: reqParams
23441
+ });
23442
+ return req;
23443
+ });
23444
+ }
23445
+ WorkflowType.GetStatuses = GetStatuses;
23446
+ /**
23447
+ * Adds statuses to the list enabled for a workflow type.
23448
+ * @param params
23449
+ */
23450
+ function AddStatuses(params) {
23451
+ return __awaiter(this, void 0, void 0, function* () {
23452
+ let { api, workflowTypeId, workflowStatusIds, req: reqParams } = params;
23453
+ if (isInvalidId(workflowTypeId)) {
23454
+ throw ("Workflow Type ID is required.");
23455
+ }
23456
+ if (!(workflowStatusIds === null || workflowStatusIds === void 0 ? void 0 : workflowStatusIds.length)) {
23457
+ throw ("Workflow Status ID is required.");
23458
+ }
23459
+ if (!api) {
23460
+ api = exports.ENVIRONMENT.Api().GetBruceApi();
23461
+ }
23462
+ yield api.POST(`workflow/type/${workflowTypeId}/status/add`, {
23463
+ "WorkflowStatus.ID": workflowStatusIds
23464
+ }, exports.Api.PrepReqParams(reqParams));
23465
+ api.Cache.Remove(GetCacheKey(workflowTypeId));
23466
+ api.Cache.Remove(GetStatusesCacheKey(workflowTypeId));
23467
+ });
23468
+ }
23469
+ WorkflowType.AddStatuses = AddStatuses;
23470
+ /**
23471
+ * Removes statuses from the list enabled for a workflow type.
23472
+ * @param params
23473
+ */
23474
+ function RemoveStatuses(params) {
23475
+ return __awaiter(this, void 0, void 0, function* () {
23476
+ let { api, workflowTypeId, workflowStatusIds, req: reqParams } = params;
23477
+ if (isInvalidId(workflowTypeId)) {
23478
+ throw ("Workflow Type ID is required.");
23479
+ }
23480
+ if (!(workflowStatusIds === null || workflowStatusIds === void 0 ? void 0 : workflowStatusIds.length)) {
23481
+ throw ("Workflow Status ID is required.");
23482
+ }
23483
+ if (!api) {
23484
+ api = exports.ENVIRONMENT.Api().GetBruceApi();
23485
+ }
23486
+ yield api.POST(`workflow/type/${workflowTypeId}/status/remove`, {
23487
+ "WorkflowStatus.ID": workflowStatusIds
23488
+ }, exports.Api.PrepReqParams(reqParams));
23489
+ api.Cache.Remove(GetCacheKey(workflowTypeId));
23490
+ api.Cache.Remove(GetStatusesCacheKey(workflowTypeId));
23491
+ });
23492
+ }
23493
+ WorkflowType.RemoveStatuses = RemoveStatuses;
23494
+ /**
23495
+ * Normalizes response from workflow type get/update endpoints.
23496
+ */
23497
+ function ParseResponse(response) {
23498
+ var _a, _b, _c, _d, _e, _f, _g, _h;
23499
+ const parsed = parseObject$6(response);
23500
+ const parsedResult = (_a = parseObject$6(parsed === null || parsed === void 0 ? void 0 : parsed.Result)) !== null && _a !== void 0 ? _a : parsed === null || parsed === void 0 ? void 0 : parsed.Result;
23501
+ return (_h = (_g = (_f = (_e = (_d = (_c = (_b = parsed === null || parsed === void 0 ? void 0 : parsed.WorkflowType) !== null && _b !== void 0 ? _b : parsed === null || parsed === void 0 ? void 0 : parsed.WorkflowItemType) !== null && _c !== void 0 ? _c : parsed === null || parsed === void 0 ? void 0 : parsed.BruceWorkflowItemType) !== null && _d !== void 0 ? _d : parsedResult === null || parsedResult === void 0 ? void 0 : parsedResult.WorkflowType) !== null && _e !== void 0 ? _e : parsedResult === null || parsedResult === void 0 ? void 0 : parsedResult.WorkflowItemType) !== null && _f !== void 0 ? _f : parsedResult === null || parsedResult === void 0 ? void 0 : parsedResult.BruceWorkflowItemType) !== null && _g !== void 0 ? _g : parsedResult) !== null && _h !== void 0 ? _h : parsed;
23502
+ }
23503
+ WorkflowType.ParseResponse = ParseResponse;
23504
+ /**
23505
+ * Normalizes response from workflow type list endpoints.
23506
+ */
23507
+ function ParseListResponse(response) {
23508
+ return parseList(response, ["WorkflowTypes", "WorkflowItemTypes", "BruceWorkflowItemTypes"]);
23509
+ }
23510
+ WorkflowType.ParseListResponse = ParseListResponse;
23511
+ /**
23512
+ * Normalizes response from workflow type status list endpoints.
23513
+ */
23514
+ function ParseStatusListResponse(response) {
23515
+ return parseList(response, ["Statuses", "WorkflowStatuses", "WorkflowItemStatuses", "BruceWorkflowItemStatuses"]);
23516
+ }
23517
+ WorkflowType.ParseStatusListResponse = ParseStatusListResponse;
23518
+ /**
23519
+ * Returns cache identifier for a workflow type by ID.
23520
+ * @param id
23521
+ * @returns
23522
+ */
23523
+ function GetCacheKey(id) {
23524
+ return `${exports.Api.ECacheKey.WorkflowType}${exports.Api.ECacheKey.Id}${id}`;
23525
+ }
23526
+ WorkflowType.GetCacheKey = GetCacheKey;
23527
+ /**
23528
+ * Returns cache identifier for the workflow type list.
23529
+ * @returns
23530
+ */
23531
+ function GetListCacheKey() {
23532
+ return exports.Api.ECacheKey.WorkflowType;
23533
+ }
23534
+ WorkflowType.GetListCacheKey = GetListCacheKey;
23535
+ /**
23536
+ * Returns cache identifier for the statuses enabled for a workflow type.
23537
+ * @param workflowTypeId
23538
+ * @returns
23539
+ */
23540
+ function GetStatusesCacheKey(workflowTypeId) {
23541
+ return `${exports.Api.ECacheKey.WorkflowType}${exports.Api.ECacheKey.Id}${workflowTypeId}${exports.Api.ECacheKey.ListId}statuses`;
23542
+ }
23543
+ WorkflowType.GetStatusesCacheKey = GetStatusesCacheKey;
23544
+ })(exports.WorkflowType || (exports.WorkflowType = {}));
23545
+ // Alias that mirrors the API route/model wording.
23546
+ var WorkflowItemType = exports.WorkflowType;
23547
+ function parseObject$6(data) {
23548
+ if (data == null || data == undefined) {
23549
+ return null;
23550
+ }
23551
+ if (typeof data == "string") {
23552
+ try {
23553
+ return JSON.parse(data);
23554
+ }
23555
+ catch (_a) {
23556
+ return null;
23557
+ }
23558
+ }
23559
+ return data;
23560
+ }
23561
+ function isInvalidId(id) {
23562
+ return id == null || id === "" || !isFinite(Number(id)) || Number(id) <= 0;
23563
+ }
23564
+ function parseList(response, wrapperKeys) {
23565
+ var _a, _b, _c, _d, _e, _f;
23566
+ const parsed = parseObject$6(response);
23567
+ const parsedResult = (_a = parseObject$6(parsed === null || parsed === void 0 ? void 0 : parsed.Result)) !== null && _a !== void 0 ? _a : parsed === null || parsed === void 0 ? void 0 : parsed.Result;
23568
+ const list = (_f = (_e = (_d = (_c = (_b = parsed === null || parsed === void 0 ? void 0 : parsed.Items) !== null && _b !== void 0 ? _b : parsedResult === null || parsedResult === void 0 ? void 0 : parsedResult.Items) !== null && _c !== void 0 ? _c : getFirstWrappedArray(parsed, wrapperKeys)) !== null && _d !== void 0 ? _d : getFirstWrappedArray(parsedResult, wrapperKeys)) !== null && _e !== void 0 ? _e : parsedResult) !== null && _f !== void 0 ? _f : parsed;
23569
+ if (Array.isArray(list)) {
23570
+ return list;
23571
+ }
23572
+ return [];
23573
+ }
23574
+ function getFirstWrappedArray(data, wrapperKeys) {
23575
+ if (!data) {
23576
+ return null;
23577
+ }
23578
+ for (const key of wrapperKeys) {
23579
+ if (Array.isArray(data[key])) {
23580
+ return data[key];
23581
+ }
23582
+ }
23583
+ return null;
23584
+ }
23585
+
23280
23586
  // This is updated with the package.json version on build.
23281
- const VERSION = "7.1.98";
23587
+ const VERSION = "7.1.99";
23282
23588
 
23283
23589
  exports.VERSION = VERSION;
23284
23590
  exports.AbstractApi = AbstractApi;
@@ -23291,6 +23597,7 @@
23291
23597
  exports.NAVIGATOR_CHAT_EVENT_SCENE_CONTEXT_PREFETCHED = NAVIGATOR_CHAT_EVENT_SCENE_CONTEXT_PREFETCHED;
23292
23598
  exports.NavigatorChatClient = NavigatorChatClient;
23293
23599
  exports.NavigatorMcpWebSocketClient = NavigatorMcpWebSocketClient;
23600
+ exports.WorkflowItemType = WorkflowItemType;
23294
23601
 
23295
23602
  Object.defineProperty(exports, '__esModule', { value: true });
23296
23603