hap-cli 0.5.0__tar.gz

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 (62) hide show
  1. hap_cli-0.5.0/PKG-INFO +223 -0
  2. hap_cli-0.5.0/hap_cli/README.md +194 -0
  3. hap_cli-0.5.0/hap_cli/README_CN.md +601 -0
  4. hap_cli-0.5.0/hap_cli/__init__.py +3 -0
  5. hap_cli-0.5.0/hap_cli/commands/__init__.py +1 -0
  6. hap_cli-0.5.0/hap_cli/commands/ai_cmd.py +224 -0
  7. hap_cli-0.5.0/hap_cli/commands/app_cmd.py +308 -0
  8. hap_cli-0.5.0/hap_cli/commands/calendar_cmd.py +138 -0
  9. hap_cli-0.5.0/hap_cli/commands/chat_cmd.py +101 -0
  10. hap_cli-0.5.0/hap_cli/commands/config_cmd.py +169 -0
  11. hap_cli-0.5.0/hap_cli/commands/contact_cmd.py +125 -0
  12. hap_cli-0.5.0/hap_cli/commands/department_cmd.py +168 -0
  13. hap_cli-0.5.0/hap_cli/commands/group_cmd.py +128 -0
  14. hap_cli-0.5.0/hap_cli/commands/instance_cmd.py +310 -0
  15. hap_cli-0.5.0/hap_cli/commands/node_cmd.py +538 -0
  16. hap_cli-0.5.0/hap_cli/commands/optionset_cmd.py +99 -0
  17. hap_cli-0.5.0/hap_cli/commands/page_cmd.py +102 -0
  18. hap_cli-0.5.0/hap_cli/commands/plugin_cmd.py +133 -0
  19. hap_cli-0.5.0/hap_cli/commands/post_cmd.py +155 -0
  20. hap_cli-0.5.0/hap_cli/commands/record_cmd.py +228 -0
  21. hap_cli-0.5.0/hap_cli/commands/role_cmd.py +221 -0
  22. hap_cli-0.5.0/hap_cli/commands/workflow_cmd.py +284 -0
  23. hap_cli-0.5.0/hap_cli/commands/worksheet_cmd.py +342 -0
  24. hap_cli-0.5.0/hap_cli/context.py +43 -0
  25. hap_cli-0.5.0/hap_cli/core/__init__.py +1 -0
  26. hap_cli-0.5.0/hap_cli/core/ai.py +133 -0
  27. hap_cli-0.5.0/hap_cli/core/app.py +307 -0
  28. hap_cli-0.5.0/hap_cli/core/auth.py +219 -0
  29. hap_cli-0.5.0/hap_cli/core/calendar_mod.py +114 -0
  30. hap_cli-0.5.0/hap_cli/core/chat.py +73 -0
  31. hap_cli-0.5.0/hap_cli/core/contact.py +85 -0
  32. hap_cli-0.5.0/hap_cli/core/department.py +131 -0
  33. hap_cli-0.5.0/hap_cli/core/flow_node.py +1001 -0
  34. hap_cli-0.5.0/hap_cli/core/group.py +99 -0
  35. hap_cli-0.5.0/hap_cli/core/instance.py +572 -0
  36. hap_cli-0.5.0/hap_cli/core/optionset.py +112 -0
  37. hap_cli-0.5.0/hap_cli/core/page.py +138 -0
  38. hap_cli-0.5.0/hap_cli/core/plugin.py +87 -0
  39. hap_cli-0.5.0/hap_cli/core/post.py +118 -0
  40. hap_cli-0.5.0/hap_cli/core/record.py +268 -0
  41. hap_cli-0.5.0/hap_cli/core/role.py +227 -0
  42. hap_cli-0.5.0/hap_cli/core/session.py +348 -0
  43. hap_cli-0.5.0/hap_cli/core/workflow.py +556 -0
  44. hap_cli-0.5.0/hap_cli/core/worksheet.py +403 -0
  45. hap_cli-0.5.0/hap_cli/hap_cli.py +105 -0
  46. hap_cli-0.5.0/hap_cli/skills/SKILL.md +383 -0
  47. hap_cli-0.5.0/hap_cli/skills/__init__.py +0 -0
  48. hap_cli-0.5.0/hap_cli/tests/__init__.py +1 -0
  49. hap_cli-0.5.0/hap_cli/tests/test_core.py +1824 -0
  50. hap_cli-0.5.0/hap_cli/tests/test_full_e2e.py +136 -0
  51. hap_cli-0.5.0/hap_cli/tests/test_integration.py +805 -0
  52. hap_cli-0.5.0/hap_cli/utils/__init__.py +1 -0
  53. hap_cli-0.5.0/hap_cli/utils/formatting.py +111 -0
  54. hap_cli-0.5.0/hap_cli/utils/options.py +10 -0
  55. hap_cli-0.5.0/hap_cli.egg-info/PKG-INFO +223 -0
  56. hap_cli-0.5.0/hap_cli.egg-info/SOURCES.txt +60 -0
  57. hap_cli-0.5.0/hap_cli.egg-info/dependency_links.txt +1 -0
  58. hap_cli-0.5.0/hap_cli.egg-info/entry_points.txt +2 -0
  59. hap_cli-0.5.0/hap_cli.egg-info/requires.txt +5 -0
  60. hap_cli-0.5.0/hap_cli.egg-info/top_level.txt +1 -0
  61. hap_cli-0.5.0/setup.cfg +4 -0
  62. hap_cli-0.5.0/setup.py +39 -0
