bruce-models 0.7.3 → 0.7.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.
Files changed (87) hide show
  1. package/dist/bruce-models.es5.js +11 -2
  2. package/dist/bruce-models.es5.js.map +1 -1
  3. package/dist/bruce-models.umd.js +11 -2
  4. package/dist/bruce-models.umd.js.map +1 -1
  5. package/dist/lib/account/account.js +244 -244
  6. package/dist/lib/ann-document/ann-document.js +116 -116
  7. package/dist/lib/api/abstract-api.js +267 -267
  8. package/dist/lib/api/api.js +85 -85
  9. package/dist/lib/api/bruce-api.js +202 -202
  10. package/dist/lib/api/cam-api.js +132 -132
  11. package/dist/lib/api/global-api.js +131 -131
  12. package/dist/lib/api/idm-api.js +132 -132
  13. package/dist/lib/bruce-models.js +83 -83
  14. package/dist/lib/calculator/calculator.js +158 -158
  15. package/dist/lib/client-file/client-file.js +188 -188
  16. package/dist/lib/common/bounds.js +2 -2
  17. package/dist/lib/common/bruce-event.js +48 -48
  18. package/dist/lib/common/bruce-variable.js +54 -54
  19. package/dist/lib/common/cache.js +86 -86
  20. package/dist/lib/common/camera.js +11 -11
  21. package/dist/lib/common/cartes.js +55 -55
  22. package/dist/lib/common/carto.js +60 -60
  23. package/dist/lib/common/color.js +86 -86
  24. package/dist/lib/common/delay-queue.js +60 -60
  25. package/dist/lib/common/dictionary.js +2 -2
  26. package/dist/lib/common/geometry.js +120 -120
  27. package/dist/lib/common/transform.js +2 -2
  28. package/dist/lib/common/utc.js +39 -39
  29. package/dist/lib/custom-form/custom-form.js +136 -136
  30. package/dist/lib/data-lab/data-lab.js +90 -90
  31. package/dist/lib/entity/entity-attachment-type.js +132 -132
  32. package/dist/lib/entity/entity-attachment.js +208 -208
  33. package/dist/lib/entity/entity-comment.js +132 -132
  34. package/dist/lib/entity/entity-coords.js +181 -181
  35. package/dist/lib/entity/entity-link.js +132 -132
  36. package/dist/lib/entity/entity-lod.js +189 -189
  37. package/dist/lib/entity/entity-relation-type.js +150 -150
  38. package/dist/lib/entity/entity-relation.js +189 -189
  39. package/dist/lib/entity/entity-source.js +176 -176
  40. package/dist/lib/entity/entity-tag.js +229 -229
  41. package/dist/lib/entity/entity-type.js +163 -163
  42. package/dist/lib/entity/entity.js +358 -349
  43. package/dist/lib/entity/entity.js.map +1 -1
  44. package/dist/lib/entity/getters/batched-data-getter.js +91 -91
  45. package/dist/lib/entity/getters/entity-filter-getter.js +344 -344
  46. package/dist/lib/entity/getters/entity-globe.js +135 -135
  47. package/dist/lib/entity/getters/view-monitor.js +2 -2
  48. package/dist/lib/import/import-cad.js +82 -82
  49. package/dist/lib/import/import-csv.js +51 -51
  50. package/dist/lib/import/import-json.js +51 -51
  51. package/dist/lib/import/import-kml.js +51 -51
  52. package/dist/lib/import/imported-file.js +121 -121
  53. package/dist/lib/markup/markup.js +40 -40
  54. package/dist/lib/program-key/program-key.js +152 -152
  55. package/dist/lib/project/menu-item.js +115 -115
  56. package/dist/lib/project/project-view-bookmark.js +172 -172
  57. package/dist/lib/project/project-view-tile-source.js +115 -115
  58. package/dist/lib/project/project-view.js +166 -166
  59. package/dist/lib/project/zoom-control.js +17 -17
  60. package/dist/lib/server/pending-action.js +106 -106
  61. package/dist/lib/server/task.js +113 -113
  62. package/dist/lib/style/style.js +152 -152
  63. package/dist/lib/tileset/tileset-cad.js +2 -2
  64. package/dist/lib/tileset/tileset-entities-map-tiles.js +18 -18
  65. package/dist/lib/tileset/tileset-entities.js +2 -2
  66. package/dist/lib/tileset/tileset-ext-map-tiles.js +17 -17
  67. package/dist/lib/tileset/tileset-ext-terrain-tiles.js +2 -2
  68. package/dist/lib/tileset/tileset-map-tiles.js +2 -2
  69. package/dist/lib/tileset/tileset-pointcloud.js +2 -2
  70. package/dist/lib/tileset/tileset-terrain-tiles.js +2 -2
  71. package/dist/lib/tileset/tileset.js +403 -403
  72. package/dist/lib/tileset/tileset.js.map +1 -1
  73. package/dist/lib/user/permission.js +20 -20
  74. package/dist/lib/user/session.js +160 -160
  75. package/dist/lib/user/user-group.js +139 -139
  76. package/dist/lib/user/user.js +451 -451
  77. package/dist/lib/util/encrypt-utils.js +20 -20
  78. package/dist/lib/util/math-utils.js +41 -41
  79. package/dist/lib/util/object-utils.js +17 -17
  80. package/dist/lib/util/path-utils.js +61 -61
  81. package/dist/lib/util/url-utils.js +107 -107
  82. package/dist/types/entity/entity-coords.d.ts +1 -1
  83. package/dist/types/entity/entity.d.ts +10 -1
  84. package/dist/types/tileset/tileset-cad.d.ts +3 -2
  85. package/dist/types/tileset/tileset-pointcloud.d.ts +3 -2
  86. package/dist/types/tileset/tileset.d.ts +0 -6
  87. package/package.json +1 -1
