bruce-models 0.7.9 → 0.8.1
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 +107 -21
- package/dist/bruce-models.es5.js.map +1 -1
- package/dist/bruce-models.umd.js +107 -21
- package/dist/bruce-models.umd.js.map +1 -1
- package/dist/lib/account/account.js +244 -244
- package/dist/lib/ann-document/ann-document.js +116 -116
- package/dist/lib/api/abstract-api.js +269 -269
- package/dist/lib/api/api.js +85 -85
- package/dist/lib/api/bruce-api.js +243 -243
- package/dist/lib/api/cam-api.js +132 -132
- package/dist/lib/api/global-api.js +131 -131
- package/dist/lib/api/idm-api.js +132 -132
- package/dist/lib/bruce-models.js +85 -85
- package/dist/lib/calculator/calculator.js +159 -159
- package/dist/lib/client-file/client-file.js +188 -188
- package/dist/lib/common/bounds.js +2 -2
- package/dist/lib/common/bruce-event.js +48 -48
- package/dist/lib/common/bruce-variable.js +54 -54
- package/dist/lib/common/cache.js +86 -86
- package/dist/lib/common/camera.js +11 -11
- package/dist/lib/common/cartes.js +55 -55
- package/dist/lib/common/carto.js +60 -60
- package/dist/lib/common/color.js +86 -86
- package/dist/lib/common/delay-queue.js +60 -60
- package/dist/lib/common/dictionary.js +2 -2
- package/dist/lib/common/geometry.js +120 -120
- package/dist/lib/common/transform.js +2 -2
- package/dist/lib/common/utc.js +39 -39
- package/dist/lib/custom-form/custom-form.js +136 -136
- package/dist/lib/data-lab/data-lab.js +90 -90
- package/dist/lib/entity/entity-attachment-type.js +132 -132
- package/dist/lib/entity/entity-attachment.js +208 -208
- package/dist/lib/entity/entity-comment.js +132 -132
- package/dist/lib/entity/entity-coords.js +181 -181
- package/dist/lib/entity/entity-link.js +132 -132
- package/dist/lib/entity/entity-lod.js +189 -189
- package/dist/lib/entity/entity-relation-type.js +150 -150
- package/dist/lib/entity/entity-relation.js +189 -189
- package/dist/lib/entity/entity-source.js +176 -176
- package/dist/lib/entity/entity-tag.js +229 -229
- package/dist/lib/entity/entity-type.js +163 -163
- package/dist/lib/entity/entity.js +358 -358
- package/dist/lib/entity/getters/batched-data-getter.js +91 -91
- package/dist/lib/entity/getters/entity-filter-getter.js +344 -344
- package/dist/lib/entity/getters/entity-globe.js +221 -135
- package/dist/lib/entity/getters/entity-globe.js.map +1 -1
- package/dist/lib/entity/getters/view-monitor.js +2 -2
- package/dist/lib/import/import-cad.js +82 -82
- package/dist/lib/import/import-csv.js +51 -51
- package/dist/lib/import/import-json.js +51 -51
- package/dist/lib/import/import-kml.js +51 -51
- package/dist/lib/import/imported-file.js +121 -121
- package/dist/lib/import/imported-file.js.map +1 -1
- package/dist/lib/markup/markup.js +40 -40
- package/dist/lib/program-key/program-key.js +152 -152
- package/dist/lib/project/menu-item.js +115 -115
- package/dist/lib/project/project-view-bookmark.js +183 -183
- package/dist/lib/project/project-view-legacy-tile.js +115 -115
- package/dist/lib/project/project-view-tile.js +119 -119
- package/dist/lib/project/project-view.js +177 -177
- package/dist/lib/project/zoom-control.js +17 -17
- package/dist/lib/server/message-broker.js +158 -158
- package/dist/lib/server/pending-action.js +106 -106
- package/dist/lib/server/task.js +113 -113
- package/dist/lib/style/style.js +152 -152
- package/dist/lib/tileset/tileset-cad.js +2 -2
- package/dist/lib/tileset/tileset-entities-map-tiles.js +18 -18
- package/dist/lib/tileset/tileset-entities.js +2 -2
- package/dist/lib/tileset/tileset-ext-map-tiles.js +17 -17
- package/dist/lib/tileset/tileset-ext-terrain-tiles.js +2 -2
- package/dist/lib/tileset/tileset-map-tiles.js +2 -2
- package/dist/lib/tileset/tileset-pointcloud.js +2 -2
- package/dist/lib/tileset/tileset-terrain-tiles.js +2 -2
- package/dist/lib/tileset/tileset.js +403 -403
- package/dist/lib/user/permission.js +20 -20
- package/dist/lib/user/session.js +160 -160
- package/dist/lib/user/user-group.js +139 -139
- package/dist/lib/user/user.js +451 -451
- package/dist/lib/util/encrypt-utils.js +20 -20
- package/dist/lib/util/math-utils.js +41 -41
- package/dist/lib/util/object-utils.js +17 -17
- package/dist/lib/util/path-utils.js +61 -61
- package/dist/lib/util/url-utils.js +107 -107
- package/dist/types/entity/getters/entity-globe.d.ts +2 -0
- package/package.json +1 -1
|
@@ -1,244 +1,244 @@
|
|
|
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 message_broker_1 = require("../server/message-broker");
|
|
58
|
-
var BruceApi;
|
|
59
|
-
(function (BruceApi) {
|
|
60
|
-
/**
|
|
61
|
-
* This is the request handler for Bruce Api,
|
|
62
|
-
* it should be passed to any method that wants to communicate with this particular api.
|
|
63
|
-
*/
|
|
64
|
-
var Api = /** @class */ (function (_super) {
|
|
65
|
-
__extends(Api, _super);
|
|
66
|
-
/**
|
|
67
|
-
* @param accountId
|
|
68
|
-
* @param env (Optional) environment to use, this will default to PROD.
|
|
69
|
-
* @param cam (Optional) cam instance to use for loading the regional base url.
|
|
70
|
-
*/
|
|
71
|
-
function Api(accountId, env, cam) {
|
|
72
|
-
var _this = _super.call(this, "x-sessionid") || this;
|
|
73
|
-
_this.baseUrl = "";
|
|
74
|
-
_this.loadCancelled = false;
|
|
75
|
-
_this.accountId = accountId;
|
|
76
|
-
_this.env = env !== null && env !== void 0 ? env : api_1.Api.EEnv.PROD;
|
|
77
|
-
_this.loadProm = _this.init(cam);
|
|
78
|
-
return _this;
|
|
79
|
-
}
|
|
80
|
-
Object.defineProperty(Api.prototype, "MessageBroker", {
|
|
81
|
-
get: function () {
|
|
82
|
-
return this.messageBroker;
|
|
83
|
-
},
|
|
84
|
-
enumerable: false,
|
|
85
|
-
configurable: true
|
|
86
|
-
});
|
|
87
|
-
Object.defineProperty(Api.prototype, "Loading", {
|
|
88
|
-
// Indicates if the init process has finished loading.
|
|
89
|
-
// This means the regional base url has been set and message broker is ready.
|
|
90
|
-
get: function () {
|
|
91
|
-
return this.loadProm;
|
|
92
|
-
},
|
|
93
|
-
enumerable: false,
|
|
94
|
-
configurable: true
|
|
95
|
-
});
|
|
96
|
-
/**
|
|
97
|
-
* Loads regional base url and sets up message broker.
|
|
98
|
-
* @param cam
|
|
99
|
-
* @returns
|
|
100
|
-
*/
|
|
101
|
-
Api.prototype.init = function (cam) {
|
|
102
|
-
var _a;
|
|
103
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
104
|
-
var prefix, url, env, camApi, settings, endpoint, e_1;
|
|
105
|
-
return __generator(this, function (_b) {
|
|
106
|
-
switch (_b.label) {
|
|
107
|
-
case 0:
|
|
108
|
-
prefix = "https://" + this.accountId + ".api.nextspace";
|
|
109
|
-
env = this.env.toUpperCase();
|
|
110
|
-
switch (env) {
|
|
111
|
-
case api_1.Api.EEnv.DEV:
|
|
112
|
-
url = prefix + "-dev.net/";
|
|
113
|
-
break;
|
|
114
|
-
case api_1.Api.EEnv.STG:
|
|
115
|
-
url = prefix + "-stg.net/";
|
|
116
|
-
break;
|
|
117
|
-
case api_1.Api.EEnv.UAT:
|
|
118
|
-
url = prefix + "-uat.net/";
|
|
119
|
-
break;
|
|
120
|
-
case api_1.Api.EEnv.PROD:
|
|
121
|
-
url = prefix + ".host/";
|
|
122
|
-
break;
|
|
123
|
-
default:
|
|
124
|
-
throw ("Specified Environment is not valid. SuppliedEnv=" + env);
|
|
125
|
-
}
|
|
126
|
-
this.baseUrl = url;
|
|
127
|
-
_b.label = 1;
|
|
128
|
-
case 1:
|
|
129
|
-
_b.trys.push([1, 3, , 4]);
|
|
130
|
-
camApi = cam ? cam : new cam_api_1.CamApi.Api(env);
|
|
131
|
-
return [4 /*yield*/, account_1.Account.GetAppSettings(camApi, this.accountId, account_1.Account.EAppId.BruceApi)];
|
|
132
|
-
case 2:
|
|
133
|
-
settings = _b.sent();
|
|
134
|
-
if (this.loadCancelled) {
|
|
135
|
-
console.warn("BruceApi: Loading was cancelled due to SetBaseUrl being called, not setting regional base url.");
|
|
136
|
-
return [2 /*return*/];
|
|
137
|
-
}
|
|
138
|
-
endpoint = (_a = settings.BruceAPIURL) === null || _a === void 0 ? void 0 : _a[env];
|
|
139
|
-
if (typeof endpoint == "string") {
|
|
140
|
-
if (!endpoint.endsWith("/")) {
|
|
141
|
-
endpoint += "/";
|
|
142
|
-
}
|
|
143
|
-
this.baseUrl = endpoint;
|
|
144
|
-
}
|
|
145
|
-
return [3 /*break*/, 4];
|
|
146
|
-
case 3:
|
|
147
|
-
e_1 = _b.sent();
|
|
148
|
-
console.error(e_1);
|
|
149
|
-
return [3 /*break*/, 4];
|
|
150
|
-
case 4:
|
|
151
|
-
this.messageBroker = new message_broker_1.MessageBroker.WebSocketBroker(this.baseUrl, this.env);
|
|
152
|
-
return [2 /*return*/];
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
});
|
|
156
|
-
};
|
|
157
|
-
/**
|
|
158
|
-
* Warning: This method does not wait for init to finish loading.
|
|
159
|
-
* This means the url could be changed once fully initialized.
|
|
160
|
-
* The url will be valid either way, but the loaded one may be faster as it is region specific.
|
|
161
|
-
* Await the "Loading" promise if you care about this.
|
|
162
|
-
* @returns
|
|
163
|
-
*/
|
|
164
|
-
Api.prototype.GetBaseUrl = function () {
|
|
165
|
-
return this.baseUrl;
|
|
166
|
-
};
|
|
167
|
-
/**
|
|
168
|
-
* Warning: This will cancel the init process.
|
|
169
|
-
* The init process loads a region specific endpoint.
|
|
170
|
-
* Setting a base url will stop that process from completing.
|
|
171
|
-
* @param url
|
|
172
|
-
*/
|
|
173
|
-
Api.prototype.SetBaseUrl = function (url) {
|
|
174
|
-
this.baseUrl = url;
|
|
175
|
-
if (!this.baseUrl.endsWith("/")) {
|
|
176
|
-
this.baseUrl += "/";
|
|
177
|
-
}
|
|
178
|
-
this.loadCancelled = true;
|
|
179
|
-
};
|
|
180
|
-
Api.prototype.GET = function (url, params) {
|
|
181
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
182
|
-
var _this = this;
|
|
183
|
-
return __generator(this, function (_a) {
|
|
184
|
-
return [2 /*return*/, new Promise(function (res, rej) {
|
|
185
|
-
_this.loadProm.then(function () {
|
|
186
|
-
_this.get(_this.baseUrl + url, params).then(res).catch(rej);
|
|
187
|
-
}).catch(rej);
|
|
188
|
-
})];
|
|
189
|
-
});
|
|
190
|
-
});
|
|
191
|
-
};
|
|
192
|
-
Api.prototype.DELETE = function (url, params) {
|
|
193
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
194
|
-
var _this = this;
|
|
195
|
-
return __generator(this, function (_a) {
|
|
196
|
-
return [2 /*return*/, new Promise(function (res, rej) {
|
|
197
|
-
_this.loadProm.then(function () {
|
|
198
|
-
_this.delete(_this.baseUrl + url, params).then(res).catch(rej);
|
|
199
|
-
}).catch(rej);
|
|
200
|
-
})];
|
|
201
|
-
});
|
|
202
|
-
});
|
|
203
|
-
};
|
|
204
|
-
Api.prototype.POST = function (url, data, params) {
|
|
205
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
206
|
-
var _this = this;
|
|
207
|
-
return __generator(this, function (_a) {
|
|
208
|
-
return [2 /*return*/, new Promise(function (res, rej) {
|
|
209
|
-
_this.loadProm.then(function () {
|
|
210
|
-
_this.post(_this.baseUrl + url, data, params).then(res).catch(rej);
|
|
211
|
-
}).catch(rej);
|
|
212
|
-
})];
|
|
213
|
-
});
|
|
214
|
-
});
|
|
215
|
-
};
|
|
216
|
-
Api.prototype.PUT = function (url, data, params) {
|
|
217
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
218
|
-
var _this = this;
|
|
219
|
-
return __generator(this, function (_a) {
|
|
220
|
-
return [2 /*return*/, new Promise(function (res, rej) {
|
|
221
|
-
_this.loadProm.then(function () {
|
|
222
|
-
_this.put(_this.baseUrl + url, data, params).then(res).catch(rej);
|
|
223
|
-
}).catch(rej);
|
|
224
|
-
})];
|
|
225
|
-
});
|
|
226
|
-
});
|
|
227
|
-
};
|
|
228
|
-
Api.prototype.UPLOAD = function (url, blob, params) {
|
|
229
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
230
|
-
var _this = this;
|
|
231
|
-
return __generator(this, function (_a) {
|
|
232
|
-
return [2 /*return*/, new Promise(function (res, rej) {
|
|
233
|
-
_this.loadProm.then(function () {
|
|
234
|
-
_this.upload(_this.baseUrl + url, blob, params).then(res).catch(rej);
|
|
235
|
-
}).catch(rej);
|
|
236
|
-
})];
|
|
237
|
-
});
|
|
238
|
-
});
|
|
239
|
-
};
|
|
240
|
-
return Api;
|
|
241
|
-
}(abstract_api_1.AbstractApi));
|
|
242
|
-
BruceApi.Api = Api;
|
|
243
|
-
})(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 message_broker_1 = require("../server/message-broker");
|
|
58
|
+
var BruceApi;
|
|
59
|
+
(function (BruceApi) {
|
|
60
|
+
/**
|
|
61
|
+
* This is the request handler for Bruce Api,
|
|
62
|
+
* it should be passed to any method that wants to communicate with this particular api.
|
|
63
|
+
*/
|
|
64
|
+
var Api = /** @class */ (function (_super) {
|
|
65
|
+
__extends(Api, _super);
|
|
66
|
+
/**
|
|
67
|
+
* @param accountId
|
|
68
|
+
* @param env (Optional) environment to use, this will default to PROD.
|
|
69
|
+
* @param cam (Optional) cam instance to use for loading the regional base url.
|
|
70
|
+
*/
|
|
71
|
+
function Api(accountId, env, cam) {
|
|
72
|
+
var _this = _super.call(this, "x-sessionid") || this;
|
|
73
|
+
_this.baseUrl = "";
|
|
74
|
+
_this.loadCancelled = false;
|
|
75
|
+
_this.accountId = accountId;
|
|
76
|
+
_this.env = env !== null && env !== void 0 ? env : api_1.Api.EEnv.PROD;
|
|
77
|
+
_this.loadProm = _this.init(cam);
|
|
78
|
+
return _this;
|
|
79
|
+
}
|
|
80
|
+
Object.defineProperty(Api.prototype, "MessageBroker", {
|
|
81
|
+
get: function () {
|
|
82
|
+
return this.messageBroker;
|
|
83
|
+
},
|
|
84
|
+
enumerable: false,
|
|
85
|
+
configurable: true
|
|
86
|
+
});
|
|
87
|
+
Object.defineProperty(Api.prototype, "Loading", {
|
|
88
|
+
// Indicates if the init process has finished loading.
|
|
89
|
+
// This means the regional base url has been set and message broker is ready.
|
|
90
|
+
get: function () {
|
|
91
|
+
return this.loadProm;
|
|
92
|
+
},
|
|
93
|
+
enumerable: false,
|
|
94
|
+
configurable: true
|
|
95
|
+
});
|
|
96
|
+
/**
|
|
97
|
+
* Loads regional base url and sets up message broker.
|
|
98
|
+
* @param cam
|
|
99
|
+
* @returns
|
|
100
|
+
*/
|
|
101
|
+
Api.prototype.init = function (cam) {
|
|
102
|
+
var _a;
|
|
103
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
104
|
+
var prefix, url, env, camApi, settings, endpoint, e_1;
|
|
105
|
+
return __generator(this, function (_b) {
|
|
106
|
+
switch (_b.label) {
|
|
107
|
+
case 0:
|
|
108
|
+
prefix = "https://" + this.accountId + ".api.nextspace";
|
|
109
|
+
env = this.env.toUpperCase();
|
|
110
|
+
switch (env) {
|
|
111
|
+
case api_1.Api.EEnv.DEV:
|
|
112
|
+
url = prefix + "-dev.net/";
|
|
113
|
+
break;
|
|
114
|
+
case api_1.Api.EEnv.STG:
|
|
115
|
+
url = prefix + "-stg.net/";
|
|
116
|
+
break;
|
|
117
|
+
case api_1.Api.EEnv.UAT:
|
|
118
|
+
url = prefix + "-uat.net/";
|
|
119
|
+
break;
|
|
120
|
+
case api_1.Api.EEnv.PROD:
|
|
121
|
+
url = prefix + ".host/";
|
|
122
|
+
break;
|
|
123
|
+
default:
|
|
124
|
+
throw ("Specified Environment is not valid. SuppliedEnv=" + env);
|
|
125
|
+
}
|
|
126
|
+
this.baseUrl = url;
|
|
127
|
+
_b.label = 1;
|
|
128
|
+
case 1:
|
|
129
|
+
_b.trys.push([1, 3, , 4]);
|
|
130
|
+
camApi = cam ? cam : new cam_api_1.CamApi.Api(env);
|
|
131
|
+
return [4 /*yield*/, account_1.Account.GetAppSettings(camApi, this.accountId, account_1.Account.EAppId.BruceApi)];
|
|
132
|
+
case 2:
|
|
133
|
+
settings = _b.sent();
|
|
134
|
+
if (this.loadCancelled) {
|
|
135
|
+
console.warn("BruceApi: Loading was cancelled due to SetBaseUrl being called, not setting regional base url.");
|
|
136
|
+
return [2 /*return*/];
|
|
137
|
+
}
|
|
138
|
+
endpoint = (_a = settings.BruceAPIURL) === null || _a === void 0 ? void 0 : _a[env];
|
|
139
|
+
if (typeof endpoint == "string") {
|
|
140
|
+
if (!endpoint.endsWith("/")) {
|
|
141
|
+
endpoint += "/";
|
|
142
|
+
}
|
|
143
|
+
this.baseUrl = endpoint;
|
|
144
|
+
}
|
|
145
|
+
return [3 /*break*/, 4];
|
|
146
|
+
case 3:
|
|
147
|
+
e_1 = _b.sent();
|
|
148
|
+
console.error(e_1);
|
|
149
|
+
return [3 /*break*/, 4];
|
|
150
|
+
case 4:
|
|
151
|
+
this.messageBroker = new message_broker_1.MessageBroker.WebSocketBroker(this.baseUrl, this.env);
|
|
152
|
+
return [2 /*return*/];
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* Warning: This method does not wait for init to finish loading.
|
|
159
|
+
* This means the url could be changed once fully initialized.
|
|
160
|
+
* The url will be valid either way, but the loaded one may be faster as it is region specific.
|
|
161
|
+
* Await the "Loading" promise if you care about this.
|
|
162
|
+
* @returns
|
|
163
|
+
*/
|
|
164
|
+
Api.prototype.GetBaseUrl = function () {
|
|
165
|
+
return this.baseUrl;
|
|
166
|
+
};
|
|
167
|
+
/**
|
|
168
|
+
* Warning: This will cancel the init process.
|
|
169
|
+
* The init process loads a region specific endpoint.
|
|
170
|
+
* Setting a base url will stop that process from completing.
|
|
171
|
+
* @param url
|
|
172
|
+
*/
|
|
173
|
+
Api.prototype.SetBaseUrl = function (url) {
|
|
174
|
+
this.baseUrl = url;
|
|
175
|
+
if (!this.baseUrl.endsWith("/")) {
|
|
176
|
+
this.baseUrl += "/";
|
|
177
|
+
}
|
|
178
|
+
this.loadCancelled = true;
|
|
179
|
+
};
|
|
180
|
+
Api.prototype.GET = function (url, params) {
|
|
181
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
182
|
+
var _this = this;
|
|
183
|
+
return __generator(this, function (_a) {
|
|
184
|
+
return [2 /*return*/, new Promise(function (res, rej) {
|
|
185
|
+
_this.loadProm.then(function () {
|
|
186
|
+
_this.get(_this.baseUrl + url, params).then(res).catch(rej);
|
|
187
|
+
}).catch(rej);
|
|
188
|
+
})];
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
};
|
|
192
|
+
Api.prototype.DELETE = function (url, params) {
|
|
193
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
194
|
+
var _this = this;
|
|
195
|
+
return __generator(this, function (_a) {
|
|
196
|
+
return [2 /*return*/, new Promise(function (res, rej) {
|
|
197
|
+
_this.loadProm.then(function () {
|
|
198
|
+
_this.delete(_this.baseUrl + url, params).then(res).catch(rej);
|
|
199
|
+
}).catch(rej);
|
|
200
|
+
})];
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
};
|
|
204
|
+
Api.prototype.POST = function (url, data, params) {
|
|
205
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
206
|
+
var _this = this;
|
|
207
|
+
return __generator(this, function (_a) {
|
|
208
|
+
return [2 /*return*/, new Promise(function (res, rej) {
|
|
209
|
+
_this.loadProm.then(function () {
|
|
210
|
+
_this.post(_this.baseUrl + url, data, params).then(res).catch(rej);
|
|
211
|
+
}).catch(rej);
|
|
212
|
+
})];
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
};
|
|
216
|
+
Api.prototype.PUT = function (url, data, params) {
|
|
217
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
218
|
+
var _this = this;
|
|
219
|
+
return __generator(this, function (_a) {
|
|
220
|
+
return [2 /*return*/, new Promise(function (res, rej) {
|
|
221
|
+
_this.loadProm.then(function () {
|
|
222
|
+
_this.put(_this.baseUrl + url, data, params).then(res).catch(rej);
|
|
223
|
+
}).catch(rej);
|
|
224
|
+
})];
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
};
|
|
228
|
+
Api.prototype.UPLOAD = function (url, blob, params) {
|
|
229
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
230
|
+
var _this = this;
|
|
231
|
+
return __generator(this, function (_a) {
|
|
232
|
+
return [2 /*return*/, new Promise(function (res, rej) {
|
|
233
|
+
_this.loadProm.then(function () {
|
|
234
|
+
_this.upload(_this.baseUrl + url, blob, params).then(res).catch(rej);
|
|
235
|
+
}).catch(rej);
|
|
236
|
+
})];
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
};
|
|
240
|
+
return Api;
|
|
241
|
+
}(abstract_api_1.AbstractApi));
|
|
242
|
+
BruceApi.Api = Api;
|
|
243
|
+
})(BruceApi = exports.BruceApi || (exports.BruceApi = {}));
|
|
244
244
|
//# sourceMappingURL=bruce-api.js.map
|