· 6 years ago · Mar 27, 2020, 04:16 AM
1(function () {
2 function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
3 try {
4 var info = gen[key](arg);
5 var value = info.value;
6 } catch (error) {
7 reject(error);
8 return;
9 }
10
11 if (info.done) {
12 resolve(value);
13 } else {
14 Promise.resolve(value).then(_next, _throw);
15 }
16 }
17
18 function _asyncToGenerator(fn) {
19 return function () {
20 var self = this,
21 args = arguments;
22 return new Promise(function (resolve, reject) {
23 var gen = fn.apply(self, args);
24
25 function _next(value) {
26 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
27 }
28
29 function _throw(err) {
30 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
31 }
32
33 _next(undefined);
34 });
35 };
36 }
37
38 function _classCallCheck(instance, Constructor) {
39 if (!(instance instanceof Constructor)) {
40 throw new TypeError("Cannot call a class as a function");
41 }
42 }
43
44 function _defineProperties(target, props) {
45 for (var i = 0; i < props.length; i++) {
46 var descriptor = props[i];
47 descriptor.enumerable = descriptor.enumerable || false;
48 descriptor.configurable = true;
49 if ("value" in descriptor) descriptor.writable = true;
50 Object.defineProperty(target, descriptor.key, descriptor);
51 }
52 }
53
54 function _createClass(Constructor, protoProps, staticProps) {
55 if (protoProps) _defineProperties(Constructor.prototype, protoProps);
56 if (staticProps) _defineProperties(Constructor, staticProps);
57 return Constructor;
58 }
59
60 function _defineProperty(obj, key, value) {
61 if (key in obj) {
62 Object.defineProperty(obj, key, {
63 value: value,
64 enumerable: true,
65 configurable: true,
66 writable: true
67 });
68 } else {
69 obj[key] = value;
70 }
71
72 return obj;
73 }
74
75 function _inherits(subClass, superClass) {
76 if (typeof superClass !== "function" && superClass !== null) {
77 throw new TypeError("Super expression must either be null or a function");
78 }
79
80 subClass.prototype = Object.create(superClass && superClass.prototype, {
81 constructor: {
82 value: subClass,
83 writable: true,
84 configurable: true
85 }
86 });
87 if (superClass) _setPrototypeOf(subClass, superClass);
88 }
89
90 function _getPrototypeOf(o) {
91 _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
92 return o.__proto__ || Object.getPrototypeOf(o);
93 };
94 return _getPrototypeOf(o);
95 }
96
97 function _setPrototypeOf(o, p) {
98 _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
99 o.__proto__ = p;
100 return o;
101 };
102
103 return _setPrototypeOf(o, p);
104 }
105
106 function _assertThisInitialized(self) {
107 if (self === void 0) {
108 throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
109 }
110
111 return self;
112 }
113
114 function _possibleConstructorReturn(self, call) {
115 if (call && (typeof call === "object" || typeof call === "function")) {
116 return call;
117 }
118
119 return _assertThisInitialized(self);
120 }
121
122 function createCommonjsModule(fn, module) {
123 return module = { exports: {} }, fn(module, module.exports), module.exports;
124 }
125
126 var runtime = createCommonjsModule(function (module) {
127 /**
128 * Copyright (c) 2014-present, Facebook, Inc.
129 *
130 * This source code is licensed under the MIT license found in the
131 * LICENSE file in the root directory of this source tree.
132 */
133 !function (global) {
134
135 var Op = Object.prototype;
136 var hasOwn = Op.hasOwnProperty;
137 var undefined$1; // More compressible than void 0.
138
139 var $Symbol = typeof Symbol === "function" ? Symbol : {};
140 var iteratorSymbol = $Symbol.iterator || "@@iterator";
141 var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
142 var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
143 var runtime = global.regeneratorRuntime;
144
145 if (runtime) {
146 {
147 // If regeneratorRuntime is defined globally and we're in a module,
148 // make the exports object identical to regeneratorRuntime.
149 module.exports = runtime;
150 } // Don't bother evaluating the rest of this file if the runtime was
151 // already defined globally.
152
153
154 return;
155 } // Define the runtime globally (as expected by generated code) as either
156 // module.exports (if we're in a module) or a new, empty object.
157
158
159 runtime = global.regeneratorRuntime = module.exports ;
160
161 function wrap(innerFn, outerFn, self, tryLocsList) {
162 // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
163 var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
164 var generator = Object.create(protoGenerator.prototype);
165 var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next,
166 // .throw, and .return methods.
167
168 generator._invoke = makeInvokeMethod(innerFn, self, context);
169 return generator;
170 }
171
172 runtime.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion
173 // record like context.tryEntries[i].completion. This interface could
174 // have been (and was previously) designed to take a closure to be
175 // invoked without arguments, but in all the cases we care about we
176 // already have an existing method we want to call, so there's no need
177 // to create a new function object. We can even get away with assuming
178 // the method takes exactly one argument, since that happens to be true
179 // in every case, so we don't have to touch the arguments object. The
180 // only additional allocation required is the completion record, which
181 // has a stable shape and so hopefully should be cheap to allocate.
182
183 function tryCatch(fn, obj, arg) {
184 try {
185 return {
186 type: "normal",
187 arg: fn.call(obj, arg)
188 };
189 } catch (err) {
190 return {
191 type: "throw",
192 arg: err
193 };
194 }
195 }
196
197 var GenStateSuspendedStart = "suspendedStart";
198 var GenStateSuspendedYield = "suspendedYield";
199 var GenStateExecuting = "executing";
200 var GenStateCompleted = "completed"; // Returning this object from the innerFn has the same effect as
201 // breaking out of the dispatch switch statement.
202
203 var ContinueSentinel = {}; // Dummy constructor functions that we use as the .constructor and
204 // .constructor.prototype properties for functions that return Generator
205 // objects. For full spec compliance, you may wish to configure your
206 // minifier not to mangle the names of these two functions.
207
208 function Generator() {}
209
210 function GeneratorFunction() {}
211
212 function GeneratorFunctionPrototype() {} // This is a polyfill for %IteratorPrototype% for environments that
213 // don't natively support it.
214
215
216 var IteratorPrototype = {};
217
218 IteratorPrototype[iteratorSymbol] = function () {
219 return this;
220 };
221
222 var getProto = Object.getPrototypeOf;
223 var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
224
225 if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
226 // This environment has a native %IteratorPrototype%; use it instead
227 // of the polyfill.
228 IteratorPrototype = NativeIteratorPrototype;
229 }
230
231 var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
232 GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
233 GeneratorFunctionPrototype.constructor = GeneratorFunction;
234 GeneratorFunctionPrototype[toStringTagSymbol] = GeneratorFunction.displayName = "GeneratorFunction"; // Helper for defining the .next, .throw, and .return methods of the
235 // Iterator interface in terms of a single ._invoke method.
236
237 function defineIteratorMethods(prototype) {
238 ["next", "throw", "return"].forEach(function (method) {
239 prototype[method] = function (arg) {
240 return this._invoke(method, arg);
241 };
242 });
243 }
244
245 runtime.isGeneratorFunction = function (genFun) {
246 var ctor = typeof genFun === "function" && genFun.constructor;
247 return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can
248 // do is to check its .name property.
249 (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
250 };
251
252 runtime.mark = function (genFun) {
253 if (Object.setPrototypeOf) {
254 Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
255 } else {
256 genFun.__proto__ = GeneratorFunctionPrototype;
257
258 if (!(toStringTagSymbol in genFun)) {
259 genFun[toStringTagSymbol] = "GeneratorFunction";
260 }
261 }
262
263 genFun.prototype = Object.create(Gp);
264 return genFun;
265 }; // Within the body of any async function, `await x` is transformed to
266 // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
267 // `hasOwn.call(value, "__await")` to determine if the yielded value is
268 // meant to be awaited.
269
270
271 runtime.awrap = function (arg) {
272 return {
273 __await: arg
274 };
275 };
276
277 function AsyncIterator(generator) {
278 function invoke(method, arg, resolve, reject) {
279 var record = tryCatch(generator[method], generator, arg);
280
281 if (record.type === "throw") {
282 reject(record.arg);
283 } else {
284 var result = record.arg;
285 var value = result.value;
286
287 if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
288 return Promise.resolve(value.__await).then(function (value) {
289 invoke("next", value, resolve, reject);
290 }, function (err) {
291 invoke("throw", err, resolve, reject);
292 });
293 }
294
295 return Promise.resolve(value).then(function (unwrapped) {
296 // When a yielded Promise is resolved, its final value becomes
297 // the .value of the Promise<{value,done}> result for the
298 // current iteration. If the Promise is rejected, however, the
299 // result for this iteration will be rejected with the same
300 // reason. Note that rejections of yielded Promises are not
301 // thrown back into the generator function, as is the case
302 // when an awaited Promise is rejected. This difference in
303 // behavior between yield and await is important, because it
304 // allows the consumer to decide what to do with the yielded
305 // rejection (swallow it and continue, manually .throw it back
306 // into the generator, abandon iteration, whatever). With
307 // await, by contrast, there is no opportunity to examine the
308 // rejection reason outside the generator function, so the
309 // only option is to throw it from the await expression, and
310 // let the generator function handle the exception.
311 result.value = unwrapped;
312 resolve(result);
313 }, reject);
314 }
315 }
316
317 var previousPromise;
318
319 function enqueue(method, arg) {
320 function callInvokeWithMethodAndArg() {
321 return new Promise(function (resolve, reject) {
322 invoke(method, arg, resolve, reject);
323 });
324 }
325
326 return previousPromise = // If enqueue has been called before, then we want to wait until
327 // all previous Promises have been resolved before calling invoke,
328 // so that results are always delivered in the correct order. If
329 // enqueue has not been called before, then it is important to
330 // call invoke immediately, without waiting on a callback to fire,
331 // so that the async generator function has the opportunity to do
332 // any necessary setup in a predictable way. This predictability
333 // is why the Promise constructor synchronously invokes its
334 // executor callback, and why async functions synchronously
335 // execute code before the first await. Since we implement simple
336 // async functions in terms of async generators, it is especially
337 // important to get this right, even though it requires care.
338 previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later
339 // invocations of the iterator.
340 callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
341 } // Define the unified helper method that is used to implement .next,
342 // .throw, and .return (see defineIteratorMethods).
343
344
345 this._invoke = enqueue;
346 }
347
348 defineIteratorMethods(AsyncIterator.prototype);
349
350 AsyncIterator.prototype[asyncIteratorSymbol] = function () {
351 return this;
352 };
353
354 runtime.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of
355 // AsyncIterator objects; they just return a Promise for the value of
356 // the final result produced by the iterator.
357
358 runtime.async = function (innerFn, outerFn, self, tryLocsList) {
359 var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList));
360 return runtime.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
361 : iter.next().then(function (result) {
362 return result.done ? result.value : iter.next();
363 });
364 };
365
366 function makeInvokeMethod(innerFn, self, context) {
367 var state = GenStateSuspendedStart;
368 return function invoke(method, arg) {
369 if (state === GenStateExecuting) {
370 throw new Error("Generator is already running");
371 }
372
373 if (state === GenStateCompleted) {
374 if (method === "throw") {
375 throw arg;
376 } // Be forgiving, per 25.3.3.3.3 of the spec:
377 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
378
379
380 return doneResult();
381 }
382
383 context.method = method;
384 context.arg = arg;
385
386 while (true) {
387 var delegate = context.delegate;
388
389 if (delegate) {
390 var delegateResult = maybeInvokeDelegate(delegate, context);
391
392 if (delegateResult) {
393 if (delegateResult === ContinueSentinel) continue;
394 return delegateResult;
395 }
396 }
397
398 if (context.method === "next") {
399 // Setting context._sent for legacy support of Babel's
400 // function.sent implementation.
401 context.sent = context._sent = context.arg;
402 } else if (context.method === "throw") {
403 if (state === GenStateSuspendedStart) {
404 state = GenStateCompleted;
405 throw context.arg;
406 }
407
408 context.dispatchException(context.arg);
409 } else if (context.method === "return") {
410 context.abrupt("return", context.arg);
411 }
412
413 state = GenStateExecuting;
414 var record = tryCatch(innerFn, self, context);
415
416 if (record.type === "normal") {
417 // If an exception is thrown from innerFn, we leave state ===
418 // GenStateExecuting and loop back for another invocation.
419 state = context.done ? GenStateCompleted : GenStateSuspendedYield;
420
421 if (record.arg === ContinueSentinel) {
422 continue;
423 }
424
425 return {
426 value: record.arg,
427 done: context.done
428 };
429 } else if (record.type === "throw") {
430 state = GenStateCompleted; // Dispatch the exception by looping back around to the
431 // context.dispatchException(context.arg) call above.
432
433 context.method = "throw";
434 context.arg = record.arg;
435 }
436 }
437 };
438 } // Call delegate.iterator[context.method](context.arg) and handle the
439 // result, either by returning a { value, done } result from the
440 // delegate iterator, or by modifying context.method and context.arg,
441 // setting context.delegate to null, and returning the ContinueSentinel.
442
443
444 function maybeInvokeDelegate(delegate, context) {
445 var method = delegate.iterator[context.method];
446
447 if (method === undefined$1) {
448 // A .throw or .return when the delegate iterator has no .throw
449 // method always terminates the yield* loop.
450 context.delegate = null;
451
452 if (context.method === "throw") {
453 if (delegate.iterator.return) {
454 // If the delegate iterator has a return method, give it a
455 // chance to clean up.
456 context.method = "return";
457 context.arg = undefined$1;
458 maybeInvokeDelegate(delegate, context);
459
460 if (context.method === "throw") {
461 // If maybeInvokeDelegate(context) changed context.method from
462 // "return" to "throw", let that override the TypeError below.
463 return ContinueSentinel;
464 }
465 }
466
467 context.method = "throw";
468 context.arg = new TypeError("The iterator does not provide a 'throw' method");
469 }
470
471 return ContinueSentinel;
472 }
473
474 var record = tryCatch(method, delegate.iterator, context.arg);
475
476 if (record.type === "throw") {
477 context.method = "throw";
478 context.arg = record.arg;
479 context.delegate = null;
480 return ContinueSentinel;
481 }
482
483 var info = record.arg;
484
485 if (!info) {
486 context.method = "throw";
487 context.arg = new TypeError("iterator result is not an object");
488 context.delegate = null;
489 return ContinueSentinel;
490 }
491
492 if (info.done) {
493 // Assign the result of the finished delegate to the temporary
494 // variable specified by delegate.resultName (see delegateYield).
495 context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield).
496
497 context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the
498 // exception, let the outer generator proceed normally. If
499 // context.method was "next", forget context.arg since it has been
500 // "consumed" by the delegate iterator. If context.method was
501 // "return", allow the original .return call to continue in the
502 // outer generator.
503
504 if (context.method !== "return") {
505 context.method = "next";
506 context.arg = undefined$1;
507 }
508 } else {
509 // Re-yield the result returned by the delegate method.
510 return info;
511 } // The delegate iterator is finished, so forget it and continue with
512 // the outer generator.
513
514
515 context.delegate = null;
516 return ContinueSentinel;
517 } // Define Generator.prototype.{next,throw,return} in terms of the
518 // unified ._invoke helper method.
519
520
521 defineIteratorMethods(Gp);
522 Gp[toStringTagSymbol] = "Generator"; // A Generator should always return itself as the iterator object when the
523 // @@iterator function is called on it. Some browsers' implementations of the
524 // iterator prototype chain incorrectly implement this, causing the Generator
525 // object to not be returned from this call. This ensures that doesn't happen.
526 // See https://github.com/facebook/regenerator/issues/274 for more details.
527
528 Gp[iteratorSymbol] = function () {
529 return this;
530 };
531
532 Gp.toString = function () {
533 return "[object Generator]";
534 };
535
536 function pushTryEntry(locs) {
537 var entry = {
538 tryLoc: locs[0]
539 };
540
541 if (1 in locs) {
542 entry.catchLoc = locs[1];
543 }
544
545 if (2 in locs) {
546 entry.finallyLoc = locs[2];
547 entry.afterLoc = locs[3];
548 }
549
550 this.tryEntries.push(entry);
551 }
552
553 function resetTryEntry(entry) {
554 var record = entry.completion || {};
555 record.type = "normal";
556 delete record.arg;
557 entry.completion = record;
558 }
559
560 function Context(tryLocsList) {
561 // The root entry object (effectively a try statement without a catch
562 // or a finally block) gives us a place to store values thrown from
563 // locations where there is no enclosing try statement.
564 this.tryEntries = [{
565 tryLoc: "root"
566 }];
567 tryLocsList.forEach(pushTryEntry, this);
568 this.reset(true);
569 }
570
571 runtime.keys = function (object) {
572 var keys = [];
573
574 for (var key in object) {
575 keys.push(key);
576 }
577
578 keys.reverse(); // Rather than returning an object with a next method, we keep
579 // things simple and return the next function itself.
580
581 return function next() {
582 while (keys.length) {
583 var key = keys.pop();
584
585 if (key in object) {
586 next.value = key;
587 next.done = false;
588 return next;
589 }
590 } // To avoid creating an additional object, we just hang the .value
591 // and .done properties off the next function object itself. This
592 // also ensures that the minifier will not anonymize the function.
593
594
595 next.done = true;
596 return next;
597 };
598 };
599
600 function values(iterable) {
601 if (iterable) {
602 var iteratorMethod = iterable[iteratorSymbol];
603
604 if (iteratorMethod) {
605 return iteratorMethod.call(iterable);
606 }
607
608 if (typeof iterable.next === "function") {
609 return iterable;
610 }
611
612 if (!isNaN(iterable.length)) {
613 var i = -1,
614 next = function next() {
615 while (++i < iterable.length) {
616 if (hasOwn.call(iterable, i)) {
617 next.value = iterable[i];
618 next.done = false;
619 return next;
620 }
621 }
622
623 next.value = undefined$1;
624 next.done = true;
625 return next;
626 };
627
628 return next.next = next;
629 }
630 } // Return an iterator with no values.
631
632
633 return {
634 next: doneResult
635 };
636 }
637
638 runtime.values = values;
639
640 function doneResult() {
641 return {
642 value: undefined$1,
643 done: true
644 };
645 }
646
647 Context.prototype = {
648 constructor: Context,
649 reset: function (skipTempReset) {
650 this.prev = 0;
651 this.next = 0; // Resetting context._sent for legacy support of Babel's
652 // function.sent implementation.
653
654 this.sent = this._sent = undefined$1;
655 this.done = false;
656 this.delegate = null;
657 this.method = "next";
658 this.arg = undefined$1;
659 this.tryEntries.forEach(resetTryEntry);
660
661 if (!skipTempReset) {
662 for (var name in this) {
663 // Not sure about the optimal order of these conditions:
664 if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
665 this[name] = undefined$1;
666 }
667 }
668 }
669 },
670 stop: function () {
671 this.done = true;
672 var rootEntry = this.tryEntries[0];
673 var rootRecord = rootEntry.completion;
674
675 if (rootRecord.type === "throw") {
676 throw rootRecord.arg;
677 }
678
679 return this.rval;
680 },
681 dispatchException: function (exception) {
682 if (this.done) {
683 throw exception;
684 }
685
686 var context = this;
687
688 function handle(loc, caught) {
689 record.type = "throw";
690 record.arg = exception;
691 context.next = loc;
692
693 if (caught) {
694 // If the dispatched exception was caught by a catch block,
695 // then let that catch block handle the exception normally.
696 context.method = "next";
697 context.arg = undefined$1;
698 }
699
700 return !!caught;
701 }
702
703 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
704 var entry = this.tryEntries[i];
705 var record = entry.completion;
706
707 if (entry.tryLoc === "root") {
708 // Exception thrown outside of any try block that could handle
709 // it, so set the completion value of the entire function to
710 // throw the exception.
711 return handle("end");
712 }
713
714 if (entry.tryLoc <= this.prev) {
715 var hasCatch = hasOwn.call(entry, "catchLoc");
716 var hasFinally = hasOwn.call(entry, "finallyLoc");
717
718 if (hasCatch && hasFinally) {
719 if (this.prev < entry.catchLoc) {
720 return handle(entry.catchLoc, true);
721 } else if (this.prev < entry.finallyLoc) {
722 return handle(entry.finallyLoc);
723 }
724 } else if (hasCatch) {
725 if (this.prev < entry.catchLoc) {
726 return handle(entry.catchLoc, true);
727 }
728 } else if (hasFinally) {
729 if (this.prev < entry.finallyLoc) {
730 return handle(entry.finallyLoc);
731 }
732 } else {
733 throw new Error("try statement without catch or finally");
734 }
735 }
736 }
737 },
738 abrupt: function (type, arg) {
739 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
740 var entry = this.tryEntries[i];
741
742 if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
743 var finallyEntry = entry;
744 break;
745 }
746 }
747
748 if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
749 // Ignore the finally entry if control is not jumping to a
750 // location outside the try/catch block.
751 finallyEntry = null;
752 }
753
754 var record = finallyEntry ? finallyEntry.completion : {};
755 record.type = type;
756 record.arg = arg;
757
758 if (finallyEntry) {
759 this.method = "next";
760 this.next = finallyEntry.finallyLoc;
761 return ContinueSentinel;
762 }
763
764 return this.complete(record);
765 },
766 complete: function (record, afterLoc) {
767 if (record.type === "throw") {
768 throw record.arg;
769 }
770
771 if (record.type === "break" || record.type === "continue") {
772 this.next = record.arg;
773 } else if (record.type === "return") {
774 this.rval = this.arg = record.arg;
775 this.method = "return";
776 this.next = "end";
777 } else if (record.type === "normal" && afterLoc) {
778 this.next = afterLoc;
779 }
780
781 return ContinueSentinel;
782 },
783 finish: function (finallyLoc) {
784 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
785 var entry = this.tryEntries[i];
786
787 if (entry.finallyLoc === finallyLoc) {
788 this.complete(entry.completion, entry.afterLoc);
789 resetTryEntry(entry);
790 return ContinueSentinel;
791 }
792 }
793 },
794 "catch": function (tryLoc) {
795 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
796 var entry = this.tryEntries[i];
797
798 if (entry.tryLoc === tryLoc) {
799 var record = entry.completion;
800
801 if (record.type === "throw") {
802 var thrown = record.arg;
803 resetTryEntry(entry);
804 }
805
806 return thrown;
807 }
808 } // The context.catch method must only be called with a location
809 // argument that corresponds to a known catch block.
810
811
812 throw new Error("illegal catch attempt");
813 },
814 delegateYield: function (iterable, resultName, nextLoc) {
815 this.delegate = {
816 iterator: values(iterable),
817 resultName: resultName,
818 nextLoc: nextLoc
819 };
820
821 if (this.method === "next") {
822 // Deliberately forget the last sent value so that we don't
823 // accidentally pass it on to the delegate.
824 this.arg = undefined$1;
825 }
826
827 return ContinueSentinel;
828 }
829 };
830 }( // In sloppy mode, unbound `this` refers to the global object, fallback to
831 // Function constructor if we're in global strict mode. That is sadly a form
832 // of indirect eval which violates Content Security Policy.
833 function () {
834 return this;
835 }() || Function("return this")());
836 });
837
838 var LHBaseClass =
839 /*#__PURE__*/
840 function () {
841 function LHBaseClass(params) {
842 _classCallCheck(this, LHBaseClass);
843 }
844
845 _createClass(LHBaseClass, [{
846 key: "getParam",
847 value: function getParam(params, strKey, defaultValue) {
848 params = params || {};
849
850 if (strKey in params) {
851 return params[strKey];
852 } else if (defaultValue === undefined) {
853 this.throwException(strKey + " is a required parameter", "Parameters Error");
854 } else {
855 return defaultValue;
856 }
857 }
858 }, {
859 key: "throwException",
860 value: function throwException(message) {
861 var title = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "Error";
862 throw new Error(this.constructor.name + " -- " + title + ": " + message);
863 }
864 }]);
865
866 return LHBaseClass;
867 }();
868
869 var LHBaseClass_1 = LHBaseClass;
870
871 var LHDelegate =
872 /*#__PURE__*/
873 function (_LHBaseClass) {
874 _inherits(LHDelegate, _LHBaseClass);
875
876 function LHDelegate(params) {
877 var _this;
878
879 _classCallCheck(this, LHDelegate);
880
881 _this = _possibleConstructorReturn(this, _getPrototypeOf(LHDelegate).call(this, params));
882 _this.delegate = _this.getParam(params, "delegate", null);
883 _this.delegateTypes = [];
884 return _this;
885 }
886
887 _createClass(LHDelegate, [{
888 key: "notify",
889 value: function () {
890 var _notify = _asyncToGenerator(
891 /*#__PURE__*/
892 regeneratorRuntime.mark(function _callee(delegateString) {
893 var object,
894 _args = arguments;
895 return regeneratorRuntime.wrap(function _callee$(_context) {
896 while (1) {
897 switch (_context.prev = _context.next) {
898 case 0:
899 object = _args.length > 1 && _args[1] !== undefined ? _args[1] : null;
900
901 if (!this.delegateTypes.includes(delegateString)) {
902 this.throwException("delegateString:" + delegateString + " is not defined in delegateTypes");
903 }
904
905 if (this.delegate) {
906 this.delegate.receive(this, delegateString, object);
907 }
908
909 case 3:
910 case "end":
911 return _context.stop();
912 }
913 }
914 }, _callee, this);
915 }));
916
917 function notify(_x) {
918 return _notify.apply(this, arguments);
919 }
920
921 return notify;
922 }()
923 }, {
924 key: "receive",
925 value: function () {
926 var _receive = _asyncToGenerator(
927 /*#__PURE__*/
928 regeneratorRuntime.mark(function _callee2(notifier, delegateString) {
929 return regeneratorRuntime.wrap(function _callee2$(_context2) {
930 while (1) {
931 switch (_context2.prev = _context2.next) {
932 case 0:
933
934 case 1:
935 case "end":
936 return _context2.stop();
937 }
938 }
939 }, _callee2);
940 }));
941
942 function receive(_x2, _x3) {
943 return _receive.apply(this, arguments);
944 }
945
946 return receive;
947 }()
948 }]);
949
950 return LHDelegate;
951 }(LHBaseClass_1);
952
953 var LHDelegate_1 = LHDelegate;
954
955 var K2Base =
956 /*#__PURE__*/
957 function (_LHDelegate) {
958 _inherits(K2Base, _LHDelegate);
959
960 function K2Base(params) {
961 var _this;
962
963 _classCallCheck(this, K2Base);
964
965 _this = _possibleConstructorReturn(this, _getPrototypeOf(K2Base).call(this, params));
966 _this.types = {
967 STRING: "string",
968 LIST: "list",
969 BOOL: "boolean",
970 DATE: "dateTime"
971 };
972 return _this;
973 }
974
975 return K2Base;
976 }(LHDelegate_1);
977
978 var K2Base_1 = K2Base;
979
980 var K2BaseIntegration =
981 /*#__PURE__*/
982 function (_K2Base) {
983 _inherits(K2BaseIntegration, _K2Base);
984
985 function K2BaseIntegration(params) {
986 var _this;
987
988 _classCallCheck(this, K2BaseIntegration);
989
990 _this = _possibleConstructorReturn(this, _getPrototypeOf(K2BaseIntegration).call(this, params));
991 _this.metaData = {
992 systemName: null,
993 displayName: null,
994 description: null
995 };
996 _this.smartObjects = [];
997 return _this;
998 }
999
1000 _createClass(K2BaseIntegration, [{
1001 key: "getSmartObject",
1002 value: function getSmartObject(name) {
1003 var _iteratorNormalCompletion = true;
1004 var _didIteratorError = false;
1005 var _iteratorError = undefined;
1006
1007 try {
1008 for (var _iterator = this.smartObjects[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
1009 var obj = _step.value;
1010
1011 if (obj.name === name) {
1012 return obj;
1013 }
1014 }
1015 } catch (err) {
1016 _didIteratorError = true;
1017 _iteratorError = err;
1018 } finally {
1019 try {
1020 if (!_iteratorNormalCompletion && _iterator["return"] != null) {
1021 _iterator["return"]();
1022 }
1023 } finally {
1024 if (_didIteratorError) {
1025 throw _iteratorError;
1026 }
1027 }
1028 }
1029
1030 this.throwException("Smart Object does not exist!");
1031 }
1032 }, {
1033 key: "getMetaData",
1034 value: function getMetaData() {
1035 return this.metaData;
1036 }
1037 }, {
1038 key: "getSchemas",
1039 value: function getSchemas() {
1040 var returnSchema = {};
1041 var _iteratorNormalCompletion2 = true;
1042 var _didIteratorError2 = false;
1043 var _iteratorError2 = undefined;
1044
1045 try {
1046 for (var _iterator2 = this.smartObjects[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
1047 var obj = _step2.value;
1048 returnSchema[obj.name] = obj.getSchema();
1049 }
1050 } catch (err) {
1051 _didIteratorError2 = true;
1052 _iteratorError2 = err;
1053 } finally {
1054 try {
1055 if (!_iteratorNormalCompletion2 && _iterator2["return"] != null) {
1056 _iterator2["return"]();
1057 }
1058 } finally {
1059 if (_didIteratorError2) {
1060 throw _iteratorError2;
1061 }
1062 }
1063 }
1064
1065 return returnSchema;
1066 }
1067 }, {
1068 key: "execute",
1069 value: function execute(objectName, methodName, parameters, properties) {
1070 var obj = this.getSmartObject(objectName);
1071 return obj[methodName](parameters, properties);
1072 }
1073 }]);
1074
1075 return K2BaseIntegration;
1076 }(K2Base_1);
1077
1078 var K2BaseIntegration_1 = K2BaseIntegration;
1079
1080 var K2BaseSmartObject =
1081 /*#__PURE__*/
1082 function (_K2Base) {
1083 _inherits(K2BaseSmartObject, _K2Base);
1084
1085 function K2BaseSmartObject(params) {
1086 var _this;
1087
1088 _classCallCheck(this, K2BaseSmartObject);
1089
1090 _this = _possibleConstructorReturn(this, _getPrototypeOf(K2BaseSmartObject).call(this, params));
1091 _this.name = "K2BaseSmartObject";
1092 _this.displayName = "K2 BaseSmart Object";
1093 _this.description = "K2 BaseSmart Object";
1094 _this.api = _this.getParam(params, "api");
1095 _this.props = {};
1096 return _this;
1097 }
1098
1099 _createClass(K2BaseSmartObject, [{
1100 key: "getProperties",
1101 value: function getProperties() {
1102 return {};
1103 }
1104 }, {
1105 key: "getSchema",
1106 value: function getSchema() {
1107 return {
1108 displayName: this.displayName,
1109 description: this.description,
1110 properties: this.getProperties()
1111 };
1112 }
1113 }]);
1114
1115 return K2BaseSmartObject;
1116 }(K2Base_1);
1117
1118 var K2BaseSmartObject_1 = K2BaseSmartObject;
1119
1120 var baseUriEndpoint = "https://graph.microsoft.com/v1.0";
1121
1122 var Apps =
1123 /*#__PURE__*/
1124 function (_K2BaseSmartObject) {
1125 _inherits(Apps, _K2BaseSmartObject);
1126
1127 function Apps(params) {
1128 var _this;
1129
1130 _classCallCheck(this, Apps);
1131
1132 _this = _possibleConstructorReturn(this, _getPrototypeOf(Apps).call(this, params));
1133 _this.name = "apps";
1134 _this.displayName = "Apps";
1135 _this.description = "Apps";
1136 _this.props = {
1137 id: "id",
1138 teamId: "teamId",
1139 displayName: "displayName",
1140 version: "version",
1141 teamAppDefinitionId: "teamAppDefinitionId",
1142 teamsAppId: "teamsAppId"
1143 };
1144 _this.methods = {
1145 list: "list"
1146 };
1147 return _this;
1148 }
1149
1150 _createClass(Apps, [{
1151 key: "getProperties",
1152 value: function getProperties() {
1153 var _ref;
1154
1155 return _ref = {}, _defineProperty(_ref, this.props.id, {
1156 displayName: "App Id",
1157 description: "App Id",
1158 type: "string"
1159 }), _defineProperty(_ref, this.props.teamId, {
1160 displayName: "Team Id",
1161 description: "Team Id",
1162 type: "string"
1163 }), _defineProperty(_ref, this.props.displayName, {
1164 displayName: "App Display Name",
1165 description: "App Display Name",
1166 type: "string"
1167 }), _defineProperty(_ref, this.props.version, {
1168 displayName: "version",
1169 description: "version",
1170 type: "string"
1171 }), _defineProperty(_ref, this.props.teamAppDefinitionId, {
1172 displayName: "Teams Apps Definition Id",
1173 description: "Teams Apps Definition Id",
1174 type: "string"
1175 }), _defineProperty(_ref, this.props.teamsAppId, {
1176 displayName: "Teams Apps Id",
1177 description: "Teams Apps Id",
1178 type: "string"
1179 }), _ref;
1180 }
1181 }, {
1182 key: "getMethods",
1183 value: function getMethods() {
1184 return _defineProperty({}, this.methods.list, {
1185 displayName: "List Installed apps",
1186 type: this.types.LIST,
1187 inputs: [this.props.id],
1188 requiredInputs: [this.props.id],
1189 outputs: [this.props.id, this.props.displayName, this.props.version, this.props.teamAppDefinitionId, this.props.teamsAppId]
1190 });
1191 }
1192 }, {
1193 key: "list",
1194 value: function list(params, properties) {
1195 var id = this.getParam(params, this.props.id);
1196 var url = baseUriEndpoint + "/teams/" + properties[this.props.teamId] + "/installedApps?$expand=teamsAppDefinition";
1197 var response = fetch(url, {
1198 method: 'GET',
1199 credentials: 'include'
1200 }).then(json).then(function (data) {
1201 var _this2 = this;
1202
1203 postResult(data.value.map(function (x) {
1204 var _ref3;
1205
1206 return _ref3 = {}, _defineProperty(_ref3, _this2.props.id, x.id), _defineProperty(_ref3, _this2.props.displayName, x.teamsAppDefinition.displayName), _defineProperty(_ref3, _this2.props.displayName, x.teamsAppDefinition.displayName), _defineProperty(_ref3, _this2.props.version, x.teamsAppDefinition.version), _defineProperty(_ref3, _this2.props.teamAppDefinitionId, x.teamsAppDefinition.id), _defineProperty(_ref3, _this2.props.teamAppDefinitionId, x.teamsAppDefinition.teamsAppId), _ref3;
1207 }));
1208 })["catch"](function (error) {
1209 console.log('Request failed', error);
1210 }); // let data = await response.json();
1211 }
1212 }]);
1213
1214 return Apps;
1215 }(K2BaseSmartObject_1);
1216
1217 var Apps_1 = Apps;
1218
1219 var MicrosoftTeamsApi =
1220 /*#__PURE__*/
1221 function (_LHDelegate) {
1222 _inherits(MicrosoftTeamsApi, _LHDelegate);
1223
1224 function MicrosoftTeamsApi(params) {
1225 _classCallCheck(this, MicrosoftTeamsApi);
1226
1227 return _possibleConstructorReturn(this, _getPrototypeOf(MicrosoftTeamsApi).call(this, params));
1228 }
1229
1230 _createClass(MicrosoftTeamsApi, [{
1231 key: "_get",
1232 value: function () {
1233 var _get2 = _asyncToGenerator(
1234 /*#__PURE__*/
1235 regeneratorRuntime.mark(function _callee(apiURLEnding, data) {
1236 var url, response;
1237 return regeneratorRuntime.wrap(function _callee$(_context) {
1238 while (1) {
1239 switch (_context.prev = _context.next) {
1240 case 0:
1241 url = this.baseURL + apiURLEnding + '?';
1242 _context.next = 3;
1243 return fetch(urlString, {
1244 method: 'get'
1245 });
1246
1247 case 3:
1248 response = _context.sent;
1249 return _context.abrupt("return", response);
1250
1251 case 5:
1252 case "end":
1253 return _context.stop();
1254 }
1255 }
1256 }, _callee, this);
1257 }));
1258
1259 function _get(_x, _x2) {
1260 return _get2.apply(this, arguments);
1261 }
1262
1263 return _get;
1264 }()
1265 }, {
1266 key: "getInstalledAppsList",
1267 value: function () {
1268 var _getInstalledAppsList = _asyncToGenerator(
1269 /*#__PURE__*/
1270 regeneratorRuntime.mark(function _callee2(id) {
1271 var url;
1272 return regeneratorRuntime.wrap(function _callee2$(_context2) {
1273 while (1) {
1274 switch (_context2.prev = _context2.next) {
1275 case 0:
1276 url = this.baseUri + "/teams/" + id + "/installedApps?$expand=teamsAppDefinition";
1277 _context2.next = 3;
1278 return this._get(url, {});
1279
1280 case 3:
1281 return _context2.abrupt("return", _context2.sent);
1282
1283 case 4:
1284 case "end":
1285 return _context2.stop();
1286 }
1287 }
1288 }, _callee2, this);
1289 }));
1290
1291 function getInstalledAppsList(_x3) {
1292 return _getInstalledAppsList.apply(this, arguments);
1293 }
1294
1295 return getInstalledAppsList;
1296 }()
1297 }]);
1298
1299 return MicrosoftTeamsApi;
1300 }(LHDelegate_1);
1301
1302 var MicrosoftTeamsApi_1 = MicrosoftTeamsApi;
1303
1304 var Integration =
1305 /*#__PURE__*/
1306 function (_K2BaseIntegration) {
1307 _inherits(Integration, _K2BaseIntegration);
1308
1309 function Integration(params) {
1310 var _this;
1311
1312 _classCallCheck(this, Integration);
1313
1314 _this = _possibleConstructorReturn(this, _getPrototypeOf(Integration).call(this, params));
1315 _this.metaData = {
1316 systemName: "MicrosoftTeamsIntegration",
1317 displayName: "Microsoft Teams Integration",
1318 description: "a simplified example version to build others off of"
1319 };
1320 _this.api = new MicrosoftTeamsApi_1();
1321 var soParams = {
1322 api: _this.api
1323 };
1324 _this.smartObjects = [new Apps_1(soParams)];
1325 return _this;
1326 }
1327
1328 _createClass(Integration, [{
1329 key: "getMetaData",
1330 value: function getMetaData() {
1331 return this.metaData;
1332 }
1333 }]);
1334
1335 return Integration;
1336 }(K2BaseIntegration_1);
1337
1338 var Integration_1 = Integration;
1339
1340 var integration = new Integration_1();
1341 metadata = integration.getMetaData();
1342
1343 ondescribe = function ondescribe() {
1344 postSchema(integration.getSchemas());
1345 };
1346
1347 onexecute = function onexecute(objectName, methodName, parameters, properties) {
1348 return integration.execute(objectName, methodName, parameters, properties);
1349 };
1350
1351}());
1352//# sourceMappingURL=index.js.map