@miso.ai/client-sdk-core 1.7.2 → 1.7.3-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 +57 -51
- package/dist/cjs/version.js +1 -1
- package/dist/es/api/ask.js +56 -50
- package/dist/es/version.js +1 -1
- package/package.json +2 -2
package/dist/cjs/api/ask.js
CHANGED
|
@@ -14,70 +14,76 @@ class Ask extends _base.default {
|
|
|
14
14
|
constructor(api) {
|
|
15
15
|
super(api, 'ask');
|
|
16
16
|
}
|
|
17
|
-
questions(payload) {
|
|
17
|
+
async questions(payload) {
|
|
18
18
|
let _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
19
19
|
let {
|
|
20
20
|
iterable = false
|
|
21
21
|
} = _ref,
|
|
22
22
|
options = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
23
|
-
|
|
24
|
-
return
|
|
23
|
+
const response = await this._run('questions', payload, options);
|
|
24
|
+
return new Answer(this, response);
|
|
25
25
|
}
|
|
26
26
|
async _questions(payload, options) {
|
|
27
27
|
return this._run('questions', payload, options);
|
|
28
28
|
}
|
|
29
|
-
async _get(
|
|
30
|
-
return this._run(`questions/${
|
|
29
|
+
async _get(questionId, options) {
|
|
30
|
+
return this._run(`questions/${questionId}/answer`, undefined, Object.assign({}, options, {
|
|
31
31
|
method: 'GET'
|
|
32
32
|
}));
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (
|
|
50
|
-
|
|
34
|
+
_iterable(questionId) {
|
|
35
|
+
let _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
36
|
+
let {
|
|
37
|
+
pollingInternal = 500
|
|
38
|
+
} = _ref2,
|
|
39
|
+
options = _objectWithoutPropertiesLoose(_ref2, _excluded2);
|
|
40
|
+
// TODO: abort signal
|
|
41
|
+
let apiErrorCount = 0;
|
|
42
|
+
const buffer = new _commons.ValueBuffer();
|
|
43
|
+
const intervalId = setInterval(async () => {
|
|
44
|
+
let response;
|
|
45
|
+
try {
|
|
46
|
+
response = await this._get(questionId, options);
|
|
47
|
+
} catch (error) {
|
|
48
|
+
apiErrorCount++;
|
|
49
|
+
if (apiErrorCount > 10) {
|
|
50
|
+
clearInterval(intervalId);
|
|
51
|
+
// TODO: cascade to buffer and user
|
|
51
52
|
}
|
|
52
|
-
let apiErrorCount = 0;
|
|
53
|
-
const buffer = new _commons.ValueBuffer();
|
|
54
|
-
const intervalId = setInterval(async () => {
|
|
55
|
-
let response;
|
|
56
|
-
try {
|
|
57
|
-
response = await _this._get(question_id, options);
|
|
58
|
-
} catch (error) {
|
|
59
|
-
apiErrorCount++;
|
|
60
|
-
if (apiErrorCount > 10) {
|
|
61
|
-
clearInterval(intervalId);
|
|
62
|
-
// TODO: cascade to buffer and user
|
|
63
|
-
}
|
|
64
53
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}();
|
|
78
|
-
} catch (e) {
|
|
79
|
-
return Promise.reject(e);
|
|
80
|
-
}
|
|
54
|
+
console.error(error); // TODO
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const {
|
|
58
|
+
finished
|
|
59
|
+
} = response;
|
|
60
|
+
buffer.update(response, finished);
|
|
61
|
+
if (response.finished) {
|
|
62
|
+
clearInterval(intervalId);
|
|
63
|
+
}
|
|
64
|
+
}, pollingInternal);
|
|
65
|
+
return buffer;
|
|
81
66
|
}
|
|
82
67
|
}
|
|
83
|
-
exports.default = Ask;
|
|
68
|
+
exports.default = Ask;
|
|
69
|
+
class Answer {
|
|
70
|
+
constructor(api, _ref3) {
|
|
71
|
+
let {
|
|
72
|
+
question_id
|
|
73
|
+
} = _ref3;
|
|
74
|
+
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
75
|
+
this._api = api;
|
|
76
|
+
this._id = question_id;
|
|
77
|
+
this._options = options;
|
|
78
|
+
}
|
|
79
|
+
get id() {
|
|
80
|
+
return this._id;
|
|
81
|
+
}
|
|
82
|
+
async get(options) {
|
|
83
|
+
options = Object.assign({}, this._options, options);
|
|
84
|
+
return this._api._get(this._id, options);
|
|
85
|
+
}
|
|
86
|
+
[Symbol.asyncIterator]() {
|
|
87
|
+
return this._api._iterable(this._id, this._options)[Symbol.asyncIterator]();
|
|
88
|
+
}
|
|
89
|
+
}
|
package/dist/cjs/version.js
CHANGED
package/dist/es/api/ask.js
CHANGED
|
@@ -7,69 +7,75 @@ export default class Ask extends ApiBase {
|
|
|
7
7
|
constructor(api) {
|
|
8
8
|
super(api, 'ask');
|
|
9
9
|
}
|
|
10
|
-
questions(payload) {
|
|
10
|
+
async questions(payload) {
|
|
11
11
|
let _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
12
12
|
let {
|
|
13
13
|
iterable = false
|
|
14
14
|
} = _ref,
|
|
15
15
|
options = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
16
|
-
|
|
17
|
-
return
|
|
16
|
+
const response = await this._run('questions', payload, options);
|
|
17
|
+
return new Answer(this, response);
|
|
18
18
|
}
|
|
19
19
|
async _questions(payload, options) {
|
|
20
20
|
return this._run('questions', payload, options);
|
|
21
21
|
}
|
|
22
|
-
async _get(
|
|
23
|
-
return this._run(`questions/${
|
|
22
|
+
async _get(questionId, options) {
|
|
23
|
+
return this._run(`questions/${questionId}/answer`, undefined, Object.assign({}, options, {
|
|
24
24
|
method: 'GET'
|
|
25
25
|
}));
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if (
|
|
43
|
-
|
|
27
|
+
_iterable(questionId) {
|
|
28
|
+
let _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
29
|
+
let {
|
|
30
|
+
pollingInternal = 500
|
|
31
|
+
} = _ref2,
|
|
32
|
+
options = _objectWithoutPropertiesLoose(_ref2, _excluded2);
|
|
33
|
+
// TODO: abort signal
|
|
34
|
+
let apiErrorCount = 0;
|
|
35
|
+
const buffer = new ValueBuffer();
|
|
36
|
+
const intervalId = setInterval(async () => {
|
|
37
|
+
let response;
|
|
38
|
+
try {
|
|
39
|
+
response = await this._get(questionId, options);
|
|
40
|
+
} catch (error) {
|
|
41
|
+
apiErrorCount++;
|
|
42
|
+
if (apiErrorCount > 10) {
|
|
43
|
+
clearInterval(intervalId);
|
|
44
|
+
// TODO: cascade to buffer and user
|
|
44
45
|
}
|
|
45
|
-
let apiErrorCount = 0;
|
|
46
|
-
const buffer = new ValueBuffer();
|
|
47
|
-
const intervalId = setInterval(async () => {
|
|
48
|
-
let response;
|
|
49
|
-
try {
|
|
50
|
-
response = await _this._get(question_id, options);
|
|
51
|
-
} catch (error) {
|
|
52
|
-
apiErrorCount++;
|
|
53
|
-
if (apiErrorCount > 10) {
|
|
54
|
-
clearInterval(intervalId);
|
|
55
|
-
// TODO: cascade to buffer and user
|
|
56
|
-
}
|
|
57
46
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
47
|
+
console.error(error); // TODO
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const {
|
|
51
|
+
finished
|
|
52
|
+
} = response;
|
|
53
|
+
buffer.update(response, finished);
|
|
54
|
+
if (response.finished) {
|
|
55
|
+
clearInterval(intervalId);
|
|
56
|
+
}
|
|
57
|
+
}, pollingInternal);
|
|
58
|
+
return buffer;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
class Answer {
|
|
62
|
+
constructor(api, _ref3) {
|
|
63
|
+
let {
|
|
64
|
+
question_id
|
|
65
|
+
} = _ref3;
|
|
66
|
+
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
67
|
+
this._api = api;
|
|
68
|
+
this._id = question_id;
|
|
69
|
+
this._options = options;
|
|
70
|
+
}
|
|
71
|
+
get id() {
|
|
72
|
+
return this._id;
|
|
73
|
+
}
|
|
74
|
+
async get(options) {
|
|
75
|
+
options = Object.assign({}, this._options, options);
|
|
76
|
+
return this._api._get(this._id, options);
|
|
77
|
+
}
|
|
78
|
+
[Symbol.asyncIterator]() {
|
|
79
|
+
return this._api._iterable(this._id, this._options)[Symbol.asyncIterator]();
|
|
74
80
|
}
|
|
75
81
|
}
|
package/dist/es/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '1.7.
|
|
1
|
+
export default '1.7.3-beta.0';
|