@juzi/wechaty-puppet-service 1.0.67 → 1.0.68

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.
Files changed (116) hide show
  1. package/dist/cjs/src/client/puppet-service.d.ts +0 -11
  2. package/dist/cjs/src/client/puppet-service.d.ts.map +1 -1
  3. package/dist/cjs/src/client/puppet-service.js +0 -19
  4. package/dist/cjs/src/client/puppet-service.js.map +1 -1
  5. package/dist/cjs/src/package-json.d.ts.map +1 -1
  6. package/dist/cjs/src/package-json.js +1 -2
  7. package/dist/cjs/src/package-json.js.map +1 -1
  8. package/dist/esm/src/client/puppet-service.d.ts +0 -11
  9. package/dist/esm/src/client/puppet-service.d.ts.map +1 -1
  10. package/dist/esm/src/client/puppet-service.js +0 -21
  11. package/dist/esm/src/client/puppet-service.js.map +1 -1
  12. package/dist/esm/src/package-json.d.ts.map +1 -1
  13. package/dist/esm/src/package-json.js +1 -2
  14. package/dist/esm/src/package-json.js.map +1 -1
  15. package/package.json +1 -2
  16. package/src/client/puppet-service.ts +1 -34
  17. package/src/package-json.ts +1 -2
  18. package/dist/cjs/src/client/duck/actions.d.ts +0 -6
  19. package/dist/cjs/src/client/duck/actions.d.ts.map +0 -1
  20. package/dist/cjs/src/client/duck/actions.js +0 -54
  21. package/dist/cjs/src/client/duck/actions.js.map +0 -1
  22. package/dist/cjs/src/client/duck/epic-recover.d.ts +0 -36
  23. package/dist/cjs/src/client/duck/epic-recover.d.ts.map +0 -1
  24. package/dist/cjs/src/client/duck/epic-recover.js +0 -41
  25. package/dist/cjs/src/client/duck/epic-recover.js.map +0 -1
  26. package/dist/cjs/src/client/duck/epic-recover.spec.d.ts +0 -3
  27. package/dist/cjs/src/client/duck/epic-recover.spec.d.ts.map +0 -1
  28. package/dist/cjs/src/client/duck/epic-recover.spec.js +0 -131
  29. package/dist/cjs/src/client/duck/epic-recover.spec.js.map +0 -1
  30. package/dist/cjs/src/client/duck/epics.d.ts +0 -4
  31. package/dist/cjs/src/client/duck/epics.d.ts.map +0 -1
  32. package/dist/cjs/src/client/duck/epics.js +0 -36
  33. package/dist/cjs/src/client/duck/epics.js.map +0 -1
  34. package/dist/cjs/src/client/duck/mod.d.ts +0 -29
  35. package/dist/cjs/src/client/duck/mod.d.ts.map +0 -1
  36. package/dist/cjs/src/client/duck/mod.js +0 -63
  37. package/dist/cjs/src/client/duck/mod.js.map +0 -1
  38. package/dist/cjs/src/client/duck/operations.d.ts +0 -23
  39. package/dist/cjs/src/client/duck/operations.d.ts.map +0 -1
  40. package/dist/cjs/src/client/duck/operations.js +0 -30
  41. package/dist/cjs/src/client/duck/operations.js.map +0 -1
  42. package/dist/cjs/src/client/duck/reducers.d.ts +0 -59
  43. package/dist/cjs/src/client/duck/reducers.d.ts.map +0 -1
  44. package/dist/cjs/src/client/duck/reducers.js +0 -51
  45. package/dist/cjs/src/client/duck/reducers.js.map +0 -1
  46. package/dist/cjs/src/client/duck/selectors.d.ts +0 -21
  47. package/dist/cjs/src/client/duck/selectors.d.ts.map +0 -1
  48. package/dist/cjs/src/client/duck/selectors.js +0 -23
  49. package/dist/cjs/src/client/duck/selectors.js.map +0 -1
  50. package/dist/cjs/src/client/duck/tests.spec.d.ts +0 -3
  51. package/dist/cjs/src/client/duck/tests.spec.d.ts.map +0 -1
  52. package/dist/cjs/src/client/duck/tests.spec.js +0 -49
  53. package/dist/cjs/src/client/duck/tests.spec.js.map +0 -1
  54. package/dist/cjs/src/client/duck/types.d.ts +0 -21
  55. package/dist/cjs/src/client/duck/types.d.ts.map +0 -1
  56. package/dist/cjs/src/client/duck/types.js +0 -24
  57. package/dist/cjs/src/client/duck/types.js.map +0 -1
  58. package/dist/cjs/src/client/duck/utils.d.ts +0 -21
  59. package/dist/cjs/src/client/duck/utils.d.ts.map +0 -1
  60. package/dist/cjs/src/client/duck/utils.js +0 -3
  61. package/dist/cjs/src/client/duck/utils.js.map +0 -1
  62. package/dist/esm/src/client/duck/actions.d.ts +0 -6
  63. package/dist/esm/src/client/duck/actions.d.ts.map +0 -1
  64. package/dist/esm/src/client/duck/actions.js +0 -28
  65. package/dist/esm/src/client/duck/actions.js.map +0 -1
  66. package/dist/esm/src/client/duck/epic-recover.d.ts +0 -36
  67. package/dist/esm/src/client/duck/epic-recover.d.ts.map +0 -1
  68. package/dist/esm/src/client/duck/epic-recover.js +0 -36
  69. package/dist/esm/src/client/duck/epic-recover.js.map +0 -1
  70. package/dist/esm/src/client/duck/epic-recover.spec.d.ts +0 -3
  71. package/dist/esm/src/client/duck/epic-recover.spec.d.ts.map +0 -1
  72. package/dist/esm/src/client/duck/epic-recover.spec.js +0 -126
  73. package/dist/esm/src/client/duck/epic-recover.spec.js.map +0 -1
  74. package/dist/esm/src/client/duck/epics.d.ts +0 -4
  75. package/dist/esm/src/client/duck/epics.d.ts.map +0 -1
  76. package/dist/esm/src/client/duck/epics.js +0 -33
  77. package/dist/esm/src/client/duck/epics.js.map +0 -1
  78. package/dist/esm/src/client/duck/mod.d.ts +0 -29
  79. package/dist/esm/src/client/duck/mod.d.ts.map +0 -1
  80. package/dist/esm/src/client/duck/mod.js +0 -29
  81. package/dist/esm/src/client/duck/mod.js.map +0 -1
  82. package/dist/esm/src/client/duck/operations.d.ts +0 -23
  83. package/dist/esm/src/client/duck/operations.d.ts.map +0 -1
  84. package/dist/esm/src/client/duck/operations.js +0 -4
  85. package/dist/esm/src/client/duck/operations.js.map +0 -1
  86. package/dist/esm/src/client/duck/reducers.d.ts +0 -59
  87. package/dist/esm/src/client/duck/reducers.d.ts.map +0 -1
  88. package/dist/esm/src/client/duck/reducers.js +0 -26
  89. package/dist/esm/src/client/duck/reducers.js.map +0 -1
  90. package/dist/esm/src/client/duck/selectors.d.ts +0 -21
  91. package/dist/esm/src/client/duck/selectors.d.ts.map +0 -1
  92. package/dist/esm/src/client/duck/selectors.js +0 -22
  93. package/dist/esm/src/client/duck/selectors.js.map +0 -1
  94. package/dist/esm/src/client/duck/tests.spec.d.ts +0 -3
  95. package/dist/esm/src/client/duck/tests.spec.d.ts.map +0 -1
  96. package/dist/esm/src/client/duck/tests.spec.js +0 -24
  97. package/dist/esm/src/client/duck/tests.spec.js.map +0 -1
  98. package/dist/esm/src/client/duck/types.d.ts +0 -21
  99. package/dist/esm/src/client/duck/types.d.ts.map +0 -1
  100. package/dist/esm/src/client/duck/types.js +0 -21
  101. package/dist/esm/src/client/duck/types.js.map +0 -1
  102. package/dist/esm/src/client/duck/utils.d.ts +0 -21
  103. package/dist/esm/src/client/duck/utils.d.ts.map +0 -1
  104. package/dist/esm/src/client/duck/utils.js +0 -2
  105. package/dist/esm/src/client/duck/utils.js.map +0 -1
  106. package/src/client/duck/actions.ts +0 -31
  107. package/src/client/duck/epic-recover.spec.ts +0 -180
  108. package/src/client/duck/epic-recover.ts +0 -109
  109. package/src/client/duck/epics.ts +0 -53
  110. package/src/client/duck/mod.ts +0 -38
  111. package/src/client/duck/operations.ts +0 -28
  112. package/src/client/duck/reducers.ts +0 -36
  113. package/src/client/duck/selectors.ts +0 -27
  114. package/src/client/duck/tests.spec.ts +0 -25
  115. package/src/client/duck/types.ts +0 -20
  116. package/src/client/duck/utils.ts +0 -20
