bruce-models 4.0.5 → 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.
@@ -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";
@@ -7246,6 +7250,162 @@
7246
7250
  });
7247
7251
  }
7248
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;
7249
7409
  /**
7250
7410
  * Filter definitions for requesting a list of client files.
7251
7411
  */
@@ -7291,6 +7451,28 @@
7291
7451
  });
7292
7452
  }
7293
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;
7294
7476
  /**
7295
7477
  * Utility for processing client files.
7296
7478
  * Commonly used to convert a file to a different format. Eg: FBX to GLB.
@@ -7342,6 +7524,22 @@
7342
7524
  return `${exports.Api.ECacheKey.ClientFile}${exports.Api.ECacheKey.Id}${fileId}`;
7343
7525
  }
7344
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;
7345
7543
  })(exports.ClientFile || (exports.ClientFile = {}));
7346
7544
 
7347
7545
  (function (ProgramKey) {
@@ -11432,7 +11630,7 @@
11432
11630
  })(exports.DataSource || (exports.DataSource = {}));
11433
11631
 
11434
11632
  // This is updated with the package.json version on build.
11435
- const VERSION = "4.0.5";
11633
+ const VERSION = "4.0.6";
11436
11634
 
11437
11635
  exports.VERSION = VERSION;
11438
11636
  exports.AbstractApi = AbstractApi;