bruce-models 0.7.5 → 0.7.6

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 (100) hide show
  1. package/dist/bruce-models.es5.js +176 -11
  2. package/dist/bruce-models.es5.js.map +1 -1
  3. package/dist/bruce-models.umd.js +173 -9
  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 +228 -202
  10. package/dist/lib/api/bruce-api.js.map +1 -1
  11. package/dist/lib/api/cam-api.js +132 -132
  12. package/dist/lib/api/cam-api.js.map +1 -1
  13. package/dist/lib/api/global-api.js +131 -131
  14. package/dist/lib/api/global-api.js.map +1 -1
  15. package/dist/lib/api/idm-api.js +132 -132
  16. package/dist/lib/api/idm-api.js.map +1 -1
  17. package/dist/lib/bruce-models.js +84 -83
  18. package/dist/lib/bruce-models.js.map +1 -1
  19. package/dist/lib/calculator/calculator.js +158 -158
  20. package/dist/lib/client-file/client-file.js +188 -188
  21. package/dist/lib/common/bounds.js +2 -2
  22. package/dist/lib/common/bruce-event.js +48 -48
  23. package/dist/lib/common/bruce-variable.js +54 -54
  24. package/dist/lib/common/cache.js +86 -86
  25. package/dist/lib/common/camera.js +11 -11
  26. package/dist/lib/common/cartes.js +55 -55
  27. package/dist/lib/common/carto.js +60 -60
  28. package/dist/lib/common/color.js +86 -86
  29. package/dist/lib/common/delay-queue.js +60 -60
  30. package/dist/lib/common/dictionary.js +2 -2
  31. package/dist/lib/common/geometry.js +120 -120
  32. package/dist/lib/common/transform.js +2 -2
  33. package/dist/lib/common/utc.js +39 -39
  34. package/dist/lib/custom-form/custom-form.js +136 -136
  35. package/dist/lib/data-lab/data-lab.js +90 -90
  36. package/dist/lib/entity/entity-attachment-type.js +132 -132
  37. package/dist/lib/entity/entity-attachment.js +208 -208
  38. package/dist/lib/entity/entity-comment.js +132 -132
  39. package/dist/lib/entity/entity-coords.js +181 -181
  40. package/dist/lib/entity/entity-link.js +132 -132
  41. package/dist/lib/entity/entity-lod.js +189 -189
  42. package/dist/lib/entity/entity-relation-type.js +150 -150
  43. package/dist/lib/entity/entity-relation.js +189 -189
  44. package/dist/lib/entity/entity-source.js +176 -176
  45. package/dist/lib/entity/entity-tag.js +229 -229
  46. package/dist/lib/entity/entity-type.js +163 -163
  47. package/dist/lib/entity/entity.js +358 -358
  48. package/dist/lib/entity/getters/batched-data-getter.js +91 -91
  49. package/dist/lib/entity/getters/entity-filter-getter.js +344 -344
  50. package/dist/lib/entity/getters/entity-globe.js +135 -135
  51. package/dist/lib/entity/getters/view-monitor.js +2 -2
  52. package/dist/lib/import/import-cad.js +82 -82
  53. package/dist/lib/import/import-csv.js +51 -51
  54. package/dist/lib/import/import-json.js +51 -51
  55. package/dist/lib/import/import-kml.js +51 -51
  56. package/dist/lib/import/imported-file.js +121 -121
  57. package/dist/lib/markup/markup.js +40 -40
  58. package/dist/lib/program-key/program-key.js +152 -152
  59. package/dist/lib/project/menu-item.js +115 -115
  60. package/dist/lib/project/project-view-bookmark.js +183 -172
  61. package/dist/lib/project/project-view-bookmark.js.map +1 -1
  62. package/dist/lib/project/{project-view-tile-source.js → project-view-legacy-tile.js} +116 -116
  63. package/dist/lib/project/project-view-legacy-tile.js.map +1 -0
  64. package/dist/lib/project/project-view-tile.js +120 -0
  65. package/dist/lib/project/project-view-tile.js.map +1 -0
  66. package/dist/lib/project/project-view.js +177 -166
  67. package/dist/lib/project/project-view.js.map +1 -1
  68. package/dist/lib/project/zoom-control.js +17 -17
  69. package/dist/lib/server/pending-action.js +106 -106
  70. package/dist/lib/server/task.js +113 -113
  71. package/dist/lib/style/style.js +152 -152
  72. package/dist/lib/tileset/tileset-cad.js +2 -2
  73. package/dist/lib/tileset/tileset-entities-map-tiles.js +18 -18
  74. package/dist/lib/tileset/tileset-entities.js +2 -2
  75. package/dist/lib/tileset/tileset-ext-map-tiles.js +17 -17
  76. package/dist/lib/tileset/tileset-ext-terrain-tiles.js +2 -2
  77. package/dist/lib/tileset/tileset-map-tiles.js +2 -2
  78. package/dist/lib/tileset/tileset-pointcloud.js +2 -2
  79. package/dist/lib/tileset/tileset-terrain-tiles.js +2 -2
  80. package/dist/lib/tileset/tileset.js +403 -403
  81. package/dist/lib/user/permission.js +20 -20
  82. package/dist/lib/user/session.js +160 -160
  83. package/dist/lib/user/user-group.js +139 -139
  84. package/dist/lib/user/user.js +451 -451
  85. package/dist/lib/util/encrypt-utils.js +20 -20
  86. package/dist/lib/util/math-utils.js +41 -41
  87. package/dist/lib/util/object-utils.js +17 -17
  88. package/dist/lib/util/path-utils.js +61 -61
  89. package/dist/lib/util/url-utils.js +107 -107
  90. package/dist/types/api/bruce-api.d.ts +22 -2
  91. package/dist/types/api/cam-api.d.ts +1 -1
  92. package/dist/types/api/global-api.d.ts +1 -1
  93. package/dist/types/api/idm-api.d.ts +1 -1
  94. package/dist/types/bruce-models.d.ts +2 -1
  95. package/dist/types/project/project-view-bookmark.d.ts +85 -36
  96. package/dist/types/project/{project-view-tile-source.d.ts → project-view-legacy-tile.d.ts} +1 -1
  97. package/dist/types/project/project-view-tile.d.ts +68 -0
  98. package/dist/types/project/project-view.d.ts +64 -39
  99. package/package.json +1 -1
  100. package/dist/lib/project/project-view-tile-source.js.map +0 -1
