bruce-models 4.0.4 → 4.0.6
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 +233 -6
- package/dist/bruce-models.es5.js.map +1 -1
- package/dist/bruce-models.umd.js +233 -6
- package/dist/bruce-models.umd.js.map +1 -1
- package/dist/lib/api/api.js +4 -0
- package/dist/lib/api/api.js.map +1 -1
- package/dist/lib/bruce-models.js +1 -1
- package/dist/lib/client-file/client-file.js +194 -0
- package/dist/lib/client-file/client-file.js.map +1 -1
- package/dist/lib/entity/entity-attachment-type.js +34 -5
- package/dist/lib/entity/entity-attachment-type.js.map +1 -1
- package/dist/types/api/api.d.ts +4 -0
- package/dist/types/bruce-models.d.ts +1 -1
- package/dist/types/client-file/client-file.d.ts +61 -0
- package/dist/types/entity/entity-attachment-type.d.ts +14 -2
- package/package.json +1 -1
package/dist/bruce-models.umd.js
CHANGED
|
@@ -46,6 +46,10 @@
|
|
|
46
46
|
ECacheKey["ProjectViewBookmark"] = "pvbookmark";
|
|
47
47
|
ECacheKey["Tileset"] = "tileset";
|
|
48
48
|
ECacheKey["ClientFile"] = "clientfile";
|
|
49
|
+
ECacheKey["ClientFileCountsPurpose"] = "clientfilecountspurpose";
|
|
50
|
+
ECacheKey["ClientFileCountsExtension"] = "clientfilecountsextensions";
|
|
51
|
+
ECacheKey["ClientFileCountsMIMEType"] = "clientfilecountsmimetypes";
|
|
52
|
+
ECacheKey["ClientFileCountsUser"] = "clientfilecountsusers";
|
|
49
53
|
ECacheKey["Session"] = "session";
|
|
50
54
|
ECacheKey["PendingAction"] = "pendingaction";
|
|
51
55
|
ECacheKey["EntitySource"] = "entitysource";
|
|
@@ -4905,21 +4909,50 @@
|
|
|
4905
4909
|
EType["Photo"] = "photo";
|
|
4906
4910
|
EType["Document"] = "document";
|
|
4907
4911
|
})(EType = EntityAttachmentType.EType || (EntityAttachmentType.EType = {}));
|
|
4912
|
+
/**
|
|
4913
|
+
* Gets an attachment type record by ID.
|
|
4914
|
+
* @param params
|
|
4915
|
+
* @returns
|
|
4916
|
+
*/
|
|
4917
|
+
function Get(params) {
|
|
4918
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4919
|
+
let { api, attachmentTypeId, req: reqParams } = params;
|
|
4920
|
+
if (!api) {
|
|
4921
|
+
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
4922
|
+
}
|
|
4923
|
+
if (!attachmentTypeId) {
|
|
4924
|
+
throw ("Type ID is required.");
|
|
4925
|
+
}
|
|
4926
|
+
reqParams = exports.Api.PrepReqParams(reqParams);
|
|
4927
|
+
const cacheData = api.GetCacheItem(GetCacheKey(attachmentTypeId), reqParams);
|
|
4928
|
+
if (cacheData === null || cacheData === void 0 ? void 0 : cacheData.found) {
|
|
4929
|
+
return cacheData.data;
|
|
4930
|
+
}
|
|
4931
|
+
const prom = api.GET(`entityAttachmentType/${attachmentTypeId}`, exports.Api.PrepReqParams(reqParams));
|
|
4932
|
+
api.SetCacheItem({
|
|
4933
|
+
key: GetCacheKey(attachmentTypeId),
|
|
4934
|
+
value: prom,
|
|
4935
|
+
req: reqParams
|
|
4936
|
+
});
|
|
4937
|
+
return prom;
|
|
4938
|
+
});
|
|
4939
|
+
}
|
|
4940
|
+
EntityAttachmentType.Get = Get;
|
|
4908
4941
|
/**
|
|
4909
4942
|
* Deletes an attachment type.
|
|
4910
4943
|
* @param params
|
|
4911
4944
|
*/
|
|
4912
4945
|
function Delete(params) {
|
|
4913
4946
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4914
|
-
let { api, attachmentTypeId
|
|
4947
|
+
let { api, attachmentTypeId, req: reqParams } = params;
|
|
4915
4948
|
if (!api) {
|
|
4916
4949
|
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
4917
4950
|
}
|
|
4918
|
-
if (!
|
|
4951
|
+
if (!attachmentTypeId) {
|
|
4919
4952
|
throw ("Type ID is required.");
|
|
4920
4953
|
}
|
|
4921
|
-
yield api.DELETE(`entityAttachmentType/${
|
|
4922
|
-
api.Cache.Remove(GetCacheKey(
|
|
4954
|
+
yield api.DELETE(`entityAttachmentType/${attachmentTypeId}`, exports.Api.PrepReqParams(reqParams));
|
|
4955
|
+
api.Cache.Remove(GetCacheKey(attachmentTypeId));
|
|
4923
4956
|
api.Cache.Remove(GetListCacheKey());
|
|
4924
4957
|
});
|
|
4925
4958
|
}
|
|
@@ -4954,7 +4987,7 @@
|
|
|
4954
4987
|
*/
|
|
4955
4988
|
function GetList(params) {
|
|
4956
4989
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4957
|
-
let { api, reqParams } = params;
|
|
4990
|
+
let { api, req: reqParams } = params;
|
|
4958
4991
|
if (!api) {
|
|
4959
4992
|
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
4960
4993
|
}
|
|
@@ -7217,6 +7250,162 @@
|
|
|
7217
7250
|
});
|
|
7218
7251
|
}
|
|
7219
7252
|
ClientFile.UploadTemp = UploadTemp;
|
|
7253
|
+
/**
|
|
7254
|
+
* Returns a dictionary of purpose counts for client files.
|
|
7255
|
+
* @param params
|
|
7256
|
+
* @returns
|
|
7257
|
+
*/
|
|
7258
|
+
function GetCountsPurpose(params) {
|
|
7259
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
7260
|
+
let { api, req: reqParams } = params;
|
|
7261
|
+
if (!api) {
|
|
7262
|
+
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
7263
|
+
}
|
|
7264
|
+
reqParams = exports.Api.PrepReqParams(reqParams);
|
|
7265
|
+
const key = GetCountsPurposeCacheKey();
|
|
7266
|
+
const cache = api.GetCacheItem(key, reqParams);
|
|
7267
|
+
if (cache === null || cache === void 0 ? void 0 : cache.found) {
|
|
7268
|
+
return cache.data;
|
|
7269
|
+
}
|
|
7270
|
+
const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
|
|
7271
|
+
try {
|
|
7272
|
+
const data = yield api.GET("file/purpose/counts", exports.Api.PrepReqParams(reqParams));
|
|
7273
|
+
res({
|
|
7274
|
+
counts: data
|
|
7275
|
+
});
|
|
7276
|
+
}
|
|
7277
|
+
catch (e) {
|
|
7278
|
+
rej(e);
|
|
7279
|
+
}
|
|
7280
|
+
}));
|
|
7281
|
+
api.SetCacheItem({
|
|
7282
|
+
key,
|
|
7283
|
+
value: prom,
|
|
7284
|
+
req: reqParams,
|
|
7285
|
+
// Short 30 second cache duration.
|
|
7286
|
+
duration: 30 * 1000
|
|
7287
|
+
});
|
|
7288
|
+
return prom;
|
|
7289
|
+
});
|
|
7290
|
+
}
|
|
7291
|
+
ClientFile.GetCountsPurpose = GetCountsPurpose;
|
|
7292
|
+
/**
|
|
7293
|
+
* Returns a dictionary of MIME type counts for client files.
|
|
7294
|
+
* @param params
|
|
7295
|
+
* @returns
|
|
7296
|
+
*/
|
|
7297
|
+
function GetCountsExtension(params) {
|
|
7298
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
7299
|
+
let { api, req: reqParams } = params;
|
|
7300
|
+
if (!api) {
|
|
7301
|
+
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
7302
|
+
}
|
|
7303
|
+
reqParams = exports.Api.PrepReqParams(reqParams);
|
|
7304
|
+
const key = GetCountsExtensionCacheKey();
|
|
7305
|
+
const cache = api.GetCacheItem(key, reqParams);
|
|
7306
|
+
if (cache === null || cache === void 0 ? void 0 : cache.found) {
|
|
7307
|
+
return cache.data;
|
|
7308
|
+
}
|
|
7309
|
+
const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
|
|
7310
|
+
try {
|
|
7311
|
+
const data = yield api.GET("file/extension/counts", exports.Api.PrepReqParams(reqParams));
|
|
7312
|
+
res({
|
|
7313
|
+
counts: data
|
|
7314
|
+
});
|
|
7315
|
+
}
|
|
7316
|
+
catch (e) {
|
|
7317
|
+
rej(e);
|
|
7318
|
+
}
|
|
7319
|
+
}));
|
|
7320
|
+
api.SetCacheItem({
|
|
7321
|
+
key,
|
|
7322
|
+
value: prom,
|
|
7323
|
+
req: reqParams,
|
|
7324
|
+
// Short 30 second cache duration.
|
|
7325
|
+
duration: 30 * 1000
|
|
7326
|
+
});
|
|
7327
|
+
return prom;
|
|
7328
|
+
});
|
|
7329
|
+
}
|
|
7330
|
+
ClientFile.GetCountsExtension = GetCountsExtension;
|
|
7331
|
+
/**
|
|
7332
|
+
* Returns a dictionary of MIME type counts for client files.
|
|
7333
|
+
* @param params
|
|
7334
|
+
* @returns
|
|
7335
|
+
*/
|
|
7336
|
+
function GetCountsMIMEType(params) {
|
|
7337
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
7338
|
+
let { api, req: reqParams } = params;
|
|
7339
|
+
if (!api) {
|
|
7340
|
+
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
7341
|
+
}
|
|
7342
|
+
reqParams = exports.Api.PrepReqParams(reqParams);
|
|
7343
|
+
const key = GetCountsMIMETypeCacheKey();
|
|
7344
|
+
const cache = api.GetCacheItem(key, reqParams);
|
|
7345
|
+
if (cache === null || cache === void 0 ? void 0 : cache.found) {
|
|
7346
|
+
return cache.data;
|
|
7347
|
+
}
|
|
7348
|
+
const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
|
|
7349
|
+
try {
|
|
7350
|
+
const data = yield api.GET("file/mimetype/counts", exports.Api.PrepReqParams(reqParams));
|
|
7351
|
+
res({
|
|
7352
|
+
counts: data
|
|
7353
|
+
});
|
|
7354
|
+
}
|
|
7355
|
+
catch (e) {
|
|
7356
|
+
rej(e);
|
|
7357
|
+
}
|
|
7358
|
+
}));
|
|
7359
|
+
api.SetCacheItem({
|
|
7360
|
+
key,
|
|
7361
|
+
value: prom,
|
|
7362
|
+
req: reqParams,
|
|
7363
|
+
// Short 30 second cache duration.
|
|
7364
|
+
duration: 30 * 1000
|
|
7365
|
+
});
|
|
7366
|
+
return prom;
|
|
7367
|
+
});
|
|
7368
|
+
}
|
|
7369
|
+
ClientFile.GetCountsMIMEType = GetCountsMIMEType;
|
|
7370
|
+
/**
|
|
7371
|
+
* Returns a dictionary of user counts for client files.
|
|
7372
|
+
* @param params
|
|
7373
|
+
* @returns
|
|
7374
|
+
*/
|
|
7375
|
+
function GetCountsUser(params) {
|
|
7376
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
7377
|
+
let { api, req: reqParams } = params;
|
|
7378
|
+
if (!api) {
|
|
7379
|
+
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
7380
|
+
}
|
|
7381
|
+
reqParams = exports.Api.PrepReqParams(reqParams);
|
|
7382
|
+
const key = GetCountsUserCacheKey();
|
|
7383
|
+
const cache = api.GetCacheItem(key, reqParams);
|
|
7384
|
+
if (cache === null || cache === void 0 ? void 0 : cache.found) {
|
|
7385
|
+
return cache.data;
|
|
7386
|
+
}
|
|
7387
|
+
const prom = new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () {
|
|
7388
|
+
try {
|
|
7389
|
+
const data = yield api.GET("file/user/counts", exports.Api.PrepReqParams(reqParams));
|
|
7390
|
+
res({
|
|
7391
|
+
counts: data
|
|
7392
|
+
});
|
|
7393
|
+
}
|
|
7394
|
+
catch (e) {
|
|
7395
|
+
rej(e);
|
|
7396
|
+
}
|
|
7397
|
+
}));
|
|
7398
|
+
api.SetCacheItem({
|
|
7399
|
+
key,
|
|
7400
|
+
value: prom,
|
|
7401
|
+
req: reqParams,
|
|
7402
|
+
// Short 30 second cache duration.
|
|
7403
|
+
duration: 30 * 1000
|
|
7404
|
+
});
|
|
7405
|
+
return prom;
|
|
7406
|
+
});
|
|
7407
|
+
}
|
|
7408
|
+
ClientFile.GetCountsUser = GetCountsUser;
|
|
7220
7409
|
/**
|
|
7221
7410
|
* Filter definitions for requesting a list of client files.
|
|
7222
7411
|
*/
|
|
@@ -7262,6 +7451,28 @@
|
|
|
7262
7451
|
});
|
|
7263
7452
|
}
|
|
7264
7453
|
ClientFile.GetList = GetList;
|
|
7454
|
+
/**
|
|
7455
|
+
* Deletes a list of client files matching the filter.
|
|
7456
|
+
* @param params
|
|
7457
|
+
*/
|
|
7458
|
+
function DeleteList(params) {
|
|
7459
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
7460
|
+
let { api, filter, req: reqParams } = params;
|
|
7461
|
+
if (!api) {
|
|
7462
|
+
api = exports.ENVIRONMENT.Api().GetBruceApi();
|
|
7463
|
+
}
|
|
7464
|
+
const res = yield api.POST("files/filtered/delete", filter, exports.Api.PrepReqParams(reqParams));
|
|
7465
|
+
// We'll clear cache if at least one file was deleted.
|
|
7466
|
+
if ((res === null || res === void 0 ? void 0 : res.OK) && (res === null || res === void 0 ? void 0 : res.DeleteFilesCount) > 0) {
|
|
7467
|
+
api.Cache.RemoveByStartsWith(exports.Api.ECacheKey.ClientFile);
|
|
7468
|
+
}
|
|
7469
|
+
return {
|
|
7470
|
+
success: res === null || res === void 0 ? void 0 : res.OK,
|
|
7471
|
+
deletedCount: res === null || res === void 0 ? void 0 : res.DeleteFilesCount
|
|
7472
|
+
};
|
|
7473
|
+
});
|
|
7474
|
+
}
|
|
7475
|
+
ClientFile.DeleteList = DeleteList;
|
|
7265
7476
|
/**
|
|
7266
7477
|
* Utility for processing client files.
|
|
7267
7478
|
* Commonly used to convert a file to a different format. Eg: FBX to GLB.
|
|
@@ -7313,6 +7524,22 @@
|
|
|
7313
7524
|
return `${exports.Api.ECacheKey.ClientFile}${exports.Api.ECacheKey.Id}${fileId}`;
|
|
7314
7525
|
}
|
|
7315
7526
|
ClientFile.GetCacheKey = GetCacheKey;
|
|
7527
|
+
function GetCountsPurposeCacheKey() {
|
|
7528
|
+
return `${exports.Api.ECacheKey.ClientFile}${exports.Api.ECacheKey.ClientFileCountsPurpose}`;
|
|
7529
|
+
}
|
|
7530
|
+
ClientFile.GetCountsPurposeCacheKey = GetCountsPurposeCacheKey;
|
|
7531
|
+
function GetCountsExtensionCacheKey() {
|
|
7532
|
+
return `${exports.Api.ECacheKey.ClientFile}${exports.Api.ECacheKey.ClientFileCountsExtension}`;
|
|
7533
|
+
}
|
|
7534
|
+
ClientFile.GetCountsExtensionCacheKey = GetCountsExtensionCacheKey;
|
|
7535
|
+
function GetCountsMIMETypeCacheKey() {
|
|
7536
|
+
return `${exports.Api.ECacheKey.ClientFile}${exports.Api.ECacheKey.ClientFileCountsMIMEType}`;
|
|
7537
|
+
}
|
|
7538
|
+
ClientFile.GetCountsMIMETypeCacheKey = GetCountsMIMETypeCacheKey;
|
|
7539
|
+
function GetCountsUserCacheKey() {
|
|
7540
|
+
return `${exports.Api.ECacheKey.ClientFile}${exports.Api.ECacheKey.ClientFileCountsUser}`;
|
|
7541
|
+
}
|
|
7542
|
+
ClientFile.GetCountsUserCacheKey = GetCountsUserCacheKey;
|
|
7316
7543
|
})(exports.ClientFile || (exports.ClientFile = {}));
|
|
7317
7544
|
|
|
7318
7545
|
(function (ProgramKey) {
|
|
@@ -11403,7 +11630,7 @@
|
|
|
11403
11630
|
})(exports.DataSource || (exports.DataSource = {}));
|
|
11404
11631
|
|
|
11405
11632
|
// This is updated with the package.json version on build.
|
|
11406
|
-
const VERSION = "4.0.
|
|
11633
|
+
const VERSION = "4.0.6";
|
|
11407
11634
|
|
|
11408
11635
|
exports.VERSION = VERSION;
|
|
11409
11636
|
exports.AbstractApi = AbstractApi;
|