bruce-models 1.9.8 → 1.9.9
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 +20 -14
- package/dist/bruce-models.es5.js.map +1 -1
- package/dist/bruce-models.umd.js +20 -14
- package/dist/bruce-models.umd.js.map +1 -1
- package/dist/lib/account/account-settings.js +2 -2
- package/dist/lib/account/account.js +185 -185
- package/dist/lib/ann-document/ann-document.js +86 -86
- package/dist/lib/api/abstract-api.js +246 -246
- package/dist/lib/api/api-getters.js +134 -134
- package/dist/lib/api/api.js +93 -93
- package/dist/lib/api/bruce-api.js +216 -216
- package/dist/lib/api/cam-api.js +85 -82
- package/dist/lib/api/cam-api.js.map +1 -1
- package/dist/lib/api/global-api.js +81 -81
- package/dist/lib/api/idm-api.js +85 -82
- package/dist/lib/api/idm-api.js.map +1 -1
- package/dist/lib/bruce-models.js +86 -86
- package/dist/lib/calculator/calculator.js +341 -341
- package/dist/lib/client-file/client-file.js +245 -245
- package/dist/lib/common/bounds.js +61 -61
- package/dist/lib/common/bruce-event.js +46 -46
- package/dist/lib/common/bruce-variable.js +60 -60
- package/dist/lib/common/cache.js +165 -165
- package/dist/lib/common/camera.js +11 -11
- package/dist/lib/common/cartes.js +123 -123
- package/dist/lib/common/carto.js +60 -60
- package/dist/lib/common/color.js +86 -86
- package/dist/lib/common/delay-queue.js +56 -56
- 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-content.js +26 -26
- package/dist/lib/custom-form/custom-form.js +106 -106
- package/dist/lib/data-lab/data-lab.js +49 -49
- package/dist/lib/entity/entity-attachment-type.js +83 -83
- package/dist/lib/entity/entity-attachment.js +122 -122
- package/dist/lib/entity/entity-attribute.js +29 -29
- package/dist/lib/entity/entity-comment.js +82 -82
- package/dist/lib/entity/entity-coords.js +149 -149
- package/dist/lib/entity/entity-link.js +82 -82
- package/dist/lib/entity/entity-lod-category.js +100 -100
- package/dist/lib/entity/entity-lod.js +185 -185
- package/dist/lib/entity/entity-relation-type.js +109 -109
- package/dist/lib/entity/entity-relation.js +132 -132
- package/dist/lib/entity/entity-source.js +136 -136
- package/dist/lib/entity/entity-tag.js +149 -149
- package/dist/lib/entity/entity-type-visual-settings.js +13 -13
- package/dist/lib/entity/entity-type.js +113 -113
- package/dist/lib/entity/entity.js +319 -319
- package/dist/lib/entity/getters/batched-data-getter.js +84 -84
- package/dist/lib/entity/getters/entity-filter-getter.js +303 -303
- package/dist/lib/entity/getters/entity-globe.js +211 -211
- package/dist/lib/entity/getters/view-monitor.js +2 -2
- package/dist/lib/import/import-cad.js +53 -53
- package/dist/lib/import/import-csv.js +23 -23
- package/dist/lib/import/import-json.js +23 -23
- package/dist/lib/import/import-kml.js +23 -23
- package/dist/lib/import/imported-file.js +91 -91
- package/dist/lib/internal/uploader.js +76 -76
- package/dist/lib/markup/markup.js +185 -185
- package/dist/lib/plugin/plugin.js +83 -83
- package/dist/lib/program-key/program-key.js +111 -111
- package/dist/lib/project/menu-item.js +121 -121
- package/dist/lib/project/project-view-bookmark.js +147 -147
- package/dist/lib/project/project-view-legacy-tile.js +77 -77
- package/dist/lib/project/project-view-tile.js +125 -125
- package/dist/lib/project/project-view.js +133 -133
- package/dist/lib/project/zoom-control.js +17 -17
- package/dist/lib/server/message-broker.js +142 -142
- package/dist/lib/server/pending-action.js +71 -71
- package/dist/lib/server/task.js +63 -63
- package/dist/lib/style/style.js +117 -117
- package/dist/lib/tileset/tileset.js +415 -415
- package/dist/lib/user/permission.js +20 -20
- package/dist/lib/user/session.js +137 -137
- package/dist/lib/user/user-group.js +94 -94
- package/dist/lib/user/user.js +446 -446
- package/dist/lib/util/encrypt-utils.js +19 -19
- package/dist/lib/util/math-utils.js +40 -40
- 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 +94 -94
- package/package.json +3 -2
|
@@ -1,247 +1,247 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.AbstractApi = void 0;
|
|
13
|
-
const cache_1 = require("../common/cache");
|
|
14
|
-
const api_1 = require("./api");
|
|
15
|
-
// TODO: Currently checks for CSV vs json specifically,
|
|
16
|
-
// Need to see if our api is generally good at setting content-type headers.
|
|
17
|
-
// Make it less specific to CSV.
|
|
18
|
-
function parseResult(data) {
|
|
19
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
if (data.status == 200) {
|
|
21
|
-
let type = data.headers.get("Content-Type");
|
|
22
|
-
if (type) {
|
|
23
|
-
type = type.trim().toLowerCase();
|
|
24
|
-
}
|
|
25
|
-
let encoding = "";
|
|
26
|
-
const charset = type ? type.split(";").find((x) => x.startsWith("charset=")) : "";
|
|
27
|
-
if (charset && charset.includes("=")) {
|
|
28
|
-
encoding = charset.split("=")[1];
|
|
29
|
-
encoding = encoding.toLowerCase();
|
|
30
|
-
}
|
|
31
|
-
// Our API has a very specific utf-16 encoding.
|
|
32
|
-
if (encoding == "utf-16") {
|
|
33
|
-
encoding = api_1.Api.EEncoding.UTF16;
|
|
34
|
-
}
|
|
35
|
-
if (!encoding || encoding == "utf-8") {
|
|
36
|
-
const text = yield data.text();
|
|
37
|
-
if (!text || !text.trim()) {
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
if (type && type.includes("text/csv")) {
|
|
41
|
-
return text;
|
|
42
|
-
}
|
|
43
|
-
return JSON.parse(text);
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
const buffer = yield data.arrayBuffer();
|
|
47
|
-
const text = new TextDecoder(encoding).decode(buffer);
|
|
48
|
-
if (type && type.includes("text/csv")) {
|
|
49
|
-
return text;
|
|
50
|
-
}
|
|
51
|
-
return JSON.parse(text);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
const error = yield data.json();
|
|
56
|
-
throw (error);
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* This is a base class for communication with an arbitrary Bruce Api.
|
|
62
|
-
*/
|
|
63
|
-
class AbstractApi {
|
|
64
|
-
constructor(params) {
|
|
65
|
-
this.ssid = "";
|
|
66
|
-
this.baseUrl = "";
|
|
67
|
-
this.Cache = new cache_1.CacheControl();
|
|
68
|
-
this.ssidHeader = params === null || params === void 0 ? void 0 : params.ssidHeader;
|
|
69
|
-
}
|
|
70
|
-
GetBaseUrl() {
|
|
71
|
-
return this.baseUrl;
|
|
72
|
-
}
|
|
73
|
-
SetBaseUrl(url) {
|
|
74
|
-
this.baseUrl = url;
|
|
75
|
-
if (!this.baseUrl.endsWith("/")) {
|
|
76
|
-
this.baseUrl += "/";
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
GetCacheItem(key, reqParams) {
|
|
80
|
-
let noCache = reqParams === null || reqParams === void 0 ? void 0 : reqParams.noCache;
|
|
81
|
-
if (noCache == null) {
|
|
82
|
-
noCache = api_1.Api.DEFAULT_NO_CACHE;
|
|
83
|
-
}
|
|
84
|
-
if (noCache) {
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
|
-
return this.Cache.Get(key);
|
|
88
|
-
}
|
|
89
|
-
GetSessionId() {
|
|
90
|
-
return this.ssid;
|
|
91
|
-
}
|
|
92
|
-
SetSessionId(value) {
|
|
93
|
-
this.ssid = value;
|
|
94
|
-
}
|
|
95
|
-
GetSessionHeader() {
|
|
96
|
-
return this.ssidHeader;
|
|
97
|
-
}
|
|
98
|
-
SetSessionHeader(value) {
|
|
99
|
-
this.ssidHeader = value;
|
|
100
|
-
}
|
|
101
|
-
get(url, params) {
|
|
102
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
-
if (!params) {
|
|
104
|
-
params = {};
|
|
105
|
-
}
|
|
106
|
-
params.headers = params.headers || {};
|
|
107
|
-
params.headers = Object.assign({ "Content-Type": "application/json;" }, params.headers);
|
|
108
|
-
if (this.ssidHeader && this.ssid) {
|
|
109
|
-
params.headers[this.ssidHeader] = this.ssid;
|
|
110
|
-
}
|
|
111
|
-
const res = yield fetch(url, {
|
|
112
|
-
headers: params.headers
|
|
113
|
-
});
|
|
114
|
-
return parseResult(res);
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
delete(url, params) {
|
|
118
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
119
|
-
if (!params) {
|
|
120
|
-
params = {};
|
|
121
|
-
}
|
|
122
|
-
params.headers = params.headers || {};
|
|
123
|
-
params.headers = Object.assign({ "Content-Type": "application/json;" }, params.headers);
|
|
124
|
-
if (this.ssidHeader && this.ssid) {
|
|
125
|
-
params.headers[this.ssidHeader] = this.ssid;
|
|
126
|
-
}
|
|
127
|
-
const res = yield fetch(url, {
|
|
128
|
-
headers: params.headers,
|
|
129
|
-
method: "DELETE"
|
|
130
|
-
});
|
|
131
|
-
return parseResult(res);
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
post(url, data, params) {
|
|
135
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
136
|
-
if (!params) {
|
|
137
|
-
params = {};
|
|
138
|
-
}
|
|
139
|
-
params.headers = params.headers || {};
|
|
140
|
-
params.headers = Object.assign({ "Content-Type": "application/json;" }, params.headers);
|
|
141
|
-
if (this.ssidHeader && this.ssid) {
|
|
142
|
-
params.headers[this.ssidHeader] = this.ssid;
|
|
143
|
-
}
|
|
144
|
-
if (!data) {
|
|
145
|
-
data = {};
|
|
146
|
-
}
|
|
147
|
-
if (typeof data != "string") {
|
|
148
|
-
data = JSON.stringify(data);
|
|
149
|
-
}
|
|
150
|
-
const res = yield fetch(url, {
|
|
151
|
-
headers: params.headers,
|
|
152
|
-
method: "POST",
|
|
153
|
-
body: data
|
|
154
|
-
});
|
|
155
|
-
return parseResult(res);
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
put(url, data, params) {
|
|
159
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
160
|
-
if (!params) {
|
|
161
|
-
params = {};
|
|
162
|
-
}
|
|
163
|
-
params.headers = params.headers || {};
|
|
164
|
-
params.headers = Object.assign({ "Content-Type": "application/json;" }, params.headers);
|
|
165
|
-
if (this.ssidHeader && this.ssid) {
|
|
166
|
-
params.headers[this.ssidHeader] = this.ssid;
|
|
167
|
-
}
|
|
168
|
-
if (!data) {
|
|
169
|
-
data = {};
|
|
170
|
-
}
|
|
171
|
-
if (typeof data != "string") {
|
|
172
|
-
data = JSON.stringify(data);
|
|
173
|
-
}
|
|
174
|
-
const res = yield fetch(url, {
|
|
175
|
-
headers: params.headers,
|
|
176
|
-
method: "PUT",
|
|
177
|
-
body: data
|
|
178
|
-
});
|
|
179
|
-
return parseResult(res);
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
upload(url, blob, params) {
|
|
183
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
184
|
-
return new Promise((res, rej) => {
|
|
185
|
-
try {
|
|
186
|
-
let xhr = new XMLHttpRequest();
|
|
187
|
-
const headers = params === null || params === void 0 ? void 0 : params.headers;
|
|
188
|
-
if (headers) {
|
|
189
|
-
const headerKeys = Object.keys(headers);
|
|
190
|
-
for (let i = 0; i < headerKeys.length; i++) {
|
|
191
|
-
const key = headerKeys[i];
|
|
192
|
-
const value = headers[key];
|
|
193
|
-
xhr.setRequestHeader(key, value);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
if (params === null || params === void 0 ? void 0 : params.onProgress) {
|
|
197
|
-
if (xhr.upload) {
|
|
198
|
-
xhr.upload.onprogress = params === null || params === void 0 ? void 0 : params.onProgress;
|
|
199
|
-
}
|
|
200
|
-
else {
|
|
201
|
-
xhr.addEventListener("progress", params === null || params === void 0 ? void 0 : params.onProgress);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
xhr.onreadystatechange = (e) => {
|
|
205
|
-
if (xhr.readyState == 4) {
|
|
206
|
-
if (xhr.status >= 400) {
|
|
207
|
-
rej(e);
|
|
208
|
-
}
|
|
209
|
-
else {
|
|
210
|
-
try {
|
|
211
|
-
res(JSON.parse(xhr.responseText));
|
|
212
|
-
}
|
|
213
|
-
catch (e) {
|
|
214
|
-
console.error(e, xhr.responseText);
|
|
215
|
-
res(xhr.responseText);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
};
|
|
220
|
-
xhr.open("POST", url, true);
|
|
221
|
-
if (this.ssidHeader && this.ssid) {
|
|
222
|
-
xhr.setRequestHeader(this.ssidHeader, this.ssid);
|
|
223
|
-
}
|
|
224
|
-
let formData;
|
|
225
|
-
if ((params === null || params === void 0 ? void 0 : params.formData) instanceof FormData) {
|
|
226
|
-
formData = params === null || params === void 0 ? void 0 : params.formData;
|
|
227
|
-
}
|
|
228
|
-
else {
|
|
229
|
-
formData = new FormData();
|
|
230
|
-
if (params === null || params === void 0 ? void 0 : params.formData) {
|
|
231
|
-
for (const key in params.formData) {
|
|
232
|
-
formData.append(key, params.formData[key]);
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
formData.append("file", blob);
|
|
237
|
-
xhr.send(formData);
|
|
238
|
-
}
|
|
239
|
-
catch (e) {
|
|
240
|
-
rej(e);
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
exports.AbstractApi = AbstractApi;
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AbstractApi = void 0;
|
|
13
|
+
const cache_1 = require("../common/cache");
|
|
14
|
+
const api_1 = require("./api");
|
|
15
|
+
// TODO: Currently checks for CSV vs json specifically,
|
|
16
|
+
// Need to see if our api is generally good at setting content-type headers.
|
|
17
|
+
// Make it less specific to CSV.
|
|
18
|
+
function parseResult(data) {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
if (data.status == 200) {
|
|
21
|
+
let type = data.headers.get("Content-Type");
|
|
22
|
+
if (type) {
|
|
23
|
+
type = type.trim().toLowerCase();
|
|
24
|
+
}
|
|
25
|
+
let encoding = "";
|
|
26
|
+
const charset = type ? type.split(";").find((x) => x.startsWith("charset=")) : "";
|
|
27
|
+
if (charset && charset.includes("=")) {
|
|
28
|
+
encoding = charset.split("=")[1];
|
|
29
|
+
encoding = encoding.toLowerCase();
|
|
30
|
+
}
|
|
31
|
+
// Our API has a very specific utf-16 encoding.
|
|
32
|
+
if (encoding == "utf-16") {
|
|
33
|
+
encoding = api_1.Api.EEncoding.UTF16;
|
|
34
|
+
}
|
|
35
|
+
if (!encoding || encoding == "utf-8") {
|
|
36
|
+
const text = yield data.text();
|
|
37
|
+
if (!text || !text.trim()) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
if (type && type.includes("text/csv")) {
|
|
41
|
+
return text;
|
|
42
|
+
}
|
|
43
|
+
return JSON.parse(text);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
const buffer = yield data.arrayBuffer();
|
|
47
|
+
const text = new TextDecoder(encoding).decode(buffer);
|
|
48
|
+
if (type && type.includes("text/csv")) {
|
|
49
|
+
return text;
|
|
50
|
+
}
|
|
51
|
+
return JSON.parse(text);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
const error = yield data.json();
|
|
56
|
+
throw (error);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* This is a base class for communication with an arbitrary Bruce Api.
|
|
62
|
+
*/
|
|
63
|
+
class AbstractApi {
|
|
64
|
+
constructor(params) {
|
|
65
|
+
this.ssid = "";
|
|
66
|
+
this.baseUrl = "";
|
|
67
|
+
this.Cache = new cache_1.CacheControl();
|
|
68
|
+
this.ssidHeader = params === null || params === void 0 ? void 0 : params.ssidHeader;
|
|
69
|
+
}
|
|
70
|
+
GetBaseUrl() {
|
|
71
|
+
return this.baseUrl;
|
|
72
|
+
}
|
|
73
|
+
SetBaseUrl(url) {
|
|
74
|
+
this.baseUrl = url;
|
|
75
|
+
if (!this.baseUrl.endsWith("/")) {
|
|
76
|
+
this.baseUrl += "/";
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
GetCacheItem(key, reqParams) {
|
|
80
|
+
let noCache = reqParams === null || reqParams === void 0 ? void 0 : reqParams.noCache;
|
|
81
|
+
if (noCache == null) {
|
|
82
|
+
noCache = api_1.Api.DEFAULT_NO_CACHE;
|
|
83
|
+
}
|
|
84
|
+
if (noCache) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
return this.Cache.Get(key);
|
|
88
|
+
}
|
|
89
|
+
GetSessionId() {
|
|
90
|
+
return this.ssid;
|
|
91
|
+
}
|
|
92
|
+
SetSessionId(value) {
|
|
93
|
+
this.ssid = value;
|
|
94
|
+
}
|
|
95
|
+
GetSessionHeader() {
|
|
96
|
+
return this.ssidHeader;
|
|
97
|
+
}
|
|
98
|
+
SetSessionHeader(value) {
|
|
99
|
+
this.ssidHeader = value;
|
|
100
|
+
}
|
|
101
|
+
get(url, params) {
|
|
102
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
if (!params) {
|
|
104
|
+
params = {};
|
|
105
|
+
}
|
|
106
|
+
params.headers = params.headers || {};
|
|
107
|
+
params.headers = Object.assign({ "Content-Type": "application/json;" }, params.headers);
|
|
108
|
+
if (this.ssidHeader && this.ssid) {
|
|
109
|
+
params.headers[this.ssidHeader] = this.ssid;
|
|
110
|
+
}
|
|
111
|
+
const res = yield fetch(url, {
|
|
112
|
+
headers: params.headers
|
|
113
|
+
});
|
|
114
|
+
return parseResult(res);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
delete(url, params) {
|
|
118
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
119
|
+
if (!params) {
|
|
120
|
+
params = {};
|
|
121
|
+
}
|
|
122
|
+
params.headers = params.headers || {};
|
|
123
|
+
params.headers = Object.assign({ "Content-Type": "application/json;" }, params.headers);
|
|
124
|
+
if (this.ssidHeader && this.ssid) {
|
|
125
|
+
params.headers[this.ssidHeader] = this.ssid;
|
|
126
|
+
}
|
|
127
|
+
const res = yield fetch(url, {
|
|
128
|
+
headers: params.headers,
|
|
129
|
+
method: "DELETE"
|
|
130
|
+
});
|
|
131
|
+
return parseResult(res);
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
post(url, data, params) {
|
|
135
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
136
|
+
if (!params) {
|
|
137
|
+
params = {};
|
|
138
|
+
}
|
|
139
|
+
params.headers = params.headers || {};
|
|
140
|
+
params.headers = Object.assign({ "Content-Type": "application/json;" }, params.headers);
|
|
141
|
+
if (this.ssidHeader && this.ssid) {
|
|
142
|
+
params.headers[this.ssidHeader] = this.ssid;
|
|
143
|
+
}
|
|
144
|
+
if (!data) {
|
|
145
|
+
data = {};
|
|
146
|
+
}
|
|
147
|
+
if (typeof data != "string") {
|
|
148
|
+
data = JSON.stringify(data);
|
|
149
|
+
}
|
|
150
|
+
const res = yield fetch(url, {
|
|
151
|
+
headers: params.headers,
|
|
152
|
+
method: "POST",
|
|
153
|
+
body: data
|
|
154
|
+
});
|
|
155
|
+
return parseResult(res);
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
put(url, data, params) {
|
|
159
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
160
|
+
if (!params) {
|
|
161
|
+
params = {};
|
|
162
|
+
}
|
|
163
|
+
params.headers = params.headers || {};
|
|
164
|
+
params.headers = Object.assign({ "Content-Type": "application/json;" }, params.headers);
|
|
165
|
+
if (this.ssidHeader && this.ssid) {
|
|
166
|
+
params.headers[this.ssidHeader] = this.ssid;
|
|
167
|
+
}
|
|
168
|
+
if (!data) {
|
|
169
|
+
data = {};
|
|
170
|
+
}
|
|
171
|
+
if (typeof data != "string") {
|
|
172
|
+
data = JSON.stringify(data);
|
|
173
|
+
}
|
|
174
|
+
const res = yield fetch(url, {
|
|
175
|
+
headers: params.headers,
|
|
176
|
+
method: "PUT",
|
|
177
|
+
body: data
|
|
178
|
+
});
|
|
179
|
+
return parseResult(res);
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
upload(url, blob, params) {
|
|
183
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
184
|
+
return new Promise((res, rej) => {
|
|
185
|
+
try {
|
|
186
|
+
let xhr = new XMLHttpRequest();
|
|
187
|
+
const headers = params === null || params === void 0 ? void 0 : params.headers;
|
|
188
|
+
if (headers) {
|
|
189
|
+
const headerKeys = Object.keys(headers);
|
|
190
|
+
for (let i = 0; i < headerKeys.length; i++) {
|
|
191
|
+
const key = headerKeys[i];
|
|
192
|
+
const value = headers[key];
|
|
193
|
+
xhr.setRequestHeader(key, value);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
if (params === null || params === void 0 ? void 0 : params.onProgress) {
|
|
197
|
+
if (xhr.upload) {
|
|
198
|
+
xhr.upload.onprogress = params === null || params === void 0 ? void 0 : params.onProgress;
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
xhr.addEventListener("progress", params === null || params === void 0 ? void 0 : params.onProgress);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
xhr.onreadystatechange = (e) => {
|
|
205
|
+
if (xhr.readyState == 4) {
|
|
206
|
+
if (xhr.status >= 400) {
|
|
207
|
+
rej(e);
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
try {
|
|
211
|
+
res(JSON.parse(xhr.responseText));
|
|
212
|
+
}
|
|
213
|
+
catch (e) {
|
|
214
|
+
console.error(e, xhr.responseText);
|
|
215
|
+
res(xhr.responseText);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
xhr.open("POST", url, true);
|
|
221
|
+
if (this.ssidHeader && this.ssid) {
|
|
222
|
+
xhr.setRequestHeader(this.ssidHeader, this.ssid);
|
|
223
|
+
}
|
|
224
|
+
let formData;
|
|
225
|
+
if ((params === null || params === void 0 ? void 0 : params.formData) instanceof FormData) {
|
|
226
|
+
formData = params === null || params === void 0 ? void 0 : params.formData;
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
formData = new FormData();
|
|
230
|
+
if (params === null || params === void 0 ? void 0 : params.formData) {
|
|
231
|
+
for (const key in params.formData) {
|
|
232
|
+
formData.append(key, params.formData[key]);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
formData.append("file", blob);
|
|
237
|
+
xhr.send(formData);
|
|
238
|
+
}
|
|
239
|
+
catch (e) {
|
|
240
|
+
rej(e);
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
exports.AbstractApi = AbstractApi;
|
|
247
247
|
//# sourceMappingURL=abstract-api.js.map
|