@jetthai/cuora 1.0.76 → 1.0.77

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
@@ -2,6 +2,8 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [1.0.77](https://github.com/jetthai/cuora-module/compare/v1.0.76...v1.0.77) (2022-01-12)
6
+
5
7
  ### [1.0.76](https://github.com/jetthai/cuora-module/compare/v1.0.75...v1.0.76) (2022-01-11)
6
8
 
7
9
  ### [1.0.75](https://github.com/jetthai/cuora-module/compare/v1.0.74...v1.0.75) (2022-01-07)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.0.76",
3
+ "version": "1.0.77",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "scripts": {
@@ -59,7 +59,7 @@ export default function (request) {
59
59
  invoke: {
60
60
  src: 'authenticate',
61
61
  onDone: {
62
- target: 'login',
62
+ target: 'authenticated',
63
63
  actions: 'setToken',
64
64
  },
65
65
  onError: {
@@ -68,48 +68,69 @@ export default function (request) {
68
68
  },
69
69
  },
70
70
  },
71
- login: {
72
- type: 'parallel',
71
+ authenticated: {
72
+ invoke: {
73
+ src: 'fetchUserInfo',
74
+ onDone: {
75
+ target: 'inline',
76
+ actions: ['setUserInfo', 'extendToken'],
77
+ },
78
+ onError: {
79
+ target: 'leaving',
80
+ },
81
+ },
82
+ },
83
+ inline: {
84
+ initial: 'pending',
73
85
  states: {
74
- timer: {
75
- initial: 'running',
76
- states: {
77
- running: {
78
- invoke: {
79
- src: 'fetchUserInfo',
80
- onDone: {
81
- target: 'pending',
82
- actions: ['setUserInfo', 'extendToken', send({ type: 'CHECK' })],
83
- },
84
- onError: {
85
- target: '#auth.leaving',
86
- },
87
- },
86
+ pending: {
87
+ always: [{ target: '#auth.login', cond: 'isNotInline' }],
88
+ after: {
89
+ TIMEOUT: {
90
+ target: 'fetching',
91
+ },
92
+ },
93
+ },
94
+ fetching: {
95
+ invoke: {
96
+ src: 'fetchUserInfo',
97
+ onDone: {
98
+ target: 'pending',
99
+ actions: ['setUserInfo', 'extendToken'],
88
100
  },
89
- pending: {
90
- after: {
91
- TIMEOUT: {
92
- target: 'running',
93
- },
94
- },
101
+ onError: {
102
+ target: '#auth.leaving',
95
103
  },
96
104
  },
97
105
  },
98
- user: {
99
- initial: 'idle',
100
- states: {
101
- idle: {},
102
- normal: {},
103
- inline: {},
106
+ },
107
+ },
108
+ login: {
109
+ initial: 'fetching',
110
+ states: {
111
+ fetching: {
112
+ invoke: {
113
+ src: 'fetchUserInfo',
114
+ onDone: {
115
+ target: 'pending',
116
+ actions: ['setUserInfo', 'extendToken'],
117
+ },
118
+ onError: {
119
+ target: '#auth.leaving',
120
+ },
104
121
  },
105
- on: {
106
- CHECK: [{ target: '.inline', cond: 'isInline' }, { target: '.normal' }],
122
+ },
123
+ pending: {
124
+ after: {
125
+ TIMEOUT: {
126
+ target: 'fetching',
127
+ },
107
128
  },
108
129
  },
109
130
  },
110
131
  on: {
111
132
  LOGOUT: {
112
- target: '#auth.leaving',
133
+ target: 'leaving',
113
134
  },
114
135
  },
115
136
  },
@@ -118,11 +139,9 @@ export default function (request) {
118
139
  src: 'logout',
119
140
  onDone: {
120
141
  target: 'logout',
121
- actions: 'removeToken',
122
142
  },
123
143
  onError: {
124
144
  target: 'logout',
125
- actions: 'removeToken',
126
145
  },
127
146
  },
128
147
  },
@@ -130,10 +149,16 @@ export default function (request) {
130
149
  after: {
131
150
  0: {
132
151
  target: 'idle',
152
+ actions: 'removeToken',
133
153
  },
134
154
  },
135
155
  },
136
156
  },
157
+ on: {
158
+ CLEAR: {
159
+ target: '.logout',
160
+ },
161
+ },
137
162
  },
138
163
  {
139
164
  delays: {
@@ -149,6 +174,9 @@ export default function (request) {
149
174
  isInline: (context, event) => {
150
175
  return context.userInfo?.rank >= 0
151
176
  },
177
+ isNotInline: (context, event) => {
178
+ return !(context.userInfo?.rank >= 0)
179
+ },
152
180
  },
153
181
  actions: {
154
182
  setLoginPhone: assign((context, event) => {
@@ -57,7 +57,7 @@ export default function () {
57
57
  },
58
58
  guards: {
59
59
  isLogout: (context, event) => {
60
- return ['ERR_A201', 'ERR_A204', 'ERR_A103', 'ERR_A104', 'ERR_A108', 'ERR_F108'].includes(context.error.code)
60
+ return ['ERR_A201', 'ERR_A204', 'ERR_A103', 'ERR_A104', 'ERR_A108', 'ERR_F108', 'ERR_A113'].includes(context.error.code)
61
61
  },
62
62
  isNoBalance: (context, event) => {
63
63
  return context.error.code === 'ERR_G106'