@miso.ai/client-sdk-ui 1.13.2-beta.1 → 1.14.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (226) hide show
  1. package/dist/cjs/asset/svgs.js +17 -4
  2. package/dist/cjs/combo/ask/index.js +2 -2
  3. package/dist/cjs/constants.js +120 -98
  4. package/dist/cjs/defaults/ask/controls.js +1 -1
  5. package/dist/cjs/defaults/hybrid-search/answer-box.js +4 -4
  6. package/dist/cjs/defaults.js +259 -0
  7. package/dist/cjs/element/container/index.js +28 -0
  8. package/dist/cjs/element/container/miso-ask.js +3 -3
  9. package/dist/cjs/element/container/miso-conversation.js +21 -0
  10. package/dist/cjs/element/container/miso-explore.js +1 -1
  11. package/dist/cjs/element/container/miso-history.js +21 -0
  12. package/dist/cjs/element/container/miso-hybrid-search.js +1 -1
  13. package/dist/cjs/element/container/miso-message-item.js +91 -0
  14. package/dist/cjs/element/container/miso-recommendation.js +1 -1
  15. package/dist/cjs/element/container/miso-search.js +1 -1
  16. package/dist/cjs/element/container/miso-thread-item.js +91 -0
  17. package/dist/cjs/element/context/miso-follow-ups.js +1 -1
  18. package/dist/cjs/element/role/index.js +49 -0
  19. package/dist/cjs/element/role/miso-delete.js +20 -0
  20. package/dist/cjs/element/role/miso-messages.js +20 -0
  21. package/dist/cjs/element/role/miso-new-thread.js +20 -0
  22. package/dist/cjs/element/role/miso-rename.js +20 -0
  23. package/dist/cjs/element/role/miso-subscription.js +20 -0
  24. package/dist/cjs/element/role/miso-threads.js +20 -0
  25. package/dist/cjs/element/role/miso-title.js +20 -0
  26. package/dist/cjs/layout/affiliation/affiliation.js +1 -1
  27. package/dist/cjs/layout/banner/banner.js +2 -1
  28. package/dist/cjs/layout/button/button.js +170 -0
  29. package/dist/cjs/layout/button/checkbox.js +116 -0
  30. package/dist/cjs/layout/button/more-button.js +3 -3
  31. package/dist/cjs/layout/container/container.js +1 -1
  32. package/dist/cjs/layout/container/item-container.js +99 -0
  33. package/dist/cjs/layout/error/error.js +2 -1
  34. package/dist/cjs/layout/index.js +42 -0
  35. package/dist/cjs/layout/input/facets.js +4 -3
  36. package/dist/cjs/layout/input/option-list.js +3 -2
  37. package/dist/cjs/layout/input/search-box.js +50 -12
  38. package/dist/cjs/layout/input/select.js +2 -1
  39. package/dist/cjs/layout/list/cards.js +2 -1
  40. package/dist/cjs/layout/list/carousel.js +2 -1
  41. package/dist/cjs/layout/list/collection.js +13 -1
  42. package/dist/cjs/layout/list/gallery.js +2 -1
  43. package/dist/cjs/layout/list/horizontal.js +2 -1
  44. package/dist/cjs/layout/list/list.js +2 -1
  45. package/dist/cjs/layout/list/messages.js +359 -0
  46. package/dist/cjs/layout/list/threads.js +199 -0
  47. package/dist/cjs/layout/mixin/trackable.js +4 -5
  48. package/dist/cjs/layout/mixin/triggerable.js +2 -2
  49. package/dist/cjs/layout/radio/feedback.js +4 -3
  50. package/dist/cjs/layout/templates.js +97 -0
  51. package/dist/cjs/layout/text/question.js +71 -0
  52. package/dist/cjs/layout/text/text.js +2 -1
  53. package/dist/cjs/layout/text/typewriter/index.js +18 -23
  54. package/dist/cjs/plugin.js +43 -104
  55. package/dist/cjs/util/confirm.js +33 -0
  56. package/dist/cjs/util/dom.js +21 -0
  57. package/dist/cjs/util/modal.js +48 -0
  58. package/dist/cjs/util/prompt.js +47 -0
  59. package/dist/cjs/version.js +1 -1
  60. package/package.json +5 -4
  61. package/src/CLAUDE.md +51 -104
  62. package/src/asset/svgs.js +16 -3
  63. package/src/combo/ask/index.js +2 -2
  64. package/src/constants.js +39 -147
  65. package/src/defaults/ask/controls.js +1 -1
  66. package/src/defaults/hybrid-search/answer-box.js +2 -2
  67. package/src/defaults.js +174 -0
  68. package/src/element/container/index.js +4 -0
  69. package/src/element/container/miso-ask.js +3 -3
  70. package/src/element/container/miso-conversation.js +19 -0
  71. package/src/element/container/miso-explore.js +1 -1
  72. package/src/element/container/miso-history.js +19 -0
  73. package/src/element/container/miso-hybrid-search.js +1 -1
  74. package/src/element/container/miso-message-item.js +94 -0
  75. package/src/element/container/miso-recommendation.js +1 -1
  76. package/src/element/container/miso-search.js +1 -1
  77. package/src/element/container/miso-thread-item.js +94 -0
  78. package/src/element/context/miso-follow-ups.js +1 -1
  79. package/src/element/role/index.js +7 -0
  80. package/src/element/role/miso-delete.js +16 -0
  81. package/src/element/role/miso-messages.js +16 -0
  82. package/src/element/role/miso-new-thread.js +16 -0
  83. package/src/element/role/miso-rename.js +16 -0
  84. package/src/element/role/miso-subscription.js +16 -0
  85. package/src/element/role/miso-threads.js +16 -0
  86. package/src/element/role/miso-title.js +16 -0
  87. package/src/layout/affiliation/affiliation.js +2 -2
  88. package/src/layout/banner/banner.js +2 -1
  89. package/src/layout/button/button.js +152 -0
  90. package/src/layout/button/checkbox.js +92 -0
  91. package/src/layout/button/more-button.js +3 -3
  92. package/src/layout/container/container.js +2 -2
  93. package/src/layout/container/item-container.js +99 -0
  94. package/src/layout/error/error.js +2 -1
  95. package/src/layout/index.js +6 -0
  96. package/src/layout/input/facets.js +3 -2
  97. package/src/layout/input/option-list.js +3 -2
  98. package/src/layout/input/search-box.js +45 -8
  99. package/src/layout/input/select.js +2 -1
  100. package/src/layout/list/cards.js +2 -1
  101. package/src/layout/list/carousel.js +2 -1
  102. package/src/layout/list/collection.js +15 -2
  103. package/src/layout/list/gallery.js +2 -1
  104. package/src/layout/list/horizontal.js +2 -1
  105. package/src/layout/list/list.js +2 -1
  106. package/src/layout/list/messages.js +316 -0
  107. package/src/layout/list/threads.js +166 -0
  108. package/src/layout/mixin/trackable.js +2 -3
  109. package/src/layout/mixin/triggerable.js +1 -1
  110. package/src/layout/radio/feedback.js +3 -2
  111. package/src/layout/templates.js +97 -0
  112. package/src/layout/text/question.js +58 -0
  113. package/src/layout/text/text.js +2 -1
  114. package/src/layout/text/typewriter/index.js +15 -18
  115. package/src/plugin.js +31 -117
  116. package/src/util/confirm.js +28 -0
  117. package/src/util/dom.js +16 -0
  118. package/src/util/modal.js +49 -0
  119. package/src/util/prompt.js +42 -0
  120. package/src/version.js +1 -1
  121. package/dist/cjs/actor/data.js +0 -132
  122. package/dist/cjs/actor/feedback.js +0 -29
  123. package/dist/cjs/actor/fields.js +0 -57
  124. package/dist/cjs/actor/filters.js +0 -161
  125. package/dist/cjs/actor/hub.js +0 -57
  126. package/dist/cjs/actor/index.js +0 -73
  127. package/dist/cjs/actor/interactions.js +0 -36
  128. package/dist/cjs/actor/sessions.js +0 -25
  129. package/dist/cjs/actor/tracker-states.js +0 -61
  130. package/dist/cjs/actor/tracker.js +0 -109
  131. package/dist/cjs/actor/trackers.js +0 -52
  132. package/dist/cjs/actor/utils.js +0 -15
  133. package/dist/cjs/actor/view.js +0 -294
  134. package/dist/cjs/actor/views.js +0 -209
  135. package/dist/cjs/source.js +0 -27
  136. package/dist/cjs/util/proxy.js +0 -88
  137. package/dist/cjs/util/trackers.js +0 -88
  138. package/dist/cjs/workflow/affiliations.js +0 -140
  139. package/dist/cjs/workflow/answer-based.js +0 -337
  140. package/dist/cjs/workflow/ask.js +0 -319
  141. package/dist/cjs/workflow/asks.js +0 -150
  142. package/dist/cjs/workflow/autocompletable.js +0 -63
  143. package/dist/cjs/workflow/autocomplete.js +0 -120
  144. package/dist/cjs/workflow/base.js +0 -418
  145. package/dist/cjs/workflow/context.js +0 -19
  146. package/dist/cjs/workflow/explore.js +0 -210
  147. package/dist/cjs/workflow/explores.js +0 -21
  148. package/dist/cjs/workflow/hybrid-search-answer.js +0 -88
  149. package/dist/cjs/workflow/hybrid-search-views.js +0 -109
  150. package/dist/cjs/workflow/hybrid-search.js +0 -213
  151. package/dist/cjs/workflow/index.js +0 -41
  152. package/dist/cjs/workflow/options/api.js +0 -41
  153. package/dist/cjs/workflow/options/auto-query.js +0 -97
  154. package/dist/cjs/workflow/options/configurable.js +0 -45
  155. package/dist/cjs/workflow/options/data-processor.js +0 -20
  156. package/dist/cjs/workflow/options/filters.js +0 -15
  157. package/dist/cjs/workflow/options/index.js +0 -126
  158. package/dist/cjs/workflow/options/interactions.js +0 -41
  159. package/dist/cjs/workflow/options/layouts.js +0 -79
  160. package/dist/cjs/workflow/options/options.js +0 -156
  161. package/dist/cjs/workflow/options/pagination.js +0 -25
  162. package/dist/cjs/workflow/options/roles.js +0 -15
  163. package/dist/cjs/workflow/options/templates.js +0 -30
  164. package/dist/cjs/workflow/options/trackers.js +0 -83
  165. package/dist/cjs/workflow/options/utils.js +0 -33
  166. package/dist/cjs/workflow/processors.js +0 -607
  167. package/dist/cjs/workflow/recommendation.js +0 -57
  168. package/dist/cjs/workflow/recommendations.js +0 -18
  169. package/dist/cjs/workflow/search-based.js +0 -337
  170. package/dist/cjs/workflow/search.js +0 -64
  171. package/dist/cjs/workflow/unit.js +0 -57
  172. package/dist/cjs/workflow/units.js +0 -42
  173. package/dist/cjs/workflow/use-link.js +0 -49
  174. package/src/actor/data.js +0 -106
  175. package/src/actor/feedback.js +0 -28
  176. package/src/actor/fields.js +0 -51
  177. package/src/actor/filters.js +0 -149
  178. package/src/actor/hub.js +0 -47
  179. package/src/actor/index.js +0 -10
  180. package/src/actor/interactions.js +0 -32
  181. package/src/actor/sessions.js +0 -21
  182. package/src/actor/tracker-states.js +0 -57
  183. package/src/actor/tracker.js +0 -104
  184. package/src/actor/trackers.js +0 -45
  185. package/src/actor/utils.js +0 -7
  186. package/src/actor/view.js +0 -272
  187. package/src/actor/views.js +0 -224
  188. package/src/source.js +0 -17
  189. package/src/util/proxy.js +0 -81
  190. package/src/util/trackers.js +0 -84
  191. package/src/workflow/affiliations.js +0 -121
  192. package/src/workflow/answer-based.js +0 -312
  193. package/src/workflow/ask.js +0 -284
  194. package/src/workflow/asks.js +0 -143
  195. package/src/workflow/autocompletable.js +0 -67
  196. package/src/workflow/autocomplete.js +0 -114
  197. package/src/workflow/base.js +0 -396
  198. package/src/workflow/context.js +0 -16
  199. package/src/workflow/explore.js +0 -194
  200. package/src/workflow/explores.js +0 -18
  201. package/src/workflow/hybrid-search-answer.js +0 -73
  202. package/src/workflow/hybrid-search-views.js +0 -116
  203. package/src/workflow/hybrid-search.js +0 -230
  204. package/src/workflow/index.js +0 -5
  205. package/src/workflow/options/api.js +0 -31
  206. package/src/workflow/options/auto-query.js +0 -70
  207. package/src/workflow/options/configurable.js +0 -48
  208. package/src/workflow/options/data-processor.js +0 -15
  209. package/src/workflow/options/filters.js +0 -10
  210. package/src/workflow/options/index.js +0 -11
  211. package/src/workflow/options/interactions.js +0 -36
  212. package/src/workflow/options/layouts.js +0 -73
  213. package/src/workflow/options/options.js +0 -175
  214. package/src/workflow/options/pagination.js +0 -18
  215. package/src/workflow/options/roles.js +0 -12
  216. package/src/workflow/options/templates.js +0 -27
  217. package/src/workflow/options/trackers.js +0 -80
  218. package/src/workflow/options/utils.js +0 -26
  219. package/src/workflow/processors.js +0 -490
  220. package/src/workflow/recommendation.js +0 -63
  221. package/src/workflow/recommendations.js +0 -14
  222. package/src/workflow/search-based.js +0 -329
  223. package/src/workflow/search.js +0 -73
  224. package/src/workflow/unit.js +0 -51
  225. package/src/workflow/units.js +0 -43
  226. package/src/workflow/use-link.js +0 -41
