bruce-models 0.3.0 → 0.3.2
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.
- package/dist/bruce-models.es5.js +105 -3
- package/dist/bruce-models.es5.js.map +1 -1
- package/dist/bruce-models.umd.js +105 -3
- package/dist/bruce-models.umd.js.map +1 -1
- package/dist/lib/api/abstract-api.js +31 -0
- package/dist/lib/api/abstract-api.js.map +1 -1
- package/dist/lib/api/bruce-api.js +7 -0
- package/dist/lib/api/bruce-api.js.map +1 -1
- package/dist/lib/entity/entity-lod.js +49 -0
- package/dist/lib/entity/entity-lod.js.map +1 -1
- package/dist/lib/project/project-view.js +18 -3
- package/dist/lib/project/project-view.js.map +1 -1
- package/dist/types/api/abstract-api.d.ts +1 -0
- package/dist/types/api/bruce-api.d.ts +1 -0
- package/dist/types/entity/entity-lod.d.ts +12 -1
- package/dist/types/project/project-view.d.ts +7 -7
- package/package.json +1 -1
package/dist/bruce-models.umd.js
CHANGED
|
@@ -531,6 +531,37 @@
|
|
|
531
531
|
});
|
|
532
532
|
});
|
|
533
533
|
};
|
|
534
|
+
AbstractApi.prototype.put = function (url, data, params) {
|
|
535
|
+
var _a;
|
|
536
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
537
|
+
var res;
|
|
538
|
+
var _b;
|
|
539
|
+
return __generator(this, function (_c) {
|
|
540
|
+
switch (_c.label) {
|
|
541
|
+
case 0:
|
|
542
|
+
if (!params) {
|
|
543
|
+
params = {};
|
|
544
|
+
}
|
|
545
|
+
params.headers = params.headers || {};
|
|
546
|
+
params.headers = __assign((_b = { "Content-Type": "application/json;" }, _b[this.ssidHeader] = this.ssid, _b), params.headers);
|
|
547
|
+
if (!data) {
|
|
548
|
+
data = {};
|
|
549
|
+
}
|
|
550
|
+
if (typeof data != "string") {
|
|
551
|
+
data = JSON.stringify(data);
|
|
552
|
+
}
|
|
553
|
+
return [4 /*yield*/, fetch(url, {
|
|
554
|
+
headers: params.headers,
|
|
555
|
+
method: "PUT",
|
|
556
|
+
body: data
|
|
557
|
+
})];
|
|
558
|
+
case 1:
|
|
559
|
+
res = _c.sent();
|
|
560
|
+
return [2 /*return*/, parseResult(res, (_a = params.response) === null || _a === void 0 ? void 0 : _a.encoding)];
|
|
561
|
+
}
|
|
562
|
+
});
|
|
563
|
+
});
|
|
564
|
+
};
|
|
534
565
|
AbstractApi.prototype.upload = function (url, blob, params) {
|
|
535
566
|
return __awaiter(this, void 0, void 0, function () {
|
|
536
567
|
var _this = this;
|
|
@@ -655,6 +686,13 @@
|
|
|
655
686
|
});
|
|
656
687
|
});
|
|
657
688
|
};
|
|
689
|
+
BruceApi.prototype.PUT = function (url, data, params) {
|
|
690
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
691
|
+
return __generator(this, function (_a) {
|
|
692
|
+
return [2 /*return*/, this.put(this.baseUrl + url, data, params)];
|
|
693
|
+
});
|
|
694
|
+
});
|
|
695
|
+
};
|
|
658
696
|
BruceApi.prototype.UPLOAD = function (url, blob, params) {
|
|
659
697
|
return __awaiter(this, void 0, void 0, function () {
|
|
660
698
|
return __generator(this, function (_a) {
|
|
@@ -2230,6 +2268,10 @@
|
|
|
2230
2268
|
return exports.Api.ECacheKey.Lod + exports.Api.ECacheKey.Id + url;
|
|
2231
2269
|
}
|
|
2232
2270
|
EntityLod.GetCacheKey = GetCacheKey;
|
|
2271
|
+
function GetTypeListKey(typeId, group) {
|
|
2272
|
+
return exports.Api.ECacheKey.Lod + exports.Api.ECacheKey.EntityType + typeId + exports.Api.ECacheKey.Id + group;
|
|
2273
|
+
}
|
|
2274
|
+
EntityLod.GetTypeListKey = GetTypeListKey;
|
|
2233
2275
|
function GetUrl(api, entityId, categoryId, level, strict) {
|
|
2234
2276
|
if (!entityId) {
|
|
2235
2277
|
throw ("Entity ID is required.");
|
|
@@ -2303,6 +2345,51 @@
|
|
|
2303
2345
|
});
|
|
2304
2346
|
}
|
|
2305
2347
|
EntityLod.GetLods = GetLods;
|
|
2348
|
+
/**
|
|
2349
|
+
* Returns lods for a specified entity type.
|
|
2350
|
+
* @param api
|
|
2351
|
+
* @param typeId
|
|
2352
|
+
* @param group default is "DEFAULT".
|
|
2353
|
+
*/
|
|
2354
|
+
function GetTypeLods(api, typeId, group) {
|
|
2355
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2356
|
+
var cacheData, url, req, prom;
|
|
2357
|
+
var _this = this;
|
|
2358
|
+
return __generator(this, function (_a) {
|
|
2359
|
+
if (!group) {
|
|
2360
|
+
group = "DEFAULT";
|
|
2361
|
+
}
|
|
2362
|
+
cacheData = api.Cache.Get(GetTypeListKey(typeId, group));
|
|
2363
|
+
if (cacheData) {
|
|
2364
|
+
return [2 /*return*/, cacheData];
|
|
2365
|
+
}
|
|
2366
|
+
url = "entityType/" + typeId + "/lods?includeClientFiles=yes" + (group ? "&group=" + group : "");
|
|
2367
|
+
req = api.GET(url, exports.Api.PrepReqParams());
|
|
2368
|
+
prom = new Promise(function (res, rej) { return __awaiter(_this, void 0, void 0, function () {
|
|
2369
|
+
var data, e_2;
|
|
2370
|
+
return __generator(this, function (_a) {
|
|
2371
|
+
switch (_a.label) {
|
|
2372
|
+
case 0:
|
|
2373
|
+
_a.trys.push([0, 2, , 3]);
|
|
2374
|
+
return [4 /*yield*/, req];
|
|
2375
|
+
case 1:
|
|
2376
|
+
data = _a.sent();
|
|
2377
|
+
res(data.Items);
|
|
2378
|
+
return [3 /*break*/, 3];
|
|
2379
|
+
case 2:
|
|
2380
|
+
e_2 = _a.sent();
|
|
2381
|
+
rej(e_2);
|
|
2382
|
+
return [3 /*break*/, 3];
|
|
2383
|
+
case 3: return [2 /*return*/];
|
|
2384
|
+
}
|
|
2385
|
+
});
|
|
2386
|
+
}); });
|
|
2387
|
+
api.Cache.Set(GetTypeListKey(typeId, group), prom, exports.Api.DEFAULT_CACHE_DURATION);
|
|
2388
|
+
return [2 /*return*/, prom];
|
|
2389
|
+
});
|
|
2390
|
+
});
|
|
2391
|
+
}
|
|
2392
|
+
EntityLod.GetTypeLods = GetTypeLods;
|
|
2306
2393
|
})(exports.EntityLod || (exports.EntityLod = {}));
|
|
2307
2394
|
|
|
2308
2395
|
(function (EntityRelationType) {
|
|
@@ -4301,18 +4388,33 @@
|
|
|
4301
4388
|
ProjectView.Delete = Delete;
|
|
4302
4389
|
function Update(api, data) {
|
|
4303
4390
|
return __awaiter(this, void 0, void 0, function () {
|
|
4391
|
+
var isNew;
|
|
4304
4392
|
return __generator(this, function (_a) {
|
|
4305
4393
|
switch (_a.label) {
|
|
4306
4394
|
case 0:
|
|
4307
|
-
if (!
|
|
4395
|
+
if (!data) {
|
|
4396
|
+
data = {};
|
|
4397
|
+
}
|
|
4398
|
+
isNew = !data.ID;
|
|
4399
|
+
if (!data.ID) {
|
|
4308
4400
|
data.ID = exports.ObjectUtils.UId();
|
|
4309
4401
|
}
|
|
4310
|
-
if (!
|
|
4402
|
+
if (!data.Name) {
|
|
4311
4403
|
data.Name = data.ID;
|
|
4312
4404
|
}
|
|
4313
|
-
|
|
4405
|
+
if (!data.CreatedByUIVersion) {
|
|
4406
|
+
data.CreatedByUIVersion = "-1";
|
|
4407
|
+
}
|
|
4408
|
+
if (!isNew) return [3 /*break*/, 2];
|
|
4409
|
+
return [4 /*yield*/, api.POST("ui.view/" + data.ID, data, exports.Api.PrepReqParams())];
|
|
4314
4410
|
case 1:
|
|
4315
4411
|
data = _a.sent();
|
|
4412
|
+
return [3 /*break*/, 4];
|
|
4413
|
+
case 2: return [4 /*yield*/, api.PUT("ui.view/" + data.ID, data, exports.Api.PrepReqParams())];
|
|
4414
|
+
case 3:
|
|
4415
|
+
data = _a.sent();
|
|
4416
|
+
_a.label = 4;
|
|
4417
|
+
case 4:
|
|
4316
4418
|
api.Cache.Remove(GetCacheKey(data.ID));
|
|
4317
4419
|
api.Cache.Remove(GetListCacheKey());
|
|
4318
4420
|
return [2 /*return*/, data];
|