@miso.ai/client-sdk-core 1.8.0-beta.17 → 1.8.0-beta.19

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 (47) hide show
  1. package/dist/cjs/api/api.js +25 -0
  2. package/dist/cjs/api/ask.js +1 -1
  3. package/dist/cjs/api/helpers.js +1 -1
  4. package/dist/cjs/api/index.js +49 -19
  5. package/dist/cjs/api/interactions.js +1 -1
  6. package/dist/cjs/api/recommendation.js +1 -1
  7. package/dist/cjs/api/search.js +1 -1
  8. package/dist/cjs/classes.js +5 -15
  9. package/dist/cjs/client.js +2 -2
  10. package/dist/cjs/index.js +31 -5
  11. package/dist/cjs/plugin/index.js +3 -3
  12. package/dist/cjs/plugin/plugin-root.js +3 -3
  13. package/dist/cjs/root.js +2 -2
  14. package/dist/cjs/version.js +1 -1
  15. package/package.json +9 -9
  16. package/{dist/es/api/index.js → src/api/api.js} +9 -6
  17. package/src/api/ask.js +75 -0
  18. package/src/api/base.js +47 -0
  19. package/{dist/es → src}/api/helpers.js +47 -91
  20. package/src/api/index.js +7 -0
  21. package/src/api/interactions.js +54 -0
  22. package/{dist/es → src}/api/recommendation.js +11 -2
  23. package/{dist/es → src}/api/search.js +8 -2
  24. package/src/classes.js +7 -0
  25. package/{dist/es → src}/client.js +25 -10
  26. package/{dist/es → src}/cmd.js +7 -8
  27. package/{dist/es → src}/constants.js +2 -2
  28. package/{dist/es → src}/context.js +4 -1
  29. package/src/index.js +3 -0
  30. package/{dist/es → src}/plugin/anonymous.js +5 -4
  31. package/{dist/es → src}/plugin/auto-events.js +24 -25
  32. package/src/plugin/index.js +3 -0
  33. package/{dist/es → src}/plugin/page-info.js +28 -24
  34. package/{dist/es → src}/plugin/plugin-root.js +37 -22
  35. package/{dist/es → src}/plugin/urls.js +2 -1
  36. package/{dist/es → src}/plugin/user.js +32 -37
  37. package/{dist/es → src}/root.js +10 -4
  38. package/src/utils.js +1 -0
  39. package/src/version.js +1 -0
  40. package/dist/es/api/ask.js +0 -85
  41. package/dist/es/api/base.js +0 -96
  42. package/dist/es/api/interactions.js +0 -82
  43. package/dist/es/classes.js +0 -20
  44. package/dist/es/index.js +0 -2
  45. package/dist/es/plugin/index.js +0 -3
  46. package/dist/es/utils.js +0 -1
  47. package/dist/es/version.js +0 -1
@@ -1,82 +0,0 @@
1
- const _excluded = ["useBeacon"],
2
- _excluded2 = ["options"];
3
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
4
- import ApiBase from './base';
5
- export default class Interactions extends ApiBase {
6
- constructor(api) {
7
- super(api, 'interactions');
8
- }
9
- async upload(payload, options) {
10
- try {
11
- return await this._run('upload', payload, options);
12
- } catch (e) {
13
- if (e.status === 400 && e.message && e.message.toLowerCase().indexOf('playground') > -1) {
14
- this._warn(`Ignore interactions uploaded to playground app.`);
15
- } else {
16
- throw e;
17
- }
18
- }
19
- }
20
- _url(_ref) {
21
- let {
22
- apiGroup,
23
- apiName,
24
- options
25
- } = _ref;
26
- const url = this.helpers.url([this._apiPath], options);
27
- return this.helpers.applyUrlPasses(this, {
28
- apiGroup,
29
- apiName,
30
- url,
31
- options
32
- });
33
- }
34
- _preprocess(_ref2) {
35
- let {
36
- apiGroup,
37
- apiName,
38
- payload
39
- } = _ref2;
40
- if (apiName === 'upload') {
41
- payload = this._normalizeUploadPayload(payload);
42
- }
43
- return super._preprocess({
44
- apiGroup,
45
- apiName,
46
- payload
47
- });
48
- }
49
- _normalizeUploadPayload(payload) {
50
- // TODO: accept string as a shortcut of { type: payload } as well
51
- if (typeof payload !== 'object') {
52
- throw new Error(`Interactions payload has to be either an object or an array of objects: ${payload}`);
53
- }
54
- if (!Array.isArray(payload)) {
55
- payload = [payload];
56
- }
57
- return {
58
- data: payload
59
- };
60
- }
61
- async _send(_ref3) {
62
- let {
63
- options: {
64
- useBeacon = true
65
- } = {}
66
- } = _ref3,
67
- options = _objectWithoutPropertiesLoose(_ref3.options, _excluded),
68
- args = _objectWithoutPropertiesLoose(_ref3, _excluded2);
69
- if (useBeacon) {
70
- const {
71
- url,
72
- payload
73
- } = args;
74
- this.helpers.sendBeacon(url, payload, options);
75
- return {};
76
- } else {
77
- return super._send(Object.assign({}, args, {
78
- options
79
- }));
80
- }
81
- }
82
- }
@@ -1,20 +0,0 @@
1
- import Api from './api';
2
- import ApiBase from './api/base';
3
- import ApiHelpers from './api/helpers';
4
- import Interactions from './api/interactions';
5
- import Recommendation from './api/recommendation';
6
- import Search from './api/search';
7
- import Context from './context';
8
- export default {
9
- api: {
10
- Api,
11
- ApiBase,
12
- ApiHelpers,
13
- Interactions,
14
- Recommendation,
15
- Search
16
- },
17
- context: {
18
- Context
19
- }
20
- };
package/dist/es/index.js DELETED
@@ -1,2 +0,0 @@
1
- import MisoClient from './client';
2
- export default MisoClient;
@@ -1,3 +0,0 @@
1
- export { default as UserPlugin } from './user';
2
- export { default as PageInfoPlugin } from './page-info';
3
- export { default as AutoEventsPlugin } from './auto-events';
package/dist/es/utils.js DELETED
@@ -1 +0,0 @@
1
- export { viewable } from '@miso.ai/commons';
@@ -1 +0,0 @@
1
- export default '1.8.0-beta.17';