hap_cli-0.5.0/PKG-INFO ADDED
@@ -0,0 +1,223 @@
1
+ Metadata-Version: 2.4
2
+ Name: hap-cli
3
+ Version: 0.5.0
4
+ Summary: CLI harness for MingDAO HAP - Enterprise no-code platform
5
+ Author: hap-cli
6
+ License: Apache-2.0
7
+ Classifier: Development Status :: 3 - Alpha
8
+ Classifier: Intended Audience :: Developers
9
+ Classifier: License :: OSI Approved :: Apache Software License
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Requires-Python: >=3.10
15
+ Description-Content-Type: text/markdown
16
+ Requires-Dist: click>=8.0
17
+ Requires-Dist: requests>=2.28
18
+ Provides-Extra: crypto
19
+ Requires-Dist: pycryptodome>=3.15; extra == "crypto"
20
+ Dynamic: author
21
+ Dynamic: classifier
22
+ Dynamic: description
23
+ Dynamic: description-content-type
24
+ Dynamic: license
25
+ Dynamic: provides-extra
26
+ Dynamic: requires-dist
27
+ Dynamic: requires-python
28
+ Dynamic: summary
29
+
30
+ # hap-cli
31
+
32
+ CLI harness for **MingDAO HAP** (明道云) - an enterprise no-code platform (hap).
33
+
34
+ ## Installation
35
+
36
+ ```bash
37
+ pip install -e .
38
+ ```
39
+
40
+ ## Quick Start
41
+
42
+ ### 1. Login
43
+
44
+ **Option A: Browser login (recommended)**
45
+
46
+ ```bash
47
+ # MingDAO SaaS (default)
48
+ hap config login
49
+
50
+ # Specify server
51
+ hap config login mingdao # MingDAO
52
+ hap config login nocoly # Nocoly
53
+ hap config login https://hap.example.com # Self-hosted
54
+ ```
55
+
56
+ Opens your browser to the MingDAO login page. Token is saved automatically after login.
57
+
58
+ **Option B: Manual token**
59
+
60
+ ```bash
61
+ hap config set \
62
+ --server https://your-mingdao-server.com \
63
+ --token YOUR_MD_PSS_ID_TOKEN \
64
+ --app-id YOUR_DEFAULT_APP_ID \
65
+ --project-id YOUR_PROJECT_ID
66
+ ```
67
+
68
+ **Other auth commands**
69
+
70
+ ```bash
71
+ hap config whoami # Show current user info
72
+ hap config logout # Clear saved token
73
+ ```
74
+
75
+ ### 2. List worksheets
76
+
77
+ ```bash
78
+ hap app worksheets
79
+ ```
80
+
81
+ ### 3. Query records
82
+
83
+ ```bash
84
+ hap record list WORKSHEET_ID --page-size 10
85
+ ```
86
+
87
+ ### 4. JSON output (for automation)
88
+
89
+ ```bash
90
+ hap --json record list WORKSHEET_ID
91
+ ```
92
+
93
+ ## Command Groups
94
+
95
+ | Group | Description |
96
+ |-------|-------------|
97
+ | `config` | Server connection and auth |
98
+ | `app` | Application management |
99
+ | `worksheet` | Worksheet info, fields, views |
100
+ | `record` | Record CRUD (list, get, create, update, delete) |
101
+ | `workflow` | Process lifecycle (create, update, publish, trigger, rollback, config) |
102
+ | `node` | Node management (add, delete, save config, test code/webhook/AI) |
103
+ | `instance` | Approval & todo (approve, reject, forward, sign, batch, history) |
104
+ | `role` | Role management and members |
105
+ | `repl` | Interactive REPL mode |
106
+
107
+ ## Workflow Management
108
+
109
+ ```bash
110
+ # Create a workflow
111
+ hap workflow create --company-id CID --name "My Flow" --app-id APP_ID
112
+
113
+ # Add an approval node
114
+ hap node add PROCESS_ID --type 4 --name "Manager Approval"
115
+
116
+ # Configure the node
117
+ hap node save PROCESS_ID NODE_ID --type 4 --config '{"accounts":[...]}'
118
+
119
+ # Test a code node
120
+ hap node test-code PROCESS_ID NODE_ID --code "return 1+1"
121
+
122
+ # Test a webhook node
123
+ hap node test-webhook PROCESS_ID NODE_ID --url https://api.example.com
124
+
125
+ # Publish the workflow
126
+ hap workflow publish PROCESS_ID
127
+
128
+ # Trigger it
129
+ hap workflow trigger PROCESS_ID --source-id ROW_ID
130
+
131
+ # Check version history
132
+ hap workflow history PROCESS_ID
133
+
134
+ # Rollback to previous version
135
+ hap workflow rollback PROCESS_ID
136
+
137
+ # Get/set global config
138
+ hap workflow config-get PROCESS_ID
139
+ hap workflow config-set PROCESS_ID --config '{"allowRevoke":true}'
140
+ ```
141
+
142
+ ## Approval & Todo
143
+
144
+ ```bash
145
+ # Check pending task count
146
+ hap instance todo-count
147
+
148
+ # List pending approval tasks
149
+ hap instance todo --type 4
150
+
151
+ # View instance detail
152
+ hap instance get INSTANCE_ID
153
+
154
+ # Approve
155
+ hap instance approve INSTANCE_ID --opinion "Looks good"
156
+
157
+ # Reject with reason
158
+ hap instance reject INSTANCE_ID --opinion "Need revision"
159
+
160
+ # Forward to another user
161
+ hap instance forward INSTANCE_ID --to USER_ID
162
+
163
+ # Add co-signer
164
+ hap instance sign INSTANCE_ID --to USER_ID --before
165
+
166
+ # Batch approve
167
+ hap instance batch --action 4 -s ID1 -s ID2
168
+
169
+ # View execution history
170
+ hap instance history --process-id PROCESS_ID --status 2
171
+ ```
172
+
173
+ ## REPL Mode
174
+
175
+ ```bash
176
+ hap repl
177
+ hap> record list WORKSHEET_ID
178
+ hap> --json workflow list APP_ID
179
+ hap> instance todo-count
180
+ hap> quit
181
+ ```
182
+
183
+ ## API Authentication
184
+
185
+ The CLI uses MingDAO's `md_pss_id` session token. Use `hap config login` for
186
+ browser-based login, or `hap config set --token TOKEN` to set the token manually.
187
+
188
+ For private deployments with encrypted API responses, install crypto support:
189
+
190
+ ```bash
191
+ pip install hap-cli[crypto]
192
+ ```
193
+
194
+ ## More Examples
195
+
196
+ ```bash
197
+ # List apps
198
+ hap app list --project-id PROJECT_ID
199
+
200
+ # Get worksheet fields
201
+ hap worksheet fields WORKSHEET_ID
202
+
203
+ # Create a record
204
+ hap record create WORKSHEET_ID -f "c001=value1" -f "c002=value2"
205
+
206
+ # Copy a workflow
207
+ hap workflow copy PROCESS_ID --name "Copy of Flow"
208
+
209
+ # Move workflow to another app
210
+ hap workflow move PROCESS_ID TARGET_APP_ID
211
+
212
+ # List code templates
213
+ hap node code-templates --keyword "email"
214
+
215
+ # Test AI node
216
+ hap node test-ai PROCESS_ID NODE_ID --prompt "Summarize this" --model gpt-4
217
+
218
+ # Terminate a stuck instance
219
+ hap instance terminate INSTANCE_ID --yes
220
+
221
+ # Retry a failed instance
222
+ hap instance retry INSTANCE_ID
223
+ ```
@@ -0,0 +1,194 @@
1
+ # hap-cli
2
+
3
+ CLI harness for **MingDAO HAP** (明道云) - an enterprise no-code platform (hap).
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install -e .
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ### 1. Login
14
+
15
+ **Option A: Browser login (recommended)**
16
+
17
+ ```bash
18
+ # MingDAO SaaS (default)
19
+ hap config login
20
+
21
+ # Specify server
22
+ hap config login mingdao # MingDAO
23
+ hap config login nocoly # Nocoly
24
+ hap config login https://hap.example.com # Self-hosted
25
+ ```
26
+
27
+ Opens your browser to the MingDAO login page. Token is saved automatically after login.
28
+
29
+ **Option B: Manual token**
30
+
31
+ ```bash
32
+ hap config set \
33
+ --server https://your-mingdao-server.com \
34
+ --token YOUR_MD_PSS_ID_TOKEN \
35
+ --app-id YOUR_DEFAULT_APP_ID \
36
+ --project-id YOUR_PROJECT_ID
37
+ ```
38
+
39
+ **Other auth commands**
40
+
41
+ ```bash
42
+ hap config whoami # Show current user info
43
+ hap config logout # Clear saved token
44
+ ```
45
+
46
+ ### 2. List worksheets
47
+
48
+ ```bash
49
+ hap app worksheets
50
+ ```
51
+
52
+ ### 3. Query records
53
+
54
+ ```bash
55
+ hap record list WORKSHEET_ID --page-size 10
56
+ ```
57
+
58
+ ### 4. JSON output (for automation)
59
+
60
+ ```bash
61
+ hap --json record list WORKSHEET_ID
62
+ ```
63
+
64
+ ## Command Groups
65
+
66
+ | Group | Description |
67
+ |-------|-------------|
68
+ | `config` | Server connection and auth |
69
+ | `app` | Application management |
70
+ | `worksheet` | Worksheet info, fields, views |
71
+ | `record` | Record CRUD (list, get, create, update, delete) |
72
+ | `workflow` | Process lifecycle (create, update, publish, trigger, rollback, config) |
73
+ | `node` | Node management (add, delete, save config, test code/webhook/AI) |
74
+ | `instance` | Approval & todo (approve, reject, forward, sign, batch, history) |
75
+ | `role` | Role management and members |
76
+ | `repl` | Interactive REPL mode |
77
+
78
+ ## Workflow Management
79
+
80
+ ```bash
81
+ # Create a workflow
82
+ hap workflow create --company-id CID --name "My Flow" --app-id APP_ID
83
+
84
+ # Add an approval node
85
+ hap node add PROCESS_ID --type 4 --name "Manager Approval"
86
+
87
+ # Configure the node
88
+ hap node save PROCESS_ID NODE_ID --type 4 --config '{"accounts":[...]}'
89
+
90
+ # Test a code node
91
+ hap node test-code PROCESS_ID NODE_ID --code "return 1+1"
92
+
93
+ # Test a webhook node
94
+ hap node test-webhook PROCESS_ID NODE_ID --url https://api.example.com
95
+
96
+ # Publish the workflow
97
+ hap workflow publish PROCESS_ID
98
+
99
+ # Trigger it
100
+ hap workflow trigger PROCESS_ID --source-id ROW_ID
101
+
102
+ # Check version history
103
+ hap workflow history PROCESS_ID
104
+
105
+ # Rollback to previous version
106
+ hap workflow rollback PROCESS_ID
107
+
108
+ # Get/set global config
109
+ hap workflow config-get PROCESS_ID
110
+ hap workflow config-set PROCESS_ID --config '{"allowRevoke":true}'
111
+ ```
112
+
113
+ ## Approval & Todo
114
+
115
+ ```bash
116
+ # Check pending task count
117
+ hap instance todo-count
118
+
119
+ # List pending approval tasks
120
+ hap instance todo --type 4
121
+
122
+ # View instance detail
123
+ hap instance get INSTANCE_ID
124
+
125
+ # Approve
126
+ hap instance approve INSTANCE_ID --opinion "Looks good"
127
+
128
+ # Reject with reason
129
+ hap instance reject INSTANCE_ID --opinion "Need revision"
130
+
131
+ # Forward to another user
132
+ hap instance forward INSTANCE_ID --to USER_ID
133
+
134
+ # Add co-signer
135
+ hap instance sign INSTANCE_ID --to USER_ID --before
136
+
137
+ # Batch approve
138
+ hap instance batch --action 4 -s ID1 -s ID2
139
+
140
+ # View execution history
141
+ hap instance history --process-id PROCESS_ID --status 2
142
+ ```
143
+
144
+ ## REPL Mode
145
+
146
+ ```bash
147
+ hap repl
148
+ hap> record list WORKSHEET_ID
149
+ hap> --json workflow list APP_ID
150
+ hap> instance todo-count
151
+ hap> quit
152
+ ```
153
+
154
+ ## API Authentication
155
+
156
+ The CLI uses MingDAO's `md_pss_id` session token. Use `hap config login` for
157
+ browser-based login, or `hap config set --token TOKEN` to set the token manually.
158
+
159
+ For private deployments with encrypted API responses, install crypto support:
160
+
161
+ ```bash
162
+ pip install hap-cli[crypto]
163
+ ```
164
+
165
+ ## More Examples
166
+
167
+ ```bash
168
+ # List apps
169
+ hap app list --project-id PROJECT_ID
170
+
171
+ # Get worksheet fields
172
+ hap worksheet fields WORKSHEET_ID
173
+
174
+ # Create a record
175
+ hap record create WORKSHEET_ID -f "c001=value1" -f "c002=value2"
176
+
177
+ # Copy a workflow
178
+ hap workflow copy PROCESS_ID --name "Copy of Flow"
179
+
180
+ # Move workflow to another app
181
+ hap workflow move PROCESS_ID TARGET_APP_ID
182
+
183
+ # List code templates
184
+ hap node code-templates --keyword "email"
185
+
186
+ # Test AI node
187
+ hap node test-ai PROCESS_ID NODE_ID --prompt "Summarize this" --model gpt-4
188
+
189
+ # Terminate a stuck instance
190
+ hap instance terminate INSTANCE_ID --yes
191
+
192
+ # Retry a failed instance
193
+ hap instance retry INSTANCE_ID
194
+ ```