bruce-models 1.5.3 → 1.5.5

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.
@@ -476,15 +476,16 @@ function parseResult(data) {
476
476
  encoding = charset.split("=")[1];
477
477
  encoding = encoding.toLowerCase();
478
478
  }
479
- if (!encoding) {
480
- return null;
481
- }
482
479
  // Our API has a very specific utf-16 encoding.
483
480
  if (encoding == "utf-16") {
484
481
  encoding = Api.EEncoding.UTF16;
485
482
  }
486
- if (encoding == "utf-8") {
487
- return data.json();
483
+ if (!encoding || encoding == "utf-8") {
484
+ const text = yield data.text();
485
+ if (!text || !text.trim()) {
486
+ return null;
487
+ }
488
+ return JSON.parse(text);
488
489
  }
489
490
  else {
490
491
  const buffer = yield data.arrayBuffer();
@@ -841,6 +842,75 @@ var Account;
841
842
  Account.GetDbRegions = GetDbRegions;
842
843
  })(Account || (Account = {}));
843
844
 
845
+ /**
846
+ * This is the request handler for Cam Api,
847
+ * it should be passed to any method that wants to communicate with this particular api.
848
+ */
849
+ var CamApi;
850
+ (function (CamApi) {
851
+ class Api$$1 extends AbstractApi {
852
+ constructor(params) {
853
+ super({
854
+ ssidHeader: "SSID"
855
+ });
856
+ this.env = (params === null || params === void 0 ? void 0 : params.env) ? params.env : Api.EEnv.PROD;
857
+ this.setBaseUrl();
858
+ }
859
+ setBaseUrl() {
860
+ const prefix = "https://cam.nextspace";
861
+ let url;
862
+ const env = this.env.toUpperCase();
863
+ switch (env) {
864
+ case Api.EEnv.DEV:
865
+ url = prefix + "-dev.net/";
866
+ break;
867
+ case Api.EEnv.STG:
868
+ url = prefix + "-stg.net/";
869
+ break;
870
+ case Api.EEnv.UAT:
871
+ url = prefix + "-uat.net/";
872
+ break;
873
+ case Api.EEnv.PROD:
874
+ url = prefix + ".host/";
875
+ break;
876
+ default:
877
+ throw ("Specified Environment is not valid. SuppliedEnv=" + env);
878
+ }
879
+ this.baseUrl = url;
880
+ }
881
+ GetBaseUrl() {
882
+ return this.baseUrl;
883
+ }
884
+ SetBaseUrl(url) {
885
+ this.baseUrl = url;
886
+ if (!this.baseUrl.endsWith("/")) {
887
+ this.baseUrl += "/";
888
+ }
889
+ }
890
+ GET(url, params) {
891
+ return __awaiter(this, void 0, void 0, function* () {
892
+ return this.get(this.baseUrl + url, params);
893
+ });
894
+ }
895
+ DELETE(url, params) {
896
+ return __awaiter(this, void 0, void 0, function* () {
897
+ return this.delete(this.baseUrl + url, params);
898
+ });
899
+ }
900
+ POST(url, data, params) {
901
+ return __awaiter(this, void 0, void 0, function* () {
902
+ return this.post(this.baseUrl + url, data, params);
903
+ });
904
+ }
905
+ UPLOAD(url, blob, params) {
906
+ return __awaiter(this, void 0, void 0, function* () {
907
+ return this.upload(this.baseUrl + url, blob, params);
908
+ });
909
+ }
910
+ }
911
+ CamApi.Api = Api$$1;
912
+ })(CamApi || (CamApi = {}));
913
+
844
914
  var MessageBroker;
845
915
  (function (MessageBroker) {
846
916
  let EAction;
@@ -995,9 +1065,14 @@ var BruceApi;
995
1065
  ssidHeader: "x-sessionid"
996
1066
  });
997
1067
  this.loadCancelled = false;
