polfan-server-js-client 0.1.99907 → 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 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"); } }
@@ -1441,27 +1459,34 @@ var MessagesManager = /*#__PURE__*/function () {
1441
1459
  while (1) {
1442
1460
  switch (_context2.prev = _context2.next) {
1443
1461
  case 0:
1444
- _context2.next = 2;
1462
+ _context2.t0 = spaceId;
1463
+ if (!_context2.t0) {
1464
+ _context2.next = 5;
1465
+ break;
1466
+ }
1467
+ _context2.next = 4;
1445
1468
  return this.tracker.spaces.get();
1446
- case 2:
1447
- if (_context2.sent.has(spaceId)) {
1448
- _context2.next = 4;
1469
+ case 4:
1470
+ _context2.t0 = !_context2.sent.has(spaceId);
1471
+ case 5:
1472
+ if (!_context2.t0) {
1473
+ _context2.next = 7;
1449
1474
  break;
1450
1475
  }
1451
1476
  throw new Error("You are not in space ".concat(spaceId));
1452
- case 4:
1453
- _context2.next = 6;
1477
+ case 7:
1478
+ _context2.next = 9;
1454
1479
  return this.tracker.rooms.get();
1455
- case 6:
1480
+ case 9:
1456
1481
  roomIds = _context2.sent.findBy('spaceId', spaceId).items.map(function (room) {
1457
1482
  return room.id;
1458
1483
  });
1459
1484
  if (roomIds.length) {
1460
- _context2.next = 9;
1485
+ _context2.next = 12;
1461
1486
  break;
1462
1487
  }
1463
1488
  return _context2.abrupt("return");
1464
- case 9:
1489
+ case 12:
1465
1490
  resultPromise = this.tracker.client.send('GetFollowedTopics', {
1466
1491
  location: {
1467
1492
  spaceId: spaceId
@@ -1470,18 +1495,18 @@ var MessagesManager = /*#__PURE__*/function () {
1470
1495
  roomIds.forEach(function (roomId) {
1471
1496
  return _this2.followedTopicsPromises.register(resultPromise, roomId);
1472
1497
  });
1473
- _context2.next = 13;
1498
+ _context2.next = 16;
1474
1499
  return resultPromise;
1475
- case 13:
1500
+ case 16:
1476
1501
  result = _context2.sent;
1477
1502
  if (!result.error) {
1478
- _context2.next = 16;
1503
+ _context2.next = 19;
1479
1504
  break;
1480
1505
  }
1481
1506
  throw result.error;
1482
- case 16:
1507
+ case 19:
1483
1508
  this.setFollowedTopicsArray(roomIds, result.data.followedTopics);
1484
- case 17:
1509
+ case 20:
1485
1510
  case "end":
1486
1511
  return _context2.stop();
1487
1512
  }
@@ -4062,9 +4087,7 @@ var AbstractRestClient = /*#__PURE__*/function () {
4062
4087
  key: "send",
4063
4088
  value: function () {
4064
4089
  var _send = AbstractRestClient_asyncToGenerator( /*#__PURE__*/AbstractRestClient_regeneratorRuntime().mark(function _callee(method, uri) {
4065
- var _result$headers$get;
4066
4090
  var data,
4067
- headers,
4068
4091
  url,
4069
4092
  body,
4070
4093
  result,
@@ -4074,13 +4097,6 @@ var AbstractRestClient = /*#__PURE__*/function () {
4074
4097
  switch (_context.prev = _context.next) {
4075
4098
  case 0:
4076
4099
  data = _args.length > 2 && _args[2] !== undefined ? _args[2] : undefined;
4077
- headers = {
4078
- 'Content-Type': 'application/json',
4079
- Accept: 'application/json'
4080
- };
4081
- if (this.options.token) {
4082
- headers.Authorization = "Bearer ".concat(this.options.token);
4083
- }
4084
4100
  url = this.getUrl(uri);
4085
4101
  body = undefined;
4086
4102
  if (data) {
@@ -4090,39 +4106,16 @@ var AbstractRestClient = /*#__PURE__*/function () {
4090
4106
  body = JSON.stringify(data);
4091
4107
  }
4092
4108
  }
4093
- _context.next = 8;
4109
+ _context.next = 6;
4094
4110
  return fetch(url, {
4095
4111
  method: method,
4096
4112
  body: body,
4097
- headers: headers
4113
+ headers: this.getHeaders()
4098
4114
  });
4099
- case 8:
4115
+ case 6:
4100
4116
  result = _context.sent;
4101
- _context.t0 = result.ok;
4102
- _context.t1 = result.status;
4103
- if (!((_result$headers$get = result.headers.get('content-type')) !== null && _result$headers$get !== void 0 && _result$headers$get.includes('json'))) {
4104
- _context.next = 17;
4105
- break;
4106
- }
4107
- _context.next = 14;
4108
- return result.json();
4109
- case 14:
4110
- _context.t2 = _context.sent;
4111
- _context.next = 20;
4112
- break;
4113
- case 17:
4114
- _context.next = 19;
4115
- return result.text();
4116
- case 19:
4117
- _context.t2 = _context.sent;
4118
- case 20:
4119
- _context.t3 = _context.t2;
4120
- return _context.abrupt("return", {
4121
- ok: _context.t0,
4122
- status: _context.t1,
4123
- data: _context.t3
4124
- });
4125
- case 22:
4117
+ return _context.abrupt("return", this.convertFetchResponse(result));
4118
+ case 8:
4126
4119
  case "end":
4127
4120
  return _context.stop();
4128
4121
  }
@@ -4134,12 +4127,69 @@ var AbstractRestClient = /*#__PURE__*/function () {
4134
4127
  }
4135
4128
  return send;
4136
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
+ }
4137
4142
  }, {
4138
4143
  key: "getUrl",
4139
4144
  value: function getUrl(uri) {
4140
4145
  var _this$options$url;
4141
4146
  return this.removeEndingSlash((_this$options$url = this.options.url) !== null && _this$options$url !== void 0 ? _this$options$url : this.defaultUrl) + '/' + this.removeStartingSlash(uri);
4142
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
+ }()
4143
4193
  }, {
4144
4194
  key: "removeStartingSlash",
4145
4195
  value: function removeStartingSlash(text) {
@@ -4292,6 +4342,96 @@ var AuthClient = /*#__PURE__*/function (_AbstractRestClient) {
4292
4342
  }]);
4293
4343
  return AuthClient;
4294
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);
4295
4435
  ;// CONCATENATED MODULE: ./src/index.ts
4296
4436
 
4297
4437
 
@@ -4299,6 +4439,7 @@ var AuthClient = /*#__PURE__*/function (_AbstractRestClient) {
4299
4439
 
4300
4440
 
4301
4441
 
4442
+
4302
4443
  /******/ return __webpack_exports__;
4303
4444
  /******/ })()
4304
4445
  ;