@@ -1,268 +1,268 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
- return new (P || (P = Promise))(function (resolve, reject) {
16
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
- step((generator = generator.apply(thisArg, _arguments || [])).next());
20
- });
21
- };
22
- var __generator = (this && this.__generator) || function (thisArg, body) {
23
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
- function verb(n) { return function (v) { return step([n, v]); }; }
26
- function step(op) {
27
- if (f) throw new TypeError("Generator is already executing.");
28
- while (_) try {
29
- 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;
30
- if (y = 0, t) op = [op[0] & 2, t.value];
31
- switch (op[0]) {
32
- case 0: case 1: t = op; break;
33
- case 4: _.label++; return { value: op[1], done: false };
34
- case 5: _.label++; y = op[1]; op = [0]; continue;
35
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
- default:
37
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
- if (t[2]) _.ops.pop();
42
- _.trys.pop(); continue;
43
- }
44
- op = body.call(thisArg, _);
45
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
- }
48
- };
49
- Object.defineProperty(exports, "__esModule", { value: true });
50
- exports.AbstractApi = void 0;
51
- var cache_1 = require("../common/cache");
52
- function parseResult(data, encoding) {
53
- return __awaiter(this, void 0, void 0, function () {
54
- var buffer, error;
55
- return __generator(this, function (_a) {
56
- switch (_a.label) {
57
- case 0:
58
- if (!(data.status == 200)) return [3 /*break*/, 4];
59
- if (!encoding) return [3 /*break*/, 2];
60
- return [4 /*yield*/, data.arrayBuffer()];
61
- case 1:
62
- buffer = _a.sent();
63
- return [2 /*return*/, JSON.parse(new TextDecoder(encoding).decode(buffer))];
64
- case 2: return [2 /*return*/, data.json()];
65
- case 3: return [3 /*break*/, 6];
66
- case 4: return [4 /*yield*/, data.json()];
67
- case 5:
68
- error = _a.sent();
69
- throw (error);
70
- case 6: return [2 /*return*/];
71
- }
72
- });
73
- });
74
- }
75
- /**
76
- * This is a base class for communication with an arbitrary Bruce Api.
77
- */
78
- var AbstractApi = /** @class */ (function () {
79
- function AbstractApi(ssidHeader) {
80
- this.ssid = "";
81
- this.Cache = new cache_1.CacheControl();
82
- this.ssidHeader = ssidHeader;
83
- }
84
- AbstractApi.prototype.GetSessionId = function () {
85
- return this.ssid;
86
- };
87
- AbstractApi.prototype.SetSessionId = function (value) {
88
- this.ssid = value;
89
- };
90
- AbstractApi.prototype.GetSessionHeader = function () {
91
- return this.ssidHeader;
92
- };
93
- AbstractApi.prototype.SetSessionHeader = function (value) {
94
- this.ssidHeader = value;
95
- };
96
- AbstractApi.prototype.get = function (url, params) {
97
- var _a;
98
- return __awaiter(this, void 0, void 0, function () {
99
- var res;
100
- var _b;
101
- return __generator(this, function (_c) {
102
- switch (_c.label) {
103
- case 0:
104
- if (!params) {
105
- params = {};
106
- }
107
- params.headers = params.headers || {};
108
- params.headers = __assign((_b = { "Content-Type": "application/json;" }, _b[this.ssidHeader] = this.ssid, _b), params.headers);
109
- return [4 /*yield*/, fetch(url, {
110
- headers: params.headers
111
- })];
112
- case 1:
113
- res = _c.sent();
114
- return [2 /*return*/, parseResult(res, (_a = params.response) === null || _a === void 0 ? void 0 : _a.encoding)];
115
- }
116
- });
117
- });
118
- };
119
- AbstractApi.prototype.delete = function (url, params) {
120
- var _a;
121
- return __awaiter(this, void 0, void 0, function () {
122
- var res;
123
- var _b;
124
- return __generator(this, function (_c) {
125
- switch (_c.label) {
126
- case 0:
127
- if (!params) {
128
- params = {};
129
- }
130
- params.headers = params.headers || {};
131
- params.headers = __assign((_b = { "Content-Type": "application/json;" }, _b[this.ssidHeader] = this.ssid, _b), params.headers);
132
- return [4 /*yield*/, fetch(url, {
133
- headers: params.headers,
134
- method: "DELETE"
135
- })];
136
- case 1:
137
- res = _c.sent();
138
- return [2 /*return*/, parseResult(res, (_a = params.response) === null || _a === void 0 ? void 0 : _a.encoding)];
139
- }
140
- });
141
- });
142
- };
143
- AbstractApi.prototype.post = function (url, data, params) {
144
- var _a;
145
- return __awaiter(this, void 0, void 0, function () {
146
- var res;
147
- var _b;
148
- return __generator(this, function (_c) {
149
- switch (_c.label) {
150
- case 0:
151
- if (!params) {
152
- params = {};
153
- }
154
- params.headers = params.headers || {};
155
- params.headers = __assign((_b = { "Content-Type": "application/json;" }, _b[this.ssidHeader] = this.ssid, _b), params.headers);
156
- if (!data) {
157
- data = {};
158
- }
159
- if (typeof data != "string") {
160
- data = JSON.stringify(data);
161
- }
162
- return [4 /*yield*/, fetch(url, {
163
- headers: params.headers,
164
- method: "POST",
165
- body: data
166
- })];
167
- case 1:
168
- res = _c.sent();
169
- return [2 /*return*/, parseResult(res, (_a = params.response) === null || _a === void 0 ? void 0 : _a.encoding)];
170
- }
171
- });
172
- });
173
- };
174
- AbstractApi.prototype.put = function (url, data, params) {
175
- var _a;
176
- return __awaiter(this, void 0, void 0, function () {
177
- var res;
178
- var _b;
179
- return __generator(this, function (_c) {
180
- switch (_c.label) {
181
- case 0:
182
- if (!params) {
183
- params = {};
184
- }
185
- params.headers = params.headers || {};
186
- params.headers = __assign((_b = { "Content-Type": "application/json;" }, _b[this.ssidHeader] = this.ssid, _b), params.headers);
187
- if (!data) {
188
- data = {};
189
- }
190
- if (typeof data != "string") {
191
- data = JSON.stringify(data);
192
- }
193
- return [4 /*yield*/, fetch(url, {
194
- headers: params.headers,
195
- method: "PUT",
196
- body: data
197
- })];
198
- case 1:
199
- res = _c.sent();
200
- return [2 /*return*/, parseResult(res, (_a = params.response) === null || _a === void 0 ? void 0 : _a.encoding)];
201
- }
202
- });
203
- });
204
- };
205
- AbstractApi.prototype.upload = function (url, blob, params) {
206
- return __awaiter(this, void 0, void 0, function () {
207
- var _this = this;
208
- return __generator(this, function (_a) {
209
- return [2 /*return*/, new Promise(function (res, rej) {
210
- try {
211
- var xhr_1 = new XMLHttpRequest();
212
- var headers = params === null || params === void 0 ? void 0 : params.headers;
213
- if (headers) {
214
- var headerKeys = Object.keys(headers);
215
- for (var i = 0; i < headerKeys.length; i++) {
216
- var key = headerKeys[i];
217
- var value = headers[key];
218
- xhr_1.setRequestHeader(key, value);
219
- }
220
- }
221
- if (params === null || params === void 0 ? void 0 : params.onProgress) {
222
- if (xhr_1.upload) {
223
- xhr_1.upload.onprogress = params === null || params === void 0 ? void 0 : params.onProgress;
224
- }
225
- else {
226
- xhr_1.addEventListener("progress", params === null || params === void 0 ? void 0 : params.onProgress);
227
- }
228
- }
229
- xhr_1.onreadystatechange = function (e) {
230
- if (xhr_1.readyState == 4) {
231
- if (xhr_1.status >= 400) {
232
- rej(e);
233
- }
234
- else {
235
- try {
236
- res(JSON.parse(xhr_1.responseText));
237
- }
238
- catch (e) {
239
- console.error(e, xhr_1.responseText);
240
- res(xhr_1.responseText);
241
- }
242
- }
243
- }
244
- };
245
- xhr_1.open("POST", url, true);
246
- if (_this.ssid) {
247
- xhr_1.setRequestHeader(_this.ssidHeader, _this.ssid);
248
- }
249
- var formData = new FormData();
250
- if (params === null || params === void 0 ? void 0 : params.formData) {
251
- for (var key in params.formData) {
252
- formData.append(key, params.formData[key]);
253
- }
254
- }
255
- formData.append("file", blob);
256
- xhr_1.send(formData);
257
- }
258
- catch (e) {
259
- rej(e);
260
- }
261
- })];
262
- });
263
- });
264
- };
265
- return AbstractApi;
266
- }());
267
- exports.AbstractApi = AbstractApi;
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (_) try {
29
+ 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;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
49
+ Object.defineProperty(exports, "__esModule", { value: true });
50
+ exports.AbstractApi = void 0;
51
+ var cache_1 = require("../common/cache");
52
+ function parseResult(data, encoding) {
53
+ return __awaiter(this, void 0, void 0, function () {
54
+ var buffer, error;
55
+ return __generator(this, function (_a) {
56
+ switch (_a.label) {
57
+ case 0:
58
+ if (!(data.status == 200)) return [3 /*break*/, 4];
59
+ if (!encoding) return [3 /*break*/, 2];
60
+ return [4 /*yield*/, data.arrayBuffer()];
61
+ case 1:
62
+ buffer = _a.sent();
63
+ return [2 /*return*/, JSON.parse(new TextDecoder(encoding).decode(buffer))];
64
+ case 2: return [2 /*return*/, data.json()];
65
+ case 3: return [3 /*break*/, 6];
66
+ case 4: return [4 /*yield*/, data.json()];
67
+ case 5:
68
+ error = _a.sent();
69
+ throw (error);
70
+ case 6: return [2 /*return*/];
71
+ }
72
+ });
73
+ });
74
+ }
75
+ /**
76
+ * This is a base class for communication with an arbitrary Bruce Api.
77
+ */
78
+ var AbstractApi = /** @class */ (function () {
79
+ function AbstractApi(ssidHeader) {
80
+ this.ssid = "";
81
+ this.Cache = new cache_1.CacheControl();
82
+ this.ssidHeader = ssidHeader;
83
+ }
84
+ AbstractApi.prototype.GetSessionId = function () {
85
+ return this.ssid;
86
+ };
87
+ AbstractApi.prototype.SetSessionId = function (value) {
88
+ this.ssid = value;
89
+ };
90
+ AbstractApi.prototype.GetSessionHeader = function () {
91
+ return this.ssidHeader;
92
+ };
93
+ AbstractApi.prototype.SetSessionHeader = function (value) {
94
+ this.ssidHeader = value;
95
+ };
96
+ AbstractApi.prototype.get = function (url, params) {
97
+ var _a;
98
+ return __awaiter(this, void 0, void 0, function () {
99
+ var res;
100
+ var _b;
101
+ return __generator(this, function (_c) {
102
+ switch (_c.label) {
103
+ case 0:
104
+ if (!params) {
105
+ params = {};
106
+ }
107
+ params.headers = params.headers || {};
108
+ params.headers = __assign((_b = { "Content-Type": "application/json;" }, _b[this.ssidHeader] = this.ssid, _b), params.headers);
109
+ return [4 /*yield*/, fetch(url, {
110
+ headers: params.headers
111
+ })];
112
+ case 1:
113
+ res = _c.sent();
114
+ return [2 /*return*/, parseResult(res, (_a = params.response) === null || _a === void 0 ? void 0 : _a.encoding)];
115
+ }
116
+ });
117
+ });
118
+ };
119
+ AbstractApi.prototype.delete = function (url, params) {
120
+ var _a;
121
+ return __awaiter(this, void 0, void 0, function () {
122
+ var res;
123
+ var _b;
124
+ return __generator(this, function (_c) {
125
+ switch (_c.label) {
126
+ case 0:
127
+ if (!params) {
128
+ params = {};
129
+ }
130
+ params.headers = params.headers || {};
131
+ params.headers = __assign((_b = { "Content-Type": "application/json;" }, _b[this.ssidHeader] = this.ssid, _b), params.headers);
132
+ return [4 /*yield*/, fetch(url, {
133
+ headers: params.headers,
134
+ method: "DELETE"
135
+ })];
136
+ case 1:
137
+ res = _c.sent();
138
+ return [2 /*return*/, parseResult(res, (_a = params.response) === null || _a === void 0 ? void 0 : _a.encoding)];
139
+ }
140
+ });
141
+ });
142
+ };
143
+ AbstractApi.prototype.post = function (url, data, params) {
144
+ var _a;
145
+ return __awaiter(this, void 0, void 0, function () {
146
+ var res;
147
+ var _b;
148
+ return __generator(this, function (_c) {
149
+ switch (_c.label) {
150
+ case 0:
151
+ if (!params) {
152
+ params = {};
153
+ }
154
+ params.headers = params.headers || {};
155
+ params.headers = __assign((_b = { "Content-Type": "application/json;" }, _b[this.ssidHeader] = this.ssid, _b), params.headers);
156
+ if (!data) {
157
+ data = {};
158
+ }
159
+ if (typeof data != "string") {
160
+ data = JSON.stringify(data);
161
+ }
162
+ return [4 /*yield*/, fetch(url, {
163
+ headers: params.headers,
164
+ method: "POST",
165
+ body: data
166
+ })];
167
+ case 1:
168
+ res = _c.sent();
169
+ return [2 /*return*/, parseResult(res, (_a = params.response) === null || _a === void 0 ? void 0 : _a.encoding)];
170
+ }
171
+ });
172
+ });
173
+ };
174
+ AbstractApi.prototype.put = function (url, data, params) {
175
+ var _a;
176
+ return __awaiter(this, void 0, void 0, function () {
177
+ var res;
178
+ var _b;
179
+ return __generator(this, function (_c) {
180
+ switch (_c.label) {
181
+ case 0:
182
+ if (!params) {
183
+ params = {};
184
+ }
185
+ params.headers = params.headers || {};
186
+ params.headers = __assign((_b = { "Content-Type": "application/json;" }, _b[this.ssidHeader] = this.ssid, _b), params.headers);
187
+ if (!data) {
188
+ data = {};
189
+ }
190
+ if (typeof data != "string") {
191
+ data = JSON.stringify(data);
192
+ }
193
+ return [4 /*yield*/, fetch(url, {
194
+ headers: params.headers,
195
+ method: "PUT",
196
+ body: data
197
+ })];
198
+ case 1:
199
+ res = _c.sent();
200
+ return [2 /*return*/, parseResult(res, (_a = params.response) === null || _a === void 0 ? void 0 : _a.encoding)];
201
+ }
202
+ });
203
+ });
204
+ };
205
+ AbstractApi.prototype.upload = function (url, blob, params) {
206
+ return __awaiter(this, void 0, void 0, function () {
207
+ var _this = this;
208
+ return __generator(this, function (_a) {
209
+ return [2 /*return*/, new Promise(function (res, rej) {
210
+ try {
211
+ var xhr_1 = new XMLHttpRequest();
212
+ var headers = params === null || params === void 0 ? void 0 : params.headers;
213
+ if (headers) {
214
+ var headerKeys = Object.keys(headers);
215
+ for (var i = 0; i < headerKeys.length; i++) {
216
+ var key = headerKeys[i];
217
+ var value = headers[key];
218
+ xhr_1.setRequestHeader(key, value);
219
+ }
220
+ }
221
+ if (params === null || params === void 0 ? void 0 : params.onProgress) {
222
+ if (xhr_1.upload) {
223
+ xhr_1.upload.onprogress = params === null || params === void 0 ? void 0 : params.onProgress;
224
+ }
225
+ else {
226
+ xhr_1.addEventListener("progress", params === null || params === void 0 ? void 0 : params.onProgress);
227
+ }
228
+ }
229
+ xhr_1.onreadystatechange = function (e) {
230
+ if (xhr_1.readyState == 4) {
231
+ if (xhr_1.status >= 400) {
232
+ rej(e);
233
+ }
234
+ else {
235
+ try {
236
+ res(JSON.parse(xhr_1.responseText));
237
+ }
238
+ catch (e) {
239
+ console.error(e, xhr_1.responseText);
240
+ res(xhr_1.responseText);
241
+ }
242
+ }
243
+ }
244
+ };
245
+ xhr_1.open("POST", url, true);
246
+ if (_this.ssid) {
247
+ xhr_1.setRequestHeader(_this.ssidHeader, _this.ssid);
248
+ }
249
+ var formData = new FormData();
250
+ if (params === null || params === void 0 ? void 0 : params.formData) {
251
+ for (var key in params.formData) {
252
+ formData.append(key, params.formData[key]);
253
+ }
254
+ }
255
+ formData.append("file", blob);
256
+ xhr_1.send(formData);
257
+ }
258
+ catch (e) {
259
+ rej(e);
260
+ }
261
+ })];
262
+ });
263
+ });
264
+ };
265
+ return AbstractApi;
266
+ }());
267
+ exports.AbstractApi = AbstractApi;
268
268
  //# sourceMappingURL=abstract-api.js.map