@miso.ai/client-sdk-core 1.8.0-beta.9 → 1.8.1-beta.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 +11 -6
  3. package/dist/cjs/api/constants.js +28 -0
  4. package/dist/cjs/api/helpers.js +2 -2
  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 +13 -4
  16. package/dist/cjs/root.js +3 -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 +80 -0
  21. package/src/api/base.js +47 -0
  22. package/src/api/constants.js +21 -0
  23. package/{dist/es → src}/api/helpers.js +48 -92
  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 +48 -23
  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 +11 -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
package/src/api/ask.js ADDED
@@ -0,0 +1,80 @@
1
+ import { polling, signals, StallTimeoutAbortController } from '@miso.ai/commons';
2
+ import { GROUP, NAME } from './constants.js';
3
+ import ApiBase from './base.js';
4
+
5
+ export default class Ask extends ApiBase {
6
+
7
+ constructor(api) {
8
+ super(api, GROUP.ASK);
9
+ }
10
+
11
+ async questions(payload, options = {}) {
12
+ if (typeof payload === 'string' && payload.charAt(0) !== '{') {
13
+ return new Answer(this, { question_id: payload }, options);
14
+ }
15
+ const response = await this._run(NAME.QUESTIONS, payload, options);
16
+ return new Answer(this, response, options);
17
+ }
18
+
19
+ async _questions(payload, options) {
20
+ return this._run(NAME.QUESTIONS, payload, options);
21
+ }
22
+
23
+ async _get(questionId, options) {
24
+ return this._run(`${NAME.QUESTIONS}/${questionId}/answer`, undefined, { ...options, method: 'GET' });
25
+ }
26
+
27
+ async relatedQuestions(payload, options = {}) {
28
+ return this._run(NAME.RELATED_QUESTIONS, payload, options);
29
+ }
30
+
31
+ }
32
+
33
+ class Answer {
34
+
35
+ constructor(api, { question_id }, options = {}) {
36
+ this._api = api;
37
+ this._questionId = question_id;
38
+ this._ac = new AbortController();
39
+ this._options = options;
40
+ }
41
+
42
+ get questionId() {
43
+ return this._questionId;
44
+ }
45
+
46
+ async get(options) {
47
+ return this._api._get(this._questionId, { ...this._options, ...options });
48
+ }
49
+
50
+ abort(reason) {
51
+ this._ac.abort(reason);
52
+ }
53
+
54
+ [Symbol.asyncIterator]() {
55
+ const fetch = async ({ signal } = {}) => {
56
+ // TODO: pass signal
57
+ const response = await this.get();
58
+ return [response, response.finished];
59
+ };
60
+ let { pollingInterval: interval, signal, stallTimeout = 120000, ...options } = this._options;
61
+ const stac = new StallTimeoutAbortController(stallTimeout);
62
+ signal = signals.any(this._ac.signal, stac.signal, signal);
63
+
64
+ let prevResponse;
65
+ const onResponse = (response, finished) => {
66
+ if (finished) {
67
+ stac.clear();
68
+ } else if (isUpdated(prevResponse, response)) {
69
+ stac.touch();
70
+ }
71
+ prevResponse = response;
72
+ };
73
+ return polling(fetch, { interval, signal, onResponse, ...options })[Symbol.asyncIterator]();
74
+ }
75
+
76
+ }
77
+
78
+ function isUpdated(prev, curr) {
79
+ return !prev || prev.answer_stage !== curr.answer_stage || prev.answer.length !== curr.answer.length;
80
+ }
@@ -0,0 +1,47 @@
1
+ import { Component } from '@miso.ai/commons';
2
+
3
+ export default class ApiBase extends Component {
4
+
5
+ // TODO: use private fields (may encounter issues with rollup)
6
+
7
+ constructor(api, apiPath) {
8
+ super(apiPath, api);
9
+ this._apiPath = apiPath;
10
+ this.helpers = api.helpers;
11
+ this.clientOptions = api._client.options;
12
+ this.context = api._client.context;
13
+ }
14
+
15
+ async _run(apiName, payload, options = {}) {
16
+ const { bulk } = options;
17
+ const bulkInfo = bulk ? { bulk: this.helpers.bulkInfo } : undefined;
18
+ const apiGroup = this._apiPath;
19
+ const url = this._url({ apiGroup, apiName, payload, options });
20
+ payload = this._preprocess({ apiGroup, apiName, payload, options });
21
+ const requestData = { apiGroup, apiName, payload, url, options };
22
+ this._events.emit('request', { ...requestData, ...bulkInfo });
23
+ const response = await this._send(requestData);
24
+ const responseData = { ...requestData, response };
25
+ this._events.emit('response', { ...responseData, ...bulkInfo });
26
+ return this._postprocess(responseData);
27
+ }
28
+
29
+ _preprocess({ apiGroup, apiName, payload }) {
30
+ return this.helpers.applyPayloadPasses(this, { apiGroup, apiName, payload });
31
+ }
32
+
33
+ _url({ apiGroup, apiName, options }) {
34
+ const url = this.helpers.url([apiGroup, apiName], options);
35
+ return this.helpers.applyUrlPasses(this, { apiGroup, apiName, url, options });
36
+ }
37
+
38
+ async _send({ apiGroup, apiName, url, payload, options: { bulk, ...options } = {} }) {
39
+ return bulk ? this.helpers.fetchForBulk(apiGroup, apiName, payload) : this.helpers.fetch(url, payload, options);
40
+ }
41
+
42
+ _postprocess({ response }) {
43
+ // TODO: we can introduce response passes
44
+ return response.data;
45
+ }
46
+
47
+ }
@@ -0,0 +1,21 @@
1
+ export const GROUP = Object.freeze({
2
+ ASK: 'ask',
3
+ SEARCH: 'search',
4
+ RECOMMENDATION: 'recommendation',
5
+ INTERACTIONS: 'interactions',
6
+ });
7
+
8
+ export const NAME = Object.freeze({
9
+ QUESTIONS: 'questions',
10
+ RELATED_QUESTIONS: 'related_questions',
11
+ SEARCH: 'search',
12
+ AUTOCOMPLETE: 'autocomplete',
13
+ MGET: 'mget',
14
+ USER_TO_PRODUCTS: 'user_to_products',
15
+ USER_TO_CATEGORIES: 'user_to_categories',
16
+ USER_TO_ATTRIBUTES: 'user_to_attributes',
17
+ USER_TO_TRENDING: 'user_to_trending',
18
+ USER_TO_HISTORY: 'user_to_history',
19
+ PRODUCT_TO_PRODUCTS: 'product_to_products',
20
+ UPLOAD: 'upload',
21
+ });
@@ -1,41 +1,42 @@
1
1
  import { Bulk, trimObj } from '@miso.ai/commons';
