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

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 (54) hide show
  1. package/dist/cjs/api/api.js +25 -0
  2. package/dist/cjs/api/ask.js +7 -6
  3. package/dist/cjs/api/constants.js +27 -0
  4. package/dist/cjs/api/helpers.js +1 -1
  5. package/dist/cjs/api/index.js +54 -19
  6. package/dist/cjs/api/interactions.js +5 -4
  7. package/dist/cjs/api/recommendation.js +9 -8
  8. package/dist/cjs/api/search.js +6 -5
  9. package/dist/cjs/classes.js +5 -15
  10. package/dist/cjs/client.js +2 -2
  11. package/dist/cjs/constants.js +2 -2
  12. package/dist/cjs/index.js +39 -5
  13. package/dist/cjs/plugin/auto-events.js +3 -2
  14. package/dist/cjs/plugin/index.js +3 -3
  15. package/dist/cjs/plugin/plugin-root.js +3 -3
  16. package/dist/cjs/root.js +2 -2
  17. package/dist/cjs/version.js +1 -1
  18. package/package.json +9 -9
  19. package/{dist/es/api/index.js → src/api/api.js} +9 -6
  20. package/src/api/ask.js +76 -0
  21. package/src/api/base.js +47 -0
  22. package/src/api/constants.js +20 -0
  23. package/{dist/es → src}/api/helpers.js +47 -91
  24. package/src/api/index.js +8 -0
  25. package/src/api/interactions.js +55 -0
  26. package/src/api/recommendation.js +34 -0
  27. package/src/api/search.js +22 -0
  28. package/src/classes.js +7 -0
  29. package/{dist/es → src}/client.js +25 -10
  30. package/{dist/es → src}/cmd.js +7 -8
  31. package/src/constants.js +4 -0
  32. package/{dist/es → src}/context.js +4 -1
  33. package/src/index.js +4 -0
  34. package/{dist/es → src}/plugin/anonymous.js +5 -4
  35. package/{dist/es → src}/plugin/auto-events.js +27 -27
  36. package/src/plugin/index.js +3 -0
  37. package/{dist/es → src}/plugin/page-info.js +28 -24
  38. package/{dist/es → src}/plugin/plugin-root.js +37 -22
  39. package/{dist/es → src}/plugin/urls.js +2 -1
  40. package/{dist/es → src}/plugin/user.js +32 -37
  41. package/{dist/es → src}/root.js +10 -4
  42. package/src/utils.js +1 -0
  43. package/src/version.js +1 -0
  44. package/dist/es/api/ask.js +0 -85
  45. package/dist/es/api/base.js +0 -96
  46. package/dist/es/api/interactions.js +0 -82
  47. package/dist/es/api/recommendation.js +0 -24
  48. package/dist/es/api/search.js +0 -15
  49. package/dist/es/classes.js +0 -20
  50. package/dist/es/constants.js +0 -4
  51. package/dist/es/index.js +0 -2
  52. package/dist/es/plugin/index.js +0 -3
  53. package/dist/es/utils.js +0 -1
  54. 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,24 +0,0 @@
1
- import ApiBase from './base';
2
- export default class Recommendation extends ApiBase {
3
- constructor(api) {
4
- super(api, 'recommendation');
5
- }
6
- async userToProducts(payload, options) {
7
- return this._run('user_to_products', payload, options);
8
- }
9
- async userToCategories(payload, options) {
10
- return this._run('user_to_categories', payload, options);
11
- }
12
- async userToAttributes(payload, options) {
13
- return this._run('user_to_attributes', payload, options);
14
- }
15
- async userToTrending(payload, options) {
16
- return this._run('user_to_trending', payload, options);
17
- }
18
- async userToHistory(payload, options) {
19
- return this._run('user_to_history', payload, options);
20
- }
21
- async productToProducts(payload, options) {
22
- return this._run('product_to_products', payload, options);
23
- }
24
- }
@@ -1,15 +0,0 @@
1
- import ApiBase from './base';
2
- export default class Search extends ApiBase {
3
- constructor(api) {
4
- super(api, 'search');
5
- }
6
- async search(payload, options) {
7
- return this._run('search', payload, options);
8
- }
9
- async autocomplete(payload, options) {
10
- return this._run('autocomplete', payload, options);
11
- }
12
- async multipleGet(payload, options) {
13
- return this._run('mget', payload, options);
14
- }
15
- }
@@ -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
- };
@@ -1,4 +0,0 @@
1
- export const API = {
2
- DATA_ENDPOINT: 'https://api-edge.askmiso.com/v1',
3
- EVENT_ENDPOINT: 'https://api.askmiso.com/v1'
4
- };
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.9';