bruce-models 7.1.80 → 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";
@@ -14040,6 +14041,167 @@
14040
14041
  EntityTag.GetListCacheKey = GetListCacheKey;
14041
14042
  })(exports.EntityTag || (exports.EntityTag = {}));
14042
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
+
14043
14205
  (function (EntityTypeTrigger) {
14044
14206
  /**
14045
14207
  * Gets a single Entity Type Trigger record.
@@ -20093,7 +20255,7 @@
20093
20255
  })(exports.UrlUtils || (exports.UrlUtils = {}));
20094
20256
 
20095
20257
  // This is updated with the package.json version on build.
20096
- const VERSION = "7.1.80";
20258
+ const VERSION = "7.1.81";
20097
20259
 
20098
20260
  exports.VERSION = VERSION;
20099
20261
  exports.AbstractApi = AbstractApi;