@@ -1,86 +1,86 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Api = void 0;
4
- /**
5
- * Contains generic descriptions used for Bruce requests.
6
- */
7
- var Api;
8
- (function (Api) {
9
- var ECacheKey;
10
- (function (ECacheKey) {
11
- ECacheKey["Id"] = ":";
12
- ECacheKey["Entity"] = "entity";
13
- ECacheKey["EntityType"] = "entitytype";
14
- ECacheKey["ProjectView"] = "projectview";
15
- ECacheKey["ProjectViewBookmark"] = "pvbookmark";
16
- ECacheKey["Tileset"] = "tileset";
17
- ECacheKey["ClientFile"] = "clientfile";
18
- ECacheKey["Session"] = "session";
19
- ECacheKey["PendingAction"] = "pendingaction";
20
- ECacheKey["EntitySource"] = "entitysource";
21
- ECacheKey["ProgramKey"] = "programkey";
22
- ECacheKey["EntityCoords"] = "entitycoords";
23
- ECacheKey["Tag"] = "tag";
24
- ECacheKey["Attachment"] = "attachment";
25
- ECacheKey["Comment"] = "comment";
26
- ECacheKey["Link"] = "link";
27
- ECacheKey["AnnDocument"] = "anndocument";
28
- ECacheKey["AttachmentType"] = "attachmenttype";
29
- ECacheKey["Relation"] = "relation";
30
- ECacheKey["RelationType"] = "relationtype";
31
- ECacheKey["Lod"] = "lod";
32
- ECacheKey["Style"] = "style";
33
- ECacheKey["PublishTileset"] = "publishtileset";
34
- ECacheKey["User"] = "user";
35
- ECacheKey["UserEmail"] = "useremail";
36
- ECacheKey["AccessToken"] = "accesstoken";
37
- ECacheKey["UserGroup"] = "usergroup";
38
- ECacheKey["Account"] = "account";
39
- ECacheKey["CustomForm"] = "customform";
40
- ECacheKey["ImportedFile"] = "importedfile";
41
- })(ECacheKey = Api.ECacheKey || (Api.ECacheKey = {}));
42
- Api.DEFAULT_CACHE_DURATION = 60 * 5; // 5 minutes.
43
- Api.TEMPLATE_ACCOUNT_ID = "template";
44
- Api.ACCESS_TOKEN_HEADER = "X-Access-Token";
45
- /**
46
- * Possible environments we host Bruce apps on.
47
- * When these are matched, they should be case-insensitive.
48
- */
49
- var EEnv;
50
- (function (EEnv) {
51
- EEnv["DEV"] = "DEV";
52
- EEnv["STG"] = "STG";
53
- EEnv["UAT"] = "UAT";
54
- EEnv["PROD"] = "PROD";
55
- })(EEnv = Api.EEnv || (Api.EEnv = {}));
56
- /**
57
- * Prepares a string to be included in a url.
58
- * @param str
59
- * @returns
60
- */
61
- function Encode(str) {
62
- return encodeURIComponent(str.replace(/\+/g, "%2B").replace(/\./g, "%2E"));
63
- }
64
- Api.Encode = Encode;
65
- var ESortOrder;
66
- (function (ESortOrder) {
67
- ESortOrder[ESortOrder["None"] = 0] = "None";
68
- ESortOrder[ESortOrder["Asc"] = 1] = "Asc";
69
- ESortOrder[ESortOrder["Desc"] = -1] = "Desc";
70
- })(ESortOrder = Api.ESortOrder || (Api.ESortOrder = {}));
71
- var EEncoding;
72
- (function (EEncoding) {
73
- EEncoding["UTF8"] = "UTF-8";
74
- EEncoding["UTF16"] = "UTF-16BE";
75
- })(EEncoding = Api.EEncoding || (Api.EEncoding = {}));
76
- /**
77
- * Prepares default settings for a request to Bruce Api.
78
- * Our requests WRONGLY have utf-16 for 95% of them. Please be wary of that.
79
- * @returns
80
- */
81
- function PrepReqParams() {
82
- return { response: { encoding: Api.EEncoding.UTF16 } };
83
- }
84
- Api.PrepReqParams = PrepReqParams;
85
- })(Api = exports.Api || (exports.Api = {}));
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Api = void 0;
4
+ /**
5
+ * Contains generic descriptions used for Bruce requests.
6
+ */
7
+ var Api;
8
+ (function (Api) {
9
+ var ECacheKey;
10
+ (function (ECacheKey) {
11
+ ECacheKey["Id"] = ":";
12
+ ECacheKey["Entity"] = "entity";
13
+ ECacheKey["EntityType"] = "entitytype";
14
+ ECacheKey["ProjectView"] = "projectview";
15
+ ECacheKey["ProjectViewBookmark"] = "pvbookmark";
16
+ ECacheKey["Tileset"] = "tileset";
17
+ ECacheKey["ClientFile"] = "clientfile";
18
+ ECacheKey["Session"] = "session";
19
+ ECacheKey["PendingAction"] = "pendingaction";
20
+ ECacheKey["EntitySource"] = "entitysource";
21
+ ECacheKey["ProgramKey"] = "programkey";
22
+ ECacheKey["EntityCoords"] = "entitycoords";
23
+ ECacheKey["Tag"] = "tag";
24
+ ECacheKey["Attachment"] = "attachment";
25
+ ECacheKey["Comment"] = "comment";
26
+ ECacheKey["Link"] = "link";
27
+ ECacheKey["AnnDocument"] = "anndocument";
28
+ ECacheKey["AttachmentType"] = "attachmenttype";
29
+ ECacheKey["Relation"] = "relation";
30
+ ECacheKey["RelationType"] = "relationtype";
31
+ ECacheKey["Lod"] = "lod";
32
+ ECacheKey["Style"] = "style";
33
+ ECacheKey["PublishTileset"] = "publishtileset";
34
+ ECacheKey["User"] = "user";
35
+ ECacheKey["UserEmail"] = "useremail";
36
+ ECacheKey["AccessToken"] = "accesstoken";
37
+ ECacheKey["UserGroup"] = "usergroup";
38
+ ECacheKey["Account"] = "account";
39
+ ECacheKey["CustomForm"] = "customform";
40
+ ECacheKey["ImportedFile"] = "importedfile";
41
+ })(ECacheKey = Api.ECacheKey || (Api.ECacheKey = {}));
42
+ Api.DEFAULT_CACHE_DURATION = 60 * 5; // 5 minutes.
43
+ Api.TEMPLATE_ACCOUNT_ID = "template";
44
+ Api.ACCESS_TOKEN_HEADER = "X-Access-Token";
45
+ /**
46
+ * Possible environments we host Bruce apps on.
47
+ * When these are matched, they should be case-insensitive.
48
+ */
49
+ var EEnv;
50
+ (function (EEnv) {
51
+ EEnv["DEV"] = "DEV";
52
+ EEnv["STG"] = "STG";
53
+ EEnv["UAT"] = "UAT";
54
+ EEnv["PROD"] = "PROD";
55
+ })(EEnv = Api.EEnv || (Api.EEnv = {}));
56
+ /**
57
+ * Prepares a string to be included in a url.
58
+ * @param str
59
+ * @returns
60
+ */
61
+ function Encode(str) {
62
+ return encodeURIComponent(str.replace(/\+/g, "%2B").replace(/\./g, "%2E"));
63
+ }
64
+ Api.Encode = Encode;
65
+ var ESortOrder;
66
+ (function (ESortOrder) {
67
+ ESortOrder[ESortOrder["None"] = 0] = "None";
68
+ ESortOrder[ESortOrder["Asc"] = 1] = "Asc";
69
+ ESortOrder[ESortOrder["Desc"] = -1] = "Desc";
70
+ })(ESortOrder = Api.ESortOrder || (Api.ESortOrder = {}));
71
+ var EEncoding;
72
+ (function (EEncoding) {
73
+ EEncoding["UTF8"] = "UTF-8";
74
+ EEncoding["UTF16"] = "UTF-16BE";
75
+ })(EEncoding = Api.EEncoding || (Api.EEncoding = {}));
76
+ /**
77
+ * Prepares default settings for a request to Bruce Api.
78
+ * Our requests WRONGLY have utf-16 for 95% of them. Please be wary of that.
79
+ * @returns
80
+ */
81
+ function PrepReqParams() {
82
+ return { response: { encoding: Api.EEncoding.UTF16 } };
83
+ }
84
+ Api.PrepReqParams = PrepReqParams;
85
+ })(Api = exports.Api || (exports.Api = {}));
86
86
  //# sourceMappingURL=api.js.map
