bruce-models 0.7.1 → 0.7.2
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.map +1 -1
- 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 +267 -267
- package/dist/lib/api/api.js +85 -85
- package/dist/lib/api/bruce-api.js +202 -202
- 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 +83 -83
- package/dist/lib/calculator/calculator.js +158 -158
- 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-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-type.js.map +1 -1
- package/dist/lib/entity/entity.js +349 -349
- 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 +135 -135
- 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/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 +172 -172
- package/dist/lib/project/project-view-tile-source.js +115 -115
- package/dist/lib/project/project-view.js +166 -166
- package/dist/lib/project/zoom-control.js +17 -17
- 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/ucs/ucs.js +135 -135
- 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/entity-type.d.ts +1 -0
- package/package.json +1 -1
package/dist/lib/ucs/ucs.js
CHANGED
|
@@ -1,136 +1,136 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
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;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.Ucs = void 0;
|
|
40
|
-
var api_1 = require("../api/api");
|
|
41
|
-
/**
|
|
42
|
-
* Describes the "UCS" concept within Bruce.
|
|
43
|
-
* A UCS is a user-coordinate-system.
|
|
44
|
-
* It is a description of an offset to apply to tilesets so that they can all align with each other.
|
|
45
|
-
*/
|
|
46
|
-
var Ucs;
|
|
47
|
-
(function (Ucs) {
|
|
48
|
-
function GetCacheKey(id, expandUsage) {
|
|
49
|
-
return api_1.Api.ECacheKey.Ucs + api_1.Api.ECacheKey.Id + id + api_1.Api.ECacheKey + expandUsage;
|
|
50
|
-
}
|
|
51
|
-
Ucs.GetCacheKey = GetCacheKey;
|
|
52
|
-
function GetListCacheKey() {
|
|
53
|
-
return api_1.Api.ECacheKey.Ucs;
|
|
54
|
-
}
|
|
55
|
-
Ucs.GetListCacheKey = GetListCacheKey;
|
|
56
|
-
var EState;
|
|
57
|
-
(function (EState) {
|
|
58
|
-
EState["Undefined"] = "undef";
|
|
59
|
-
EState["Prepared"] = "ready";
|
|
60
|
-
})(EState = Ucs.EState || (Ucs.EState = {}));
|
|
61
|
-
function Get(api, ucsId, expandUsage) {
|
|
62
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
63
|
-
var cacheData, req;
|
|
64
|
-
return __generator(this, function (_a) {
|
|
65
|
-
if (!ucsId) {
|
|
66
|
-
throw ("UCS ID is required.");
|
|
67
|
-
}
|
|
68
|
-
if (!expandUsage) {
|
|
69
|
-
expandUsage = false;
|
|
70
|
-
}
|
|
71
|
-
cacheData = api.Cache.Get(GetCacheKey(ucsId, expandUsage));
|
|
72
|
-
if (cacheData) {
|
|
73
|
-
return [2 /*return*/, cacheData];
|
|
74
|
-
}
|
|
75
|
-
req = api.GET("ucs/" + ucsId);
|
|
76
|
-
api.Cache.Set(GetCacheKey(ucsId, expandUsage), req, api_1.Api.DEFAULT_CACHE_DURATION);
|
|
77
|
-
return [2 /*return*/, req];
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
Ucs.Get = Get;
|
|
82
|
-
function Delete(api, ucsId) {
|
|
83
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
84
|
-
return __generator(this, function (_a) {
|
|
85
|
-
switch (_a.label) {
|
|
86
|
-
case 0:
|
|
87
|
-
if (!ucsId) {
|
|
88
|
-
throw ("UCS ID is required.");
|
|
89
|
-
}
|
|
90
|
-
return [4 /*yield*/, api.DELETE("ucs/" + ucsId)];
|
|
91
|
-
case 1:
|
|
92
|
-
_a.sent();
|
|
93
|
-
api.Cache.RemoveByStartsWith(api_1.Api.ECacheKey.Ucs + api_1.Api.ECacheKey.Id + ucsId);
|
|
94
|
-
api.Cache.Remove(GetListCacheKey());
|
|
95
|
-
return [2 /*return*/];
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
Ucs.Delete = Delete;
|
|
101
|
-
function GetList(api) {
|
|
102
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
103
|
-
var cacheData, req;
|
|
104
|
-
return __generator(this, function (_a) {
|
|
105
|
-
cacheData = api.Cache.Get(GetListCacheKey());
|
|
106
|
-
if (cacheData) {
|
|
107
|
-
return [2 /*return*/, cacheData];
|
|
108
|
-
}
|
|
109
|
-
req = api.GET("ucs");
|
|
110
|
-
api.Cache.Set(GetListCacheKey(), req, api_1.Api.DEFAULT_CACHE_DURATION);
|
|
111
|
-
return [2 /*return*/, req];
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
Ucs.GetList = GetList;
|
|
116
|
-
function Update(api, data) {
|
|
117
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
118
|
-
return __generator(this, function (_a) {
|
|
119
|
-
switch (_a.label) {
|
|
120
|
-
case 0:
|
|
121
|
-
if (!(data === null || data === void 0 ? void 0 : data.name)) {
|
|
122
|
-
throw ("UCS name is required.");
|
|
123
|
-
}
|
|
124
|
-
return [4 /*yield*/, api.POST("ucs" + (!data.id ? "" : "/" + data.id), data)];
|
|
125
|
-
case 1:
|
|
126
|
-
data = _a.sent();
|
|
127
|
-
api.Cache.RemoveByStartsWith(api_1.Api.ECacheKey.Ucs + api_1.Api.ECacheKey.Id + data.id);
|
|
128
|
-
api.Cache.Remove(GetListCacheKey());
|
|
129
|
-
return [2 /*return*/, data];
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
Ucs.Update = Update;
|
|
135
|
-
})(Ucs = exports.Ucs || (exports.Ucs = {}));
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
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;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.Ucs = void 0;
|
|
40
|
+
var api_1 = require("../api/api");
|
|
41
|
+
/**
|
|
42
|
+
* Describes the "UCS" concept within Bruce.
|
|
43
|
+
* A UCS is a user-coordinate-system.
|
|
44
|
+
* It is a description of an offset to apply to tilesets so that they can all align with each other.
|
|
45
|
+
*/
|
|
46
|
+
var Ucs;
|
|
47
|
+
(function (Ucs) {
|
|
48
|
+
function GetCacheKey(id, expandUsage) {
|
|
49
|
+
return api_1.Api.ECacheKey.Ucs + api_1.Api.ECacheKey.Id + id + api_1.Api.ECacheKey + expandUsage;
|
|
50
|
+
}
|
|
51
|
+
Ucs.GetCacheKey = GetCacheKey;
|
|
52
|
+
function GetListCacheKey() {
|
|
53
|
+
return api_1.Api.ECacheKey.Ucs;
|
|
54
|
+
}
|
|
55
|
+
Ucs.GetListCacheKey = GetListCacheKey;
|
|
56
|
+
var EState;
|
|
57
|
+
(function (EState) {
|
|
58
|
+
EState["Undefined"] = "undef";
|
|
59
|
+
EState["Prepared"] = "ready";
|
|
60
|
+
})(EState = Ucs.EState || (Ucs.EState = {}));
|
|
61
|
+
function Get(api, ucsId, expandUsage) {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
63
|
+
var cacheData, req;
|
|
64
|
+
return __generator(this, function (_a) {
|
|
65
|
+
if (!ucsId) {
|
|
66
|
+
throw ("UCS ID is required.");
|
|
67
|
+
}
|
|
68
|
+
if (!expandUsage) {
|
|
69
|
+
expandUsage = false;
|
|
70
|
+
}
|
|
71
|
+
cacheData = api.Cache.Get(GetCacheKey(ucsId, expandUsage));
|
|
72
|
+
if (cacheData) {
|
|
73
|
+
return [2 /*return*/, cacheData];
|
|
74
|
+
}
|
|
75
|
+
req = api.GET("ucs/" + ucsId);
|
|
76
|
+
api.Cache.Set(GetCacheKey(ucsId, expandUsage), req, api_1.Api.DEFAULT_CACHE_DURATION);
|
|
77
|
+
return [2 /*return*/, req];
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
Ucs.Get = Get;
|
|
82
|
+
function Delete(api, ucsId) {
|
|
83
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
84
|
+
return __generator(this, function (_a) {
|
|
85
|
+
switch (_a.label) {
|
|
86
|
+
case 0:
|
|
87
|
+
if (!ucsId) {
|
|
88
|
+
throw ("UCS ID is required.");
|
|
89
|
+
}
|
|
90
|
+
return [4 /*yield*/, api.DELETE("ucs/" + ucsId)];
|
|
91
|
+
case 1:
|
|
92
|
+
_a.sent();
|
|
93
|
+
api.Cache.RemoveByStartsWith(api_1.Api.ECacheKey.Ucs + api_1.Api.ECacheKey.Id + ucsId);
|
|
94
|
+
api.Cache.Remove(GetListCacheKey());
|
|
95
|
+
return [2 /*return*/];
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
Ucs.Delete = Delete;
|
|
101
|
+
function GetList(api) {
|
|
102
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
103
|
+
var cacheData, req;
|
|
104
|
+
return __generator(this, function (_a) {
|
|
105
|
+
cacheData = api.Cache.Get(GetListCacheKey());
|
|
106
|
+
if (cacheData) {
|
|
107
|
+
return [2 /*return*/, cacheData];
|
|
108
|
+
}
|
|
109
|
+
req = api.GET("ucs");
|
|
110
|
+
api.Cache.Set(GetListCacheKey(), req, api_1.Api.DEFAULT_CACHE_DURATION);
|
|
111
|
+
return [2 /*return*/, req];
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
Ucs.GetList = GetList;
|
|
116
|
+
function Update(api, data) {
|
|
117
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
118
|
+
return __generator(this, function (_a) {
|
|
119
|
+
switch (_a.label) {
|
|
120
|
+
case 0:
|
|
121
|
+
if (!(data === null || data === void 0 ? void 0 : data.name)) {
|
|
122
|
+
throw ("UCS name is required.");
|
|
123
|
+
}
|
|
124
|
+
return [4 /*yield*/, api.POST("ucs" + (!data.id ? "" : "/" + data.id), data)];
|
|
125
|
+
case 1:
|
|
126
|
+
data = _a.sent();
|
|
127
|
+
api.Cache.RemoveByStartsWith(api_1.Api.ECacheKey.Ucs + api_1.Api.ECacheKey.Id + data.id);
|
|
128
|
+
api.Cache.Remove(GetListCacheKey());
|
|
129
|
+
return [2 /*return*/, data];
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
Ucs.Update = Update;
|
|
135
|
+
})(Ucs = exports.Ucs || (exports.Ucs = {}));
|
|
136
136
|
//# sourceMappingURL=ucs.js.map
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Permission = void 0;
|
|
4
|
-
var Permission;
|
|
5
|
-
(function (Permission) {
|
|
6
|
-
var EPerm;
|
|
7
|
-
(function (EPerm) {
|
|
8
|
-
EPerm["ADMIN"] = "ADMIN";
|
|
9
|
-
EPerm["LOGIN"] = "LOGIN";
|
|
10
|
-
EPerm["DELETE_ENTITY_TYPE"] = "DELETE_ENTITY_TYPE";
|
|
11
|
-
EPerm["CREATE_ENTITY_TYPE"] = "CREATE_ENTITY_TYPE";
|
|
12
|
-
EPerm["UPDATE_ENTITY_TYPE"] = "UPDATE_ENTITY_TYPE";
|
|
13
|
-
})(EPerm = Permission.EPerm || (Permission.EPerm = {}));
|
|
14
|
-
var EPermPrefix;
|
|
15
|
-
(function (EPermPrefix) {
|
|
16
|
-
EPermPrefix["ACCESS_PROJECT_VIEW"] = "UIVIEW_";
|
|
17
|
-
EPermPrefix["MANAGE_PROJECT_VIEW_BOOKMARKS"] = "UIVIEW_MANAGE_BOOKMARKS_";
|
|
18
|
-
EPermPrefix["ACCESS_TILESET"] = "TILESET_";
|
|
19
|
-
})(EPermPrefix = Permission.EPermPrefix || (Permission.EPermPrefix = {}));
|
|
20
|
-
})(Permission = exports.Permission || (exports.Permission = {}));
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Permission = void 0;
|
|
4
|
+
var Permission;
|
|
5
|
+
(function (Permission) {
|
|
6
|
+
var EPerm;
|
|
7
|
+
(function (EPerm) {
|
|
8
|
+
EPerm["ADMIN"] = "ADMIN";
|
|
9
|
+
EPerm["LOGIN"] = "LOGIN";
|
|
10
|
+
EPerm["DELETE_ENTITY_TYPE"] = "DELETE_ENTITY_TYPE";
|
|
11
|
+
EPerm["CREATE_ENTITY_TYPE"] = "CREATE_ENTITY_TYPE";
|
|
12
|
+
EPerm["UPDATE_ENTITY_TYPE"] = "UPDATE_ENTITY_TYPE";
|
|
13
|
+
})(EPerm = Permission.EPerm || (Permission.EPerm = {}));
|
|
14
|
+
var EPermPrefix;
|
|
15
|
+
(function (EPermPrefix) {
|
|
16
|
+
EPermPrefix["ACCESS_PROJECT_VIEW"] = "UIVIEW_";
|
|
17
|
+
EPermPrefix["MANAGE_PROJECT_VIEW_BOOKMARKS"] = "UIVIEW_MANAGE_BOOKMARKS_";
|
|
18
|
+
EPermPrefix["ACCESS_TILESET"] = "TILESET_";
|
|
19
|
+
})(EPermPrefix = Permission.EPermPrefix || (Permission.EPermPrefix = {}));
|
|
20
|
+
})(Permission = exports.Permission || (exports.Permission = {}));
|
|
21
21
|
//# sourceMappingURL=permission.js.map
|
package/dist/lib/user/session.js
CHANGED
|
@@ -1,161 +1,161 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
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;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.Session = void 0;
|
|
40
|
-
var api_1 = require("../api/api");
|
|
41
|
-
var permission_1 = require("./permission");
|
|
42
|
-
/**
|
|
43
|
-
* Describes the "Session" concept within Bruce.
|
|
44
|
-
* A session is a set of settings produced from a user or access token login.
|
|
45
|
-
* The session describes what the access should be allowed to do.
|
|
46
|
-
*/
|
|
47
|
-
var Session;
|
|
48
|
-
(function (Session) {
|
|
49
|
-
function GetCacheKey(sessionId) {
|
|
50
|
-
return "" + api_1.Api.ECacheKey.Session + api_1.Api.ECacheKey.Id + sessionId;
|
|
51
|
-
}
|
|
52
|
-
function Get(api, sessionId) {
|
|
53
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
54
|
-
var key, cacheData, req;
|
|
55
|
-
return __generator(this, function (_a) {
|
|
56
|
-
if (!sessionId) {
|
|
57
|
-
throw ("Session ID is required.");
|
|
58
|
-
}
|
|
59
|
-
key = GetCacheKey(sessionId);
|
|
60
|
-
cacheData = api.Cache.Get(key);
|
|
61
|
-
if (cacheData) {
|
|
62
|
-
return [2 /*return*/, cacheData];
|
|
63
|
-
}
|
|
64
|
-
req = api.GET("session/" + sessionId);
|
|
65
|
-
api.Cache.Set(key, req, api_1.Api.DEFAULT_CACHE_DURATION);
|
|
66
|
-
return [2 /*return*/, req];
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
Session.Get = Get;
|
|
71
|
-
function Login(api, username, password, accountId) {
|
|
72
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
73
|
-
var data, session, ssid;
|
|
74
|
-
return __generator(this, function (_a) {
|
|
75
|
-
switch (_a.label) {
|
|
76
|
-
case 0:
|
|
77
|
-
if (!username || !password) {
|
|
78
|
-
throw ("Username and password are required.");
|
|
79
|
-
}
|
|
80
|
-
return [4 /*yield*/, api.POST("login", {
|
|
81
|
-
account: accountId ? accountId : "",
|
|
82
|
-
login: username,
|
|
83
|
-
password: password
|
|
84
|
-
})];
|
|
85
|
-
case 1:
|
|
86
|
-
data = _a.sent();
|
|
87
|
-
session = data === null || data === void 0 ? void 0 : data.Session;
|
|
88
|
-
ssid = session === null || session === void 0 ? void 0 : session.ID;
|
|
89
|
-
api.SetSessionId(ssid);
|
|
90
|
-
api.Cache.Remove(GetCacheKey(ssid));
|
|
91
|
-
return [2 /*return*/, session];
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
Session.Login = Login;
|
|
97
|
-
function Logout(api) {
|
|
98
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
99
|
-
var ssid;
|
|
100
|
-
return __generator(this, function (_a) {
|
|
101
|
-
switch (_a.label) {
|
|
102
|
-
case 0:
|
|
103
|
-
ssid = api.GetSessionId();
|
|
104
|
-
if (!ssid) return [3 /*break*/, 2];
|
|
105
|
-
return [4 /*yield*/, api.POST("logout", null)];
|
|
106
|
-
case 1:
|
|
107
|
-
_a.sent();
|
|
108
|
-
api.SetSessionId(null);
|
|
109
|
-
api.Cache.Remove(GetCacheKey(ssid));
|
|
110
|
-
_a.label = 2;
|
|
111
|
-
case 2: return [2 /*return*/];
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
Session.Logout = Logout;
|
|
117
|
-
function IsPermEnabled(session, accountId, perm) {
|
|
118
|
-
var _a, _b;
|
|
119
|
-
if (!perm) {
|
|
120
|
-
throw ("Perm is required.");
|
|
121
|
-
}
|
|
122
|
-
perm = perm.toLocaleUpperCase();
|
|
123
|
-
var perms = (_b = (_a = session === null || session === void 0 ? void 0 : session.User) === null || _a === void 0 ? void 0 : _a.AccessPermissions) === null || _b === void 0 ? void 0 : _b.find(function (x) { return x["ClientAccount.ID"] == accountId; });
|
|
124
|
-
if (!perms) {
|
|
125
|
-
return false;
|
|
126
|
-
}
|
|
127
|
-
if (!perms.UserGroups) {
|
|
128
|
-
perms.UserGroups = [];
|
|
129
|
-
}
|
|
130
|
-
for (var i = 0; i < perms.UserGroups.length; i++) {
|
|
131
|
-
var group = perms.UserGroups[i];
|
|
132
|
-
if (typeof group != "string") {
|
|
133
|
-
var features = group.Features;
|
|
134
|
-
if (features && features.findIndex(function (x) { return x.toLocaleUpperCase() == perm; }) > -1) {
|
|
135
|
-
return true;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
return false;
|
|
140
|
-
}
|
|
141
|
-
Session.IsPermEnabled = IsPermEnabled;
|
|
142
|
-
function IsSuperPermEnabled(session, perm) {
|
|
143
|
-
var _a, _b;
|
|
144
|
-
if (!perm) {
|
|
145
|
-
throw ("Perm is required.");
|
|
146
|
-
}
|
|
147
|
-
perm = perm.toLocaleUpperCase();
|
|
148
|
-
var accessPerms = (_b = (_a = session === null || session === void 0 ? void 0 : session.HypeportalAccessPermisssions) === null || _a === void 0 ? void 0 : _a.EnabledFeatures) !== null && _b !== void 0 ? _b : [];
|
|
149
|
-
return accessPerms.findIndex(function (x) { return x.toLocaleUpperCase() == perm; }) > -1;
|
|
150
|
-
}
|
|
151
|
-
Session.IsSuperPermEnabled = IsSuperPermEnabled;
|
|
152
|
-
function IsAccountAdmin(session, accountId) {
|
|
153
|
-
return IsPermEnabled(session, accountId, permission_1.Permission.EPerm.ADMIN);
|
|
154
|
-
}
|
|
155
|
-
Session.IsAccountAdmin = IsAccountAdmin;
|
|
156
|
-
function IsSuperAdmin(session) {
|
|
157
|
-
return IsSuperPermEnabled(session, permission_1.Permission.EPerm.ADMIN);
|
|
158
|
-
}
|
|
159
|
-
Session.IsSuperAdmin = IsSuperAdmin;
|
|
160
|
-
})(Session = exports.Session || (exports.Session = {}));
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
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;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.Session = void 0;
|
|
40
|
+
var api_1 = require("../api/api");
|
|
41
|
+
var permission_1 = require("./permission");
|
|
42
|
+
/**
|
|
43
|
+
* Describes the "Session" concept within Bruce.
|
|
44
|
+
* A session is a set of settings produced from a user or access token login.
|
|
45
|
+
* The session describes what the access should be allowed to do.
|
|
46
|
+
*/
|
|
47
|
+
var Session;
|
|
48
|
+
(function (Session) {
|
|
49
|
+
function GetCacheKey(sessionId) {
|
|
50
|
+
return "" + api_1.Api.ECacheKey.Session + api_1.Api.ECacheKey.Id + sessionId;
|
|
51
|
+
}
|
|
52
|
+
function Get(api, sessionId) {
|
|
53
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
54
|
+
var key, cacheData, req;
|
|
55
|
+
return __generator(this, function (_a) {
|
|
56
|
+
if (!sessionId) {
|
|
57
|
+
throw ("Session ID is required.");
|
|
58
|
+
}
|
|
59
|
+
key = GetCacheKey(sessionId);
|
|
60
|
+
cacheData = api.Cache.Get(key);
|
|
61
|
+
if (cacheData) {
|
|
62
|
+
return [2 /*return*/, cacheData];
|
|
63
|
+
}
|
|
64
|
+
req = api.GET("session/" + sessionId);
|
|
65
|
+
api.Cache.Set(key, req, api_1.Api.DEFAULT_CACHE_DURATION);
|
|
66
|
+
return [2 /*return*/, req];
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
Session.Get = Get;
|
|
71
|
+
function Login(api, username, password, accountId) {
|
|
72
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
73
|
+
var data, session, ssid;
|
|
74
|
+
return __generator(this, function (_a) {
|
|
75
|
+
switch (_a.label) {
|
|
76
|
+
case 0:
|
|
77
|
+
if (!username || !password) {
|
|
78
|
+
throw ("Username and password are required.");
|
|
79
|
+
}
|
|
80
|
+
return [4 /*yield*/, api.POST("login", {
|
|
81
|
+
account: accountId ? accountId : "",
|
|
82
|
+
login: username,
|
|
83
|
+
password: password
|
|
84
|
+
})];
|
|
85
|
+
case 1:
|
|
86
|
+
data = _a.sent();
|
|
87
|
+
session = data === null || data === void 0 ? void 0 : data.Session;
|
|
88
|
+
ssid = session === null || session === void 0 ? void 0 : session.ID;
|
|
89
|
+
api.SetSessionId(ssid);
|
|
90
|
+
api.Cache.Remove(GetCacheKey(ssid));
|
|
91
|
+
return [2 /*return*/, session];
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
Session.Login = Login;
|
|
97
|
+
function Logout(api) {
|
|
98
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
99
|
+
var ssid;
|
|
100
|
+
return __generator(this, function (_a) {
|
|
101
|
+
switch (_a.label) {
|
|
102
|
+
case 0:
|
|
103
|
+
ssid = api.GetSessionId();
|
|
104
|
+
if (!ssid) return [3 /*break*/, 2];
|
|
105
|
+
return [4 /*yield*/, api.POST("logout", null)];
|
|
106
|
+
case 1:
|
|
107
|
+
_a.sent();
|
|
108
|
+
api.SetSessionId(null);
|
|
109
|
+
api.Cache.Remove(GetCacheKey(ssid));
|
|
110
|
+
_a.label = 2;
|
|
111
|
+
case 2: return [2 /*return*/];
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
Session.Logout = Logout;
|
|
117
|
+
function IsPermEnabled(session, accountId, perm) {
|
|
118
|
+
var _a, _b;
|
|
119
|
+
if (!perm) {
|
|
120
|
+
throw ("Perm is required.");
|
|
121
|
+
}
|
|
122
|
+
perm = perm.toLocaleUpperCase();
|
|
123
|
+
var perms = (_b = (_a = session === null || session === void 0 ? void 0 : session.User) === null || _a === void 0 ? void 0 : _a.AccessPermissions) === null || _b === void 0 ? void 0 : _b.find(function (x) { return x["ClientAccount.ID"] == accountId; });
|
|
124
|
+
if (!perms) {
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
if (!perms.UserGroups) {
|
|
128
|
+
perms.UserGroups = [];
|
|
129
|
+
}
|
|
130
|
+
for (var i = 0; i < perms.UserGroups.length; i++) {
|
|
131
|
+
var group = perms.UserGroups[i];
|
|
132
|
+
if (typeof group != "string") {
|
|
133
|
+
var features = group.Features;
|
|
134
|
+
if (features && features.findIndex(function (x) { return x.toLocaleUpperCase() == perm; }) > -1) {
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
Session.IsPermEnabled = IsPermEnabled;
|
|
142
|
+
function IsSuperPermEnabled(session, perm) {
|
|
143
|
+
var _a, _b;
|
|
144
|
+
if (!perm) {
|
|
145
|
+
throw ("Perm is required.");
|
|
146
|
+
}
|
|
147
|
+
perm = perm.toLocaleUpperCase();
|
|
148
|
+
var accessPerms = (_b = (_a = session === null || session === void 0 ? void 0 : session.HypeportalAccessPermisssions) === null || _a === void 0 ? void 0 : _a.EnabledFeatures) !== null && _b !== void 0 ? _b : [];
|
|
149
|
+
return accessPerms.findIndex(function (x) { return x.toLocaleUpperCase() == perm; }) > -1;
|
|
150
|
+
}
|
|
151
|
+
Session.IsSuperPermEnabled = IsSuperPermEnabled;
|
|
152
|
+
function IsAccountAdmin(session, accountId) {
|
|
153
|
+
return IsPermEnabled(session, accountId, permission_1.Permission.EPerm.ADMIN);
|
|
154
|
+
}
|
|
155
|
+
Session.IsAccountAdmin = IsAccountAdmin;
|
|
156
|
+
function IsSuperAdmin(session) {
|
|
157
|
+
return IsSuperPermEnabled(session, permission_1.Permission.EPerm.ADMIN);
|
|
158
|
+
}
|
|
159
|
+
Session.IsSuperAdmin = IsSuperAdmin;
|
|
160
|
+
})(Session = exports.Session || (exports.Session = {}));
|
|
161
161
|
//# sourceMappingURL=session.js.map
|