@miso.ai/client-sdk-dev-tool 1.8.0-beta.11 → 1.8.0-beta.13
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/index.js +2 -2
- package/package.json +9 -9
- package/{dist/es → src}/debug.js +46 -56
- package/{dist/es → src}/dry-run.js +10 -13
- package/src/index.js +2 -0
- package/dist/es/index.js +0 -2
package/dist/cjs/index.js
CHANGED
|
@@ -15,6 +15,6 @@ Object.defineProperty(exports, "DryRunPlugin", {
|
|
|
15
15
|
return _dryRun.default;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
var _debug = _interopRequireDefault(require("./debug"));
|
|
19
|
-
var _dryRun = _interopRequireDefault(require("./dry-run"));
|
|
18
|
+
var _debug = _interopRequireDefault(require("./debug.js"));
|
|
19
|
+
var _dryRun = _interopRequireDefault(require("./dry-run.js"));
|
|
20
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@miso.ai/client-sdk-dev-tool",
|
|
3
3
|
"description": "Dev tool plugins for Miso JavaScript client SDK.",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"main": "dist/cjs/index.js",
|
|
5
|
-
"module": "
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
|
|
6
|
+
"module": "src/index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
"import": "./src/index.js",
|
|
9
|
+
"require": "./dist/cjs/index.js"
|
|
10
|
+
},
|
|
9
11
|
"publishConfig": {
|
|
10
12
|
"access": "public"
|
|
11
13
|
},
|
|
12
14
|
"scripts": {
|
|
13
|
-
"start": "npx babel src --root-mode upward --out-dir dist/es --watch",
|
|
14
15
|
"build:clean": "npx rimraf dist",
|
|
15
|
-
"build:esm": "npx babel src --root-mode upward --out-dir dist/es",
|
|
16
16
|
"build:cjs": "BABEL_ENV=cjs npx babel src --root-mode upward --out-dir dist/cjs",
|
|
17
|
-
"build": "npm run build:clean && npm run build:
|
|
17
|
+
"build": "npm run build:clean && npm run build:cjs"
|
|
18
18
|
},
|
|
19
19
|
"repository": "MisoAI/miso-client-js-sdk",
|
|
20
20
|
"homepage": "https://misoai.github.io/miso-client-js-sdk",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"url": "https://github.com/MisoAI/miso-client-js-sdk/issues"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@miso.ai/commons": "1.8.0-beta.
|
|
29
|
+
"@miso.ai/commons": "1.8.0-beta.13"
|
|
30
30
|
},
|
|
31
|
-
"version": "1.8.0-beta.
|
|
31
|
+
"version": "1.8.0-beta.13"
|
|
32
32
|
}
|
package/{dist/es → src}/debug.js
RENAMED
|
@@ -1,36 +1,34 @@
|
|
|
1
|
-
const _excluded = ["groupName", "apiName", "url", "bulk"];
|
|
2
|
-
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; }
|
|
3
1
|
const ID = 'std:debug';
|
|
2
|
+
|
|
4
3
|
export default class DebugPlugin {
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
|
|
5
|
+
constructor(options = {}) {
|
|
7
6
|
this._options = options;
|
|
8
7
|
}
|
|
8
|
+
|
|
9
9
|
static get id() {
|
|
10
10
|
return ID;
|
|
11
11
|
}
|
|
12
|
+
|
|
12
13
|
install(MisoClient) {
|
|
13
|
-
var _this = this;
|
|
14
14
|
this._injectComponents(MisoClient);
|
|
15
|
-
MisoClient.debug =
|
|
16
|
-
return _this._logr(...arguments);
|
|
17
|
-
};
|
|
15
|
+
MisoClient.debug = (...args) => this._logr(...args);
|
|
18
16
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
this._options =
|
|
17
|
+
|
|
18
|
+
config(options = {}) {
|
|
19
|
+
this._options = {
|
|
20
|
+
...this._options,
|
|
21
|
+
...options,
|
|
22
|
+
}
|
|
22
23
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
component.on('child', c => this._injectComponents(c, treePath));
|
|
26
|
-
component.on('subtree', c => this._injectComponents(c, treePath.concat(component.meta.path)));
|
|
24
|
+
|
|
25
|
+
_injectComponents(component, treePath = []) {
|
|
26
|
+
component.on('child', (c) => this._injectComponents(c, treePath));
|
|
27
|
+
component.on('subtree', (c) => this._injectComponents(c, treePath.concat(component.meta.path)));
|
|
27
28
|
component.on('*', (data, meta) => this._handleEvent(component, meta, data, treePath));
|
|
28
29
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
name
|
|
32
|
-
} = _ref;
|
|
33
|
-
let treePath = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
|
|
30
|
+
|
|
31
|
+
_handleEvent(component, { name }, data, treePath = []) {
|
|
34
32
|
if (name === 'child' || name === 'subtree') {
|
|
35
33
|
return;
|
|
36
34
|
}
|
|
@@ -46,9 +44,7 @@ export default class DebugPlugin {
|
|
|
46
44
|
case 'client':
|
|
47
45
|
switch (path[1]) {
|
|
48
46
|
case 'api':
|
|
49
|
-
this._handleApiEvent(name,
|
|
50
|
-
groupName: path[2]
|
|
51
|
-
}));
|
|
47
|
+
this._handleApiEvent(name, { ...data, groupName: path[2] });
|
|
52
48
|
return;
|
|
53
49
|
}
|
|
54
50
|
break;
|
|
@@ -62,32 +58,30 @@ export default class DebugPlugin {
|
|
|
62
58
|
}
|
|
63
59
|
this._logw(path.join('.'), name, data);
|
|
64
60
|
}
|
|
61
|
+
|
|
65
62
|
_handleCreateClient(eventName, data) {
|
|
66
63
|
this._logw('client', eventName, data);
|
|
67
64
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
groupName,
|
|
71
|
-
url,
|
|
72
|
-
bulk
|
|
73
|
-
} = _ref2,
|
|
74
|
-
data = _objectWithoutPropertiesLoose(_ref2, _excluded);
|
|
65
|
+
|
|
66
|
+
_handleApiEvent(eventName, { groupName, apiName, url, bulk, ...data }) {
|
|
75
67
|
const pathname = new URL(url).pathname;
|
|
76
68
|
const args = ['api', eventName];
|
|
69
|
+
|
|
77
70
|
bulk && args.push(`(bulk ${bulk.bulkId})`);
|
|
71
|
+
|
|
78
72
|
args.push(`POST ${pathname}`);
|
|
73
|
+
|
|
79
74
|
if (groupName === 'interactions') {
|
|
80
75
|
// TODO: handle multiple interactions
|
|
81
|
-
const {
|
|
82
|
-
type
|
|
83
|
-
} = data.payload.data[0];
|
|
76
|
+
const { type } = data.payload.data[0];
|
|
84
77
|
args.push(type);
|
|
85
78
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
79
|
+
|
|
80
|
+
args.push([{ ...data, url }]);
|
|
81
|
+
|
|
89
82
|
this._log(...args);
|
|
90
83
|
}
|
|
84
|
+
|
|
91
85
|
_handlePluginsEvent(eventName, plugin) {
|
|
92
86
|
let data = [];
|
|
93
87
|
if (Array.isArray(plugin)) {
|
|
@@ -96,30 +90,29 @@ export default class DebugPlugin {
|
|
|
96
90
|
}
|
|
97
91
|
this._log('plugins', eventName, `${plugin.id || '(anonymous)'}`, [plugin, ...data]);
|
|
98
92
|
}
|
|
93
|
+
|
|
99
94
|
_handlePluginSpecificEvent(pluginId, path, name, data) {
|
|
100
95
|
this._logw([pluginId, path.join('.')], name, data);
|
|
101
96
|
}
|
|
97
|
+
|
|
102
98
|
_getPath(component) {
|
|
103
99
|
const path = [];
|
|
104
100
|
for (let c = component; c; c = c.meta.parent) {
|
|
105
|
-
c.meta.name && path.push(c.meta.name)
|
|
101
|
+
c.meta.name && path.push(c.meta.name)
|
|
106
102
|
}
|
|
107
103
|
return path.reverse();
|
|
108
104
|
}
|
|
109
|
-
|
|
105
|
+
|
|
106
|
+
_logr(...data) {
|
|
110
107
|
const options = this._options.console || {};
|
|
111
|
-
for (var _len = arguments.length, data = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
112
|
-
data[_key] = arguments[_key];
|
|
113
|
-
}
|
|
114
108
|
console.log(_tag(options), _style(options), ...data);
|
|
115
109
|
}
|
|
116
|
-
|
|
110
|
+
|
|
111
|
+
_log(path, name, ...data) {
|
|
117
112
|
const options = this._options.console || {};
|
|
118
|
-
for (var _len2 = arguments.length, data = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
|
119
|
-
data[_key2 - 2] = arguments[_key2];
|
|
120
|
-
}
|
|
121
113
|
console.log(_tag(options), _style(options), _path(path), _name(name), ...data);
|
|
122
114
|
}
|
|
115
|
+
|
|
123
116
|
_logw(path, name, data) {
|
|
124
117
|
if (data === undefined) {
|
|
125
118
|
this._log(path, name);
|
|
@@ -129,18 +122,14 @@ export default class DebugPlugin {
|
|
|
129
122
|
this._log(path, name, _wrapObj(data));
|
|
130
123
|
}
|
|
131
124
|
}
|
|
125
|
+
|
|
132
126
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
text = 'Miso'
|
|
136
|
-
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
127
|
+
|
|
128
|
+
function _tag({ text = 'Miso' } = {}) {
|
|
137
129
|
return `%c${text}`;
|
|
138
130
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
color = '#fff',
|
|
142
|
-
background = '#334cbb'
|
|
143
|
-
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
131
|
+
|
|
132
|
+
function _style({ color = '#fff', background = '#334cbb' } = {}) {
|
|
144
133
|
return `color: ${color}; background-color: ${background}; padding: 2px 2px 1px 4px;`;
|
|
145
134
|
}
|
|
146
135
|
|
|
@@ -153,7 +142,8 @@ function _path(path) {
|
|
|
153
142
|
function _name(name) {
|
|
154
143
|
return `[${name}]`;
|
|
155
144
|
}
|
|
145
|
+
|
|
156
146
|
function _wrapObj(value) {
|
|
157
147
|
const type = typeof value;
|
|
158
|
-
return type === 'function' || type === 'object' && !Array.isArray(value) ? [value] : value;
|
|
159
|
-
}
|
|
148
|
+
return type === 'function' || (type === 'object' && !Array.isArray(value)) ? [value] : value;
|
|
149
|
+
}
|
|
@@ -1,30 +1,27 @@
|
|
|
1
1
|
import { addUrlParameter } from '@miso.ai/commons';
|
|
2
|
+
|
|
2
3
|
const ID = 'std:dry-run';
|
|
4
|
+
|
|
3
5
|
export default class DryRunPlugin {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
|
|
7
|
+
constructor(options = {}) {
|
|
6
8
|
this._options = options;
|
|
7
9
|
this.id = 'std:dry-run';
|
|
8
10
|
this.name = 'dry-run';
|
|
9
11
|
}
|
|
12
|
+
|
|
10
13
|
static get id() {
|
|
11
14
|
return ID;
|
|
12
15
|
}
|
|
13
16
|
|
|
14
17
|
// TODO: config({ active })
|
|
15
18
|
|
|
16
|
-
install(_,
|
|
17
|
-
let {
|
|
18
|
-
addUrlPass
|
|
19
|
-
} = _ref;
|
|
19
|
+
install(_, { addUrlPass }) {
|
|
20
20
|
addUrlPass(this._modifyUrl.bind(this));
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
apiGroup,
|
|
25
|
-
apiName,
|
|
26
|
-
url
|
|
27
|
-
} = _ref2;
|
|
22
|
+
|
|
23
|
+
_modifyUrl({ apiGroup, apiName, url }) {
|
|
28
24
|
return apiGroup === 'interactions' && apiName === 'upload' ? addUrlParameter(url, 'dry_run', '1') : url;
|
|
29
25
|
}
|
|
30
|
-
|
|
26
|
+
|
|
27
|
+
}
|
package/src/index.js
ADDED
package/dist/es/index.js
DELETED