@@ -1,126 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _roles = require("./roles.js");
7
- Object.keys(_roles).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _roles[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _roles[key];
14
- }
15
- });
16
- });
17
- var _api = require("./api.js");
18
- Object.keys(_api).forEach(function (key) {
19
- if (key === "default" || key === "__esModule") return;
20
- if (key in exports && exports[key] === _api[key]) return;
21
- Object.defineProperty(exports, key, {
22
- enumerable: true,
23
- get: function () {
24
- return _api[key];
25
- }
26
- });
27
- });
28
- var _layouts = require("./layouts.js");
29
- Object.keys(_layouts).forEach(function (key) {
30
- if (key === "default" || key === "__esModule") return;
31
- if (key in exports && exports[key] === _layouts[key]) return;
32
- Object.defineProperty(exports, key, {
33
- enumerable: true,
34
- get: function () {
35
- return _layouts[key];
36
- }
37
- });
38
- });
39
- var _dataProcessor = require("./data-processor.js");
40
- Object.keys(_dataProcessor).forEach(function (key) {
41
- if (key === "default" || key === "__esModule") return;
42
- if (key in exports && exports[key] === _dataProcessor[key]) return;
43
- Object.defineProperty(exports, key, {
44
- enumerable: true,
45
- get: function () {
46
- return _dataProcessor[key];
47
- }
48
- });
49
- });
50
- var _trackers = require("./trackers.js");
51
- Object.keys(_trackers).forEach(function (key) {
52
- if (key === "default" || key === "__esModule") return;
53
- if (key in exports && exports[key] === _trackers[key]) return;
54
- Object.defineProperty(exports, key, {
55
- enumerable: true,
56
- get: function () {
57
- return _trackers[key];
58
- }
59
- });
60
- });
61
- var _interactions = require("./interactions.js");
62
- Object.keys(_interactions).forEach(function (key) {
63
- if (key === "default" || key === "__esModule") return;
64
- if (key in exports && exports[key] === _interactions[key]) return;
65
- Object.defineProperty(exports, key, {
66
- enumerable: true,
67
- get: function () {
68
- return _interactions[key];
69
- }
70
- });
71
- });
72
- var _filters = require("./filters.js");
73
- Object.keys(_filters).forEach(function (key) {
74
- if (key === "default" || key === "__esModule") return;
75
- if (key in exports && exports[key] === _filters[key]) return;
76
- Object.defineProperty(exports, key, {
77
- enumerable: true,
78
- get: function () {
79
- return _filters[key];
80
- }
81
- });
82
- });
83
- var _pagination = require("./pagination.js");
84
- Object.keys(_pagination).forEach(function (key) {
85
- if (key === "default" || key === "__esModule") return;
86
- if (key in exports && exports[key] === _pagination[key]) return;
87
- Object.defineProperty(exports, key, {
88
- enumerable: true,
89
- get: function () {
90
- return _pagination[key];
91
- }
92
- });
93
- });
94
- var _options = require("./options.js");
95
- Object.keys(_options).forEach(function (key) {
96
- if (key === "default" || key === "__esModule") return;
97
- if (key in exports && exports[key] === _options[key]) return;
98
- Object.defineProperty(exports, key, {
99
- enumerable: true,
100
- get: function () {
101
- return _options[key];
102
- }
103
- });
104
- });
105
- var _configurable = require("./configurable.js");
106
- Object.keys(_configurable).forEach(function (key) {
107
- if (key === "default" || key === "__esModule") return;
108
- if (key in exports && exports[key] === _configurable[key]) return;
109
- Object.defineProperty(exports, key, {
110
- enumerable: true,
111
- get: function () {
112
- return _configurable[key];
113
- }
114
- });
115
- });
116
- var _autoQuery = require("./auto-query.js");
117
- Object.keys(_autoQuery).forEach(function (key) {
118
- if (key === "default" || key === "__esModule") return;
119
- if (key in exports && exports[key] === _autoQuery[key]) return;
120
- Object.defineProperty(exports, key, {
121
- enumerable: true,
122
- get: function () {
123
- return _autoQuery[key];
124
- }
125
- });
126
- });
@@ -1,41 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.mergeInteractionsOptions = mergeInteractionsOptions;
7
- exports.normalizeInteractionsOptions = normalizeInteractionsOptions;
8
- var _commons = require("@miso.ai/commons");
9
- var _utils = require("./utils.js");
10
- function normalizeInteractionsOptions(options) {
11
- if (options === undefined) {
12
- return undefined;
13
- }
14
- if (options === false) {
15
- return {
16
- handle: () => {}
17
- };
18
- }
19
- // preprocess
20
- const preprocess = (0, _commons.asArray)(options.preprocess);
21
- for (const p of preprocess) {
22
- if (typeof p !== 'function') {
23
- throw new Error(`Expect preprocess options to be a function: ${p}`);
24
- }
25
- }
26
- // handle
27
- if (options.handle && typeof options.handle !== 'function') {
28
- throw new Error(`Expect handle options to be a function: ${options.handle}`);
29
- }
30
- return Object.assign({}, options, {
31
- preprocess
32
- });
33
- }
34
- function mergeInteractionsOptions(...optionsList) {
35
- if (optionsList[optionsList.length - 1] === false) {
36
- return false;
37
- }
38
- return (0, _utils.mergeOptions)(optionsList, (merged, options) => Object.assign(merged, Object.assign({}, options, {
39
- preprocess: (0, _utils.concatArrays)(merged.preprocess, options.preprocess)
40
- })));
41
- }
@@ -1,79 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.mergeLayoutsOptions = mergeLayoutsOptions;
7
- exports.normalizeLayoutsOptions = normalizeLayoutsOptions;
8
- var _commons = require("@miso.ai/commons");
9
- var _constants = require("../../constants.js");
10
- var _utils = require("./utils.js");
11
- const _excluded = ["results"];
12
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
13
- function normalizeLayoutsOptions(options = {}) {
14
- if (options === false) {
15
- return false;
16
- }
17
- // fallback: results -> products
18
- const {
19
- results
20
- } = options,
21
- rest = _objectWithoutPropertiesLoose(options, _excluded);
22
- if (results !== undefined) {
23
- console.warn(`useLayouts({ results: ... }) is deprecated, use useLayouts({ ${_constants.ROLE.PRODUCTS}: ... }) instead`);
24
- options = Object.assign({}, rest, {
25
- [_constants.ROLE.PRODUCTS]: results
26
- });
27
- }
28
- const normalize = {};
29
- for (const [role, args] of Object.entries(options)) {
30
- normalize[normalizeRole(role)] = normalizeLayoutOptions(args);
31
- }
32
- return normalize;
33
- }
34
- function normalizeRole(role) {
35
- role = (0, _commons.lowerCamelToSnake)(role);
36
- role = (0, _commons.kebabToSnake)(role);
37
- return role;
38
- }
39
- function normalizeLayoutOptions(args) {
40
- // take args:
41
- // * undefined
42
- // * false
43
- // * name (string)
44
- // * options (object)
45
- // * [name, options]
46
- if (args === undefined) {
47
- return undefined;
48
- }
49
- let [name, options] = (0, _commons.asArray)(args);
50
- if (typeof name === 'object') {
51
- options = name;
52
- name = undefined;
53
- }
54
- return [name, options];
55
- }
56
- function mergeLayoutsOptions(...optionsList) {
57
- if (optionsList[optionsList.length - 1] === false) {
58
- return false;
59
- }
60
- return (0, _utils.mergeOptions)(optionsList, (merged, options) => {
61
- for (const [role, args] of Object.entries(options)) {
62
- merged[role] = mergeLayoutOptions(merged[role], args);
63
- }
64
- return merged;
65
- });
66
- }
67
- function mergeLayoutOptions(base, overrides) {
68
- overrides = normalizeLayoutOptions(overrides);
69
- if (overrides[0] === false) {
70
- return overrides;
71
- }
72
- return base && overrides ? [overrides[0] || base[0], mergeLayoutParameters(base[1], overrides[1])] : overrides || base;
73
- }
74
- function mergeLayoutParameters(base, overrides) {
75
- return Object.assign({}, base, overrides, {
76
- link: Object.assign({}, base && base.link, overrides && overrides.link),
77
- templates: Object.assign({}, base && base.templates, overrides && overrides.templates)
78
- });
79
- }
@@ -1,156 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.WorkflowOptions = exports.WorkflowContextOptions = void 0;
7
- var _commons = require("@miso.ai/commons");
8
- var _constants = require("../../constants.js");
9
- var _api = require("./api.js");
10
- var _layouts = require("./layouts.js");
11
- var _dataProcessor = require("./data-processor.js");
12
- var _trackers = require("./trackers.js");
13
- var _interactions = require("./interactions.js");
14
- var _filters = require("./filters.js");
15
- var _pagination = require("./pagination.js");
16
- var _templates = require("./templates.js");
17
- const FEATURES = [{
18
- key: _constants.WORKFLOW_CONFIGURABLE.API,
19
- normalize: _api.normalizeApiOptions,
20
- merge: _api.mergeApiOptions
21
- }, {
22
- key: _constants.WORKFLOW_CONFIGURABLE.LAYOUTS,
23
- normalize: _layouts.normalizeLayoutsOptions,
24
- merge: _layouts.mergeLayoutsOptions
25
- }, {
26
- key: _constants.WORKFLOW_CONFIGURABLE.DATA_PROCESSOR,
27
- normalize: _dataProcessor.normalizeDataProcessorOptions,
28
- merge: _dataProcessor.mergeDataProcessorOptions
29
- }, {
30
- key: _constants.WORKFLOW_CONFIGURABLE.TRACKERS,
31
- normalize: _trackers.normalizeTrackersOptions,
32
- merge: _trackers.mergeTrackersOptions
33
- }, {
34
- key: _constants.WORKFLOW_CONFIGURABLE.INTERACTIONS,
35
- normalize: _interactions.normalizeInteractionsOptions,
36
- merge: _interactions.mergeInteractionsOptions
37
- }, {
38
- key: _constants.WORKFLOW_CONFIGURABLE.FILTERS,
39
- normalize: _filters.normalizeFiltersOptions,
40
- merge: _filters.mergeFiltersOptions
41
- }, {
42
- key: _constants.WORKFLOW_CONFIGURABLE.PAGINATION,
43
- normalize: _pagination.normalizePaginationOptions,
44
- merge: _pagination.mergePaginationOptions
45
- }, {
46
- key: _constants.WORKFLOW_CONFIGURABLE.TEMPLATES,
47
- normalize: _templates.normalizeTemplatesOptions,
48
- merge: _templates.mergeTemplatesOptions
49
- }];
50
- class WorkflowContextOptions {
51
- constructor() {
52
- this._events = new _commons.EventEmitter({
53
- target: this
54
- });
55
- this._globals = {};
56
- }
57
- _notify(name) {
58
- this._events.emit(name);
59
- this._events.emit('_update', name);
60
- }
61
- }
62
- exports.WorkflowContextOptions = WorkflowContextOptions;
63
- class WorkflowOptions {
64
- constructor(context = {}, defaults = {}) {
65
- this._events = new _commons.EventEmitter({
66
- target: this
67
- });
68
- this._defaults = defaults; // TODO: we should call normalize() on defaults
69
- this._context = context || {};
70
- this._locals = {};
71
- (0, _commons.defineValues)(this, {
72
- resolved: new ResolvedWorkflowOptions(this),
73
- defaults
74
- });
75
- if (context && context.on) {
76
- this._unsubscribes = [context.on('_update', name => this._notify(name))];
77
- }
78
- }
79
- _notify(name) {
80
- this.resolved._invalidate(name);
81
- this._events.emit(name);
82
- }
83
- _destroy() {
84
- for (const unsubscribe of this._unsubscribes || []) {
85
- unsubscribe();
86
- }
87
- this._unsubscribes = [];
88
- }
89
- }
90
- exports.WorkflowOptions = WorkflowOptions;
91
- class ResolvedWorkflowOptions {
92
- constructor(options) {
93
- this._options = options;
94
- this._cache = {};
95
- }
96
- _invalidate(key) {
97
- this._cache[key] = undefined;
98
- }
99
- _get({
100
- key,
101
- merge
102
- }) {
103
- if (this._cache[key] === undefined) {
104
- const options = this._options;
105
- const contextFeature = options._context[key];
106
- this._cache[key] = merge(options._defaults[key], contextFeature && contextFeature.get(), options._locals[key]);
107
- }
108
- return this._cache[key];
109
- }
110
- }
111
- class WorkflowConfigurableFeature {
112
- constructor(options, store, key, normalize, merge) {
113
- this._options = options;
114
- this._store = store;
115
- this._key = key;
116
- this._normalize = value => value !== undefined ? normalize(value) : undefined;
117
- this._merge = merge;
118
- }
119
- get() {
120
- return this._store[this._key];
121
- }
122
- set(value) {
123
- this._set(this._normalize(value));
124
- }
125
- merge(value) {
126
- this._set(this._merge(this.get(), this._normalize(value)));
127
- }
128
- _set(value) {
129
- this._store[this._key] = value;
130
- this._options._notify(this._key);
131
- }
132
- }
133
- for (const feature of FEATURES) {
134
- const {
135
- key,
136
- normalize,
137
- merge
138
- } = feature;
139
- Object.defineProperty(WorkflowContextOptions.prototype, key, {
140
- get: function () {
141
- const _key = `_${key}`;
142
- return this[_key] || (this[_key] = new WorkflowConfigurableFeature(this, this._globals, key, normalize, merge));
143
- }
144
- });
145
- Object.defineProperty(WorkflowOptions.prototype, key, {
146
- get: function () {
147
- const _key = `_${key}`;
148
- return this[_key] || (this[_key] = new WorkflowConfigurableFeature(this, this._locals, key, normalize, merge));
149
- }
150
- });
151
- Object.defineProperty(ResolvedWorkflowOptions.prototype, key, {
152
- get: function () {
153
- return this._get(feature);
154
- }
155
- });
156
- }
@@ -1,25 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.mergePaginationOptions = mergePaginationOptions;
7
- exports.normalizePaginationOptions = normalizePaginationOptions;
8
- var _utils = require("./utils.js");
9
- function normalizePaginationOptions(options) {
10
- if (options === undefined) {
11
- throw new Error(`Expect pagination options to be an object or a boolean value: ${options}`);
12
- }
13
- if (typeof options === 'boolean') {
14
- options = {
15
- active: options
16
- };
17
- }
18
- return options;
19
- }
20
- function mergePaginationOptions(...optionsList) {
21
- if (optionsList[optionsList.length - 1] === false) {
22
- return false;
23
- }
24
- return (0, _utils.mergeOptions)(optionsList, (merged, options) => Object.assign(merged, options));
25
- }
@@ -1,15 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.mergeRolesOptions = mergeRolesOptions;
7
- function mergeRolesOptions(base, overrides) {
8
- return Object.freeze(Object.assign({}, base, overrides, {
9
- members: mergeRolesMembers(base.members, overrides.members),
10
- mappings: Object.freeze(Object.assign({}, base.mappings, overrides.mappings))
11
- }));
12
- }
13
- function mergeRolesMembers(base = [], overrides = []) {
14
- return [...new Set([...base, ...overrides])];
15
- }
@@ -1,30 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.mergeTemplatesOptions = mergeTemplatesOptions;
7
- exports.normalizeTemplatesOptions = normalizeTemplatesOptions;
8
- var _utils = require("./utils.js");
9
- function normalizeTemplatesOptions(options = {}) {
10
- const normalize = {};
11
- for (const [key, args] of Object.entries(options)) {
12
- normalize[key] = normalizeTemplateOptions(args);
13
- }
14
- return normalize;
15
- }
16
- function normalizeTemplateOptions(args) {
17
- // TODO: if object, make it function arguments
18
- return args === undefined ? undefined : typeof args !== 'function' ? () => args : args;
19
- }
20
- function mergeTemplatesOptions(...optionsList) {
21
- return (0, _utils.mergeOptions)(optionsList, (merged, options) => {
22
- for (const [key, args] of Object.entries(options)) {
23
- merged[key] = mergeTemplateOptions(merged[key], args);
24
- }
25
- return merged;
26
- });
27
- }
28
- function mergeTemplateOptions(base, overrides) {
29
- return normalizeTemplateOptions(overrides) || base;
30
- }
@@ -1,83 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.DEFAULT_TRACKER_OPTIONS = void 0;
7
- exports.mergeTrackersOptions = mergeTrackersOptions;
8
- exports.normalizeTrackersOptions = normalizeTrackersOptions;
9
- var _constants = require("../../constants.js");
10
- var _utils = require("./utils.js");
11
- const _excluded = ["active"],
12
- _excluded2 = ["active"];
13
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
14
- const DEFAULT_TRACKER_OPTIONS = exports.DEFAULT_TRACKER_OPTIONS = Object.freeze({
15
- active: true,
16
- impression: Object.freeze({
17
- active: true
18
- }),
19
- viewable: Object.freeze({
20
- active: true,
21
- area: 0.5,
22
- duration: 1000
23
- }),
24
- click: Object.freeze({
25
- active: true,
26
- lenient: false
27
- })
28
- });
29
- function normalizeTrackersOptions(options = {}) {
30
- options = (0, _utils.normalizeOptions)(options);
31
- const {
32
- active
33
- } = options,
34
- rest = _objectWithoutPropertiesLoose(options, _excluded);
35
- const normalized = {};
36
- for (const [role, args] of Object.entries(rest)) {
37
- normalized[role] = normalizeTrackerOptions(args);
38
- }
39
- return Object.assign({
40
- active
41
- }, normalized);
42
- }
43
- function normalizeTrackerOptions(options = {}) {
44
- options = (0, _utils.normalizeOptions)(options);
45
- const rest = _objectWithoutPropertiesLoose(options, _excluded2);
46
- const normalized = {};
47
- for (const [role, args] of Object.entries(rest)) {
48
- normalized[role] = normalizeTrackerEventOptions(args);
49
- }
50
- return options;
51
- }
52
- function normalizeTrackerEventOptions(options = {}) {
53
- options = (0, _utils.normalizeOptions)(options);
54
- return options;
55
- }
56
- function mergeTrackersOptions(...optionsList) {
57
- // TODO: should be able to remove this
58
- if (optionsList[optionsList.length - 1] === false) {
59
- return false;
60
- }
61
- return (0, _utils.mergeOptions)(optionsList, (merged, options) => {
62
- for (const [key, args] of Object.entries(options)) {
63
- if (args === undefined) {
64
- continue;
65
- }
66
- merged[key] = key === 'active' ? args : mergeTrackerOptions(merged[key], args);
67
- }
68
- return merged;
69
- });
70
- }
71
- function mergeTrackerOptions(base = {}, overrides = {}) {
72
- const merged = Object.assign({}, base);
73
- for (const [key, args] of Object.entries(overrides)) {
74
- if (args === undefined) {
75
- continue;
76
- }
77
- merged[key] = _constants.TRACKING_EVENT_TYPES.includes(key) ? mergeTrackerEventOptions(base[key], args) : args;
78
- }
79
- return merged;
80
- }
81
- function mergeTrackerEventOptions(base = {}, overrides = {}) {
82
- return Object.assign({}, base, overrides);
83
- }
@@ -1,33 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.concatArrays = concatArrays;
7
- exports.mergeOptions = mergeOptions;
8
- exports.normalizeOptions = normalizeOptions;
9
- var _commons = require("@miso.ai/commons");
10
- function concatArrays(a0, a1) {
11
- return a0 && a0.length ? a1 && a1.length ? [...a0, ...a1] : a0 : a1;
12
- }
13
- function mergeOptions(optionsList, merge) {
14
- let merged = {};
15
- for (const options of optionsList) {
16
- if (!options) {
17
- continue;
18
- }
19
- merged = merge(merged, options);
20
- }
21
- return (0, _commons.trimObj)(merged);
22
- }
23
- function normalizeOptions(options) {
24
- if (options === undefined) {
25
- throw new Error(`Expect options to be an object or a boolean value: ${options}`);
26
- }
27
- if (typeof options === 'boolean') {
28
- options = {
29
- active: options
30
- };
31
- }
32
- return options;
33
- }