bruce-models 7.1.79 → 7.1.81

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.
@@ -44,6 +44,7 @@
44
44
  ECacheKey["Assembly"] = "assembly";
45
45
  ECacheKey["Entity"] = "entity";
46
46
  ECacheKey["EntityType"] = "entitytype";
47
+ ECacheKey["EntityTypeRelation"] = "entitytyperelation";
47
48
  ECacheKey["Ontology"] = "ontology";
48
49
  ECacheKey["EntityTypeTrigger"] = "entitytypetrigger";
49
50
  ECacheKey["DataFeed"] = "datafeed";
@@ -9177,6 +9178,22 @@
9177
9178
  function GetFindGeneratedTextureCacheKey(entityTypeSourceId, attribute) {
9178
9179
  return `client-file-find-generated-texture-${entityTypeSourceId}-${attribute}`;
9179
9180
  }
9181
+ const GENERATED_TEXTURE_PURPOSE = "Polygon Texture, ValueMap";
9182
+ const GENERATED_TEXTURE_SOURCE_PATH = "generation/Identity/EntityTypeSourceID";
9183
+ const GENERATED_TEXTURE_ATTRIBUTE_PATH = "generation/Identity/Attribute";
9184
+ /**
9185
+ * Whether a file is the generated value map for this source and attribute.
9186
+ */
9187
+ function IsGeneratedTextureFor(file, entityTypeSourceId, attribute) {
9188
+ var _a, _b;
9189
+ const identity = (_b = (_a = file === null || file === void 0 ? void 0 : file.Data) === null || _a === void 0 ? void 0 : _a.generation) === null || _b === void 0 ? void 0 : _b.Identity;
9190
+ if (!identity) {
9191
+ return false;
9192
+ }
9193
+ // A source ID reaches us as a number from the API and as a string from a filter echo.
9194
+ return Number(identity.EntityTypeSourceID) === Number(entityTypeSourceId) && identity.Attribute === attribute;
9195
+ }
9196
+ ClientFile.IsGeneratedTextureFor = IsGeneratedTextureFor;
9180
9197
  /**
9181
9198
  * Returns a generated texture file for given source ID + attribute combination.
9182
9199
  */
@@ -9198,11 +9215,11 @@
9198
9215
  filter: {
9199
9216
  PageSize: 300,
9200
9217
  PageIndex: 0,
9201
- Purpose: "Polygon Texture",
9218
+ Purpose: GENERATED_TEXTURE_PURPOSE,
9202
9219
  FilterRows: [
9203
9220
  {
9204
9221
  column: Filter.EColumn.Data,
9205
- path: "generation/EntityType.Source.ID",
9222
+ path: GENERATED_TEXTURE_SOURCE_PATH,
9206
9223
  rowOperator: Filter.ERowOperator.AND,
9207
9224
  value: String(entityTypeSourceId),
9208
9225
  includes: true,
@@ -9211,7 +9228,7 @@
9211
9228
  },
9212
9229
  {
9213
9230
  column: Filter.EColumn.Data,
9214
- path: "generation/Attribute",
9231
+ path: GENERATED_TEXTURE_ATTRIBUTE_PATH,
9215
9232
  rowOperator: Filter.ERowOperator.AND,
9216
9233
  value: attribute,
9217
9234
  includes: true,
@@ -9222,12 +9239,7 @@
9222
9239
  },
9223
9240
  req: reqParams
9224
9241
  });
9225
- const match = (res.clientFiles || []).find((file) => {
9226
- var _a;
9227
- const generation = (_a = file === null || file === void 0 ? void 0 : file.Data) === null || _a === void 0 ? void 0 : _a.generation;
9228
- return ((generation === null || generation === void 0 ? void 0 : generation["EntityType.Source.ID"]) === entityTypeSourceId &&
9229
- (generation === null || generation === void 0 ? void 0 : generation.Attribute) === attribute);
9230
- });
9242
+ const match = (res.clientFiles || []).find((file) => IsGeneratedTextureFor(file, entityTypeSourceId, attribute));
9231
9243
  return match || null;
9232
9244
  }))();
9233
9245
  api.SetCacheItem({
@@ -14029,6 +14041,167 @@
14029
14041
  EntityTag.GetListCacheKey = GetListCacheKey;
14030
14042
  })(exports.EntityTag || (exports.EntityTag = {}));
14031
14043
 
