bruce-models 7.1.107 → 7.1.109

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.
@@ -45,6 +45,7 @@
45
45
  ECacheKey["Entity"] = "entity";
46
46
  ECacheKey["EntityType"] = "entitytype";
47
47
  ECacheKey["EntityTypeRelation"] = "entitytyperelation";
48
+ ECacheKey["EntityTypeSource"] = "entitytypesource";
48
49
  ECacheKey["Ontology"] = "ontology";
49
50
  ECacheKey["EntityTypeTrigger"] = "entitytypetrigger";
50
51
  ECacheKey["DataFeed"] = "datafeed";
@@ -17001,6 +17002,111 @@
17001
17002
  }
17002
17003
  })(exports.EntityTypeRelation || (exports.EntityTypeRelation = {}));
17003
17004
 
17005
+ (function (EntityTypeSource) {
17006
+ let EKind;
17007
+ (function (EKind) {
17008
+ // Deprecated. Behaves as Entity.
17009
+ EKind["Unset"] = "UNSET";
17010
+ // Creates or updates Entities matching the key in the Data Mapping.
17011
+ EKind["Entity"] = "ENTITY";
17012
+ // Overlays attributes onto Entities that already exist.
17013
+ EKind["Attribute"] = "ATTRIBUTE";
17014
+ // On demand only. The Entity's Outline carries a URL to fetch its rows.
17015
+ EKind["Reference"] = "REFERENCE";
17016
+ })(EKind = EntityTypeSource.EKind || (EntityTypeSource.EKind = {}));
17017
+ /**
17018
+ * Gets a single Entity Type Source record, including its Data Mapping.
17019
+ */
17020
+ function Get(params) {
17021
+ return __awaiter(this, void 0, void 0, function* () {
17022
+ let { api, entityTypeId, entityTypeSourceId, req } = params;
17023
+ if (!entityTypeId) {
17024
+ throw ("Entity Type ID is required.");
17025
+ }
17026
+ if (!entityTypeSourceId) {
17027
+ throw ("Entity Type Source ID is required.");
17028
+ }
17029
+ if (!api) {
17030
+ api = exports.ENVIRONMENT.Api().GetBruceApi();
17031
+ }
17032
+ const key = GetCacheKey(entityTypeId, entityTypeSourceId);
17033
+ const cache = api.GetCacheItem(key, req);
17034
+ if (cache === null || cache === void 0 ? void 0 : cache.found) {
17035
+ return cache.data;
17036
+ }
17037
+ const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
17038
+ try {
17039
+ const data = yield api.GET(`entityType/${entityTypeId}/source/${entityTypeSourceId}`, exports.Api.PrepReqParams(req));
17040
+ res({
17041
+ source: data
17042
+ });
17043
+ }
17044
+ catch (e) {
17045
+ rej(e);
17046
+ }
17047
+ }));
17048
+ api.SetCacheItem({
17049
+ key,
17050
+ value: prom,
17051
+ req
17052
+ });
17053
+ return prom;
17054
+ });
17055
+ }
17056
+ EntityTypeSource.Get = Get;
17057
+ /**
17058
+ * Gets the Entity Type Source records feeding the specified Entity Type.
17059
+ */
17060
+ function GetList(params) {
17061
+ return __awaiter(this, void 0, void 0, function* () {
17062
+ let { api, entityTypeId, req } = params;
17063
+ if (!entityTypeId) {
17064
+ throw ("Entity Type ID is required.");
17065
+ }
17066
+ if (!api) {
17067
+ api = exports.ENVIRONMENT.Api().GetBruceApi();
17068
+ }
17069
+ const key = GetListCacheKey(entityTypeId);
17070
+ const cache = api.GetCacheItem(key, req);
17071
+ if (cache === null || cache === void 0 ? void 0 : cache.found) {
17072
+ return cache.data;
17073
+ }
17074
+ const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
17075
+ try {
17076
+ const data = yield api.GET(`entityType/${entityTypeId}/sources`, exports.Api.PrepReqParams(req));
17077
+ res({
17078
+ sources: Array.isArray(data === null || data === void 0 ? void 0 : data.Items) ? data.Items : []
17079
+ });
17080
+ }
17081
+ catch (e) {
17082
+ rej(e);
17083
+ }
17084
+ }));
17085
+ api.SetCacheItem({
17086
+ key,
17087
+ value: prom,
17088
+ req
17089
+ });
17090
+ return prom;
17091
+ });
17092
+ }
17093
+ EntityTypeSource.GetList = GetList;
17094
+ /**
17095
+ * Returns cache identifier for an Entity Type Source record.
17096
+ */
17097
+ function GetCacheKey(entityTypeId, entityTypeSourceId) {
17098
+ return exports.Api.ECacheKey.EntityTypeSource + exports.Api.ECacheKey.Id + entityTypeId + exports.Api.ECacheKey.Id + entityTypeSourceId;
17099
+ }
17100
+ EntityTypeSource.GetCacheKey = GetCacheKey;
17101
+ /**
17102
+ * Returns cache identifier for the list of Entity Type Source records for an Entity Type.
17103
+ */
17104
+ function GetListCacheKey(entityTypeId) {
17105
+ return exports.Api.ECacheKey.EntityTypeSource + exports.Api.ECacheKey.Id + entityTypeId;
17106
+ }
17107
+ EntityTypeSource.GetListCacheKey = GetListCacheKey;
17108
+ })(exports.EntityTypeSource || (exports.EntityTypeSource = {}));
17109
+
17004
17110
  (function (EntityTypeTrigger) {
17005
17111
  let EType;
17006
17112
  (function (EType) {
@@ -18366,6 +18472,17 @@
18366
18472
  EAnchorDivSide["BottomRight"] = "BottomRight";
18367
18473
  EAnchorDivSide["TopRight"] = "TopRight";
18368
18474
  })(EAnchorDivSide = Div.EAnchorDivSide || (Div.EAnchorDivSide = {}));
18475
+ /**
18476
+ * Whether a div's height is authored or taken from what is in it.
18477
+ */
18478
+ let ECellSizing;
18479
+ (function (ECellSizing) {
18480
+ // The stored height is the height. Content that does not fit is clipped.
18481
+ ECellSizing["Fixed"] = "FIXED";
18482
+ // The content decides the height, with the stored height as a floor.
18483
+ // The stored height is kept up to date from what was actually laid out.
18484
+ ECellSizing["Auto"] = "AUTO";
18485
+ })(ECellSizing = Div.ECellSizing || (Div.ECellSizing = {}));
18369
18486
  // Describes expected content of a row cell.
18370
18487
  let EItemType;
18371
18488
  (function (EItemType) {
@@ -18909,6 +19026,8 @@
18909
19026
  constructor(toolHandler, options = {}) {
18910
19027
  this.ws = null;
18911
19028
  this.isConnecting = false;
19029
+ this.responseGeneration = 0;
19030
+ this.pendingResponses = [];
18912
19031
  this.toolHandler = toolHandler;
18913
19032
  this.options = options;
18914
19033
  this.currentAuth = options.auth;
@@ -18919,7 +19038,7 @@
18919
19038
  connect(auth) {
18920
19039
  var _a, _b, _c, _d, _e, _f, _g;
18921
19040
  if (auth) {
18922
- this.currentAuth = auth;
19041
+ this.setAuth(auth);
18923
19042
  }
18924
19043
  if (this.isConnecting || ((_a = this.ws) === null || _a === void 0 ? void 0 : _a.readyState) === WebSocket.OPEN) {
18925
19044
  (_c = (_b = this.logger()).debug) === null || _c === void 0 ? void 0 : _c.call(_b, "[NavigatorMcpWS] Connection already active or in-flight; skipping connect.");
@@ -18930,24 +19049,34 @@
18930
19049
  const url = this.buildUrl();
18931
19050
  (_e = (_d = this.logger()).log) === null || _e === void 0 ? void 0 : _e.call(_d, "[NavigatorMcpWS] Connecting to", url);
18932
19051
  this.ws = new WebSocket(url);
19052
+ const socket = this.ws;
18933
19053
  this.ws.onopen = (event) => {
18934
19054
  var _a, _b, _c, _d;
19055
+ if (this.ws !== socket)
19056
+ return;
18935
19057
  (_b = (_a = this.logger()).log) === null || _b === void 0 ? void 0 : _b.call(_a, "[NavigatorMcpWS] Connected");
18936
19058
  this.isConnecting = false;
18937
19059
  this.send({ method: "server_ready" });
19060
+ this.flushResponses();
18938
19061
  (_d = (_c = this.options).onOpen) === null || _d === void 0 ? void 0 : _d.call(_c, event);
18939
19062
  };
18940
19063
  this.ws.onmessage = (event) => {
19064
+ if (this.ws !== socket)
19065
+ return;
18941
19066
  this.handleMessage(event.data);
18942
19067
  };
18943
19068
  this.ws.onerror = (event) => {
18944
19069
  var _a, _b, _c, _d;
19070
+ if (this.ws !== socket)
19071
+ return;
18945
19072
  (_b = (_a = this.logger()).error) === null || _b === void 0 ? void 0 : _b.call(_a, "[NavigatorMcpWS] Error", event);
18946
19073
  (_d = (_c = this.options).onError) === null || _d === void 0 ? void 0 : _d.call(_c, event);
18947
19074
  this.isConnecting = false;
18948
19075
  };
18949
19076
  this.ws.onclose = (event) => {
18950
19077
  var _a, _b, _c, _d;
19078
+ if (this.ws !== socket)
19079
+ return;
18951
19080
  (_b = (_a = this.logger()).log) === null || _b === void 0 ? void 0 : _b.call(_a, "[NavigatorMcpWS] Disconnected");
18952
19081
  this.ws = null;
18953
19082
  this.isConnecting = false;
@@ -18961,6 +19090,9 @@
18961
19090
  }
18962
19091
  disconnect() {
18963
19092
  var _a, _b;
19093
+ // An explicit disconnect ends the logical session; never replay its results.
19094
+ this.responseGeneration++;
19095
+ this.pendingResponses = [];
18964
19096
  if (this.ws) {
18965
19097
  (_b = (_a = this.logger()).debug) === null || _b === void 0 ? void 0 : _b.call(_a, "[NavigatorMcpWS] Closing connection");
18966
19098
  this.ws.close();
@@ -18977,6 +19109,16 @@
18977
19109
  * Call connect() afterwards to establish a connection with the new auth.
18978
19110
  */
18979
19111
  setAuth(auth) {
19112
+ const key = (value) => JSON.stringify([
19113
+ value === null || value === void 0 ? void 0 : value.accountId,
19114
+ value === null || value === void 0 ? void 0 : value.sessionId,
19115
+ value === null || value === void 0 ? void 0 : value.fingerprint,
19116
+ value === null || value === void 0 ? void 0 : value.apiBaseUrl
19117
+ ]);
19118
+ if (key(auth) !== key(this.currentAuth)) {
19119
+ this.responseGeneration++;
19120
+ this.pendingResponses = [];
19121
+ }
18980
19122
  this.currentAuth = auth;
18981
19123
  }
18982
19124
  sendChatEvent(event) {
@@ -19021,7 +19163,7 @@
19021
19163
  return urlInstance.toString();
19022
19164
  }
19023
19165
  handleMessage(raw) {
19024
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
19166
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
19025
19167
  return __awaiter(this, void 0, void 0, function* () {
19026
19168
  try {
19027
19169
  const message = typeof raw === "string" ? JSON.parse(raw) : raw;
@@ -19043,6 +19185,7 @@
19043
19185
  return;
19044
19186
  }
19045
19187
  let result;
19188
+ const generation = this.responseGeneration;
19046
19189
  try {
19047
19190
  result = yield this.toolHandler({
19048
19191
  name: toolName,
@@ -19054,23 +19197,62 @@
19054
19197
  (_l = (_k = this.logger()).error) === null || _l === void 0 ? void 0 : _l.call(_k, "[NavigatorMcpWS] Tool handler threw", error);
19055
19198
  result = `Error: ${error instanceof Error ? error.message : String(error)}`;
19056
19199
  }
19057
- this.send({
19200
+ if (generation !== this.responseGeneration) {
19201
+ (_o = (_m = this.logger()).warn) === null || _o === void 0 ? void 0 : _o.call(_m, "[NavigatorMcpWS] Discarding result from a previous session", messageId);
19202
+ return;
19203
+ }
19204
+ this.sendResponse({
19058
19205
  method: "tool_response",
19059
19206
  id: messageId,
19060
19207
  result
19061
19208
  });
19062
19209
  }
19063
19210
  catch (error) {
19064
- (_o = (_m = this.logger()).error) === null || _o === void 0 ? void 0 : _o.call(_m, "[NavigatorMcpWS] Invalid message", error);
19211
+ (_q = (_p = this.logger()).error) === null || _q === void 0 ? void 0 : _q.call(_p, "[NavigatorMcpWS] Invalid message", error);
19065
19212
  }
19066
19213
  });
19067
19214
  }
19215
+ sendResponse(message) {
19216
+ var _a, _b, _c, _d, _e;
19217
+ if (this.send(message))
19218
+ return;
19219
+ this.pendingResponses = this.pendingResponses.filter((entry) => entry.expiresAt > Date.now());
19220
+ if (this.pendingResponses.length >= NavigatorMcpWebSocketClient.MAX_PENDING_RESPONSES) {
19221
+ const dropped = this.pendingResponses.shift();
19222
+ (_b = (_a = this.logger()).warn) === null || _b === void 0 ? void 0 : _b.call(_a, "[NavigatorMcpWS] Response queue full; dropping oldest result", (_c = dropped === null || dropped === void 0 ? void 0 : dropped.message) === null || _c === void 0 ? void 0 : _c.id);
19223
+ }
19224
+ this.pendingResponses.push({ message, expiresAt: Date.now() + NavigatorMcpWebSocketClient.RESPONSE_TTL_MS });
19225
+ (_e = (_d = this.logger()).warn) === null || _e === void 0 ? void 0 : _e.call(_d, "[NavigatorMcpWS] Tool result queued until reconnect", message.id);
19226
+ }
19227
+ flushResponses() {
19228
+ var _a, _b;
19229
+ const pending = this.pendingResponses;
19230
+ this.pendingResponses = [];
19231
+ for (const entry of pending) {
19232
+ if (entry.expiresAt <= Date.now()) {
19233
+ (_b = (_a = this.logger()).warn) === null || _b === void 0 ? void 0 : _b.call(_a, "[NavigatorMcpWS] Tool result expired before reconnect", entry.message.id);
19234
+ }
19235
+ else if (!this.send(entry.message)) {
19236
+ this.pendingResponses.push(entry);
19237
+ }
19238
+ }
19239
+ }
19068
19240
  send(message) {
19069
- if (this.ws && this.ws.readyState === WebSocket.OPEN) {
19241
+ var _a, _b;
19242
+ if (!this.ws || this.ws.readyState !== WebSocket.OPEN)
19243
+ return false;
19244
+ try {
19070
19245
  this.ws.send(JSON.stringify(message));
19246
+ return true;
19247
+ }
19248
+ catch (error) {
19249
+ (_b = (_a = this.logger()).error) === null || _b === void 0 ? void 0 : _b.call(_a, "[NavigatorMcpWS] Send failed", error);
19250
+ return false;
19071
19251
  }
19072
19252
  }
19073
19253
  }
19254
+ NavigatorMcpWebSocketClient.RESPONSE_TTL_MS = 60000;
19255
+ NavigatorMcpWebSocketClient.MAX_PENDING_RESPONSES = 32;
19074
19256
 
19075
19257
  (function (Plugin) {
19076
19258
  /**
@@ -23943,14 +24125,15 @@
23943
24125
  if (!api) {
23944
24126
  api = exports.ENVIRONMENT.Api().GetBruceApi();
23945
24127
  }
23946
- const key = GetListCacheKey();
24128
+ const url = BuildListUrl(params);
24129
+ const key = GetListCacheKey(params);
23947
24130
  const cache = api.GetCacheItem(key, req);
23948
24131
  if (cache === null || cache === void 0 ? void 0 : cache.found) {
23949
24132
  return cache.data;
23950
24133
  }
23951
24134
  const request = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
23952
24135
  try {
23953
- const data = yield api.GET("workflow/schedules", exports.Api.PrepReqParams(req));
24136
+ const data = yield api.GET(url, exports.Api.PrepReqParams(req));
23954
24137
  res({ workflowSchedules: ParseListResponse(data) });
23955
24138
  }
23956
24139
  catch (e) {
@@ -23974,7 +24157,7 @@
23974
24157
  const id = workflowSchedule.ID && workflowSchedule.ID > 0 ? workflowSchedule.ID : 0;
23975
24158
  const data = yield api.POST(`workflow/schedule/${id}`, workflowSchedule, exports.Api.PrepReqParams(req));
23976
24159
  const parsed = ParseResponse(data);
23977
- api.Cache.Remove(GetListCacheKey());
24160
+ api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.WorkflowSchedule);
23978
24161
  if (id > 0) {
23979
24162
  api.Cache.Remove(GetCacheKey(id));
23980
24163
  }
@@ -23996,12 +24179,20 @@
23996
24179
  api = exports.ENVIRONMENT.Api().GetBruceApi();
23997
24180
  }
23998
24181
  yield api.DELETE(`workflow/schedule/${workflowScheduleId}`, exports.Api.PrepReqParams(req));
23999
- api.Cache.Remove(GetCacheKey(workflowScheduleId));
24000
- api.Cache.Remove(GetListCacheKey());
24182
+ api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.WorkflowSchedule);
24001
24183
  api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.WorkflowItem);
24002
24184
  });
24003
24185
  }
24004
24186
  WorkflowSchedule.Delete = Delete;
24187
+ function BuildListUrl(params) {
24188
+ var _a, _b, _c, _d;
24189
+ const q = new URLSearchParams();
24190
+ appendParam$1(q, "Entity.InternalID", (_b = (_a = params === null || params === void 0 ? void 0 : params.entityInternalId) !== null && _a !== void 0 ? _a : params === null || params === void 0 ? void 0 : params["Entity.InternalID"]) !== null && _b !== void 0 ? _b : params === null || params === void 0 ? void 0 : params.EntityInternalID);
24191
+ appendParam$1(q, "Entity.ID", (_d = (_c = params === null || params === void 0 ? void 0 : params.entityId) !== null && _c !== void 0 ? _c : params === null || params === void 0 ? void 0 : params["Entity.ID"]) !== null && _d !== void 0 ? _d : params === null || params === void 0 ? void 0 : params.EntityID);
24192
+ const qs = q.toString();
24193
+ return qs ? `workflow/schedules?${qs}` : "workflow/schedules";
24194
+ }
24195
+ WorkflowSchedule.BuildListUrl = BuildListUrl;
24005
24196
  function ParseResponse(response) {
24006
24197
  var _a, _b, _c, _d;
24007
24198
  const parsed = parseObject$6(response);
@@ -24030,11 +24221,26 @@
24030
24221
  return `${exports.Api.ECacheKey.WorkflowSchedule}${exports.Api.ECacheKey.Id}${id}`;
24031
24222
  }
24032
24223
  WorkflowSchedule.GetCacheKey = GetCacheKey;
24033
- function GetListCacheKey() {
24034
- return exports.Api.ECacheKey.WorkflowSchedule;
24224
+ function GetListCacheKey(params) {
24225
+ const url = BuildListUrl(params);
24226
+ return url === "workflow/schedules"
24227
+ ? exports.Api.ECacheKey.WorkflowSchedule
24228
+ : `${exports.Api.ECacheKey.WorkflowSchedule}${exports.Api.ECacheKey.ListId}${url}`;
24035
24229
  }
24036
24230
  WorkflowSchedule.GetListCacheKey = GetListCacheKey;
24037
24231
  })(exports.WorkflowSchedule || (exports.WorkflowSchedule = {}));
24232
+ function appendParam$1(q, key, value) {
24233
+ if (value == null || value === "") {
24234
+ return;
24235
+ }
24236
+ if (Array.isArray(value)) {
24237
+ if (value.length) {
24238
+ q.append(key, value.join(","));
24239
+ }
24240
+ return;
24241
+ }
24242
+ q.append(key, String(value));
24243
+ }
24038
24244
  function parseObject$6(data) {
24039
24245
  if (data == null || data == undefined) {
24040
24246
  return null;
@@ -24359,7 +24565,7 @@
24359
24565
  }
24360
24566
 
24361
24567
  // This is updated with the package.json version on build.
24362
- const VERSION = "7.1.107";
24568
+ const VERSION = "7.1.109";
24363
24569
 
24364
24570
  exports.VERSION = VERSION;
24365
24571
  exports.AbstractApi = AbstractApi;