@monterosa/sdk-interact-kit 0.18.9 → 0.18.10-local-only-storage.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +86 -26
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm2017.js +86 -26
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +87 -27
- package/dist/index.esm5.js.map +1 -1
- package/dist/sdk-interact-kit.d.ts +1372 -0
- package/dist/src/core/connection_health/index.d.ts +7 -1
- package/dist/src/core/connection_health/public-types.d.ts +1 -1
- package/dist/src/core/element/api.d.ts +28 -7
- package/dist/src/core/element/public-types.d.ts +24 -13
- package/dist/src/core/event/api.d.ts +20 -3
- package/dist/src/core/event/public-types.d.ts +18 -14
- package/dist/src/core/project/api.d.ts +13 -5
- package/dist/src/core/project/public-types.d.ts +8 -6
- package/dist/src/index.d.ts +5 -5
- package/dist/src/tsdoc-metadata.json +11 -0
- package/package.json +7 -7
package/dist/index.cjs.js
CHANGED
|
@@ -413,7 +413,7 @@ exports.ConnectionHealthState = void 0;
|
|
|
413
413
|
ConnectionHealthState["Ok"] = "ok";
|
|
414
414
|
/**
|
|
415
415
|
* The client is either trying to establish a connection but failing, or
|
|
416
|
-
* the client has been
|
|
416
|
+
* the client has been explicitly {@link @monterosa/sdk-connect-kit#disconnect() | disconnected}
|
|
417
417
|
*/
|
|
418
418
|
ConnectionHealthState["Error"] = "error";
|
|
419
419
|
})(exports.ConnectionHealthState || (exports.ConnectionHealthState = {}));
|
|
@@ -486,6 +486,9 @@ var getConnectionHealthMemoized = sdkUtil.memoizePromise(function (sdk) { return
|
|
|
486
486
|
}); }, function (sdk) { return sdk.options.host; });
|
|
487
487
|
/**
|
|
488
488
|
* Returns {@link ConnectionHealth | connection health} instance
|
|
489
|
+
*
|
|
490
|
+
* @param sdk - The SDK instance to monitor
|
|
491
|
+
* @returns The connection health instance.
|
|
489
492
|
*/
|
|
490
493
|
function getConnectionHealth(sdk) {
|
|
491
494
|
if (sdk === void 0) { sdk = sdkCore.getSdk(); }
|
|
@@ -493,7 +496,10 @@ function getConnectionHealth(sdk) {
|
|
|
493
496
|
}
|
|
494
497
|
/**
|
|
495
498
|
* Adds an observer for when
|
|
496
|
-
* {@link ConnectionHealth
|
|
499
|
+
* {@link ConnectionHealth | connection health state} changed
|
|
500
|
+
*
|
|
501
|
+
* @param connectionHealth - The instance to observe
|
|
502
|
+
* @param callback - Called with the new state
|
|
497
503
|
*/
|
|
498
504
|
function onConnectionHealthState(connectionHealth, callback) {
|
|
499
505
|
return sdkUtil.subscribe(connectionHealth, 'state', callback);
|
|
@@ -987,15 +993,22 @@ var getProjectMemoized = sdkUtil.memoizePromise(function (sdk) { return __awaite
|
|
|
987
993
|
}); }, function (sdk) { return sdk.options.projectId; });
|
|
988
994
|
/**
|
|
989
995
|
* Returns {@link InteractProject | project instance} associated
|
|
990
|
-
* with the
|
|
996
|
+
* with the
|
|
997
|
+
* {@link @monterosa/sdk-core#MonterosaSdk | configured sdk}
|
|
998
|
+
*
|
|
999
|
+
* @param sdk - The SDK instance. Defaults to the default SDK.
|
|
1000
|
+
* @returns The project instance.
|
|
991
1001
|
*/
|
|
992
1002
|
function getProject(sdk) {
|
|
993
1003
|
if (sdk === void 0) { sdk = sdkCore.getSdk(); }
|
|
994
1004
|
return getProjectMemoized(sdk);
|
|
995
1005
|
}
|
|
996
1006
|
/**
|
|
997
|
-
* Adds an observer for when
|
|
998
|
-
* are updated
|
|
1007
|
+
* Adds an observer for when
|
|
1008
|
+
* {@link InteractProject | project fields} are updated
|
|
1009
|
+
*
|
|
1010
|
+
* @param project - The project to observe
|
|
1011
|
+
* @param callback - Called when project fields change
|
|
999
1012
|
*/
|
|
1000
1013
|
function onProjectFieldsUpdated(project, callback) {
|
|
1001
1014
|
return sdkUtil.subscribe(project, 'updated', callback);
|
|
@@ -1003,8 +1016,9 @@ function onProjectFieldsUpdated(project, callback) {
|
|
|
1003
1016
|
/**
|
|
1004
1017
|
* Adds an observer that is called when the project listings are updated.
|
|
1005
1018
|
*
|
|
1006
|
-
* @deprecated Use {@link onEventAdded
|
|
1007
|
-
* {@link
|
|
1019
|
+
* @deprecated Use {@link onEventAdded},
|
|
1020
|
+
* {@link onEventUpdated} and
|
|
1021
|
+
* {@link onEventRemoved} instead
|
|
1008
1022
|
*/
|
|
1009
1023
|
function onProjectListingsUpdated(project, callback) {
|
|
1010
1024
|
console.warn('onProjectListingsUpdated() is deprecated. Please use onEventAdded(), onEventUpdated() and onEventRemoved() instead');
|
|
@@ -1057,14 +1071,14 @@ function fetchHistory(host, id) {
|
|
|
1057
1071
|
exports.EventState = void 0;
|
|
1058
1072
|
(function (EventState) {
|
|
1059
1073
|
/**
|
|
1060
|
-
* The event is in the `upcoming` state when its {@link InteractEvent
|
|
1061
|
-
* less than the {@link now | current time}.
|
|
1074
|
+
* The event is in the `upcoming` state when its {@link InteractEvent | startAt}
|
|
1075
|
+
* less than the {@link @monterosa/sdk-util#now | current time}.
|
|
1062
1076
|
*/
|
|
1063
1077
|
EventState["Upcoming"] = "upcoming";
|
|
1064
1078
|
/**
|
|
1065
|
-
* The event is in the `active` state when its {@link InteractEvent
|
|
1066
|
-
* equal or more than the {@link now | current time} and less than the
|
|
1067
|
-
* {@link InteractEvent
|
|
1079
|
+
* The event is in the `active` state when its {@link InteractEvent | startAt}
|
|
1080
|
+
* equal or more than the {@link @monterosa/sdk-util#now | current time} and less than the
|
|
1081
|
+
* {@link InteractEvent | endAt}.
|
|
1068
1082
|
*/
|
|
1069
1083
|
EventState["Active"] = "active";
|
|
1070
1084
|
/**
|
|
@@ -1072,8 +1086,8 @@ exports.EventState = void 0;
|
|
|
1072
1086
|
*/
|
|
1073
1087
|
EventState["Prolonged"] = "prolonged";
|
|
1074
1088
|
/**
|
|
1075
|
-
* The event is in the `finished` state when its {@link InteractEvent
|
|
1076
|
-
* equal or more than the {@link now | current time}.
|
|
1089
|
+
* The event is in the `finished` state when its {@link InteractEvent | endAt}
|
|
1090
|
+
* equal or more than the {@link @monterosa/sdk-util#now | current time}.
|
|
1077
1091
|
*/
|
|
1078
1092
|
EventState["Finished"] = "finished";
|
|
1079
1093
|
})(exports.EventState || (exports.EventState = {}));
|
|
@@ -1484,7 +1498,7 @@ var getEventsMemoized = sdkUtil.memoizePromise(function (project) { return __awa
|
|
|
1484
1498
|
// Calling builder function that creates an event instance.
|
|
1485
1499
|
// Existing event will be returned if it already exists in the cache
|
|
1486
1500
|
.map(function (data) { return buildEvent(data, context); })
|
|
1487
|
-
// Sort events so the
|
|
1501
|
+
// Sort events so the oldest event is first, and the most recent is last
|
|
1488
1502
|
.sort(function (a, b) { return a.startAt - b.startAt; }))];
|
|
1489
1503
|
}
|
|
1490
1504
|
});
|
|
@@ -1523,6 +1537,7 @@ function (project) {
|
|
|
1523
1537
|
*
|
|
1524
1538
|
* @param project - A project instance. If not provided,
|
|
1525
1539
|
* the one from the default sdk will be fetched.
|
|
1540
|
+
* @returns A promise that resolves to an array of events.
|
|
1526
1541
|
*/
|
|
1527
1542
|
function getEvents(project) {
|
|
1528
1543
|
return getEventsMemoized(project);
|
|
@@ -1577,20 +1592,27 @@ var getEventMemoized = sdkUtil.memoizePromise(function (id, project) { return __
|
|
|
1577
1592
|
* @param project - A project instance. If not provided,
|
|
1578
1593
|
* the one from the default sdk will be fetched.
|
|
1579
1594
|
*
|
|
1580
|
-
* @returns
|
|
1581
|
-
* event exists in the project.
|
|
1595
|
+
* @returns The event associated with the provided id,
|
|
1596
|
+
* or null if no such event exists in the project.
|
|
1582
1597
|
*/
|
|
1583
1598
|
function getEvent(id, project) {
|
|
1584
1599
|
return getEventMemoized(id, project);
|
|
1585
1600
|
}
|
|
1586
1601
|
/**
|
|
1587
|
-
* Adds an observer for when
|
|
1602
|
+
* Adds an observer for when
|
|
1603
|
+
* {@link InteractEvent | event state} changed
|
|
1604
|
+
*
|
|
1605
|
+
* @param event - The event to observe
|
|
1606
|
+
* @param callback - Called with the new state
|
|
1588
1607
|
*/
|
|
1589
1608
|
function onEventState(event, callback) {
|
|
1590
1609
|
return sdkUtil.subscribe(event, 'state', callback);
|
|
1591
1610
|
}
|
|
1592
1611
|
/**
|
|
1593
1612
|
* Adds an observer for when event's data changed
|
|
1613
|
+
*
|
|
1614
|
+
* @param event - The event to observe
|
|
1615
|
+
* @param callback - Called when the event data changes
|
|
1594
1616
|
*/
|
|
1595
1617
|
function onEventUpdated(event, callback) {
|
|
1596
1618
|
return sdkUtil.subscribe(event, 'updated', callback);
|
|
@@ -1609,6 +1631,9 @@ function onEventUpdated(event, callback) {
|
|
|
1609
1631
|
* - When a future event starts, a new future event may be added to the list,
|
|
1610
1632
|
* depending on the project configuration, to ensure a minimum number of
|
|
1611
1633
|
* upcoming events are always available.
|
|
1634
|
+
*
|
|
1635
|
+
* @param project - The project to observe
|
|
1636
|
+
* @param callback - Called with the added event
|
|
1612
1637
|
*/
|
|
1613
1638
|
function onEventAdded(project, callback) {
|
|
1614
1639
|
var _this = this;
|
|
@@ -1659,6 +1684,9 @@ function onEventAdded(project, callback) {
|
|
|
1659
1684
|
* {@link onEventAdded} alias.
|
|
1660
1685
|
*
|
|
1661
1686
|
* @deprecated Use the new {@link onEventAdded} function instead.
|
|
1687
|
+
*
|
|
1688
|
+
* @param project - The project to observe
|
|
1689
|
+
* @param callback - Called with the added event
|
|
1662
1690
|
*/
|
|
1663
1691
|
function onEventPublished(project, callback) {
|
|
1664
1692
|
console.warn('onEventPublished() is deprecated. Please use onEventAdded() instead');
|
|
@@ -1678,6 +1706,9 @@ function onEventPublished(project, callback) {
|
|
|
1678
1706
|
* - The event is removed after a period of time since its completion. This period
|
|
1679
1707
|
* is calculated as 45 seconds plus the Maximum allowed delay (configured in
|
|
1680
1708
|
* Project Settings in Studio).
|
|
1709
|
+
*
|
|
1710
|
+
* @param project - The project to observe
|
|
1711
|
+
* @param callback - Called with the removed event
|
|
1681
1712
|
*/
|
|
1682
1713
|
function onEventRemoved(project, callback) {
|
|
1683
1714
|
var _this = this;
|
|
@@ -1742,13 +1773,21 @@ var _a;
|
|
|
1742
1773
|
*/
|
|
1743
1774
|
exports.AnswerError = void 0;
|
|
1744
1775
|
(function (AnswerError) {
|
|
1776
|
+
/** Selected option index is out of range. */
|
|
1745
1777
|
AnswerError["OptionIndexOutOfRange"] = "out_of_range";
|
|
1778
|
+
/** Fewer options selected than the minimum required. */
|
|
1746
1779
|
AnswerError["BelowMinVoteOptions"] = "below_min_vote_options";
|
|
1780
|
+
/** More options selected than the maximum allowed. */
|
|
1747
1781
|
AnswerError["AboveMaxVoteOptions"] = "above_max_vote_options";
|
|
1782
|
+
/** User has exceeded the maximum votes allowed. */
|
|
1748
1783
|
AnswerError["AboveMaxVotesPerUser"] = "above_max_per_user";
|
|
1784
|
+
/** A single option received more votes than allowed. */
|
|
1749
1785
|
AnswerError["AboveMaxVotesPerOption"] = "above_max_per_option";
|
|
1786
|
+
/** Attempted to vote on a non-interactive element. */
|
|
1750
1787
|
AnswerError["VotedOnNonInteractiveElement"] = "non_interactive_element";
|
|
1788
|
+
/** Attempted to vote on a closed element. */
|
|
1751
1789
|
AnswerError["VotedOnClosedElement"] = "closed_element";
|
|
1790
|
+
/** No vote value was provided. */
|
|
1752
1791
|
AnswerError["EmptyVote"] = "empty_vote";
|
|
1753
1792
|
})(exports.AnswerError || (exports.AnswerError = {}));
|
|
1754
1793
|
var AnswerErrorMessages = (_a = {},
|
|
@@ -2568,7 +2607,10 @@ var getElementMemoized = sdkUtil.memoizePromise(function (event, id) { return __
|
|
|
2568
2607
|
});
|
|
2569
2608
|
}); }, function (event, id) { return id; });
|
|
2570
2609
|
/**
|
|
2571
|
-
* Returns an element of a specific event by its id
|
|
2610
|
+
* Returns an element of a specific event by its id.
|
|
2611
|
+
*
|
|
2612
|
+
* @param event - The event that owns the element
|
|
2613
|
+
* @param id - The element identifier
|
|
2572
2614
|
*/
|
|
2573
2615
|
function getElement(event, id) {
|
|
2574
2616
|
return getElementMemoized(event, id);
|
|
@@ -2585,7 +2627,7 @@ var getElementsMemoized = sdkUtil.memoizePromise(function (event) { return __awa
|
|
|
2585
2627
|
return [2 /*return*/, (Array.from(elements.values())
|
|
2586
2628
|
// Get elements which belong only to the provided event
|
|
2587
2629
|
.filter(function (element) { return element.eventId === event.id; })
|
|
2588
|
-
// Sort elements so the
|
|
2630
|
+
// Sort elements so the oldest element is first, and the most recent is last
|
|
2589
2631
|
.sort(function (a, b) { return a.publishedAt - b.publishedAt; }))];
|
|
2590
2632
|
}
|
|
2591
2633
|
});
|
|
@@ -2594,6 +2636,9 @@ var getElementsMemoized = sdkUtil.memoizePromise(function (event) { return __awa
|
|
|
2594
2636
|
});
|
|
2595
2637
|
/**
|
|
2596
2638
|
* Returns the list of elements published in a specific event
|
|
2639
|
+
*
|
|
2640
|
+
* @param event - The event to fetch elements for
|
|
2641
|
+
* @returns The published elements, sorted oldest first.
|
|
2597
2642
|
*/
|
|
2598
2643
|
function getElements(event) {
|
|
2599
2644
|
return getElementsMemoized(event);
|
|
@@ -2689,22 +2734,31 @@ function isNumbers(value) {
|
|
|
2689
2734
|
return value.every(function (v) { return typeof v === 'number'; });
|
|
2690
2735
|
}
|
|
2691
2736
|
/**
|
|
2692
|
-
* Adds an observer for when
|
|
2693
|
-
* are updated
|
|
2737
|
+
* Adds an observer for when
|
|
2738
|
+
* {@link InteractElement | element results} are updated
|
|
2739
|
+
*
|
|
2740
|
+
* @param element - The element to observe
|
|
2741
|
+
* @param callback - Called when results are updated
|
|
2694
2742
|
*/
|
|
2695
2743
|
function onElementResults(element, callback) {
|
|
2696
2744
|
return sdkUtil.subscribe(element, 'results', callback);
|
|
2697
2745
|
}
|
|
2698
2746
|
/**
|
|
2699
|
-
* Adds an observer for when
|
|
2700
|
-
* changed
|
|
2747
|
+
* Adds an observer for when
|
|
2748
|
+
* {@link InteractElement | element state} changed
|
|
2749
|
+
*
|
|
2750
|
+
* @param element - The element to observe
|
|
2751
|
+
* @param callback - Called when the state changes
|
|
2701
2752
|
*/
|
|
2702
2753
|
function onElementStateChanged(element, callback) {
|
|
2703
2754
|
return sdkUtil.subscribe(element, 'state', callback);
|
|
2704
2755
|
}
|
|
2705
2756
|
/**
|
|
2706
|
-
* Adds an observer for when
|
|
2707
|
-
*
|
|
2757
|
+
* Adds an observer for when
|
|
2758
|
+
* {@link InteractElement | element fields} are updated
|
|
2759
|
+
*
|
|
2760
|
+
* @param event - The event containing the elements
|
|
2761
|
+
* @param callback - Called with the updated element
|
|
2708
2762
|
*/
|
|
2709
2763
|
function onElementUpdated(event, callback) {
|
|
2710
2764
|
configureEvent(event);
|
|
@@ -2712,6 +2766,9 @@ function onElementUpdated(event, callback) {
|
|
|
2712
2766
|
}
|
|
2713
2767
|
/**
|
|
2714
2768
|
* Adds an observer for when a new element is published
|
|
2769
|
+
*
|
|
2770
|
+
* @param event - The event to observe
|
|
2771
|
+
* @param callback - Called with the published element
|
|
2715
2772
|
*/
|
|
2716
2773
|
function onElementPublished(event, callback) {
|
|
2717
2774
|
configureEvent(event);
|
|
@@ -2723,6 +2780,9 @@ function onElementPublished(event, callback) {
|
|
|
2723
2780
|
}
|
|
2724
2781
|
/**
|
|
2725
2782
|
* Adds an observer for when an element is revoked
|
|
2783
|
+
*
|
|
2784
|
+
* @param event - The event to observe
|
|
2785
|
+
* @param callback - Called with the revoked element
|
|
2726
2786
|
*/
|
|
2727
2787
|
function onElementRevoked(event, callback) {
|
|
2728
2788
|
configureEvent(event);
|