@@ -1,109 +0,0 @@
1
- /**
2
- * Wechaty Open Source Software - https://github.com/wechaty
3
- *
4
- * @copyright 2016 Huan LI (李卓桓) <https://github.com/huan>, and
5
- * Wechaty Contributors <https://github.com/wechaty>.
6
- *
7
- * Licensed under the Apache License, Version 2.0 (the "License");
8
- * you may not use this file except in compliance with the License.
9
- * You may obtain a copy of the License at
10
- *
11
- * http://www.apache.org/licenses/LICENSE-2.0
12
- *
13
- * Unless required by applicable law or agreed to in writing, software
14
- * distributed under the License is distributed on an "AS IS" BASIS,
15
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- * See the License for the specific language governing permissions and
17
- * limitations under the License.
18
- *
19
- */
20
- import {
21
- Observable,
22
- interval,
23
- timer,
24
- } from 'rxjs'
25
- import {
26
- debounce,
27
- filter,
28
- map,
29
- switchMap,
30
- takeUntil,
31
- tap,
32
- } from 'rxjs/operators'
33
- import {
34
- isActionOf,
35
- } from 'typesafe-actions'
36
- import type {
37
- // type Action,
38
- AnyAction,
39
- } from 'redux'
40
- import {
41
- Duck as PuppetDuck,
42
- } from '@juzi/wechaty-redux'
43
- import { log } from '@juzi/wechaty-puppet'
44
-
45
- const stateActive$ = (action$: Observable<AnyAction>) => action$.pipe(
46
- filter(isActionOf(PuppetDuck.actions.STATE_ACTIVATED_EVENT)),
47
- filter(action => action.payload.state === true),
48
- )
49
-
50
- const stateInactive$ = (action$: Observable<AnyAction>) => action$.pipe(
51
- filter(isActionOf(PuppetDuck.actions.STATE_INACTIVATED_EVENT)),
52
- )
53
-
54
- const heartbeat$ = (action$: Observable<AnyAction>) => action$.pipe(
55
- filter(isActionOf([
56
- PuppetDuck.actions.HEARTBEAT_RECEIVED_EVENT,
57
- PuppetDuck.actions.DONG_RECEIVED_EVENT,
58
- ])),
59
- )
60
-
61
- // Emit once when an active puppet lost heartbeat after a timeout period
62
- const monitorHeartbeat$ = (timeoutMilliseconds: number) =>
63
- (action$: Observable<AnyAction>) =>
64
- stateActive$(action$).pipe(
65
- switchMap(action => heartbeat$(action$).pipe(
66
- debounce(() => interval(timeoutMilliseconds)),
67
- tap(() => log.verbose('PuppetService', 'monitorHeartbeat$() %d seconds TIMEOUT',
68
- Math.floor(timeoutMilliseconds / 1000),
69
- )),
70
- map(() => PuppetDuck.actions.ERROR_RECEIVED_EVENT(
71
- action.meta.puppetId,
72
- { gerror: `monitorHeartbeat$() TIMEOUT(${timeoutMilliseconds})` },
73
- )),
74
- )),
75
- )
76
-
77
- const epicRecoverDing$ = (timeoutMilliseconds: number) =>
78
- (action$: Observable<AnyAction>) =>
79
- monitorHeartbeat$(timeoutMilliseconds)(action$).pipe(
80
- switchMap(action => timer(0, Math.floor(timeoutMilliseconds)).pipe(
81
- tap(n => log.verbose('PuppetService', 'epicRecoverDing$() actions.ding() emitted #%d', n)),
82
- map(() => PuppetDuck.actions.DING_COMMAND(
83
- action.meta.puppetId,
84
- 'epicRecoverDing$',
85
- )),
86
- takeUntil(heartbeat$(action$)),
87
- takeUntil(stateInactive$(action$)),
88
- )),
89
- )
90
-
91
- const epicRecoverReset$ = (timeoutMilliseconds: number) =>
92
- (action$: Observable<AnyAction>) =>
93
- monitorHeartbeat$(timeoutMilliseconds)(action$).pipe(
94
- switchMap(action => timer(0, timeoutMilliseconds * 2).pipe(
95
- tap(n => log.verbose('PuppetService', 'epicRecoverReset$() actions.reset() emitted #%d', n)),
96
- map(() => PuppetDuck.actions.RESET_COMMAND(
97
- action.meta.puppetId,
98
- 'epicRecoverReset$',
99
- )),
100
- takeUntil(heartbeat$(action$)),
101
- takeUntil(stateInactive$(action$)),
102
- )),
103
- )
104
-
105
- export {
106
- monitorHeartbeat$,
107
- epicRecoverReset$,
108
- epicRecoverDing$,
109
- }
@@ -1,53 +0,0 @@
1
- /**
2
- * Wechaty Open Source Software - https://github.com/wechaty
3
- *
4
- * @copyright 2016 Huan LI (李卓桓) <https://github.com/huan>, and
5
- * Wechaty Contributors <https://github.com/wechaty>.
6
- *
7
- * Licensed under the Apache License, Version 2.0 (the "License");
8
- * you may not use this file except in compliance with the License.
9
- * You may obtain a copy of the License at
10
- *
11
- * http://www.apache.org/licenses/LICENSE-2.0
12
- *
13
- * Unless required by applicable law or agreed to in writing, software
14
- * distributed under the License is distributed on an "AS IS" BASIS,
15
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- * See the License for the specific language governing permissions and
17
- * limitations under the License.
18
- *
19
- */
20
- import {
21
- Observable,
22
- merge,
23
- } from 'rxjs'
24
- import type {
25
- AnyAction,
26
- } from 'redux'
27
- import type {
28
- Epic,
29
- } from 'redux-observable'
30
-
31
- import {
32
- epicRecoverDing$,
33
- epicRecoverReset$,
34
- } from './epic-recover.js'
35
-
36
- /**
37
- * The GRPC keepalive timeout is 20 seconds
38
- * So we use 15 seconds to save the GRPC keepalive cost
39
- *
40
- * https://github.com/grpc/grpc/blob/master/doc/keepalive.md
41
- * GRPC_ARG_KEEPALIVE_TIMEOUT_MS 20000 (20 seconds) 20000 (20 seconds)
42
- */
43
- const TIMEOUT_SOFT = 15 * 1000
44
- const TIMEOUT_HARD = Math.floor(4.5 * TIMEOUT_SOFT)
45
-
46
- const recoverEpic: Epic = (action$: Observable<AnyAction>) => merge(
47
- epicRecoverDing$(TIMEOUT_SOFT)(action$),
48
- epicRecoverReset$(TIMEOUT_HARD)(action$),
49
- )
50
-
51
- export {
52
- recoverEpic,
53
- }
@@ -1,38 +0,0 @@
1
- /**
2
- * Wechaty Open Source Software - https://github.com/wechaty
3
- *
4
- * @copyright 2016 Huan LI (李卓桓) <https://github.com/huan>, and
5
- * Wechaty Contributors <https://github.com/wechaty>.
6
- *
7
- * Licensed under the Apache License, Version 2.0 (the "License");
8
- * you may not use this file except in compliance with the License.
9
- * You may obtain a copy of the License at
10
- *
11
- * http://www.apache.org/licenses/LICENSE-2.0
12
- *
13
- * Unless required by applicable law or agreed to in writing, software
14
- * distributed under the License is distributed on an "AS IS" BASIS,
15
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- * See the License for the specific language governing permissions and
17
- * limitations under the License.
18
- *
19
- */
20
- import reducer from './reducers.js'
21
-
22
- import * as actions from './actions.js'
23
- import * as epics from './epics.js'
24
- import * as operations from './operations.js'
25
- import * as selectors from './selectors.js'
26
- import * as types from './types.js'
27
- import * as utils from './utils.js'
28
-
29
- export {
30
- actions,
31
- epics,
32
- operations,
33
- selectors,
34
- types,
35
- utils,
36
- }
37
-
38
- export default reducer
@@ -1,28 +0,0 @@
1
- /**
2
- * Wechaty Open Source Software - https://github.com/wechaty
3
- *
4
- * @copyright 2016 Huan LI (李卓桓) <https://github.com/huan>, and
5
- * Wechaty Contributors <https://github.com/wechaty>.
6
- *
7
- * Licensed under the Apache License, Version 2.0 (the "License");
8
- * you may not use this file except in compliance with the License.
9
- * You may obtain a copy of the License at
10
- *
11
- * http://www.apache.org/licenses/LICENSE-2.0
12
- *
13
- * Unless required by applicable law or agreed to in writing, software
14
- * distributed under the License is distributed on an "AS IS" BASIS,
15
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- * See the License for the specific language governing permissions and
17
- * limitations under the License.
18
- *
19
- */
20
- import type { Dispatch } from 'redux'
21
-
22
- import * as actions from './actions.js'
23
-
24
- const nop = (dispatch: Dispatch) => () => dispatch(actions.nop())
25
-
26
- export {
27
- nop,
28
- }
@@ -1,36 +0,0 @@
1
- /**
2
- * Wechaty Open Source Software - https://github.com/wechaty
3
- *
4
- * @copyright 2016 Huan LI (李卓桓) <https://github.com/huan>, and
5
- * Wechaty Contributors <https://github.com/wechaty>.
6
- *
7
- * Licensed under the Apache License, Version 2.0 (the "License");
8
- * you may not use this file except in compliance with the License.
9
- * You may obtain a copy of the License at
10
- *
11
- * http://www.apache.org/licenses/LICENSE-2.0
12
- *
13
- * Unless required by applicable law or agreed to in writing, software
14
- * distributed under the License is distributed on an "AS IS" BASIS,
15
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- * See the License for the specific language governing permissions and
17
- * limitations under the License.
18
- *
19
- */
20
- import {
21
- createReducer,
22
- type ActionType,
23
- } from 'typesafe-actions'
24
- import type {
25
- DeepReadonly,
26
- } from 'utility-types'
27
-
28
- import * as actions from './actions.js'
29
-
30
- const initialState: DeepReadonly<{}> = {}
31
-
32
- const reducer = createReducer<typeof initialState, ActionType<typeof actions>>(initialState)
33
- .handleAction(actions.nop, (state, _action) => state)
34
-
35
- export type State = ReturnType<typeof reducer>
36
- export default reducer
@@ -1,27 +0,0 @@
1
- /**
2
- * Wechaty Open Source Software - https://github.com/wechaty
3
- *
4
- * @copyright 2016 Huan LI (李卓桓) <https://github.com/huan>, and
5
- * Wechaty Contributors <https://github.com/wechaty>.
6
- *
7
- * Licensed under the Apache License, Version 2.0 (the "License");
8
- * you may not use this file except in compliance with the License.
9
- * You may obtain a copy of the License at
10
- *
11
- * http://www.apache.org/licenses/LICENSE-2.0
12
- *
13
- * Unless required by applicable law or agreed to in writing, software
14
- * distributed under the License is distributed on an "AS IS" BASIS,
15
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- * See the License for the specific language governing permissions and
17
- * limitations under the License.
18
- *
19
- */
20
- // import type { State } from './reducers.js'
21
-
22
- // const getQrCode = (state: State) => (wechatyId: string) => state[wechatyId]?.qrcode
23
- // const getCurrentUser = (state: State) => (wechatyId: string) => state[wechatyId]?.currentUser // PUPPET.payloads.Contact
24
- // const isLoggedIn = (state: State) => (wechatyId: string) => state[wechatyId]?.currentUser !== undefined
25
-
26
- export {
27
- }
@@ -1,25 +0,0 @@
1
- #!/usr/bin/env -S node --no-warnings --loader ts-node/esm
2
- /**
3
- * Wechaty Open Source Software - https://github.com/wechaty
4
- *
5
- * @copyright 2016 Huan LI (李卓桓) <https://github.com/huan>, and
6
- * Wechaty Contributors <https://github.com/wechaty>.
7
- *
8
- * Licensed under the Apache License, Version 2.0 (the "License");
9
- * you may not use this file except in compliance with the License.
10
- * You may obtain a copy of the License at
11
- *
12
- * http://www.apache.org/licenses/LICENSE-2.0
13
- *
14
- * Unless required by applicable law or agreed to in writing, software
15
- * distributed under the License is distributed on an "AS IS" BASIS,
16
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
- * See the License for the specific language governing permissions and
18
- * limitations under the License.
19
- *
20
- */
21
- import { validateDuck } from 'ducks'
22
-
23
- import * as Duck from './mod.js'
24
-
25
- validateDuck(Duck)
@@ -1,20 +0,0 @@
1
- /**
2
- * Wechaty Open Source Software - https://github.com/wechaty
3
- *
4
- * @copyright 2016 Huan LI (李卓桓) <https://github.com/huan>, and
5
- * Wechaty Contributors <https://github.com/wechaty>.
6
- *
7
- * Licensed under the Apache License, Version 2.0 (the "License");
8
- * you may not use this file except in compliance with the License.
9
- * You may obtain a copy of the License at
10
- *
11
- * http://www.apache.org/licenses/LICENSE-2.0
12
- *
13
- * Unless required by applicable law or agreed to in writing, software
14
- * distributed under the License is distributed on an "AS IS" BASIS,
15
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- * See the License for the specific language governing permissions and
17
- * limitations under the License.
18
- *
19
- */
20
- export const NOP = 'wechaty-puppet-service/NOP'
@@ -1,20 +0,0 @@
1
- /**
2
- * Wechaty Open Source Software - https://github.com/wechaty
3
- *
4
- * @copyright 2016 Huan LI (李卓桓) <https://github.com/huan>, and
5
- * Wechaty Contributors <https://github.com/wechaty>.
6
- *
7
- * Licensed under the Apache License, Version 2.0 (the "License");
8
- * you may not use this file except in compliance with the License.
9
- * You may obtain a copy of the License at
10
- *
11
- * http://www.apache.org/licenses/LICENSE-2.0
12
- *
13
- * Unless required by applicable law or agreed to in writing, software
14
- * distributed under the License is distributed on an "AS IS" BASIS,
15
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- * See the License for the specific language governing permissions and
17
- * limitations under the License.
18
- *
19
- */
20
- export {}