998
- const { accountId, env, cam, loadRegionalBaseUrl } = params;
1068
+ let { accountId, env, cam, loadRegionalBaseUrl } = params;
999
1069
  this.accountId = accountId;
1000
1070
  this.env = env !== null && env !== void 0 ? env : Api.EEnv.PROD;
1071
+ if (loadRegionalBaseUrl && !cam) {
1072
+ cam = new CamApi.Api({
1073
+ env: this.env
1074
+ });
1075
+ }
1001
1076
  this.loadProm = this.init(cam, loadRegionalBaseUrl);
1002
1077
  }
1003
1078
  get MessageBroker() {
@@ -1146,75 +1221,6 @@ var BruceApi;
1146
1221
  BruceApi.Api = Api$$1;
1147
1222
  })(BruceApi || (BruceApi = {}));
1148
1223
 
1149
- /**
1150
- * This is the request handler for Cam Api,
1151
- * it should be passed to any method that wants to communicate with this particular api.
1152
- */
1153
- var CamApi;
1154
- (function (CamApi) {
1155
- class Api$$1 extends AbstractApi {
1156
- constructor(params) {
1157
- super({
1158
- ssidHeader: "SSID"
1159
- });
1160
- this.env = (params === null || params === void 0 ? void 0 : params.env) ? params.env : Api.EEnv.PROD;
1161
- this.setBaseUrl();
1162
- }
1163
- setBaseUrl() {
1164
- const prefix = "https://cam.nextspace";
1165
- let url;
1166
- const env = this.env.toUpperCase();
1167
- switch (env) {
1168
- case Api.EEnv.DEV:
1169
- url = prefix + "-dev.net/";
1170
- break;
1171
- case Api.EEnv.STG:
1172
- url = prefix + "-stg.net/";
1173
- break;
1174
- case Api.EEnv.UAT:
1175
- url = prefix + "-uat.net/";
1176
- break;
1177
- case Api.EEnv.PROD:
1178
- url = prefix + ".host/";
1179
- break;
1180
- default:
1181
- throw ("Specified Environment is not valid. SuppliedEnv=" + env);
1182
- }
1183
- this.baseUrl = url;
1184
- }
1185
- GetBaseUrl() {
1186
- return this.baseUrl;
1187
- }
1188
- SetBaseUrl(url) {
1189
- this.baseUrl = url;
1190
- if (!this.baseUrl.endsWith("/")) {
1191
- this.baseUrl += "/";
1192
- }
1193
- }
1194
- GET(url, params) {
1195
- return __awaiter(this, void 0, void 0, function* () {
1196
- return this.get(this.baseUrl + url, params);
1197
- });
1198
- }
1199
- DELETE(url, params) {
1200
- return __awaiter(this, void 0, void 0, function* () {
1201
- return this.delete(this.baseUrl + url, params);
1202
- });
1203
- }
1204
- POST(url, data, params) {
1205
- return __awaiter(this, void 0, void 0, function* () {
1206
- return this.post(this.baseUrl + url, data, params);
1207
- });
1208
- }
1209
- UPLOAD(url, blob, params) {
1210
- return __awaiter(this, void 0, void 0, function* () {
1211
- return this.upload(this.baseUrl + url, blob, params);
1212
- });
1213
- }
1214
- }
1215
- CamApi.Api = Api$$1;
1216
- })(CamApi || (CamApi = {}));
1217
-
1218
1224
  var IdmApi;
1219
1225
  (function (IdmApi) {
1220
1226
  /**
@@ -3450,9 +3456,6 @@ var EntityRelation;
3450
3456
  if (data["Data.Entity.ID"]) {
3451
3457
  api.Cache.RemoveByStartsWith(Api.ECacheKey.Relation + Api.ECacheKey.Entity + Api.ECacheKey.Id + data["Data.Entity.ID"]);
3452
3458
  }
3453
- return {
3454
- relation: res
3455
- };
3456
3459
  });
3457
3460
  }
3458
3461
  EntityRelation.Update = Update;