bruce-models 7.1.123 → 7.1.126

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.
@@ -1227,8 +1227,9 @@ class AbstractApi {
1227
1227
  }
1228
1228
  /**
1229
1229
  * Injects auth header into the headers object.
1230
+ * Use this for a request made outside the GET/POST/PUT/DELETE/UPLOAD methods, such as a raw fetch.
1230
1231
  */
1231
- applyAuthHeader(headers) {
1232
+ ApplyAuthHeader(headers) {
1232
1233
  if (!this.ssidHeader) {
1233
1234
  return;
1234
1235
  }
@@ -1271,7 +1272,7 @@ class AbstractApi {
1271
1272
  }
1272
1273
  params.headers = params.headers || {};
1273
1274
  params.headers = Object.assign({ "Content-Type": "application/json;" }, params.headers);
1274
- this.applyAuthHeader(params.headers);
1275
+ this.ApplyAuthHeader(params.headers);
1275
1276
  const res = yield fetch(url, {
1276
1277
  headers: params.headers,
1277
1278
  signal: params.abortSignal
@@ -1293,7 +1294,7 @@ class AbstractApi {
1293
1294
  }
1294
1295
  params.headers = params.headers || {};
1295
1296
  params.headers = Object.assign({ "Content-Type": "application/json;" }, params.headers);
1296
- this.applyAuthHeader(params.headers);
1297
+ this.ApplyAuthHeader(params.headers);
1297
1298
  if (data != null && typeof data != "string") {
1298
1299
  data = JSON.stringify(data);
1299
1300
  }
@@ -1321,7 +1322,7 @@ class AbstractApi {
1321
1322
  }
1322
1323
  params.headers = params.headers || {};
1323
1324
  params.headers = Object.assign({ "Content-Type": "application/json;" }, params.headers);
1324
- this.applyAuthHeader(params.headers);
1325
+ this.ApplyAuthHeader(params.headers);
1325
1326
  if (!data) {
1326
1327
  data = {};
1327
1328
  }
@@ -1352,7 +1353,7 @@ class AbstractApi {
1352
1353
  }
1353
1354
  params.headers = params.headers || {};
1354
1355
  params.headers = Object.assign({ "Content-Type": "application/json;" }, params.headers);
1355
- this.applyAuthHeader(params.headers);
1356
+ this.ApplyAuthHeader(params.headers);
1356
1357
  if (!data) {
1357
1358
  data = {};
1358
1359
  }
@@ -1382,7 +1383,7 @@ class AbstractApi {
1382
1383
  params = {};
1383
1384
  }
1384
1385
  params.headers = Object.assign({}, params.headers);
1385
- this.applyAuthHeader(params.headers);
1386
+ this.ApplyAuthHeader(params.headers);
1386
1387
  const formData = params.formData instanceof FormData ? params.formData : new FormData();
1387
1388
  if (formData.has("file")) {
1388
1389
  formData.delete("file");
@@ -7202,7 +7203,7 @@ var Entity;
7202
7203
  function Update(params) {
7203
7204
  var _a, _b, _c, _d, _e, _f, _g;
7204
7205
  return __awaiter(this, void 0, void 0, function* () {
7205
- let { api, entity: data, entities, override, req: reqParams, migrated, skipSourcePush } = params;
7206
+ let { api, entity: data, entities, override, req: reqParams, migrated, skipSourcePush, expandLocation } = params;
7206
7207
  if (migrated == null || migrated == undefined) {
7207
7208
  // Changed to default = true. 18th April 2025.
7208
7209
  migrated = true;
@@ -7228,9 +7229,16 @@ var Entity;
7228
7229
  if (!api) {
7229
7230
  api = ENVIRONMENT.Api().GetBruceApi();
7230
7231
  }
7231
- let reqUrl = "v3/entities";
7232
+ const urlParams = new URLSearchParams();
7232
7233
  if (skipSourcePushParam) {
7233
- reqUrl += `?SkipSourcePush=${encodeURIComponent(skipSourcePushParam)}`;
7234
+ urlParams.set("SkipSourcePush", skipSourcePushParam);
7235
+ }
7236
+ if (expandLocation) {
7237
+ urlParams.set("Expand", "location");
7238
+ }
7239
+ let reqUrl = "v3/entities";
7240
+ if (urlParams.toString()) {
7241
+ reqUrl += `?${urlParams.toString()}`;
7234
7242
  }
7235
7243
  const reqBody = {
7236
7244
  Items: entities,
@@ -7294,6 +7302,9 @@ var Entity;
7294
7302
  if (skipSourcePushParam) {
7295
7303
  reqUrl += `&SkipSourcePush=${encodeURIComponent(skipSourcePushParam)}`;
7296
7304
  }
7305
+ if (expandLocation) {
7306
+ reqUrl += "&Expand=location";
7307
+ }
7297
7308
  const res = yield api.POST(reqUrl, data, Api.PrepReqParams(reqParams));
7298
7309
  api.Cache.RemoveByContains(GetContainsKey(data.Bruce.ID));
7299
7310
  EntityHistoricData.ClearCacheByEntityIds(api, [data.Bruce.ID]);
@@ -20024,16 +20035,31 @@ var Plugin;
20024
20035
  * @returns
20025
20036
  */
20026
20037
  function GetLoadUrl(params) {
20027
- let { api, pluginId, cacheKey, viaCdn } = params;
20038
+ const { fileUrl } = GetFileUrl(Object.assign(Object.assign({}, params), { filePath: "index.jsc" }));
20039
+ return {
20040
+ indexFileUrl: fileUrl
20041
+ };
20042
+ }
20043
+ Plugin.GetLoadUrl = GetLoadUrl;
20044
+ /**
20045
+ * Returns a URL to a file within a plugin's ZIP.
20046
+ * @param params
20047
+ * @returns
20048
+ */
20049
+ function GetFileUrl(params) {
20050
+ let { api, pluginId, filePath, cacheKey, viaCdn } = params;
20028
20051
  if (!api) {
20029
20052
  api = ENVIRONMENT.Api().GetBruceApi();
20030
20053
  }
20031
20054
  if (!cacheKey) {
20032
20055
  cacheKey = 0;
20033
20056
  }
20057
+ if (filePath.startsWith("/")) {
20058
+ filePath = filePath.substring(1);
20059
+ }
20034
20060
  return {
20035
- indexFileUrl: api.ConstructUrl({
20036
- url: `ui.plugin/${pluginId}/file/index.jsc`,
20061
+ fileUrl: api.ConstructUrl({
20062
+ url: `ui.plugin/${pluginId}/file/${filePath}`,
20037
20063
  urlParams: {
20038
20064
  "version": String(cacheKey)
20039
20065
  },
@@ -20041,7 +20067,53 @@ var Plugin;
20041
20067
  })
20042
20068
  };
20043
20069
  }
20044
- Plugin.GetLoadUrl = GetLoadUrl;
20070
+ Plugin.GetFileUrl = GetFileUrl;
20071
+ /**
20072
+ * Fetches a file within a plugin's ZIP, with the session attached.
20073
+ * Read the returned response as text, blob or JSON depending on the file.
20074
+ * @param params
20075
+ * @returns
20076
+ */
20077
+ function LoadFile(params) {
20078
+ return __awaiter(this, void 0, void 0, function* () {
20079
+ let { api, pluginId, plugin, filePath, req } = params;
20080
+ if (!filePath) {
20081
+ throw ("File path is required.");
20082
+ }
20083
+ if (!api) {
20084
+ api = ENVIRONMENT.Api().GetBruceApi();
20085
+ }
20086
+ yield api.Loading;
20087
+ if (!plugin && pluginId) {
20088
+ plugin = (yield Plugin.Get({
20089
+ pluginId,
20090
+ api,
20091
+ req
20092
+ })).plugin;
20093
+ }
20094
+ if (plugin && !pluginId) {
20095
+ pluginId = plugin.ID;
20096
+ }
20097
+ const { fileUrl } = GetFileUrl({
20098
+ api,
20099
+ pluginId,
20100
+ filePath,
20101
+ cacheKey: plugin.Version,
20102
+ viaCdn: !plugin.IsLoginRequired
20103
+ });
20104
+ const headers = {};
20105
+ api.ApplyAuthHeader(headers);
20106
+ const res = yield fetch(fileUrl, {
20107
+ headers: headers,
20108
+ signal: req === null || req === void 0 ? void 0 : req.abortSignal
20109
+ });
20110
+ if (!res.ok) {
20111
+ throw new Error(`Failed to load "${filePath}" from plugin "${pluginId}" (${res.status}).`);
20112
+ }
20113
+ return res;
20114
+ });
20115
+ }
20116
+ Plugin.LoadFile = LoadFile;
20045
20117
  /**
20046
20118
  * Creates or updates a plugin.
20047
20119
  * @param params
@@ -20151,9 +20223,7 @@ var Plugin;
20151
20223
  }
20152
20224
  else {
20153
20225
  const headers = {};
20154
- if (plugin.IsLoginRequired) {
20155
- headers[api.GetSessionHeader()] = api.GetSessionId();
20156
- }
20226
+ api.ApplyAuthHeader(headers);
20157
20227
  // A refusal must not be cached and run as if it were the plugin's code.
20158
20228
  fileContentProm = fetch(indexFileUrl, {
20159
20229
  headers: headers
@@ -20212,6 +20282,13 @@ var Plugin;
20212
20282
  const paramsId = ObjectUtils.UId();
20213
20283
  window[paramsId] = pluginParams ? pluginParams : {};
20214
20284
  window["PLUGIN_" + pluginId] = plugin;
20285
+ const loadFileId = ObjectUtils.UId();
20286
+ window[loadFileId] = (filePath) => LoadFile({
20287
+ api: loaded.api,
20288
+ plugin,
20289
+ filePath,
20290
+ req
20291
+ });
20215
20292
  const disposeId = ObjectUtils.UId();
20216
20293
  const elementId = ObjectUtils.UId();
20217
20294
  let script = `
@@ -20242,7 +20319,8 @@ var Plugin;
20242
20319
  container: container,
20243
20320
  pluginParams: params,
20244
20321
  pluginId: "${pluginId}",
20245
- plugin: plugin
20322
+ plugin: plugin,
20323
+ loadFile: window["${loadFileId}"]
20246
20324
  });
20247
20325
  }
20248
20326
  run();
@@ -20277,6 +20355,7 @@ var Plugin;
20277
20355
  }
20278
20356
  }
20279
20357
  callDispose();
20358
+ delete window[loadFileId];
20280
20359
  };
20281
20360
  }
20282
20361
  };
@@ -20304,7 +20383,12 @@ var Plugin;
20304
20383
  const contextId = "PLUGIN_CONTEXT_" + callId;
20305
20384
  const resultId = "PLUGIN_RESULT_" + callId;
20306
20385
  window[argsId] = args ? args : {};
20307
- window[contextId] = Object.assign({ config: loaded.plugin.Settings ? loaded.plugin.Settings.config : undefined, plugin: loaded.plugin }, (context ? context : {}));
20386
+ window[contextId] = Object.assign({ config: loaded.plugin.Settings ? loaded.plugin.Settings.config : undefined, plugin: loaded.plugin, loadFile: (filePath) => LoadFile({
20387
+ api: loaded.api,
20388
+ plugin: loaded.plugin,
20389
+ filePath,
20390
+ req
20391
+ }) }, (context ? context : {}));
20308
20392
  const script = `
20309
20393
  function invoke() {
20310
20394
  "use strict";
@@ -25598,7 +25682,7 @@ function getFirstWrappedArray(data, wrapperKeys) {
25598
25682
  }
25599
25683
 
25600
25684
  // This is updated with the package.json version on build.
25601
- const VERSION = "7.1.123";
25685
+ const VERSION = "7.1.126";
25602
25686
 
25603
25687
  export { VERSION, Account, AccountAudit, AccountConcept, AccountFeatures, AccountInvite, AccountLimits, AccountTemplate, AccountType, AnnDocument, AbstractApi, Api, ApiGetters, BruceApi, GlobalApi, GuardianApi, Assembly, Calculator, ChangeSet, ClientFile, ClientFileFolder, ClientFileValueMap, Bounds, BruceEvent, BruceVariable, CacheControl, Camera, Cartes, Carto, Color, DelayQueue, RequestLane, GeoJson, Geometry, LRUCache, UTC, CustomForm, DashboardView, DataFeed, DataLab, DataLabGroup, DataSource, DataTransform, Comment, Entity, EntityAttachment, EntityAttachmentType, EntityAttribute, EntityComment, EntityCoords, EntityHistoricData, EntityLink, EntityLod, EntityLodCategory, EntityRelation, EntityRelationType, EntitySource, EntityTableView, EntityTag, EntityType, EntityTypeRelation, EntityTypeSource, EntityTypeTrigger, Ontology, OntologyDocument, ENVIRONMENT, ExportBrz, ExportCsv, ExportNsx, ExportUsd, Hexbin, ImportAssembly, ImportCad, ImportCsv, ImportGeoJson, ImportJson, ImportKml, ImportLcc, ImportTif, ImportedFile, Uploader, Markup, UIMarkup, NAVIGATOR_CHAT_EVENT_ENTITY_HIGHLIGHT_APPLIED, NAVIGATOR_CHAT_EVENT_SCENE_CONTEXT_PREFETCHED, NavigatorChatClient, NavigatorMcpWebSocketClient, Plugin, PluginAiTool, ProgramKey, MenuItem, ProjectView, ProjectViewBookmark, ProjectViewBookmarkGroup, ProjectViewLegacy, ProjectViewLegacyBookmark, ProjectViewLegacyTile, ProjectViewTile, ZoomControl, Scenario, HostingLocation, MessageBroker, PendingAction, RecordChangeFeed, Style, Tileset, Tracking, Permission, Session, User, UserGroup, UserMfaMethod, EncryptUtils, MathUtils, ObjectUtils, PathUtils, UrlUtils, WorkflowItem, WorkflowSchedule, WorkflowType, WorkflowItemType };
25604
25688
  //# sourceMappingURL=bruce-models.es5.js.map