@doreamonjs/plugin-analysis 0.3.12 → 0.3.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/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.3.13](https://github.com/zcorky/zodash/compare/v0.3.12...v0.3.13) (2022-08-31)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * plugin-authorization model + types ([7c4058c](https://github.com/zcorky/zodash/commit/7c4058c47429eda26de6af08ce6b2d2a423f83c9))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [0.3.12](https://github.com/zcorky/zodash/compare/v0.3.11...v0.3.12) (2022-08-31)
7
18
 
8
19
  **Note:** Version bump only for package @doreamonjs/plugin-analysis
package/lib/model.js CHANGED
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Model = void 0;
4
4
  const doreamon_1 = require("@zodash/doreamon");
5
- const service = require("@doreamonjs/plugin-service");
6
5
  const constants_1 = require("./constants");
7
6
  const service_1 = require("./service");
8
7
  class Model {
@@ -19,123 +18,39 @@ class Model {
19
18
  return constants_1.NAMESPACE;
20
19
  }
21
20
  build() {
21
+ const service = this.service;
22
22
  return {
23
23
  namespace: constants_1.NAMESPACE,
24
- state: {
25
- captcha: `/captcha?_t=${Date.now()}`,
26
- },
24
+ state: {},
27
25
  reducers: {
28
- 'captcha/save'(state, { payload: captcha }) {
29
- return { ...state, captcha };
26
+ save(state, { payload: config }) {
27
+ return {
28
+ ...state,
29
+ config,
30
+ };
30
31
  },
31
32
  },
32
33
  effects: {
33
- *login({ payload: { username, password, captcha }, done }, { race, call, put }) {
34
- yield call(doreamon_1.default.delay, 1000);
34
+ *setup({ payload: config }, { put }) {
35
+ var _a;
36
+ yield put({ type: 'save', payload: config });
35
37
  try {
36
- const { timeout } = yield race({
37
- data: call(service.authorization.login.bind(service.authorization.login), username, password, captcha),
38
- timeout: call(doreamon_1.default.delay, 10000),
39
- });
40
- if (timeout) {
41
- yield put({
42
- type: 'message/tip/error',
43
- payload: '服务器开小差啦',
44
- });
45
- done();
46
- return false;
47
- }
48
- }
49
- catch (err) {
50
- yield put({ type: 'refresh/captcha' });
51
- setTimeout(() => {
52
- // @TODO hack clear captcha
53
- const node = document.querySelector('input#captcha');
54
- if (node) {
55
- node.value = '';
56
- }
57
- }, 0);
58
- done();
59
- throw err;
38
+ (_a = service.setup) === null || _a === void 0 ? void 0 : _a.call(service, config);
60
39
  }
61
- yield call(doreamon_1.default.delay, 1000);
62
- // router change
63
- // @TODO should support redirect
64
- const query = doreamon_1.default.qs.parse(window.location.search);
65
- const redirect = query.redirect || '/';
66
- window.location.href = redirect;
67
- },
68
- *logout(action, { select, race, call, put }) {
69
- // @TODO request call backend api
70
- const { username } = yield select((state) => state.user.values);
71
- const { timeout } = yield race({
72
- data: call(service.authorization.logout.bind(service.authorization), username),
73
- timeout: call(doreamon_1.default.delay, 10000),
74
- });
75
- if (timeout) {
76
- yield put({
77
- type: 'message/tip/error',
78
- payload: '服务器开小差啦',
79
- });
80
- return false;
40
+ catch (error) {
41
+ doreamon_1.default.logger.error('[model] analysis setup error', error);
81
42
  }
82
- // solution @2
83
- // const currentPath = window.location.pathname;
84
- // window.location.href = `/login?redirect=${encodeURIComponent(currentPath)}`;
85
- const currentPath = window.location.pathname;
86
- window.location.href = `/logout?from=${encodeURIComponent(currentPath)}`;
87
43
  },
88
- *register({ payload }, { race, call, put }) {
89
- const { username, password, confirmPassword, captcha } = payload;
90
- const { data, timeout } = yield race({
91
- data: call(service.authorization.register.bind(service.authorization), username, password, confirmPassword, captcha),
92
- timeout: call(doreamon_1.default.delay, 10000),
93
- });
94
- if (timeout) {
95
- yield put({
96
- type: 'message/tip/error',
97
- payload: '服务器开小差啦',
98
- });
99
- return false;
100
- }
101
- yield put({
102
- type: 'message/tip/success',
103
- payload: '注册成功, 正在跳转登陆界面...',
104
- });
105
- yield call(doreamon_1.default.delay, 1000);
106
- window.location.href = '/';
107
- },
108
- // login
109
- *'refresh/captcha'(action, { race, call, put }) {
110
- const { data, timeout } = yield race({
111
- data: call(service.authorization.captcha.bind(service.authorization)),
112
- timeout: call(doreamon_1.default.delay, 10000),
113
- });
114
- if (timeout) {
115
- yield put({
116
- type: 'message/tip/error',
117
- payload: '服务器开小差啦',
118
- });
119
- return false;
44
+ *track({ payload: { event, attributes } }, { select }) {
45
+ var _a;
46
+ // fix eslint: This generator function does not have 'yield' require-yield
47
+ yield select((state) => state[constants_1.NAMESPACE]);
48
+ try {
49
+ (_a = service.track) === null || _a === void 0 ? void 0 : _a.call(service, event, attributes);
120
50
  }
121
- yield put({ type: 'captcha/save', payload: data.url });
122
- },
123
- *'send/captcha/to/email_or_other'({ payload: { username } }, { race, call, put }) {
124
- const { timeout } = yield race({
125
- data: call(service.authorization.sendCaptchaToEmailOrOther.bind(service.authorization), username),
126
- timeout: call(doreamon_1.default.delay, 10000),
127
- });
128
- if (timeout) {
129
- yield put({
130
- type: 'message/tip/error',
131
- payload: '服务器开小差啦',
132
- });
133
- return false;
51
+ catch (error) {
52
+ doreamon_1.default.logger.error('[model] analysis track error', error);
134
53
  }
135
- yield put({
136
- type: 'message/tip/success',
137
- payload: '验证码发送成功,请查看邮箱',
138
- });
139
54
  },
140
55
  },
141
56
  };
package/lib/service.d.ts CHANGED
@@ -1,9 +1,8 @@
1
+ import { Client } from './types';
1
2
  interface ServiceConfig {
2
3
  clients: AnalysisClient[];
3
4
  }
4
- interface AnalysisClient {
5
- provider: string;
6
- config: any;
5
+ interface AnalysisClient extends Client {
7
6
  }
8
7
  export declare class Service {
9
8
  private logger;
package/lib/types.d.ts CHANGED
@@ -1,25 +1,7 @@
1
1
  export interface State {
2
- visible: boolean;
3
- attributes: Attributes;
4
- datasets: Datasets;
5
- queue: State[];
6
- callback?: (err: Error | null, type: 'open' | 'close' | 'cancel' | 'ok', vallues?: any) => void;
2
+ clients: Client[];
7
3
  }
8
- export interface Attributes {
9
- type?: 'modal' | 'drawer';
10
- title: string;
11
- description?: string;
12
- cancelText?: string;
13
- analysisText?: string;
14
- target: AttributeTarget;
4
+ export interface Client {
5
+ provider: string;
6
+ config: any;
15
7
  }
16
- export interface Datasets {
17
- origin: object;
18
- values: object;
19
- }
20
- export interface AttributeTarget {
21
- namespace: string;
22
- effect: string;
23
- props: any;
24
- }
25
- export declare type Type = 'modal' | 'drawer';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doreamonjs/plugin-analysis",
3
- "version": "0.3.12",
3
+ "version": "0.3.13",
4
4
  "description": "analysis plugin for doreamonjs",
5
5
  "keywords": [
6
6
  "doreamonjs",
@@ -66,7 +66,7 @@
66
66
  },
67
67
  "dependencies": {
68
68
  "@doreamonjs/plugin-request": "^0.3.2",
69
- "@doreamonjs/plugin-shared": "^0.3.12",
69
+ "@doreamonjs/plugin-shared": "^0.3.13",
70
70
  "@sentry/browser": "^7.11.1",
71
71
  "@sentry/tracing": "^7.11.1",
72
72
  "@zcorky/delay": "^1.0.1",
@@ -77,5 +77,5 @@
77
77
  "mixpanel-browser": "^2.45.0",
78
78
  "thinkingdata-browser": "^1.6.0"
79
79
  },
80
- "gitHead": "efeb8d0d8b1e496c165164fbb4f9508c65ee21d9"
80
+ "gitHead": "1b28761e66cad9a1e9e3f35b39258a0e3c3caf6c"
81
81
  }