Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Actor model (since 1973) & XState #1

Merged
merged 340 commits into from
May 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
340 commits
Select commit Hold shift + click to select a range
9c0f623
add send address test
huan Jan 3, 2022
9dee55c
fixed by [email protected] (https://github.com/statelyai/xstate/issues/2914)
huan Jan 3, 2022
e5d563e
fixed by [email protected] (https://github.com/statelyai/xstate/issues/2914)
huan Jan 3, 2022
15f48ca
refactor Mailbox to be a class
huan Jan 4, 2022
281dea7
code clean
huan Jan 4, 2022
562439a
add typed inject ioc poc code
huan Jan 4, 2022
c7b9371
refactor mailbox code
huan Jan 4, 2022
cf7f367
refactor for using interface
huan Jan 4, 2022
9082401
code clean
huan Jan 4, 2022
e4f601a
enable ioc injection with factory helpers
huan Jan 4, 2022
adcc6f4
code clean
huan Jan 4, 2022
ca77969
refactory with ioc
huan Jan 5, 2022
f122c8e
add docs
huan Jan 5, 2022
dcff130
fix typo: aquire -> acquire
huan Jan 5, 2022
5e858c3
Merge branch 'main' into actor-pattern
huan Jan 5, 2022
a3b0d1c
better link
huan Jan 5, 2022
fcb8f9b
working on brainstorming actor
huan Jan 5, 2022
fd002dd
add module name to log
huan Jan 7, 2022
bb25991
add module name to log
huan Jan 7, 2022
5486805
fix wechaty ContactSelf not ready bug
huan Jan 7, 2022
caa9b0e
refactor
huan Jan 9, 2022
93b819f
add debug for unit test
huan Jan 9, 2022
1ce1625
support REPORT event & better log module name
huan Jan 9, 2022
9d8134c
clean names
huan Jan 9, 2022
236c705
add null address
huan Jan 9, 2022
af2375c
support devTools & remote state chart (#10)
huan Jan 10, 2022
863b784
fix register actor bug
huan Jan 10, 2022
cf146d1
reproduce statechart error (https://github.com/statelyai/xstate/issue…
huan Jan 10, 2022
206cad2
add more actions order test
huan Jan 11, 2022
39f703f
fix register context clean order
huan Jan 11, 2022
962d940
rename NOTIFY -> NEW_MESSAGE
huan Jan 11, 2022
d7f99bf
better deal with new message when child is busy: can accept it or not
huan Jan 11, 2022
ecae10c
delay Mailbox.Actions.reply event to next task in the event loop (#11)
huan Jan 12, 2022
78ce7b7
unit test for reply (#11)
huan Jan 12, 2022
d9de7af
fix register actor
huan Jan 12, 2022
f1d9100
add bot5 fixture & unit test for nextContact
huan Jan 12, 2022
3de2429
better log message for debugging & readme docs
huan Jan 12, 2022
77909f4
fix intent tests
huan Jan 12, 2022
f2615bf
fix bugs
huan Jan 12, 2022
b8fe3a8
add more states with better names, refactoring unit tests
huan Jan 12, 2022
daabdf3
fix & refactoring brainstorming actor
huan Jan 13, 2022
9f825b5
fix all unit tests & refactoring
huan Jan 14, 2022
77ba4a5
fix actors linting
huan Jan 14, 2022
5dc6505
fix linting & clean for mailbox
huan Jan 14, 2022
22eed57
fix baby & cofee & ding-dong machine
huan Jan 16, 2022
baa7fee
clean action
huan Jan 16, 2022
c2dbb60
fix wrap unit tests
huan Jan 17, 2022
bd13ade
fix wrap unit tests
huan Jan 17, 2022
20b26d9
add testing util
huan Jan 17, 2022
0ef81aa
fix mailbox unit tests
huan Jan 17, 2022
81f5f66
fix some linting problems
huan Jan 17, 2022
d03181d
code clean
huan Jan 17, 2022
b3c7506
add notice actor
huan Jan 17, 2022
b516c6e
draft wechaty actor
huan Jan 25, 2022
c487252
refactoring mailbox
huan Feb 28, 2022
7e26d48
remove registry (use wechaty-redux instead)
huan Mar 16, 2022
26b0bdf
finish wechaty actor with cqrs
huan Mar 28, 2022
086e80e
upgrade deps
huan Mar 28, 2022
1be1968
add license to source code
huan Mar 28, 2022
936060a
add notice
huan Mar 28, 2022
0e319df
moved wechaty actors
huan Mar 28, 2022
cb502a6
clean & refactoring schemas
huan Mar 28, 2022
cf52561
clean ioc
huan Mar 28, 2022
136b416
fix message-to-intents
huan Mar 28, 2022
96ac255
fix fixture text
huan Mar 28, 2022
983d30e
export actor interface
huan Mar 28, 2022
cf2cda8
fix typing
huan Mar 28, 2022
4cfeb54
wip actors
huan Mar 28, 2022
9f39461
fix notice actor
huan Mar 28, 2022
e7fdbc5
wip
huan Mar 29, 2022
dd716e0
wip
huan Mar 29, 2022
c0bd14e
final changes for mailbox
huan Mar 29, 2022
ce51e6b
use mailbox npm module
huan Apr 1, 2022
bbe3589
remove deprecated mailbox code (using mailbox npm instead)
huan Apr 2, 2022
da2c7c4
use the latest Mailbox API
huan Apr 2, 2022
7a7bf74
working on batch loop actor
huan Apr 3, 2022
ba4802d
add batch feature to wechaty actor
huan Apr 3, 2022
2dde169
add BATCH event support for wechaty actor
huan Apr 4, 2022
c39c7bc
code clean & upgrade mailbox
huan Apr 4, 2022
dd5352c
finish register actor
huan Apr 4, 2022
a9a19b3
fix notice actor
huan Apr 4, 2022
a92a393
using uppser case for event creators name
huan Apr 5, 2022
ca3984f
clean
huan Apr 5, 2022
07eb723
finish fileBox to text actor
huan Apr 5, 2022
4bea3ee
code clean
huan Apr 5, 2022
59a27c1
finish intent actor
huan Apr 8, 2022
161eb1b
author
huan Apr 8, 2022
927f92b
work in progress ducksify
huan Apr 9, 2022
a922224
duckularizing
huan Apr 9, 2022
45afbcb
WIP ...
huan Apr 10, 2022
5b5633a
add duckularize
huan Apr 10, 2022
f43a48c
first duckula actor modulize interface
huan Apr 10, 2022
b178a3a
duckularize file-box-to-text-actor
huan Apr 12, 2022
50b3dc4
fix duck values
huan Apr 12, 2022
18633ba
duckularize rigistering actor
huan Apr 12, 2022
90d5652
duckularize noticing actor
huan Apr 12, 2022
8e08398
fix selector with union typings
huan Apr 15, 2022
58c992d
modulize duckula (wip)
huan Apr 15, 2022
cf359e6
fix duckularize typing by overriding
huan Apr 16, 2022
293a8c0
fix duckularize typing by overriding
huan Apr 16, 2022
f32118a
wip
huan Apr 17, 2022
1b800b1
add comments
huan Apr 17, 2022
34dcef1
rename to fancy enum
huan Apr 17, 2022
9de6424
restruct folder
huan Apr 17, 2022
6310ed1
fix wechaty actor with duckula
huan Apr 17, 2022
99066ef
fix wechaty actor duckula typing
huan Apr 17, 2022
d9aea08
fix actor duckula typing
huan Apr 17, 2022
512d34a
code log clean
huan Apr 17, 2022
6a1e57b
restructure folder
huan Apr 17, 2022
d108d15
fix race condition bug of mailbox (https://github.com/huan/mailbox/is…
huan Apr 19, 2022
022fac6
code clean & upgrade git-scripts
huan Apr 19, 2022
a456b76
move Duckula to Mailbox
huan Apr 19, 2022
4f46adf
clean State names
huan Apr 19, 2022
a5bc2ff
duckularization
huan Apr 19, 2022
48f2ef0
duckularize noticing actor
huan Apr 19, 2022
415279a
duckularize file-box-to-text actor
huan Apr 19, 2022
0de00a5
duckularize intent actor
huan Apr 19, 2022
02649a3
add GetMessageFile from CQRS for FileBox
huan Apr 20, 2022
dc5ca59
reponse the original response for wechaty actor
huan Apr 20, 2022
aee4536
clean stt code
huan Apr 20, 2022
5d557c3
fix message-to-feedback
huan Apr 20, 2022
66f9ca1
finish message to feedback actor
huan Apr 20, 2022
a7ebf6d
clean
huan Apr 20, 2022
1fd824e
code clean
huan Apr 20, 2022
f27480b
code clean
huan Apr 20, 2022
3b45306
restructure infrastructure actor
huan Apr 20, 2022
aed6e26
add MessageToFile actor
huan Apr 20, 2022
4c8675a
restructure TextToIntent actor folder
huan Apr 20, 2022
741dfed
Noticing actor
huan Apr 20, 2022
29136e1
code clean
huan Apr 20, 2022
380cd32
code clean Register actor
huan Apr 20, 2022
b1ca6ee
upgrade dep
huan Apr 20, 2022
c70ea05
code clean
huan Apr 20, 2022
e5b73e6
emit GERROR when theres any error
huan Apr 21, 2022
18cf8c8
add removeUndefined filter typing guard
huan Apr 21, 2022
0b4c9c5
WIP messageToMention actor
huan Apr 21, 2022
8ff4aaa
WIP messageToMention actor
huan Apr 21, 2022
074c1e7
finish messageToMentions Actor
huan Apr 21, 2022
da6b55f
emit GERROR for error
huan Apr 21, 2022
b48eeee
code clean
huan Apr 21, 2022
c6e0444
clean
huan Apr 21, 2022
535bcf7
restructure folder
huan Apr 21, 2022
60bb30b
wip
huan Apr 21, 2022
b66b24e
finish messageToText actor
huan Apr 22, 2022
37b2b79
code clean
huan Apr 22, 2022
4e64443
restructure folders
huan Apr 22, 2022
e0e8d77
clean registor actor
huan Apr 22, 2022
a395c48
fix path
huan Apr 22, 2022
bece200
move path
huan Apr 22, 2022
ea6b9e5
wip
huan Apr 22, 2022
20d4dc2
fix messageToFeedback actor
huan Apr 23, 2022
151dab5
enhance duckula
huan Apr 23, 2022
cfa177b
code clean
huan Apr 23, 2022
6c63b5d
fix unit test
huan Apr 23, 2022
b163944
code clean
huan Apr 23, 2022
13d253e
code clean
huan Apr 23, 2022
c9f35d9
add transition log
huan Apr 25, 2022
1a88504
upgrade deps
huan Apr 25, 2022
e4cd3f3
upgrade mailbox
huan Apr 25, 2022
9c7f5b6
fix actor unit test
huan Apr 25, 2022
fa91e29
finished feedback actor
huan Apr 25, 2022
f9dae68
wip brainstorming
huan Apr 25, 2022
5952b85
code clean
huan Apr 25, 2022
1fc3f39
code clean
huan Apr 25, 2022
623b5a3
restructure fixture folder
huan Apr 25, 2022
91b3025
code clean
huan Apr 25, 2022
8d9be97
finish brainstorming actor
huan Apr 27, 2022
a3f233a
fix register actor
huan Apr 27, 2022
533d717
duckularize meeting actor
huan Apr 27, 2022
412a39b
add Apache-2.0 LICENSE comments
huan Apr 28, 2022
46f675f
add Apache-2.0 LICENSE comments
huan Apr 28, 2022
6f390f8
code clean register actor
huan Apr 28, 2022
1e4cd0b
fix register actor
huan Apr 28, 2022
25279d0
code clean noticing actor
huan Apr 28, 2022
afc0aa4
code clean text-to-intents actor
huan Apr 28, 2022
1ee312e
WIP MeetingActor ...
huan Apr 28, 2022
2d326fc
upgrade mailbox
huan Apr 28, 2022
1748ec3
rename to actors
huan Apr 28, 2022
e4fc165
wip.../
huan Apr 28, 2022
7e76119
add intent actor
huan Apr 28, 2022
ba7eb4d
code clean with renaming
huan Apr 28, 2022
edb3d4a
code clean with renaming
huan Apr 28, 2022
76dbc8d
code clean with renaming
huan Apr 28, 2022
98302f3
add message to intent event
huan Apr 28, 2022
552f75b
clean code for feedback actor
huan Apr 29, 2022
9ed5dd4
link message payload to context & events
huan Apr 29, 2022
535bda7
add actor utils for response states
huan Apr 29, 2022
9fa31ae
add actor utils for response states
huan Apr 29, 2022
094b68e
use responseStates to clean code for MessageToFile
huan Apr 29, 2022
c55eff6
use responseStates to clean code for MessageToMentions
huan Apr 29, 2022
12773b8
use responseStates to clean code for MessageToText
huan Apr 29, 2022
4a9ec75
use responseStates to clean code for Feedback
huan Apr 29, 2022
ce31a74
use responseStates to clean code for Intent
huan Apr 29, 2022
f489dfc
code clean
huan Apr 29, 2022
734067d
use responseStates to clean code for Register
huan Apr 29, 2022
1f84282
use responseStates to clean code for FileToText
huan Apr 29, 2022
a59374d
use responseStates to clean code for TextToIntents
huan Apr 29, 2022
b8c3213
code clean
huan Apr 29, 2022
0a5812b
code clean
huan Apr 29, 2022
af839ae
code clean
huan Apr 29, 2022
d6fdc9e
code clean
huan Apr 29, 2022
127cafd
rename noticing -> notice
huan Apr 29, 2022
5b1e27b
code clean
huan Apr 29, 2022
dd571c8
move NoticeActor to be spawned internally
huan Apr 29, 2022
9c6efad
add admins as string[] in context
huan Apr 29, 2022
dfc29fa
move notice as a local spawned actor
huan Apr 29, 2022
a2075c4
code clean
huan Apr 29, 2022
161b70e
make initialContext to be itself
huan Apr 29, 2022
d893a25
code clean
huan Apr 30, 2022
36b6b70
renaming Responded -> Responded
huan Apr 30, 2022
1bd4a95
rename Responded -> Responding
huan Apr 30, 2022
21040f0
rename Responded -> Responding
huan Apr 30, 2022
9095a88
rename Responded -> Responding
huan Apr 30, 2022
a5e422d
remove deprecated actor
huan Apr 30, 2022
e9582f9
use Responding & Erroring instead of `ed`, and code clean
huan Apr 30, 2022
983a297
rename INTRODUCE to HELP
huan Apr 30, 2022
89aaf87
add MessageToRoom actor
huan Apr 30, 2022
fcc34af
export FIXTURES for duckula
huan Apr 30, 2022
bffa8fe
refactoring FileBox EVENT
huan Apr 30, 2022
84358d2
refactoring file box json
huan Apr 30, 2022
4ebecff
code improvements & bug fixes
huan Apr 30, 2022
3ec6355
code clean
huan Apr 30, 2022
59303bf
code clean
huan Apr 30, 2022
85f2727
code refactoring & clean
huan Apr 30, 2022
af40e56
clean code, rename BATCH_EXECUTE -> BATCH for fewer confusing
huan May 1, 2022
7443129
code clean
huan May 1, 2022
4db3d2c
log context in initializing state
huan May 1, 2022
545d340
log context in initializing state
huan May 1, 2022
e61d915
finish MessageToText actor (finally after 3 days!)
huan May 2, 2022
e00953a
code clean
huan May 2, 2022
dafe518
finish MessageToIntent actor
huan May 3, 2022
26b34df
finish MessageToIntent actor
huan May 3, 2022
c2f916f
add more intents tests
huan May 3, 2022
f9037f8
move intents module to top folder
huan May 3, 2022
3be09cd
finish Register actor
huan May 3, 2022
9d621e7
WIP register actor
huan May 3, 2022
02b3706
wip register actor & unit tests
huan May 3, 2022
286e7af
register actor passed unit tests
huan May 3, 2022
590c4fa
support BATCH event for responseStates
huan May 5, 2022
7cb1e0a
use BATCH to response multiple responses
huan May 5, 2022
6df987d
add BATCH event
huan May 5, 2022
5ee361a
fix Feedback Actor
huan May 7, 2022
9c55307
code clean
huan May 7, 2022
d9b9bef
code clean
huan May 7, 2022
4479a3d
code clean
huan May 7, 2022
6166e74
finish BrainStorming actor & unit tests
huan May 7, 2022
3a5539c
code clean
huan May 7, 2022
25a7b02
code clean
huan May 7, 2022
4fdcdd8
use BATCH as response to REPORT
huan May 7, 2022
f2273de
final meeting FSM flow chart
huan May 8, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// eslint-disable-next-line semi

const rules = {
'array-bracket-spacing': [
'error',
'always',
],
}

module.exports = {
Expand Down
27 changes: 27 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "pwa-node",
"request": "launch",
"name": "Launch Program",
"runtimeExecutable": "/home/huan/.nvm/versions/node/v16.13.2/bin/node",
"runtimeArgs": [
"--loader",
"ts-node/esm",
"--no-warnings",
],
"skipFiles": [
"<node_internals>/**",
"${workspaceFolder}/node_modules/**/*.js",
],
"program": "${workspaceFolder}/src/application-actors/message-to-text/machine.spec.ts",
"outFiles": [
"${workspaceFolder}/**/*.js"
]
}
]
}
142 changes: 142 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,135 @@ BOT5 Meeting Assistant BOT powered by RSVP.ai & Wechaty & XState.

![BOT5 Club](docs/images/caq-bot5-qingyu.webp)

## BOT5 Club Seminar Flow Chart

```mermaid
flowchart TD
Initializing --> Loading
subgraph Loading
LoadSavedState
end

Loading --> Restoring
subgraph Restoring
SetContext
TransitionToLastStateOrCalling
end

Restoring --> Calling
subgraph Calling
SetChairs
SetTalks
SetSchedule
end

Calling --> Registering
subgraph Registering
attendees
EveryDay
8h
4h
2h
1h
20m
10m
end

Registering --> Checkining
Checkining --> Starting
Starting --> Introducing
Introducing --> Retrospecting
Retrospecting --> Welcoming
subgraph Welcoming
Joining
introducing
end

Welcoming --> Presenting
Presenting --> Promoting
subgraph Promoting
Newcomer
TrialMember
Member
TrialChair
Chair
end

Promoting --> Brainstorming
Brainstorming --> Roasting
Roasting --> Chairing
subgraph Chairing
Electing
Naming
Voting
Deciding
Summarizing
Pledging
end

Chairing --> Photoing
subgraph Photoing
ShootingChairs
ShootingAll
end

Photoing --> Housekeeping
Housekeeping --> AfterParty
subgraph AfterParty
Chatting
Drinking
ShootingDrinkers
Paying
end

AfterParty --> Completing
Completing --> Completed
```

```



```

See also: [BOT5 Club Chair Manual](http://bot5.ml/manuals/chair/)

## User Journey Diagram

Learn more from [BOT Friday Club Seminar Chair Manual](http://bot5.ml/manuals/chair/)

To be writen...

### Registering

```mermaid
journey
title Registering - BOT Friday Club Seminar
section Register
Make tea: 5: Chair
Go upstairs: 3: Chair
Do work: 1: Member
Miao: 3: Cat, Member
section Go home
Go downstairs: 5: Chair
Sit down: 5: Member
```

### Mindstorming

```mermaid
journey
title Mindstorming - BOT Friday Club Seminar
section Mindsotming
Make tea: 5: Chair
Go upstairs: 3: Chair
Do work: 1: Member
Miao: 3: Cat, Member
section Member PTT
Go downstairs: 5: Chair
Sit down: 5: Member
```

## Getting Started

### Step 1: Install
Expand Down Expand Up @@ -69,6 +198,19 @@ We are trying to use [XState](https://xstate.js.org/) to implement the FSM and u

Currently we are just getting started, you can learn more about the BOT5 Club Meeting FSM at <https://wechaty.github.io/bot5-assistant/>

## Resources

### Projects

- [Dialogs modeled as finite state machines, Giorgio Robino, Jul 14, 2016](https://solyarisoftware.medium.com/dialoghi-come-macchine-a-stati-41bb748fd5b0)

### Papers

- [Dialog Management for Credit Card Selling via Finite State Machine Using Sentiment Classification in Turkish Language, Gizem Sogancıo ˘ glu et. al., INTELLI 2017 : The Sixth International Conference on Intelligent Systems and Applications (includes InManEnt)](https://www.thinkmind.org/articles/intelli_2017_2_30_60066.pdf)
- [State Machine Based Human-Bot Conversation Model and Services, Shayan Zamanirad et. al., May 9, 2020, CAiSE 2020](https://www.semanticscholar.org/paper/State-Machine-Based-Human-Bot-Conversation-Model-Zamanirad-Benatallah/ffa524c4e247a9f532ea4ddb6407be0c9cc8d301)
- [Tartan: A retrieval-based socialbot powered by a dynamic finite-state machine architecture, George Larionov, 4 Dec 2018](https://arxiv.org/abs/1812.01260)
- [A Chatbot by Combining Finite State Machine , Information Retrieval , and Bot-Initiative Strategy, Sanghyun Yi, Published 2017](https://www.semanticscholar.org/paper/A-Chatbot-by-Combining-Finite-State-Machine-%2C-%2C-and-Yi/1fc7c24d80ede54871696e8e44a60fb6d0c8a475)

## History

### main v0.3 (Nov 29, 2021)
Expand Down
47 changes: 32 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wechaty-bot5-assistant",
"version": "0.3.8",
"version": "1.11.0",
"description": "BOT Friday Club Assistant",
"type": "module",
"exports": {
Expand Down Expand Up @@ -31,9 +31,16 @@
"wechaty"
],
"author": {
"name": "Anqi CUI",
"url": "https://wechaty.js.org/contributors/caq"
"name": "Huan LI",
"url": "https://wechaty.js.org/contributors/huan",
"email": "[email protected]"
},
"contributors": [
{
"name": "Anqi CUI",
"url": "https://wechaty.js.org/contributors/caq"
}
],
"repository": {
"type": "git",
"url": "git+https://github.com/wechaty/bot5-assistant.git"
Expand All @@ -45,26 +52,36 @@
"license": "Apache-2.0",
"devDependencies": {
"@chatie/eslint-config": "^1.0.4",
"@chatie/git-scripts": "^0.6.2",
"@chatie/git-scripts": "^0.7.7",
"@chatie/semver": "^0.4.7",
"@chatie/tsconfig": "^4.6.2",
"@types/lru-cache": "^5.1.1",
"@types/request": "^2.48.7",
"@types/uuid": "^8.3.3",
"wechaty": "^1",
"wechaty-mocker": "^1.10.2",
"wechaty-puppet-mock": "^1"
"@chatie/tsconfig": "^4.6.3",
"@types/lru-cache": "^7.4.0",
"@types/request": "^2.48.8",
"@types/uuid": "^8.3.4",
"@types/ws": "^8.5.3",
"@xstate/inspect": "^0.6.4",
"typescript": "^4.6.2",
"utility-types": "^3.10.0",
"wechaty": "^1.18.1",
"wechaty-mocker": "^1.11.3",
"wechaty-puppet-mock": "^1.19.3",
"ws": "^8.5.0"
},
"peerDependencies": {
"wechaty-plugin-contrib": "^1"
"wechaty-plugin-contrib": "^1.11.1"
},
"readme": "README.md",
"dependencies": {
"lru-cache": "^6.0.0",
"file-box": "^1.4.15",
"lru-cache": "^7.5.0",
"mailbox": "^0.10.9",
"request": "^2.88.2",
"tencentcloud-sdk-nodejs": "^4.0.246",
"tencentcloud-sdk-nodejs": "^4.0.306",
"typed-inject": "^3.0.1",
"typesafe-actions": "^5.1.0",
"uuid": "^8.3.2",
"xstate": "^4.26.1"
"wechaty-cqrs": "^0.15.4",
"xstate": "^4.31.0"
},
"git": {
"scripts": {
Expand Down
17 changes: 17 additions & 0 deletions src/actor-utils/invoke-id.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env -S node --no-warnings --loader ts-node/esm
import { test } from 'tstest'

import { invokeId } from './invoke-id.js'

test('invokeId() smoke testing', async t => {
const FIXTURES = [
[
[ 'childId', 'parentId', 'id1', 'id2' ],
'childId@parentId@id1@id2',
],
] as const

for (const [ ids, expected ] of FIXTURES) {
t.equal(invokeId(ids[0], ids[1], ...ids.slice(2)), expected, `invokeId(${ids}) should be ${expected}`)
}
})
13 changes: 13 additions & 0 deletions src/actor-utils/invoke-id.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Generate an invoke id in an machine for make it distinct
*
* @param childId { string } - the id of the child actor
* @param parentId { string } - the id of the parent actor
* @param ids - additional ids
* @returns generated invoke id
*/
export function invokeId (childId: string, parentId: string, ...ids: string[]) {
return [ parentId, ...ids ].reduce((acc, id) => {
return acc + '@' + id
}, childId)
}
1 change: 1 addition & 0 deletions src/actor-utils/mod.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { responseStates } from './response-states.js'
Loading