@@ -1,203 +1,203 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- extendStatics(d, b);
11
- function __() { this.constructor = d; }
12
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
- };
14
- })();
15
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
16
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
17
- return new (P || (P = Promise))(function (resolve, reject) {
18
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
19
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
20
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
21
- step((generator = generator.apply(thisArg, _arguments || [])).next());
22
- });
23
- };
24
- var __generator = (this && this.__generator) || function (thisArg, body) {
25
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
26
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
27
- function verb(n) { return function (v) { return step([n, v]); }; }
28
- function step(op) {
29
- if (f) throw new TypeError("Generator is already executing.");
30
- while (_) try {
31
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
32
- if (y = 0, t) op = [op[0] & 2, t.value];
33
- switch (op[0]) {
34
- case 0: case 1: t = op; break;
35
- case 4: _.label++; return { value: op[1], done: false };
36
- case 5: _.label++; y = op[1]; op = [0]; continue;
37
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
38
- default:
39
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
40
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
41
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
42
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
43
- if (t[2]) _.ops.pop();
44
- _.trys.pop(); continue;
45
- }
46
- op = body.call(thisArg, _);
47
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
48
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
49
- }
50
- };
51
- Object.defineProperty(exports, "__esModule", { value: true });
52
- exports.BruceApi = void 0;
53
- var account_1 = require("../account/account");
54
- var abstract_api_1 = require("./abstract-api");
55
- var api_1 = require("./api");
56
- var cam_api_1 = require("./cam-api");
57
- var BruceApi;
58
- (function (BruceApi) {
59
- /**
60
- * This is the request handler for Bruce Api,
61
- * it should be passed to any method that wants to communicate with this particular api.
62
- */
63
- var Api = /** @class */ (function (_super) {
64
- __extends(Api, _super);
65
- function Api(accountId, env) {
66
- var _this = _super.call(this, "x-sessionid") || this;
67
- _this.baseUrl = "";
68
- _this.accountId = accountId;
69
- _this.env = env !== null && env !== void 0 ? env : api_1.Api.EEnv.PROD;
70
- _this.loadProm = _this.setBaseUrl();
71
- return _this;
72
- }
73
- Object.defineProperty(Api.prototype, "Loading", {
74
- get: function () {
75
- return this.loadProm;
76
- },
77
- enumerable: false,
78
- configurable: true
79
- });
80
- Api.prototype.setBaseUrl = function () {
81
- var _a;
82
- return __awaiter(this, void 0, void 0, function () {
83
- var prefix, url, env, camApi, settings, endpoint, e_1;
84
- return __generator(this, function (_b) {
85
- switch (_b.label) {
86
- case 0:
87
- prefix = "https://" + this.accountId + ".api.nextspace";
88
- env = this.env.toUpperCase();
89
- switch (env) {
90
- case api_1.Api.EEnv.DEV:
91
- url = prefix + "-dev.net/";
92
- break;
93
- case api_1.Api.EEnv.STG:
94
- url = prefix + "-stg.net/";
95
- break;
96
- case api_1.Api.EEnv.UAT:
97
- url = prefix + "-uat.net/";
98
- break;
99
- case api_1.Api.EEnv.PROD:
100
- url = prefix + ".host/";
101
- break;
102
- default:
103
- throw ("Specified Environment is not valid. SuppliedEnv=" + env);
104
- }
105
- this.baseUrl = url;
106
- _b.label = 1;
107
- case 1:
108
- _b.trys.push([1, 3, , 4]);
109
- camApi = new cam_api_1.CamApi.Api(env);
110
- return [4 /*yield*/, account_1.Account.GetAppSettings(camApi, this.accountId, account_1.Account.EAppId.BruceApi)];
111
- case 2:
112
- settings = _b.sent();
113
- endpoint = (_a = settings.BruceAPIURL) === null || _a === void 0 ? void 0 : _a[env];
114
- if (typeof endpoint == "string") {
115
- if (!endpoint.endsWith("/")) {
116
- endpoint += "/";
117
- }
118
- this.baseUrl = endpoint;
119
- }
120
- return [3 /*break*/, 4];
121
- case 3:
122
- e_1 = _b.sent();
123
- console.error(e_1);
124
- return [3 /*break*/, 4];
125
- case 4: return [2 /*return*/];
126
- }
127
- });
128
- });
129
- };
130
- Api.prototype.GetBaseUrl = function () {
131
- return this.baseUrl;
132
- };
133
- Api.prototype.SetBaseUrl = function (url) {
134
- this.baseUrl = url;
135
- if (!this.baseUrl.endsWith("/")) {
136
- this.baseUrl += "/";
137
- }
138
- };
139
- Api.prototype.GET = function (url, params) {
140
- return __awaiter(this, void 0, void 0, function () {
141
- var _this = this;
142
- return __generator(this, function (_a) {
143
- return [2 /*return*/, new Promise(function (res, rej) {
144
- _this.loadProm.then(function () {
145
- _this.get(_this.baseUrl + url, params).then(res).catch(rej);
146
- }).catch(rej);
147
- })];
148
- });
149
- });
150
- };
151
- Api.prototype.DELETE = function (url, params) {
152
- return __awaiter(this, void 0, void 0, function () {
153
- var _this = this;
154
- return __generator(this, function (_a) {
155
- return [2 /*return*/, new Promise(function (res, rej) {
156
- _this.loadProm.then(function () {
157
- _this.delete(_this.baseUrl + url, params).then(res).catch(rej);
158
- }).catch(rej);
159
- })];
160
- });
161
- });
162
- };
163
- Api.prototype.POST = function (url, data, params) {
164
- return __awaiter(this, void 0, void 0, function () {
165
- var _this = this;
166
- return __generator(this, function (_a) {
167
- return [2 /*return*/, new Promise(function (res, rej) {
168
- _this.loadProm.then(function () {
169
- _this.post(_this.baseUrl + url, data, params).then(res).catch(rej);
170
- }).catch(rej);
171
- })];
172
- });
173
- });
174
- };
175
- Api.prototype.PUT = function (url, data, params) {
176
- return __awaiter(this, void 0, void 0, function () {
177
- var _this = this;
178
- return __generator(this, function (_a) {
179
- return [2 /*return*/, new Promise(function (res, rej) {
180
- _this.loadProm.then(function () {
181
- _this.put(_this.baseUrl + url, data, params).then(res).catch(rej);
182
- }).catch(rej);
183
- })];
184
- });
185
- });
186
- };
187
- Api.prototype.UPLOAD = function (url, blob, params) {
188
- return __awaiter(this, void 0, void 0, function () {
189
- var _this = this;
190
- return __generator(this, function (_a) {
191
- return [2 /*return*/, new Promise(function (res, rej) {
192
- _this.loadProm.then(function () {
193
- _this.upload(_this.baseUrl + url, blob, params).then(res).catch(rej);
194
- }).catch(rej);
195
- })];
196
- });
197
- });
198
- };
199
- return Api;
200
- }(abstract_api_1.AbstractApi));
201
- BruceApi.Api = Api;
202
- })(BruceApi = exports.BruceApi || (exports.BruceApi = {}));
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ extendStatics(d, b);
11
+ function __() { this.constructor = d; }
12
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
+ };
14
+ })();
15
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
16
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
17
+ return new (P || (P = Promise))(function (resolve, reject) {
18
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
19
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
20
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
21
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
22
+ });
23
+ };
24
+ var __generator = (this && this.__generator) || function (thisArg, body) {
25
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
26
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
27
+ function verb(n) { return function (v) { return step([n, v]); }; }
28
+ function step(op) {
29
+ if (f) throw new TypeError("Generator is already executing.");
30
+ while (_) try {
31
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
32
+ if (y = 0, t) op = [op[0] & 2, t.value];
33
+ switch (op[0]) {
34
+ case 0: case 1: t = op; break;
35
+ case 4: _.label++; return { value: op[1], done: false };
36
+ case 5: _.label++; y = op[1]; op = [0]; continue;
37
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
38
+ default:
39
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
40
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
41
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
42
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
43
+ if (t[2]) _.ops.pop();
44
+ _.trys.pop(); continue;
45
+ }
46
+ op = body.call(thisArg, _);
47
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
48
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
49
+ }
50
+ };
51
+ Object.defineProperty(exports, "__esModule", { value: true });
52
+ exports.BruceApi = void 0;
53
+ var account_1 = require("../account/account");
54
+ var abstract_api_1 = require("./abstract-api");
55
+ var api_1 = require("./api");
56
+ var cam_api_1 = require("./cam-api");
57
+ var BruceApi;
58
+ (function (BruceApi) {
59
+ /**
60
+ * This is the request handler for Bruce Api,
61
+ * it should be passed to any method that wants to communicate with this particular api.
62
+ */
63
+ var Api = /** @class */ (function (_super) {
64
+ __extends(Api, _super);
65
+ function Api(accountId, env) {
66
+ var _this = _super.call(this, "x-sessionid") || this;
67
+ _this.baseUrl = "";
68
+ _this.accountId = accountId;
69
+ _this.env = env !== null && env !== void 0 ? env : api_1.Api.EEnv.PROD;
70
+ _this.loadProm = _this.setBaseUrl();
71
+ return _this;
72
+ }
73
+ Object.defineProperty(Api.prototype, "Loading", {
74
+ get: function () {
75
+ return this.loadProm;
76
+ },
77
+ enumerable: false,
78
+ configurable: true
79
+ });
80
+ Api.prototype.setBaseUrl = function () {
81
+ var _a;
82
+ return __awaiter(this, void 0, void 0, function () {
83
+ var prefix, url, env, camApi, settings, endpoint, e_1;
84
+ return __generator(this, function (_b) {
85
+ switch (_b.label) {
86
+ case 0:
87
+ prefix = "https://" + this.accountId + ".api.nextspace";
88
+ env = this.env.toUpperCase();
89
+ switch (env) {
90
+ case api_1.Api.EEnv.DEV:
91
+ url = prefix + "-dev.net/";
92
+ break;
93
+ case api_1.Api.EEnv.STG:
94
+ url = prefix + "-stg.net/";
95
+ break;
96
+ case api_1.Api.EEnv.UAT:
97
+ url = prefix + "-uat.net/";
98
+ break;
99
+ case api_1.Api.EEnv.PROD:
100
+ url = prefix + ".host/";
101
+ break;
102
+ default:
103
+ throw ("Specified Environment is not valid. SuppliedEnv=" + env);
104
+ }
105
+ this.baseUrl = url;
106
+ _b.label = 1;
107
+ case 1:
108
+ _b.trys.push([1, 3, , 4]);
109
+ camApi = new cam_api_1.CamApi.Api(env);
110
+ return [4 /*yield*/, account_1.Account.GetAppSettings(camApi, this.accountId, account_1.Account.EAppId.BruceApi)];
111
+ case 2:
112
+ settings = _b.sent();
113
+ endpoint = (_a = settings.BruceAPIURL) === null || _a === void 0 ? void 0 : _a[env];
114
+ if (typeof endpoint == "string") {
115
+ if (!endpoint.endsWith("/")) {
116
+ endpoint += "/";
117
+ }
118
+ this.baseUrl = endpoint;
119
+ }
120
+ return [3 /*break*/, 4];
121
+ case 3:
122
+ e_1 = _b.sent();
123
+ console.error(e_1);
124
+ return [3 /*break*/, 4];
125
+ case 4: return [2 /*return*/];
126
+ }
127
+ });
128
+ });
129
+ };
130
+ Api.prototype.GetBaseUrl = function () {
131
+ return this.baseUrl;
132
+ };
133
+ Api.prototype.SetBaseUrl = function (url) {
134
+ this.baseUrl = url;
135
+ if (!this.baseUrl.endsWith("/")) {
136
+ this.baseUrl += "/";
137
+ }
138
+ };
139
+ Api.prototype.GET = function (url, params) {
140
+ return __awaiter(this, void 0, void 0, function () {
141
+ var _this = this;
142
+ return __generator(this, function (_a) {
143
+ return [2 /*return*/, new Promise(function (res, rej) {
144
+ _this.loadProm.then(function () {
145
+ _this.get(_this.baseUrl + url, params).then(res).catch(rej);
146
+ }).catch(rej);
147
+ })];
148
+ });
149
+ });
150
+ };
151
+ Api.prototype.DELETE = function (url, params) {
152
+ return __awaiter(this, void 0, void 0, function () {
153
+ var _this = this;
154
+ return __generator(this, function (_a) {
155
+ return [2 /*return*/, new Promise(function (res, rej) {
156
+ _this.loadProm.then(function () {
157
+ _this.delete(_this.baseUrl + url, params).then(res).catch(rej);
158
+ }).catch(rej);
159
+ })];
160
+ });
161
+ });
162
+ };
163
+ Api.prototype.POST = function (url, data, params) {
164
+ return __awaiter(this, void 0, void 0, function () {
165
+ var _this = this;
166
+ return __generator(this, function (_a) {
167
+ return [2 /*return*/, new Promise(function (res, rej) {
168
+ _this.loadProm.then(function () {
169
+ _this.post(_this.baseUrl + url, data, params).then(res).catch(rej);
170
+ }).catch(rej);
171
+ })];
172
+ });
173
+ });
174
+ };
175
+ Api.prototype.PUT = function (url, data, params) {
176
+ return __awaiter(this, void 0, void 0, function () {
177
+ var _this = this;
178
+ return __generator(this, function (_a) {
179
+ return [2 /*return*/, new Promise(function (res, rej) {
180
+ _this.loadProm.then(function () {
181
+ _this.put(_this.baseUrl + url, data, params).then(res).catch(rej);
182
+ }).catch(rej);
183
+ })];
184
+ });
185
+ });
186
+ };
187
+ Api.prototype.UPLOAD = function (url, blob, params) {
188
+ return __awaiter(this, void 0, void 0, function () {
189
+ var _this = this;
190
+ return __generator(this, function (_a) {
191
+ return [2 /*return*/, new Promise(function (res, rej) {
192
+ _this.loadProm.then(function () {
193
+ _this.upload(_this.baseUrl + url, blob, params).then(res).catch(rej);
194
+ }).catch(rej);
195
+ })];
196
+ });
197
+ });
198
+ };
199
+ return Api;
200
+ }(abstract_api_1.AbstractApi));
201
+ BruceApi.Api = Api;
202
+ })(BruceApi = exports.BruceApi || (exports.BruceApi = {}));
203
203
  //# sourceMappingURL=bruce-api.js.map