2
- import { API } from '../constants';
2
+ import { API } from '../constants.js';
3
+
3
4
  export default class ApiHelpers {
5
+
4
6
  constructor(client, root) {
5
7
  this._client = client;
6
8
  this._root = root;
7
9
  this._bulk = new Bulk(this._runBulkFetch.bind(this), client._error.bind(client));
8
10
  }
9
- async fetch(url, payload) {
10
- let {
11
- method = 'POST',
12
- headers,
13
- timeout,
14
- sendApiKeyByHeader
15
- } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
16
- const {
17
- apiKey,
18
- request = {}
19
- } = this._client.options;
11
+
12
+ async fetch(url, payload, {
13
+ method = 'POST',
14
+ headers,
15
+ timeout,
16
+ sendApiKeyByHeader,
17
+ } = {}) {
18
+ const { apiKey, request = {} } = this._client.options;
20
19
  timeout = timeout || request.timeout;
21
20
  sendApiKeyByHeader = sendApiKeyByHeader || request.sendApiKeyByHeader;
21
+
22
22
  if (sendApiKeyByHeader) {
23
- headers = Object.assign({}, headers, {
24
- 'X-API-KEY': apiKey
25
- });
23
+ headers = { ...headers, 'X-API-KEY': apiKey };
26
24
  }
27
25
  // TODO: external abort signal
28
26
  // TODO: organize arguments
29
27
  const body = method !== 'GET' && payload != undefined ? JSON.stringify(payload) : undefined;
28
+
30
29
  const signal = timeout ? AbortSignal.timeout(timeout) : undefined;
31
- const res = await window.fetch(url, trimObj({
30
+
31
+ const res = await (this._root._customFetch || window.fetch)(url, trimObj({
32
32
  method,
33
33
  headers,
34
34
  body,
35
35
  cache: 'no-cache',
36
36
  mode: 'cors',
37
- signal
37
+ signal,
38
38
  }));
39
+
39
40
  const resBody = await res.json();
40
41
  if (res.status >= 400 || resBody.errors) {
41
42
  var err = new Error(resBody.message);
@@ -45,66 +46,40 @@ export default class ApiHelpers {
45
46
  }
46
47
  return resBody;
47
48
  }
49
+
48
50
  get bulkInfo() {
49
51
  return this._bulk.info;
50
52
  }
51
- async fetchForBulk(apiGroup, apiName, payload) {
52
- let {
53
- method
54
- } = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
53
+
54
+ async fetchForBulk(apiGroup, apiName, payload, { method } = {}) {
55
55
  if (method && method !== 'POST') {
56
56
  throw new Error(`Non-POST API is not supported in bulk mode: ${url}`);
57
57
  }
58
- return this._bulk.run({
59
- apiGroup,
60
- apiName,
61
- payload
62
- });
58
+ return this._bulk.run({ apiGroup, apiName, payload });
63
59
  }
60
+
64
61
  async _runBulkFetch(requests) {
65
62
  // TODO: request options?
66
63
  const url = this.url(['bulk']);
67
64
  const payload = {
68
- requests: requests.map(_ref => {
69
- let {
70
- action: {
71
- apiGroup,
72
- apiName,
73
- payload
74
- }
75
- } = _ref;
76
- return {
77
- api_name: `${apiGroup}/${apiName}`,
78
- body: payload
79
- };
80
- })
65
+ requests: requests.map(({ action: { apiGroup, apiName, payload } }) => ({
66
+ api_name: `${apiGroup}/${apiName}`,
67
+ body: payload,
68
+ })),
81
69
  };
82
- const {
83
- data: responses
84
- } = await this.fetch(url, payload);
70
+ const { data: responses } = await this.fetch(url, payload);
85
71
  for (let i = 0, len = requests.length; i < len; i++) {
86
- const {
87
- resolution
88
- } = requests[i];
89
- const {
90
- error,
91
- status_code,
92
- body
93
- } = responses[i];
72
+ const { resolution } = requests[i];
73
+ const { error, status_code, body } = responses[i];
94
74
  if (status_code >= 400 || error) {
95
- resolution.reject({
96
- status_code,
97
- body
98
- });
75
+ resolution.reject({ status_code, body });
99
76
  } else {
100
77
  resolution.resolve(body);
101
78
  }
102
79
  }
103
80
  }
104
- sendBeacon(url, payload) {
105
- let {
106
- method
107
- } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
81
+
82
+ sendBeacon(url, payload, { method } = {}) {
108
83
  if (method && method !== 'POST') {
109
84
  throw new Error(`Non-POST API is not supported in useBeacon mode: ${url}`);
110
85
  }
@@ -112,64 +87,45 @@ export default class ApiHelpers {
112
87
  throw new Error(`Send beacon unsuccessful: ${url}`);
113
88
  }
114
89
  }
115
- url(paths) {
116
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
117
- const {
118
- apiKey,
119
- request = {}
120
- } = this._client.options;
90
+
91
+ url(paths, options = {}) {
92
+ const { apiKey, request = {} } = this._client.options;
121
93
  const sendApiKeyByHeader = options.sendApiKeyByHeader || request.sendApiKeyByHeader;
122
94
  const apiName = paths.filter(s => s).join('/');
123
95
  const url = `${this.getApiEndpoint(apiName)}/${apiName}`;
124
96
  return sendApiKeyByHeader ? url : `${url}?api_key=${window.encodeURIComponent(apiKey)}`;
125
97
  }
98
+
126
99
  getApiEndpoint(apiName) {
127
100
  const {
128
101
  dataEndpoint = API.DATA_ENDPOINT,
129
- eventEndpoint = API.EVENT_ENDPOINT
102
+ eventEndpoint = API.EVENT_ENDPOINT,
130
103
  } = this._client.options;
131
104
  return apiName === 'interactions' ? eventEndpoint : dataEndpoint;
132
105
  }
133
- applyUrlPasses(component, _ref2) {
134
- let {
135
- apiGroup,
136
- apiName,
137
- url
138
- } = _ref2;
106
+
107
+ applyUrlPasses(component, { apiGroup, apiName, url }) {
139
108
  const client = this._client;
140
109
  for (const pass of this._root._urlPasses) {
141
110
  try {
142
- url = pass({
143
- client,
144
- apiGroup,
145
- apiName,
146
- url
147
- }) || url;
148
- } catch (e) {
111
+ url = pass({ client, apiGroup, apiName, url }) || url;
112
+ } catch(e) {
149
113
  component.error(e);
150
114
  }
151
115
  }
152
116
  return url;
153
117
  }
154
- applyPayloadPasses(component, _ref3) {
155
- let {
156
- apiGroup,
157
- apiName,
158
- payload
159
- } = _ref3;
118
+
119
+ applyPayloadPasses(component, { apiGroup, apiName, payload }) {
160
120
  const client = this._client;
161
121
  for (const pass of this._root._payloadPasses) {
162
122
  try {
163
- payload = pass({
164
- client,
165
- apiGroup,
166
- apiName,
167
- payload
168
- }) || payload;
169
- } catch (e) {
123
+ payload = pass({ client, apiGroup, apiName, payload }) || payload;
124
+ } catch(e) {
170
125
  component.error(e);
171
126
  }
172
127
  }
173
128
  return payload;
174
129
  }
175
- }
130
+
131
+ }
@@ -0,0 +1,8 @@
1
+ export { default as Api } from './api.js';
2
+ export { default as ApiBase } from './base.js';
3
+ export { default as ApiHelpers } from './helpers.js';
4
+ export { default as Interactions } from './interactions.js';
5
+ export { default as Ask } from './ask.js';
6
+ export { default as Search } from './search.js';
7
+ export { default as Recommendation } from './recommendation.js';
8
+ export * as constants from './constants.js';
@@ -0,0 +1,55 @@
1
+ import { GROUP, NAME } from './constants.js';
2
+ import ApiBase from './base.js';
3
+
4
+ export default class Interactions extends ApiBase {
5
+
6
+ constructor(api) {
7
+ super(api, GROUP.INTERACTIONS);
8
+ }
9
+
10
+ async upload(payload, options) {
11
+ try {
12
+ return await this._run(NAME.UPLOAD, payload, options);
13
+ } catch (e) {
14
+ if (e.status === 400 && e.message && e.message.toLowerCase().indexOf('playground') > -1) {
15
+ this._warn(`Ignore interactions uploaded to playground app.`);
16
+ } else {
17
+ throw e;
18
+ }
19
+ }
20
+ }
21
+
22
+ _url({ apiGroup, apiName, options }) {
23
+ const url = this.helpers.url([this._apiPath], options);
24
+ return this.helpers.applyUrlPasses(this, { apiGroup, apiName, url, options });
25
+ }
26
+
27
+ _preprocess({ apiGroup, apiName, payload }) {
28
+ if (apiName === NAME.UPLOAD) {
29
+ payload = this._normalizeUploadPayload(payload);
30
+ }
31
+ return super._preprocess({ apiGroup, apiName, payload });
32
+ }
33
+
34
+ _normalizeUploadPayload(payload) {
35
+ // TODO: accept string as a shortcut of { type: payload } as well
36
+ if (typeof payload !== 'object') {
37
+ throw new Error(`Interactions payload has to be either an object or an array of objects: ${payload}`);
38
+ }
39
+ if (!Array.isArray(payload)) {
40
+ payload = [payload];
41
+ }
42
+ return { data: payload };
43
+ }
44
+
45
+ async _send({ options: { useBeacon = true, ...options } = {}, ...args }) {
46
+ if (useBeacon) {
47
+ const { url, payload } = args;
48
+ this.helpers.sendBeacon(url, payload, options);
49
+ return {};
50
+ } else {
51
+ return super._send({ ...args, options });
52
+ }
53
+ }
54
+
55
+ }
@@ -0,0 +1,34 @@
1
+ import { GROUP, NAME } from './constants.js';
2
+ import ApiBase from './base.js';
3
+
4
+ export default class Recommendation extends ApiBase {
5
+
6
+ constructor(api) {
7
+ super(api, GROUP.RECOMMENDATION);
8
+ }
9
+
10
+ async userToProducts(payload, options) {
11
+ return this._run(NAME.USER_TO_PRODUCTS, payload, options);
12
+ }
13
+
14
+ async userToCategories(payload, options) {
15
+ return this._run(NAME.USER_TO_CATEGORIES, payload, options);
16
+ }
17
+
18
+ async userToAttributes(payload, options) {
19
+ return this._run(NAME.USER_TO_ATTRIBUTES, payload, options);
20
+ }
21
+
22
+ async userToTrending(payload, options) {
23
+ return this._run(NAME.USER_TO_TRENDING, payload, options);
24
+ }
25
+
26
+ async userToHistory(payload, options) {
27
+ return this._run(NAME.USER_TO_HISTORY, payload, options);
28
+ }
29
+
30
+ async productToProducts(payload, options) {
31
+ return this._run(NAME.PRODUCT_TO_PRODUCTS, payload, options);
32
+ }
33
+
34
+ }
@@ -0,0 +1,22 @@
1
+ import { GROUP, NAME } from './constants.js';
2
+ import ApiBase from './base.js';
3
+
4
+ export default class Search extends ApiBase {
5
+
6
+ constructor(api) {
7
+ super(api, GROUP.SEARCH);
8
+ }
9
+
10
+ async search(payload, options) {
11
+ return this._run(NAME.SEARCH, payload, options);
12
+ }
13
+
14
+ async autocomplete(payload, options) {
15
+ return this._run(NAME.AUTOCOMPLETE, payload, options);
16
+ }
17
+
18
+ async multipleGet(payload, options) {
19
+ return this._run(NAME.MGET, payload, options);
20
+ }
21
+
22
+ }
package/src/classes.js ADDED
@@ -0,0 +1,7 @@
1
+ import * as api from './api/index.js';
2
+ import Context from './context.js';
3
+
4
+ export default {
5
+ api,
6
+ context: { Context },
7
+ }
@@ -1,9 +1,11 @@
1
1
  import { trimObj, Component, uuidv4, defineValues } from '@miso.ai/commons';
2
2
  import { root, register, init } from './root';
3
- import Api from './api';
3
+ import { Api } from './api/index.js';
4
4
  import Context from './context';
5
5
  import * as helpers from './utils';
6
+
6
7
  class MisoClient extends Component {
8
+
7
9
  static attach() {
8
10
  (window.MisoClients || (window.MisoClients = [])).push(MisoClient);
9
11
  if (window.MisoClient) {
@@ -15,48 +17,61 @@ class MisoClient extends Component {
15
17
  }
16
18
  window.MisoClient = MisoClient;
17
19
  }
20
+
18
21
  constructor(options) {
19
22
  super('client', root);
20
23
  this._config(options);
24
+
21
25
  this.context = new Context(this);
22
26
  this.api = new Api(this, root);
27
+
23
28
  register(this);
24
29
  }
30
+
25
31
  get version() {
26
32
  return MisoClient.version;
27
33
  }
34
+
28
35
  _config(options) {
29
36
  this.options = Object.freeze(this._normalizeOptions(options));
30
37
  }
31
- _normalizeOptions() {
32
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
38
+
39
+ _normalizeOptions(options = {}) {
33
40
  if (typeof options === 'string') {
34
- options = {
35
- apiKey: options
36
- };
41
+ options = { apiKey: options };
37
42
  }
38
43
  if (options.readConfigFromScriptUrl) {
39
- options = Object.assign({}, this._readConfigFromScriptUrl(), options);
44
+ options = {
45
+ ...this._readConfigFromScriptUrl(),
46
+ ...options,
47
+ };
40
48
  }
41
49
  if (!options.apiKey) {
42
50
  throw new Error('Require API key to initialize miso client.');
43
51
  }
52
+
44
53
  options.dataEndpoint = options.dataEndpoint || options.apiHost;
45
54
  options.eventEndpoint = options.eventEndpoint || options.apiHost;
46
55
  delete options.apiHost;
56
+
47
57
  return trimObj(options);
48
58
  }
59
+
49
60
  _readConfigFromScriptUrl() {
50
61
  const me = document.currentScript;
51
62
  const url = me.src || me.href; // might be <link> as well
52
63
  const params = new URL(new Request(url).url).searchParams;
53
64
  return trimObj({
54
- apiKey: params.get('api_key') || undefined
65
+ apiKey: params.get('api_key') || undefined,
55
66
  });
56
67
  }
68
+
57
69
  }
70
+
58
71
  MisoClient.helpers = helpers;
72
+
59
73
  defineValues(MisoClient, {
60
- uuid: uuidv4()
74
+ uuid: uuidv4(),
61
75
  });
62
- export default init(MisoClient);
76
+
77
+ export default init(MisoClient);
@@ -5,22 +5,21 @@ function execute(onError, fn) {
5
5
  onError(e);
6
6
  }
7
7
  }
8
- export default function (key) {
9
- let onError = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : e => console.error(e);
8
+
9
+ export default function(key, onError = e => console.error(e)) {
10
10
  const cmds = window[key] || (window[key] = []);
11
11
  if (cmds._processed) {
12
12
  return;
13
13
  }
14
14
  cmds._processed = true;
15
- const exec = fn => execute(onError, fn);
16
15
 
16
+ const exec = fn => execute(onError, fn);
17
+
17
18
  // overrides push function so future commands are executed immediately
18
- Object.defineProperty(cmds, 'push', {
19
- value: exec
20
- });
21
-
19
+ Object.defineProperty(cmds, 'push', { value: exec });
20
+
22
21
  // process existing miso commands
23
22
  for (const fn of cmds) {
24
23
  exec(fn);
25
24
  }
26
- }
25
+ }
@@ -0,0 +1,4 @@
1
+ export const API = Object.freeze({
2
+ DATA_ENDPOINT: 'https://api-edge.askmiso.com/v1',
3
+ EVENT_ENDPOINT: 'https://api.askmiso.com/v1',
4
+ });
@@ -1,7 +1,10 @@
1
1
  import { Component } from '@miso.ai/commons';
2
+
2
3
  export default class Context extends Component {
4
+
3
5
  constructor(client) {
4
6
  super('context', client);
5
7
  this._client = client;
6
8
  }
7
- }
9
+
10
+ }
package/src/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export { default as version } from './version.js';
2
+ export { default as MisoClient } from './client.js';
3
+ export { constants as API } from './api/index.js';
4
+ export * from './plugin/index.js';
@@ -1,8 +1,9 @@
1
1
  import { defineValues } from '@miso.ai/commons';
2
+
2
3
  export default class AnonymousPlugin {
4
+
3
5
  constructor(install) {
4
- defineValues(this, {
5
- install
6
- });
6
+ defineValues(this, { install });
7
7
  }
8
- }
8
+
9
+ }