polfan-server-js-client 0.1.99906 → 0.1.99908
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/build/index.js +209 -63
- package/build/index.js.map +1 -1
- package/build/types/AbstractRestClient.d.ts +2 -0
- package/build/types/FilesClient.d.ts +13 -0
- package/build/types/index.d.ts +3 -2
- package/build/types/state-tracker/MessagesManager.d.ts +1 -1
- package/build/types/types/src/schemes/Message.d.ts +1 -0
- package/package.json +1 -1
- package/src/AbstractRestClient.ts +22 -14
- package/src/FilesClient.ts +29 -0
- package/src/index.ts +4 -2
- package/src/state-tracker/MessagesManager.ts +7 -4
- package/src/types/src/schemes/Message.ts +1 -0
package/build/index.js
CHANGED
|
@@ -50,17 +50,35 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
50
50
|
// EXPORTS
|
|
51
51
|
__webpack_require__.d(__webpack_exports__, {
|
|
52
52
|
"AuthClient": () => (/* reexport */ AuthClient),
|
|
53
|
+
"File": () => (/* reexport */ FilesClient_namespaceObject.File),
|
|
54
|
+
"FilesClient": () => (/* reexport */ FilesClient),
|
|
53
55
|
"IndexedCollection": () => (/* reexport */ IndexedCollection),
|
|
54
56
|
"IndexedObjectCollection": () => (/* reexport */ IndexedObjectCollection),
|
|
55
57
|
"Layer": () => (/* reexport */ Layer),
|
|
58
|
+
"MyAccountInterface": () => (/* reexport */ AuthClient_namespaceObject.MyAccountInterface),
|
|
56
59
|
"ObservableIndexedCollection": () => (/* reexport */ ObservableIndexedCollection),
|
|
57
60
|
"ObservableIndexedObjectCollection": () => (/* reexport */ ObservableIndexedObjectCollection),
|
|
58
61
|
"PermissionDefinition": () => (/* reexport */ PermissionDefinition),
|
|
59
62
|
"Permissions": () => (/* reexport */ Permissions),
|
|
63
|
+
"TokenInterface": () => (/* reexport */ AuthClient_namespaceObject.TokenInterface),
|
|
60
64
|
"WebApiChatClient": () => (/* reexport */ WebApiChatClient),
|
|
61
65
|
"WebSocketChatClient": () => (/* reexport */ WebSocketChatClient)
|
|
62
66
|
});
|
|
63
67
|
|
|
68
|
+
// NAMESPACE OBJECT: ./src/AuthClient.ts
|
|
69
|
+
var AuthClient_namespaceObject = {};
|
|
70
|
+
__webpack_require__.r(AuthClient_namespaceObject);
|
|
71
|
+
__webpack_require__.d(AuthClient_namespaceObject, {
|
|
72
|
+
"L": () => (AuthClient)
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
// NAMESPACE OBJECT: ./src/FilesClient.ts
|
|
76
|
+
var FilesClient_namespaceObject = {};
|
|
77
|
+
__webpack_require__.r(FilesClient_namespaceObject);
|
|
78
|
+
__webpack_require__.d(FilesClient_namespaceObject, {
|
|
79
|
+
"Q": () => (FilesClient)
|
|
80
|
+
});
|
|
81
|
+
|
|
64
82
|
;// CONCATENATED MODULE: ./src/EventTarget.ts
|
|
65
83
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
66
84
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
@@ -1435,48 +1453,60 @@ var MessagesManager = /*#__PURE__*/function () {
|
|
|
1435
1453
|
key: "cacheSpaceFollowedTopics",
|
|
1436
1454
|
value: function () {
|
|
1437
1455
|
var _cacheSpaceFollowedTopics = MessagesManager_asyncToGenerator( /*#__PURE__*/MessagesManager_regeneratorRuntime().mark(function _callee2(spaceId) {
|
|
1438
|
-
var
|
|
1456
|
+
var _this2 = this;
|
|
1457
|
+
var roomIds, resultPromise, result;
|
|
1439
1458
|
return MessagesManager_regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1440
1459
|
while (1) {
|
|
1441
1460
|
switch (_context2.prev = _context2.next) {
|
|
1442
1461
|
case 0:
|
|
1443
|
-
_context2.
|
|
1462
|
+
_context2.t0 = spaceId;
|
|
1463
|
+
if (!_context2.t0) {
|
|
1464
|
+
_context2.next = 5;
|
|
1465
|
+
break;
|
|
1466
|
+
}
|
|
1467
|
+
_context2.next = 4;
|
|
1444
1468
|
return this.tracker.spaces.get();
|
|
1445
|
-
case
|
|
1446
|
-
|
|
1447
|
-
|
|
1469
|
+
case 4:
|
|
1470
|
+
_context2.t0 = !_context2.sent.has(spaceId);
|
|
1471
|
+
case 5:
|
|
1472
|
+
if (!_context2.t0) {
|
|
1473
|
+
_context2.next = 7;
|
|
1448
1474
|
break;
|
|
1449
1475
|
}
|
|
1450
1476
|
throw new Error("You are not in space ".concat(spaceId));
|
|
1451
|
-
case
|
|
1452
|
-
_context2.next =
|
|
1477
|
+
case 7:
|
|
1478
|
+
_context2.next = 9;
|
|
1453
1479
|
return this.tracker.rooms.get();
|
|
1454
|
-
case
|
|
1480
|
+
case 9:
|
|
1455
1481
|
roomIds = _context2.sent.findBy('spaceId', spaceId).items.map(function (room) {
|
|
1456
1482
|
return room.id;
|
|
1457
1483
|
});
|
|
1458
1484
|
if (roomIds.length) {
|
|
1459
|
-
_context2.next =
|
|
1485
|
+
_context2.next = 12;
|
|
1460
1486
|
break;
|
|
1461
1487
|
}
|
|
1462
1488
|
return _context2.abrupt("return");
|
|
1463
|
-
case
|
|
1464
|
-
|
|
1465
|
-
return this.tracker.client.send('GetFollowedTopics', {
|
|
1489
|
+
case 12:
|
|
1490
|
+
resultPromise = this.tracker.client.send('GetFollowedTopics', {
|
|
1466
1491
|
location: {
|
|
1467
1492
|
spaceId: spaceId
|
|
1468
1493
|
}
|
|
1469
1494
|
});
|
|
1470
|
-
|
|
1495
|
+
roomIds.forEach(function (roomId) {
|
|
1496
|
+
return _this2.followedTopicsPromises.register(resultPromise, roomId);
|
|
1497
|
+
});
|
|
1498
|
+
_context2.next = 16;
|
|
1499
|
+
return resultPromise;
|
|
1500
|
+
case 16:
|
|
1471
1501
|
result = _context2.sent;
|
|
1472
1502
|
if (!result.error) {
|
|
1473
|
-
_context2.next =
|
|
1503
|
+
_context2.next = 19;
|
|
1474
1504
|
break;
|
|
1475
1505
|
}
|
|
1476
1506
|
throw result.error;
|
|
1477
|
-
case
|
|
1507
|
+
case 19:
|
|
1478
1508
|
this.setFollowedTopicsArray(roomIds, result.data.followedTopics);
|
|
1479
|
-
case
|
|
1509
|
+
case 20:
|
|
1480
1510
|
case "end":
|
|
1481
1511
|
return _context2.stop();
|
|
1482
1512
|
}
|
|
@@ -1496,7 +1526,7 @@ var MessagesManager = /*#__PURE__*/function () {
|
|
|
1496
1526
|
key: "getRoomFollowedTopics",
|
|
1497
1527
|
value: function () {
|
|
1498
1528
|
var _getRoomFollowedTopics = MessagesManager_asyncToGenerator( /*#__PURE__*/MessagesManager_regeneratorRuntime().mark(function _callee4(roomId) {
|
|
1499
|
-
var
|
|
1529
|
+
var _this3 = this;
|
|
1500
1530
|
return MessagesManager_regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
1501
1531
|
while (1) {
|
|
1502
1532
|
switch (_context4.prev = _context4.next) {
|
|
@@ -1522,7 +1552,7 @@ var MessagesManager = /*#__PURE__*/function () {
|
|
|
1522
1552
|
switch (_context3.prev = _context3.next) {
|
|
1523
1553
|
case 0:
|
|
1524
1554
|
_context3.next = 2;
|
|
1525
|
-
return
|
|
1555
|
+
return _this3.tracker.client.send('GetFollowedTopics', {
|
|
1526
1556
|
location: {
|
|
1527
1557
|
roomId: roomId
|
|
1528
1558
|
}
|
|
@@ -1535,7 +1565,7 @@ var MessagesManager = /*#__PURE__*/function () {
|
|
|
1535
1565
|
}
|
|
1536
1566
|
throw result.error;
|
|
1537
1567
|
case 5:
|
|
1538
|
-
|
|
1568
|
+
_this3.setFollowedTopicsArray([roomId], result.data.followedTopics);
|
|
1539
1569
|
case 6:
|
|
1540
1570
|
case "end":
|
|
1541
1571
|
return _context3.stop();
|
|
@@ -1769,12 +1799,12 @@ var MessagesManager = /*#__PURE__*/function () {
|
|
|
1769
1799
|
}, {
|
|
1770
1800
|
key: "handleSession",
|
|
1771
1801
|
value: function handleSession(ev) {
|
|
1772
|
-
var
|
|
1802
|
+
var _this4 = this;
|
|
1773
1803
|
this.followedTopics.deleteAll();
|
|
1774
1804
|
this.followedTopicsPromises.forgetAll();
|
|
1775
1805
|
this.roomHistories.deleteAll();
|
|
1776
1806
|
ev.state.rooms.forEach(function (room) {
|
|
1777
|
-
return
|
|
1807
|
+
return _this4.createHistoryForNewRoom(room);
|
|
1778
1808
|
});
|
|
1779
1809
|
this.deferredSession.resolve();
|
|
1780
1810
|
}
|
|
@@ -1807,7 +1837,7 @@ var MessagesManager = /*#__PURE__*/function () {
|
|
|
1807
1837
|
}, {
|
|
1808
1838
|
key: "setFollowedTopicsArray",
|
|
1809
1839
|
value: function setFollowedTopicsArray(roomIds, followedTopics) {
|
|
1810
|
-
var
|
|
1840
|
+
var _this5 = this;
|
|
1811
1841
|
var roomToTopics = {};
|
|
1812
1842
|
|
|
1813
1843
|
// Reassign followed topics to limit collection change event emit
|
|
@@ -1817,14 +1847,14 @@ var MessagesManager = /*#__PURE__*/function () {
|
|
|
1817
1847
|
roomToTopics[followedTopic.location.roomId].push(followedTopic);
|
|
1818
1848
|
});
|
|
1819
1849
|
roomIds.forEach(function (roomId) {
|
|
1820
|
-
if (!
|
|
1821
|
-
|
|
1850
|
+
if (!_this5.followedTopics.has(roomId)) {
|
|
1851
|
+
_this5.followedTopics.set([roomId, new ObservableIndexedObjectCollection(function (followedTopic) {
|
|
1822
1852
|
return followedTopic.location.topicId;
|
|
1823
1853
|
})]);
|
|
1824
1854
|
}
|
|
1825
1855
|
if (roomToTopics[roomId]) {
|
|
1826
|
-
var
|
|
1827
|
-
(
|
|
1856
|
+
var _this5$followedTopics;
|
|
1857
|
+
(_this5$followedTopics = _this5.followedTopics.get(roomId)).set.apply(_this5$followedTopics, MessagesManager_toConsumableArray(roomToTopics[roomId]));
|
|
1828
1858
|
}
|
|
1829
1859
|
});
|
|
1830
1860
|
}
|
|
@@ -4057,9 +4087,7 @@ var AbstractRestClient = /*#__PURE__*/function () {
|
|
|
4057
4087
|
key: "send",
|
|
4058
4088
|
value: function () {
|
|
4059
4089
|
var _send = AbstractRestClient_asyncToGenerator( /*#__PURE__*/AbstractRestClient_regeneratorRuntime().mark(function _callee(method, uri) {
|
|
4060
|
-
var _result$headers$get;
|
|
4061
4090
|
var data,
|
|
4062
|
-
headers,
|
|
4063
4091
|
url,
|
|
4064
4092
|
body,
|
|
4065
4093
|
result,
|
|
@@ -4069,13 +4097,6 @@ var AbstractRestClient = /*#__PURE__*/function () {
|
|
|
4069
4097
|
switch (_context.prev = _context.next) {
|
|
4070
4098
|
case 0:
|
|
4071
4099
|
data = _args.length > 2 && _args[2] !== undefined ? _args[2] : undefined;
|
|
4072
|
-
headers = {
|
|
4073
|
-
'Content-Type': 'application/json',
|
|
4074
|
-
Accept: 'application/json'
|
|
4075
|
-
};
|
|
4076
|
-
if (this.options.token) {
|
|
4077
|
-
headers.Authorization = "Bearer ".concat(this.options.token);
|
|
4078
|
-
}
|
|
4079
4100
|
url = this.getUrl(uri);
|
|
4080
4101
|
body = undefined;
|
|
4081
4102
|
if (data) {
|
|
@@ -4085,39 +4106,16 @@ var AbstractRestClient = /*#__PURE__*/function () {
|
|
|
4085
4106
|
body = JSON.stringify(data);
|
|
4086
4107
|
}
|
|
4087
4108
|
}
|
|
4088
|
-
_context.next =
|
|
4109
|
+
_context.next = 6;
|
|
4089
4110
|
return fetch(url, {
|
|
4090
4111
|
method: method,
|
|
4091
4112
|
body: body,
|
|
4092
|
-
headers:
|
|
4113
|
+
headers: this.getHeaders()
|
|
4093
4114
|
});
|
|
4094
|
-
case
|
|
4115
|
+
case 6:
|
|
4095
4116
|
result = _context.sent;
|
|
4096
|
-
_context.
|
|
4097
|
-
|
|
4098
|
-
if (!((_result$headers$get = result.headers.get('content-type')) !== null && _result$headers$get !== void 0 && _result$headers$get.includes('json'))) {
|
|
4099
|
-
_context.next = 17;
|
|
4100
|
-
break;
|
|
4101
|
-
}
|
|
4102
|
-
_context.next = 14;
|
|
4103
|
-
return result.json();
|
|
4104
|
-
case 14:
|
|
4105
|
-
_context.t2 = _context.sent;
|
|
4106
|
-
_context.next = 20;
|
|
4107
|
-
break;
|
|
4108
|
-
case 17:
|
|
4109
|
-
_context.next = 19;
|
|
4110
|
-
return result.text();
|
|
4111
|
-
case 19:
|
|
4112
|
-
_context.t2 = _context.sent;
|
|
4113
|
-
case 20:
|
|
4114
|
-
_context.t3 = _context.t2;
|
|
4115
|
-
return _context.abrupt("return", {
|
|
4116
|
-
ok: _context.t0,
|
|
4117
|
-
status: _context.t1,
|
|
4118
|
-
data: _context.t3
|
|
4119
|
-
});
|
|
4120
|
-
case 22:
|
|
4117
|
+
return _context.abrupt("return", this.convertFetchResponse(result));
|
|
4118
|
+
case 8:
|
|
4121
4119
|
case "end":
|
|
4122
4120
|
return _context.stop();
|
|
4123
4121
|
}
|
|
@@ -4129,12 +4127,69 @@ var AbstractRestClient = /*#__PURE__*/function () {
|
|
|
4129
4127
|
}
|
|
4130
4128
|
return send;
|
|
4131
4129
|
}()
|
|
4130
|
+
}, {
|
|
4131
|
+
key: "getHeaders",
|
|
4132
|
+
value: function getHeaders() {
|
|
4133
|
+
var headers = {
|
|
4134
|
+
'Content-Type': 'application/json',
|
|
4135
|
+
Accept: 'application/json'
|
|
4136
|
+
};
|
|
4137
|
+
if (this.options.token) {
|
|
4138
|
+
headers.Authorization = "Bearer ".concat(this.options.token);
|
|
4139
|
+
}
|
|
4140
|
+
return headers;
|
|
4141
|
+
}
|
|
4132
4142
|
}, {
|
|
4133
4143
|
key: "getUrl",
|
|
4134
4144
|
value: function getUrl(uri) {
|
|
4135
4145
|
var _this$options$url;
|
|
4136
4146
|
return this.removeEndingSlash((_this$options$url = this.options.url) !== null && _this$options$url !== void 0 ? _this$options$url : this.defaultUrl) + '/' + this.removeStartingSlash(uri);
|
|
4137
4147
|
}
|
|
4148
|
+
}, {
|
|
4149
|
+
key: "convertFetchResponse",
|
|
4150
|
+
value: function () {
|
|
4151
|
+
var _convertFetchResponse = AbstractRestClient_asyncToGenerator( /*#__PURE__*/AbstractRestClient_regeneratorRuntime().mark(function _callee2(result) {
|
|
4152
|
+
var _result$headers$get;
|
|
4153
|
+
return AbstractRestClient_regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
4154
|
+
while (1) {
|
|
4155
|
+
switch (_context2.prev = _context2.next) {
|
|
4156
|
+
case 0:
|
|
4157
|
+
_context2.t0 = result.ok;
|
|
4158
|
+
_context2.t1 = result.status;
|
|
4159
|
+
if (!((_result$headers$get = result.headers.get('content-type')) !== null && _result$headers$get !== void 0 && _result$headers$get.includes('json'))) {
|
|
4160
|
+
_context2.next = 8;
|
|
4161
|
+
break;
|
|
4162
|
+
}
|
|
4163
|
+
_context2.next = 5;
|
|
4164
|
+
return result.json();
|
|
4165
|
+
case 5:
|
|
4166
|
+
_context2.t2 = _context2.sent;
|
|
4167
|
+
_context2.next = 11;
|
|
4168
|
+
break;
|
|
4169
|
+
case 8:
|
|
4170
|
+
_context2.next = 10;
|
|
4171
|
+
return result.text();
|
|
4172
|
+
case 10:
|
|
4173
|
+
_context2.t2 = _context2.sent;
|
|
4174
|
+
case 11:
|
|
4175
|
+
_context2.t3 = _context2.t2;
|
|
4176
|
+
return _context2.abrupt("return", {
|
|
4177
|
+
ok: _context2.t0,
|
|
4178
|
+
status: _context2.t1,
|
|
4179
|
+
data: _context2.t3
|
|
4180
|
+
});
|
|
4181
|
+
case 13:
|
|
4182
|
+
case "end":
|
|
4183
|
+
return _context2.stop();
|
|
4184
|
+
}
|
|
4185
|
+
}
|
|
4186
|
+
}, _callee2);
|
|
4187
|
+
}));
|
|
4188
|
+
function convertFetchResponse(_x3) {
|
|
4189
|
+
return _convertFetchResponse.apply(this, arguments);
|
|
4190
|
+
}
|
|
4191
|
+
return convertFetchResponse;
|
|
4192
|
+
}()
|
|
4138
4193
|
}, {
|
|
4139
4194
|
key: "removeStartingSlash",
|
|
4140
4195
|
value: function removeStartingSlash(text) {
|
|
@@ -4287,6 +4342,96 @@ var AuthClient = /*#__PURE__*/function (_AbstractRestClient) {
|
|
|
4287
4342
|
}]);
|
|
4288
4343
|
return AuthClient;
|
|
4289
4344
|
}(AbstractRestClient);
|
|
4345
|
+
;// CONCATENATED MODULE: ./src/FilesClient.ts
|
|
4346
|
+
function FilesClient_typeof(obj) { "@babel/helpers - typeof"; return FilesClient_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, FilesClient_typeof(obj); }
|
|
4347
|
+
function FilesClient_regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ FilesClient_regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == FilesClient_typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
4348
|
+
function FilesClient_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
4349
|
+
function FilesClient_asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { FilesClient_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { FilesClient_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
4350
|
+
function FilesClient_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
4351
|
+
function FilesClient_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, FilesClient_toPropertyKey(descriptor.key), descriptor); } }
|
|
4352
|
+
function FilesClient_createClass(Constructor, protoProps, staticProps) { if (protoProps) FilesClient_defineProperties(Constructor.prototype, protoProps); if (staticProps) FilesClient_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
4353
|
+
function FilesClient_inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) FilesClient_setPrototypeOf(subClass, superClass); }
|
|
4354
|
+
function FilesClient_setPrototypeOf(o, p) { FilesClient_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return FilesClient_setPrototypeOf(o, p); }
|
|
4355
|
+
function FilesClient_createSuper(Derived) { var hasNativeReflectConstruct = FilesClient_isNativeReflectConstruct(); return function _createSuperInternal() { var Super = FilesClient_getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = FilesClient_getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return FilesClient_possibleConstructorReturn(this, result); }; }
|
|
4356
|
+
function FilesClient_possibleConstructorReturn(self, call) { if (call && (FilesClient_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return FilesClient_assertThisInitialized(self); }
|
|
4357
|
+
function FilesClient_assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
4358
|
+
function FilesClient_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
4359
|
+
function FilesClient_getPrototypeOf(o) { FilesClient_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return FilesClient_getPrototypeOf(o); }
|
|
4360
|
+
function FilesClient_defineProperty(obj, key, value) { key = FilesClient_toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
4361
|
+
function FilesClient_toPropertyKey(arg) { var key = FilesClient_toPrimitive(arg, "string"); return FilesClient_typeof(key) === "symbol" ? key : String(key); }
|
|
4362
|
+
function FilesClient_toPrimitive(input, hint) { if (FilesClient_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (FilesClient_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
4363
|
+
|
|
4364
|
+
var FilesClient = /*#__PURE__*/function (_AbstractRestClient) {
|
|
4365
|
+
FilesClient_inherits(FilesClient, _AbstractRestClient);
|
|
4366
|
+
var _super = FilesClient_createSuper(FilesClient);
|
|
4367
|
+
function FilesClient() {
|
|
4368
|
+
var _this;
|
|
4369
|
+
FilesClient_classCallCheck(this, FilesClient);
|
|
4370
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
4371
|
+
args[_key] = arguments[_key];
|
|
4372
|
+
}
|
|
4373
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
4374
|
+
FilesClient_defineProperty(FilesClient_assertThisInitialized(_this), "defaultUrl", 'https://polfan.pl/webservice/api/files');
|
|
4375
|
+
return _this;
|
|
4376
|
+
}
|
|
4377
|
+
FilesClient_createClass(FilesClient, [{
|
|
4378
|
+
key: "uploadFile",
|
|
4379
|
+
value: function () {
|
|
4380
|
+
var _uploadFile = FilesClient_asyncToGenerator( /*#__PURE__*/FilesClient_regeneratorRuntime().mark(function _callee(file) {
|
|
4381
|
+
var formData, headers, response;
|
|
4382
|
+
return FilesClient_regeneratorRuntime().wrap(function _callee$(_context) {
|
|
4383
|
+
while (1) {
|
|
4384
|
+
switch (_context.prev = _context.next) {
|
|
4385
|
+
case 0:
|
|
4386
|
+
formData = new FormData();
|
|
4387
|
+
formData.append('file', file);
|
|
4388
|
+
headers = this.getHeaders();
|
|
4389
|
+
headers['Content-Type'] = 'multipart/form-data';
|
|
4390
|
+
_context.next = 6;
|
|
4391
|
+
return fetch(this.defaultUrl, {
|
|
4392
|
+
method: 'POST',
|
|
4393
|
+
body: formData,
|
|
4394
|
+
headers: headers
|
|
4395
|
+
});
|
|
4396
|
+
case 6:
|
|
4397
|
+
response = _context.sent;
|
|
4398
|
+
return _context.abrupt("return", this.convertFetchResponse(response));
|
|
4399
|
+
case 8:
|
|
4400
|
+
case "end":
|
|
4401
|
+
return _context.stop();
|
|
4402
|
+
}
|
|
4403
|
+
}
|
|
4404
|
+
}, _callee, this);
|
|
4405
|
+
}));
|
|
4406
|
+
function uploadFile(_x) {
|
|
4407
|
+
return _uploadFile.apply(this, arguments);
|
|
4408
|
+
}
|
|
4409
|
+
return uploadFile;
|
|
4410
|
+
}()
|
|
4411
|
+
}, {
|
|
4412
|
+
key: "getFileMetadata",
|
|
4413
|
+
value: function () {
|
|
4414
|
+
var _getFileMetadata = FilesClient_asyncToGenerator( /*#__PURE__*/FilesClient_regeneratorRuntime().mark(function _callee2(id) {
|
|
4415
|
+
return FilesClient_regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
4416
|
+
while (1) {
|
|
4417
|
+
switch (_context2.prev = _context2.next) {
|
|
4418
|
+
case 0:
|
|
4419
|
+
return _context2.abrupt("return", this.send('GET', '/' + id));
|
|
4420
|
+
case 1:
|
|
4421
|
+
case "end":
|
|
4422
|
+
return _context2.stop();
|
|
4423
|
+
}
|
|
4424
|
+
}
|
|
4425
|
+
}, _callee2, this);
|
|
4426
|
+
}));
|
|
4427
|
+
function getFileMetadata(_x2) {
|
|
4428
|
+
return _getFileMetadata.apply(this, arguments);
|
|
4429
|
+
}
|
|
4430
|
+
return getFileMetadata;
|
|
4431
|
+
}()
|
|
4432
|
+
}]);
|
|
4433
|
+
return FilesClient;
|
|
4434
|
+
}(AbstractRestClient);
|
|
4290
4435
|
;// CONCATENATED MODULE: ./src/index.ts
|
|
4291
4436
|
|
|
4292
4437
|
|
|
@@ -4294,6 +4439,7 @@ var AuthClient = /*#__PURE__*/function (_AbstractRestClient) {
|
|
|
4294
4439
|
|
|
4295
4440
|
|
|
4296
4441
|
|
|
4442
|
+
|
|
4297
4443
|
/******/ return __webpack_exports__;
|
|
4298
4444
|
/******/ })()
|
|
4299
4445
|
;
|