@miso.ai/client-sdk-core 1.10.0-beta.0 → 1.10.0-beta.2
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/plugin/user.js +36 -1
- package/dist/cjs/utils.js +6 -0
- package/dist/cjs/version.js +1 -1
- package/package.json +2 -2
- package/src/plugin/user.js +28 -3
- package/src/utils.js +1 -1
- package/src/version.js +1 -1
package/dist/cjs/plugin/user.js
CHANGED
|
@@ -5,6 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _commons = require("@miso.ai/commons");
|
|
8
|
+
const {
|
|
9
|
+
GROUP,
|
|
10
|
+
NAME
|
|
11
|
+
} = _commons.API;
|
|
8
12
|
const PLUGIN_ID = 'std:user';
|
|
9
13
|
class UserPlugin extends _commons.Component {
|
|
10
14
|
static get id() {
|
|
@@ -31,7 +35,13 @@ class UserPlugin extends _commons.Component {
|
|
|
31
35
|
apiName,
|
|
32
36
|
payload
|
|
33
37
|
} = _ref;
|
|
34
|
-
|
|
38
|
+
if (apiGroup === GROUP.INTERACTIONS && apiName === NAME.UPLOAD) {
|
|
39
|
+
return this._modifyPayloadForInteractions(client, payload);
|
|
40
|
+
}
|
|
41
|
+
if (apiGroup === GROUP.ASK && apiName === NAME.QUESTIONS) {
|
|
42
|
+
return this._modifyPayloadForAsk(client, payload);
|
|
43
|
+
}
|
|
44
|
+
return this._modifyPayloadForOthers(client, payload);
|
|
35
45
|
}
|
|
36
46
|
_modifyPayloadForOthers(client, payload) {
|
|
37
47
|
const {
|
|
@@ -47,6 +57,24 @@ class UserPlugin extends _commons.Component {
|
|
|
47
57
|
};
|
|
48
58
|
return Object.assign({}, userInfo, payload);
|
|
49
59
|
}
|
|
60
|
+
_modifyPayloadForAsk(client, payload) {
|
|
61
|
+
const {
|
|
62
|
+
user_id,
|
|
63
|
+
user_hash,
|
|
64
|
+
user_type,
|
|
65
|
+
anonymous_id
|
|
66
|
+
} = client.context;
|
|
67
|
+
const userInfo = user_id ? {
|
|
68
|
+
user_id,
|
|
69
|
+
user_hash
|
|
70
|
+
} : {
|
|
71
|
+
anonymous_id
|
|
72
|
+
};
|
|
73
|
+
if (user_id && user_type) {
|
|
74
|
+
userInfo.user_type = user_type;
|
|
75
|
+
}
|
|
76
|
+
return Object.assign({}, userInfo, payload);
|
|
77
|
+
}
|
|
50
78
|
_modifyPayloadForInteractions(client, _ref2) {
|
|
51
79
|
let {
|
|
52
80
|
data
|
|
@@ -99,4 +127,11 @@ class UserContext {
|
|
|
99
127
|
this._userHash = value;
|
|
100
128
|
this._plugin._events.emit('set', `user_hash = '${value}'`);
|
|
101
129
|
}
|
|
130
|
+
get user_type() {
|
|
131
|
+
return this._userType;
|
|
132
|
+
}
|
|
133
|
+
set user_type(value) {
|
|
134
|
+
this._userType = value;
|
|
135
|
+
this._plugin._events.emit('set', `user_type = '${value}'`);
|
|
136
|
+
}
|
|
102
137
|
}
|
package/dist/cjs/utils.js
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
Object.defineProperty(exports, "debounce", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _commons.debounce;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
6
12
|
Object.defineProperty(exports, "viewable", {
|
|
7
13
|
enumerable: true,
|
|
8
14
|
get: function () {
|
package/dist/cjs/version.js
CHANGED
package/package.json
CHANGED
package/src/plugin/user.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { uuidv4, asString, trimObj, Component, delegateProperties, getOrComputeFromStorage } from '@miso.ai/commons';
|
|
1
|
+
import { API, uuidv4, asString, trimObj, Component, delegateProperties, getOrComputeFromStorage } from '@miso.ai/commons';
|
|
2
|
+
|
|
3
|
+
const { GROUP, NAME } = API;
|
|
2
4
|
|
|
3
5
|
const PLUGIN_ID = 'std:user';
|
|
4
6
|
|
|
@@ -26,8 +28,13 @@ export default class UserPlugin extends Component {
|
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
_modifyPayload({ client, apiGroup, apiName, payload }) {
|
|
29
|
-
|
|
30
|
-
this._modifyPayloadForInteractions(client, payload)
|
|
31
|
+
if (apiGroup === GROUP.INTERACTIONS && apiName === NAME.UPLOAD) {
|
|
32
|
+
return this._modifyPayloadForInteractions(client, payload);
|
|
33
|
+
}
|
|
34
|
+
if (apiGroup === GROUP.ASK && apiName === NAME.QUESTIONS) {
|
|
35
|
+
return this._modifyPayloadForAsk(client, payload);
|
|
36
|
+
}
|
|
37
|
+
return this._modifyPayloadForOthers(client, payload);
|
|
31
38
|
}
|
|
32
39
|
|
|
33
40
|
_modifyPayloadForOthers(client, payload) {
|
|
@@ -36,6 +43,15 @@ export default class UserPlugin extends Component {
|
|
|
36
43
|
return { ...userInfo, ...payload };
|
|
37
44
|
}
|
|
38
45
|
|
|
46
|
+
_modifyPayloadForAsk(client, payload) {
|
|
47
|
+
const { user_id, user_hash, user_type, anonymous_id } = client.context;
|
|
48
|
+
const userInfo = user_id ? { user_id, user_hash } : { anonymous_id };
|
|
49
|
+
if (user_id && user_type) {
|
|
50
|
+
userInfo.user_type = user_type;
|
|
51
|
+
}
|
|
52
|
+
return { ...userInfo, ...payload };
|
|
53
|
+
}
|
|
54
|
+
|
|
39
55
|
_modifyPayloadForInteractions(client, { data }) {
|
|
40
56
|
const { anonymous_id, user_id } = client.context;
|
|
41
57
|
const baseObj = trimObj({ anonymous_id, user_id });
|
|
@@ -87,4 +103,13 @@ class UserContext {
|
|
|
87
103
|
this._plugin._events.emit('set', `user_hash = '${value}'`);
|
|
88
104
|
}
|
|
89
105
|
|
|
106
|
+
get user_type() {
|
|
107
|
+
return this._userType;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
set user_type(value) {
|
|
111
|
+
this._userType = value;
|
|
112
|
+
this._plugin._events.emit('set', `user_type = '${value}'`);
|
|
113
|
+
}
|
|
114
|
+
|
|
90
115
|
}
|
package/src/utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { viewable } from '@miso.ai/commons';
|
|
1
|
+
export { viewable, debounce } from '@miso.ai/commons';
|
package/src/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '1.10.0-beta.
|
|
1
|
+
export default '1.10.0-beta.2';
|