14044
+ (function (EntityTypeRelation) {
14045
+ /**
14046
+ * Gets a single Entity Type Relation record.
14047
+ * This calls: GET entityType/{entityType_id}/relation/{entity_type_relation_id}
14048
+ */
14049
+ function Get(params) {
14050
+ return __awaiter(this, void 0, void 0, function* () {
14051
+ let { api, entityTypeId, entityTypeRelationId, req } = params;
14052
+ if (!entityTypeId) {
14053
+ throw ("Entity Type ID is required.");
14054
+ }
14055
+ if (!entityTypeRelationId) {
14056
+ throw ("Entity Type Relation ID is required.");
14057
+ }
14058
+ if (!api) {
14059
+ api = exports.ENVIRONMENT.Api().GetBruceApi();
14060
+ }
14061
+ const key = GetCacheKey(entityTypeId, entityTypeRelationId);
14062
+ const cache = api.GetCacheItem(key, req);
14063
+ if (cache === null || cache === void 0 ? void 0 : cache.found) {
14064
+ return cache.data;
14065
+ }
14066
+ const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
14067
+ try {
14068
+ const data = yield api.GET(`entityType/${entityTypeId}/relation/${entityTypeRelationId}`, exports.Api.PrepReqParams(req));
14069
+ res({
14070
+ relation: data
14071
+ });
14072
+ }
14073
+ catch (e) {
14074
+ rej(e);
14075
+ }
14076
+ }));
14077
+ api.SetCacheItem({
14078
+ key,
14079
+ value: prom,
14080
+ req
14081
+ });
14082
+ return prom;
14083
+ });
14084
+ }
14085
+ EntityTypeRelation.Get = Get;
14086
+ /**
14087
+ * Gets Entity Type Relation records for the specified Entity Type.
14088
+ * This calls: GET entityType/{entityType_id}/relations
14089
+ */
14090
+ function GetList(params) {
14091
+ return __awaiter(this, void 0, void 0, function* () {
14092
+ let { api, entityTypeId, req } = params;
14093
+ if (!entityTypeId) {
14094
+ throw ("Entity Type ID is required.");
14095
+ }
14096
+ if (!api) {
14097
+ api = exports.ENVIRONMENT.Api().GetBruceApi();
14098
+ }
14099
+ const key = GetListCacheKey(entityTypeId);
14100
+ const cache = api.GetCacheItem(key, req);
14101
+ if (cache === null || cache === void 0 ? void 0 : cache.found) {
14102
+ return cache.data;
14103
+ }
14104
+ const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
14105
+ try {
14106
+ const data = yield api.GET(`entityType/${entityTypeId}/relations`, exports.Api.PrepReqParams(req));
14107
+ res({
14108
+ relations: Array.isArray(data === null || data === void 0 ? void 0 : data.Items) ? data.Items : []
14109
+ });
14110
+ }
14111
+ catch (e) {
14112
+ rej(e);
14113
+ }
14114
+ }));
14115
+ api.SetCacheItem({
14116
+ key,
14117
+ value: prom,
14118
+ req
14119
+ });
14120
+ return prom;
14121
+ });
14122
+ }
14123
+ EntityTypeRelation.GetList = GetList;
14124
+ /**
14125
+ * Creates or updates an Entity Type Relation record.
14126
+ * This calls: POST entityType/{entityType_id}/relation/{entity_type_relation_id}
14127
+ */
14128
+ function Update(params) {
14129
+ var _a;
14130
+ return __awaiter(this, void 0, void 0, function* () {
14131
+ let { api, entityTypeId, relation: data, entityTypeRelationId, req } = params;
14132
+ if (!entityTypeId) {
14133
+ throw ("Entity Type ID is required.");
14134
+ }
14135
+ if (!data) {
14136
+ throw ("Entity Type Relation is required.");
14137
+ }
14138
+ if (!api) {
14139
+ api = exports.ENVIRONMENT.Api().GetBruceApi();
14140
+ }
14141
+ const relationId = (_a = entityTypeRelationId !== null && entityTypeRelationId !== void 0 ? entityTypeRelationId : data.ID) !== null && _a !== void 0 ? _a : 0;
14142
+ if (isCreateRoute(relationId) && (!data["A.EntityType.ID"] || !data["B.EntityType.ID"] || !data["EntityRelationType.ID"])) {
14143
+ throw ("A.EntityType.ID, B.EntityType.ID, and EntityRelationType.ID are required.");
14144
+ }
14145
+ const res = yield api.POST(`entityType/${entityTypeId}/relation/${relationId}`, data, exports.Api.PrepReqParams(req));
14146
+ removeRelationCache(api, entityTypeId, relationId, res);
14147
+ return {
14148
+ relation: res
14149
+ };
14150
+ });
14151
+ }
14152
+ EntityTypeRelation.Update = Update;
14153
+ /**
14154
+ * Deletes an Entity Type Relation record.
14155
+ * This calls: DELETE entityType/{entityType_id}/relation/{entity_type_relation_id}
14156
+ */
14157
+ function Delete(params) {
14158
+ return __awaiter(this, void 0, void 0, function* () {
14159
+ let { api, entityTypeId, entityTypeRelationId, req } = params;
14160
+ if (!entityTypeId) {
14161
+ throw ("Entity Type ID is required.");
14162
+ }
14163
+ if (!entityTypeRelationId) {
14164
+ throw ("Entity Type Relation ID is required.");
14165
+ }
14166
+ if (!api) {
14167
+ api = exports.ENVIRONMENT.Api().GetBruceApi();
14168
+ }
14169
+ yield api.DELETE(`entityType/${entityTypeId}/relation/${entityTypeRelationId}`, exports.Api.PrepReqParams(req));
14170
+ removeRelationCache(api, entityTypeId, entityTypeRelationId);
14171
+ });
14172
+ }
14173
+ EntityTypeRelation.Delete = Delete;
14174
+ /**
14175
+ * Returns cache identifier for an Entity Type Relation record.
14176
+ */
14177
+ function GetCacheKey(entityTypeId, entityTypeRelationId) {
14178
+ return exports.Api.ECacheKey.EntityTypeRelation + exports.Api.ECacheKey.Id + entityTypeId + exports.Api.ECacheKey.Id + entityTypeRelationId;
14179
+ }
14180
+ EntityTypeRelation.GetCacheKey = GetCacheKey;
14181
+ /**
14182
+ * Returns cache identifier for the list of Entity Type Relation records for an Entity Type.
14183
+ */
14184
+ function GetListCacheKey(entityTypeId) {
14185
+ return exports.Api.ECacheKey.EntityTypeRelation + exports.Api.ECacheKey.Id + entityTypeId;
14186
+ }
14187
+ EntityTypeRelation.GetListCacheKey = GetListCacheKey;
14188
+ function isCreateRoute(entityTypeRelationId) {
14189
+ return entityTypeRelationId === 0 || entityTypeRelationId === "0";
14190
+ }
14191
+ function removeRelationCache(api, entityTypeId, entityTypeRelationId, relation) {
14192
+ api.Cache.RemoveByStartsWith(GetListCacheKey(entityTypeId));
14193
+ if (!isCreateRoute(entityTypeRelationId)) {
14194
+ api.Cache.Remove(GetCacheKey(entityTypeId, entityTypeRelationId));
14195
+ }
14196
+ if ((relation === null || relation === void 0 ? void 0 : relation["A.EntityType.ID"]) && relation["A.EntityType.ID"] !== entityTypeId) {
14197
+ api.Cache.RemoveByStartsWith(GetListCacheKey(relation["A.EntityType.ID"]));
14198
+ }
14199
+ if ((relation === null || relation === void 0 ? void 0 : relation["B.EntityType.ID"]) && relation["B.EntityType.ID"] !== entityTypeId) {
14200
+ api.Cache.RemoveByStartsWith(GetListCacheKey(relation["B.EntityType.ID"]));
14201
+ }
14202
+ }
14203
+ })(exports.EntityTypeRelation || (exports.EntityTypeRelation = {}));
14204
+
14032
14205
  (function (EntityTypeTrigger) {
14033
14206
  /**
14034
14207
  * Gets a single Entity Type Trigger record.
@@ -20082,7 +20255,7 @@
20082
20255
  })(exports.UrlUtils || (exports.UrlUtils = {}));
20083
20256
 
20084
20257
  // This is updated with the package.json version on build.
20085
- const VERSION = "7.1.79";
20258
+ const VERSION = "7.1.81";
20086
20259
 
20087
20260
  exports.VERSION = VERSION;
20088
20261
  exports.AbstractApi = AbstractApi;