@miso.ai/client-sdk-core 1.8.0 → 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.
- package/dist/cjs/api/ask.js +4 -0
- package/dist/cjs/api/constants.js +1 -0
- package/dist/cjs/api/helpers.js +1 -1
- package/dist/cjs/plugin/plugin-root.js +10 -1
- package/dist/cjs/root.js +1 -0
- package/dist/cjs/version.js +1 -1
- package/package.json +2 -2
- package/src/api/ask.js +4 -0
- package/src/api/constants.js +1 -0
- package/src/api/helpers.js +1 -1
- package/src/plugin/plugin-root.js +11 -1
- package/src/root.js +1 -0
- package/src/version.js +1 -1
package/dist/cjs/api/ask.js
CHANGED
|
@@ -32,6 +32,10 @@ class Ask extends _base.default {
|
|
|
32
32
|
method: 'GET'
|
|
33
33
|
}));
|
|
34
34
|
}
|
|
35
|
+
async relatedQuestions(payload) {
|
|
36
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
37
|
+
return this._run(_constants.NAME.RELATED_QUESTIONS, payload, options);
|
|
38
|
+
}
|
|
35
39
|
}
|
|
36
40
|
exports.default = Ask;
|
|
37
41
|
class Answer {
|
package/dist/cjs/api/helpers.js
CHANGED
|
@@ -34,7 +34,7 @@ class ApiHelpers {
|
|
|
34
34
|
// TODO: organize arguments
|
|
35
35
|
const body = method !== 'GET' && payload != undefined ? JSON.stringify(payload) : undefined;
|
|
36
36
|
const signal = timeout ? AbortSignal.timeout(timeout) : undefined;
|
|
37
|
-
const res = await window.fetch(url, (0, _commons.trimObj)({
|
|
37
|
+
const res = await (this._root._customFetch || window.fetch)(url, (0, _commons.trimObj)({
|
|
38
38
|
method,
|
|
39
39
|
headers,
|
|
40
40
|
body,
|
|
@@ -71,6 +71,9 @@ class PluginRoot extends _commons.Registry {
|
|
|
71
71
|
return this.whenInstalled(plugin);
|
|
72
72
|
}
|
|
73
73
|
async whenInstalled(id) {
|
|
74
|
+
if (typeof id === 'function' && id.id && typeof id.id === 'string') {
|
|
75
|
+
id = id.id;
|
|
76
|
+
}
|
|
74
77
|
if (this.isInstalled(id)) {
|
|
75
78
|
return this.get(id);
|
|
76
79
|
}
|
|
@@ -95,6 +98,12 @@ class PluginRoot extends _commons.Registry {
|
|
|
95
98
|
}
|
|
96
99
|
this._root._urlPasses.push(pass);
|
|
97
100
|
}
|
|
101
|
+
setCustomFetch(fetch) {
|
|
102
|
+
if (typeof fetch !== 'function') {
|
|
103
|
+
throw new Error(`Expect parameter to be a function: ${fetch}`);
|
|
104
|
+
}
|
|
105
|
+
this._root._customFetch = fetch;
|
|
106
|
+
}
|
|
98
107
|
_tryConfig(instance, options) {
|
|
99
108
|
if (options === undefined) {
|
|
100
109
|
return;
|
|
@@ -206,7 +215,7 @@ class PluginRoot extends _commons.Registry {
|
|
|
206
215
|
exports.default = PluginRoot;
|
|
207
216
|
class PluginContext {
|
|
208
217
|
constructor(root, classes) {
|
|
209
|
-
(0, _commons.delegateGetters)(this, root, ['getPluginClass', 'addSubtree', 'addPayloadPass', 'addUrlPass', 'whenInstalled', 'whenRegistered']);
|
|
218
|
+
(0, _commons.delegateGetters)(this, root, ['getPluginClass', 'addSubtree', 'addPayloadPass', 'addUrlPass', 'setCustomFetch', 'whenInstalled', 'whenRegistered']);
|
|
210
219
|
(0, _commons.defineValues)(this, {
|
|
211
220
|
classes
|
|
212
221
|
});
|
package/dist/cjs/root.js
CHANGED
package/dist/cjs/version.js
CHANGED
package/package.json
CHANGED
package/src/api/ask.js
CHANGED
|
@@ -24,6 +24,10 @@ export default class Ask extends ApiBase {
|
|
|
24
24
|
return this._run(`${NAME.QUESTIONS}/${questionId}/answer`, undefined, { ...options, method: 'GET' });
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
async relatedQuestions(payload, options = {}) {
|
|
28
|
+
return this._run(NAME.RELATED_QUESTIONS, payload, options);
|
|
29
|
+
}
|
|
30
|
+
|
|
27
31
|
}
|
|
28
32
|
|
|
29
33
|
class Answer {
|
package/src/api/constants.js
CHANGED
package/src/api/helpers.js
CHANGED
|
@@ -28,7 +28,7 @@ export default class ApiHelpers {
|
|
|
28
28
|
|
|
29
29
|
const signal = timeout ? AbortSignal.timeout(timeout) : undefined;
|
|
30
30
|
|
|
31
|
-
const res = await window.fetch(url, trimObj({
|
|
31
|
+
const res = await (this._root._customFetch || window.fetch)(url, trimObj({
|
|
32
32
|
method,
|
|
33
33
|
headers,
|
|
34
34
|
body,
|
|
@@ -72,6 +72,9 @@ export default class PluginRoot extends Registry {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
async whenInstalled(id) {
|
|
75
|
+
if (typeof id === 'function' && id.id && typeof id.id === 'string') {
|
|
76
|
+
id = id.id;
|
|
77
|
+
}
|
|
75
78
|
if (this.isInstalled(id)) {
|
|
76
79
|
return this.get(id);
|
|
77
80
|
}
|
|
@@ -98,6 +101,13 @@ export default class PluginRoot extends Registry {
|
|
|
98
101
|
this._root._urlPasses.push(pass);
|
|
99
102
|
}
|
|
100
103
|
|
|
104
|
+
setCustomFetch(fetch) {
|
|
105
|
+
if (typeof fetch !== 'function') {
|
|
106
|
+
throw new Error(`Expect parameter to be a function: ${fetch}`);
|
|
107
|
+
}
|
|
108
|
+
this._root._customFetch = fetch;
|
|
109
|
+
}
|
|
110
|
+
|
|
101
111
|
_tryConfig(instance, options) {
|
|
102
112
|
if (options === undefined) {
|
|
103
113
|
return;
|
|
@@ -212,7 +222,7 @@ export default class PluginRoot extends Registry {
|
|
|
212
222
|
class PluginContext {
|
|
213
223
|
|
|
214
224
|
constructor(root, classes) {
|
|
215
|
-
delegateGetters(this, root, ['getPluginClass', 'addSubtree', 'addPayloadPass', 'addUrlPass', 'whenInstalled', 'whenRegistered']);
|
|
225
|
+
delegateGetters(this, root, ['getPluginClass', 'addSubtree', 'addPayloadPass', 'addUrlPass', 'setCustomFetch', 'whenInstalled', 'whenRegistered']);
|
|
216
226
|
defineValues(this, { classes });
|
|
217
227
|
}
|
|
218
228
|
|
package/src/root.js
CHANGED
package/src/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '1.8.0';
|
|
1
|
+
export default '1.8.1-beta.0';
|