hap-cli 0.5.0__py3-none-any.whl

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 (58) hide show
  1. hap_cli/README.md +194 -0
  2. hap_cli/README_CN.md +601 -0
  3. hap_cli/__init__.py +3 -0
  4. hap_cli/commands/__init__.py +1 -0
  5. hap_cli/commands/ai_cmd.py +224 -0
  6. hap_cli/commands/app_cmd.py +308 -0
  7. hap_cli/commands/calendar_cmd.py +138 -0
  8. hap_cli/commands/chat_cmd.py +101 -0
  9. hap_cli/commands/config_cmd.py +169 -0
  10. hap_cli/commands/contact_cmd.py +125 -0
  11. hap_cli/commands/department_cmd.py +168 -0
  12. hap_cli/commands/group_cmd.py +128 -0
  13. hap_cli/commands/instance_cmd.py +310 -0
  14. hap_cli/commands/node_cmd.py +538 -0
  15. hap_cli/commands/optionset_cmd.py +99 -0
  16. hap_cli/commands/page_cmd.py +102 -0
  17. hap_cli/commands/plugin_cmd.py +133 -0
  18. hap_cli/commands/post_cmd.py +155 -0
  19. hap_cli/commands/record_cmd.py +228 -0
  20. hap_cli/commands/role_cmd.py +221 -0
  21. hap_cli/commands/workflow_cmd.py +284 -0
  22. hap_cli/commands/worksheet_cmd.py +342 -0
  23. hap_cli/context.py +43 -0
  24. hap_cli/core/__init__.py +1 -0
  25. hap_cli/core/ai.py +133 -0
  26. hap_cli/core/app.py +307 -0
  27. hap_cli/core/auth.py +219 -0
  28. hap_cli/core/calendar_mod.py +114 -0
  29. hap_cli/core/chat.py +73 -0
  30. hap_cli/core/contact.py +85 -0
  31. hap_cli/core/department.py +131 -0
  32. hap_cli/core/flow_node.py +1001 -0
  33. hap_cli/core/group.py +99 -0
  34. hap_cli/core/instance.py +572 -0
  35. hap_cli/core/optionset.py +112 -0
  36. hap_cli/core/page.py +138 -0
  37. hap_cli/core/plugin.py +87 -0
  38. hap_cli/core/post.py +118 -0
  39. hap_cli/core/record.py +268 -0
  40. hap_cli/core/role.py +227 -0
  41. hap_cli/core/session.py +348 -0
  42. hap_cli/core/workflow.py +556 -0
  43. hap_cli/core/worksheet.py +403 -0
  44. hap_cli/hap_cli.py +105 -0
  45. hap_cli/skills/SKILL.md +383 -0
  46. hap_cli/skills/__init__.py +0 -0
  47. hap_cli/tests/__init__.py +1 -0
  48. hap_cli/tests/test_core.py +1824 -0
  49. hap_cli/tests/test_full_e2e.py +136 -0
  50. hap_cli/tests/test_integration.py +805 -0
  51. hap_cli/utils/__init__.py +1 -0
  52. hap_cli/utils/formatting.py +111 -0
  53. hap_cli/utils/options.py +10 -0
  54. hap_cli-0.5.0.dist-info/METADATA +223 -0
  55. hap_cli-0.5.0.dist-info/RECORD +58 -0
  56. hap_cli-0.5.0.dist-info/WHEEL +5 -0
  57. hap_cli-0.5.0.dist-info/entry_points.txt +2 -0
  58. hap_cli-0.5.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,383 @@
1
+ ---
2
+ name: hap-cli
3
+ description: CLI harness for MingDAO HAP (明道云) enterprise no-code platform
4
+ version: 0.5.0
5
+ software: hap
6
+ platform: cross-platform
7
+ auth: md_pss_id session token (browser login or manual)
8
+ api_protocol: REST POST /api/{Controller}/{Action}
9
+ install: pip install hap-cli
10
+ binary: hap
11
+ ---
12
+
13
+ # hap-cli
14
+
15
+ CLI harness for **MingDAO HAP** (明道云), an enterprise no-code/low-code platform.
16
+ Enables programmatic management of applications, worksheets, records, workflows, nodes, approvals, roles, AI assistants, plugins, contacts, departments, groups, chats, posts, calendars, custom pages, and option sets.
17
+
18
+ ## Command Groups
19
+
20
+ ### config - Server Configuration & Authentication
21
+ ```bash
22
+ hap config login [SERVER] # Browser login (mingdao/nocoly/self-hosted URL)
23
+ hap config set --server URL --token TOKEN [--app-id ID] [--project-id ID]
24
+ hap config show
25
+ hap config whoami # Show current logged-in user
26
+ hap config logout # Clear saved token
27
+ ```
28
+
29
+ ### app - Application Management
30
+ ```bash
31
+ hap app list --project-id PID [--keyword K]
32
+ hap app info APP_ID
33
+ hap app worksheets APP_ID
34
+ ```
35
+
36
+ ### worksheet - Worksheet Operations
37
+ ```bash
38
+ hap worksheet info WS_ID [--app-id ID]
39
+ hap worksheet fields WS_ID [--app-id ID]
40
+ hap worksheet views WS_ID [--app-id ID]
41
+ ```
42
+
43
+ ### record - Record CRUD
44
+ ```bash
45
+ hap record list WS_ID [--view-id V] [--page-size N] [--keywords K]
46
+ hap record get WS_ID ROW_ID
47
+ hap record create WS_ID -f CID=VAL [-f ...]
48
+ hap record update WS_ID ROW_ID -f CID=VAL [-f ...]
49
+ hap record delete WS_ID ROW_ID1 [ROW_ID2 ...] [--yes]
50
+ ```
51
+
52
+ ### workflow - Process Lifecycle
53
+ ```bash
54
+ hap workflow list APP_ID [--keyword K]
55
+ hap workflow get PROCESS_ID
56
+ hap workflow create --company-id CID --name N [--app-id A] [--type 1]
57
+ hap workflow update PROCESS_ID [--name N] [--desc D]
58
+ hap workflow delete PROCESS_ID [--yes]
59
+ hap workflow copy PROCESS_ID --name N [--sub-process]
60
+ hap workflow move PROCESS_ID TARGET_APP_ID
61
+ hap workflow publish PROCESS_ID [--disable]
62
+ hap workflow rollback PROCESS_ID [--yes]
63
+ hap workflow history PROCESS_ID
64
+ hap workflow config-get PROCESS_ID
65
+ hap workflow config-set PROCESS_ID --config '{"allowRevoke":true}'
66
+ hap workflow trigger PROCESS_ID [--source-id ROW_ID]
67
+ hap workflow trigger-pbp PROCESS_ID --app-id A
68
+ hap workflow groups APP_ID
69
+ hap workflow stats --company-id CID
70
+ ```
71
+
72
+ ### node - Node Management
73
+ ```bash
74
+ hap node types # Show all node types and action IDs
75
+ hap node list PROCESS_ID
76
+ hap node get PROCESS_ID NODE_ID [--type 4]
77
+ hap node add PROCESS_ID --type 6 [--name N] [--after NODE_ID] [--action-id 1]
78
+ hap node delete PROCESS_ID NODE_ID [--yes]
79
+ hap node rename PROCESS_ID NODE_ID --name N
80
+ hap node desc PROCESS_ID NODE_ID [--desc D] [--alias A]
81
+ hap node save PROCESS_ID NODE_ID --type 4 --config '{...}'
82
+ hap node controls PROCESS_ID NODE_ID --app-id WS_ID # Get worksheet fields for node config
83
+ # Data processing nodes:
84
+ hap node save-action PID NID -a 1 --app-id WS [-f '[{fieldId,type,fieldValue}]'] [-s SRC_NID]
85
+ hap node save-action PID NID -a 2 --app-id WS -s SRC_NID [-f '[...]'] # Edit record
86
+ hap node save-action PID NID -a 3 --app-id WS -s SRC_NID # Delete record
87
+ hap node save-search PID NID -a 406 --app-id WS [--condition '[...]'] [--not-found 0|1|2]
88
+ hap node save-search PID NID -a 421 --app-id WS [-f '[...]'] # Find & update
89
+ hap node save-search PID NID -a 422 --app-id WS # Find & delete
90
+ hap node save-get-more PID NID -a 400 --app-id WS [--condition '[...]'] [--limit '{...}']
91
+ hap node save-get-more PID NID -a 412 --app-id WS [-f '[...]'] # Batch update
92
+ hap node save-get-more PID NID -a 413 --app-id WS # Batch delete
93
+ # Testing:
94
+ hap node test-code PROCESS_ID NODE_ID --code 'return 1+1' [--input '[...]']
95
+ hap node test-webhook PROCESS_ID NODE_ID --url URL [--method GET] [--body '{}']
96
+ hap node test-ai PROCESS_ID NODE_ID --prompt 'Summarize' [--model M]
97
+ # Utilities:
98
+ hap node form-property PROCESS_ID NODE_ID
99
+ hap node sub-processes PROCESS_ID
100
+ hap node json-to-controls --json-str '{"key":"val"}'
101
+ hap node code-templates [--keyword K]
102
+ hap node create-code-template --name N --code C
103
+ ```
104
+
105
+ ### instance - Approval & Todo
106
+ ```bash
107
+ hap instance todo-count
108
+ hap instance todo [--type -1] [--keyword K] [--process-id P]
109
+ hap instance get INSTANCE_ID [--work-id W]
110
+ hap instance operations INSTANCE_ID
111
+ hap instance op-history INSTANCE_ID
112
+ hap instance approve INSTANCE_ID [--work-id W] [--opinion O]
113
+ hap instance reject INSTANCE_ID [--opinion O] [--back-to NODE_ID]
114
+ hap instance forward INSTANCE_ID --to USER_ID [--opinion O]
115
+ hap instance sign INSTANCE_ID --to USER_ID [--before/--after]
116
+ hap instance submit INSTANCE_ID [--work-id W]
117
+ hap instance revoke INSTANCE_ID
118
+ hap instance urge INSTANCE_ID
119
+ hap instance terminate INSTANCE_ID [--yes]
120
+ hap instance retry INSTANCE_ID
121
+ hap instance restart INSTANCE_ID
122
+ hap instance history [--process-id P] [--status 1] [--keyword K]
123
+ hap instance history-detail INSTANCE_ID
124
+ hap instance batch --action 4 [--select ID1 -s ID2]
125
+ ```
126
+
127
+ ### role - Role Management
128
+ ```bash
129
+ hap role list APP_ID
130
+ hap role create APP_ID --name N [--permission 10]
131
+ hap role delete APP_ID ROLE_ID [--move-to R] [--yes]
132
+ hap role add-member APP_ID ROLE_ID -u UID [-u ...]
133
+ hap role remove-member APP_ID ROLE_ID -u UID [-u ...]
134
+ hap role permissions APP_ID ROLE_ID
135
+ hap role set-permissions APP_ID ROLE_ID --config '{...}'
136
+ hap role rename APP_ID ROLE_ID --name N
137
+ hap role apply APP_ID ROLE_ID [--note N]
138
+ hap role approve APP_ID ROLE_ID --account-id UID
139
+ hap role reject APP_ID ROLE_ID --account-id UID
140
+ hap role pending APP_ID ROLE_ID
141
+ ```
142
+
143
+ ### optionset - Option Set Management
144
+ ```bash
145
+ hap optionset list --app-id APP_ID
146
+ hap optionset get COLLECT_ID
147
+ hap optionset save --app-id APP_ID --name N --options '[{...}]'
148
+ hap optionset delete COLLECT_ID [--yes]
149
+ hap optionset move COLLECT_ID --app-id TARGET_APP_ID
150
+ ```
151
+
152
+ ### page - Custom Page Management
153
+ ```bash
154
+ hap page copy APP_ID PAGE_ID --name N
155
+ hap page authorize APP_ID PAGE_ID --role-id ROLE_ID
156
+ hap page permissions APP_ID PAGE_ID
157
+ hap page edit-permission APP_ID PAGE_ID AUTH_ID --status 0|1
158
+ hap page delete-permission APP_ID PAGE_ID AUTH_ID [--yes]
159
+ hap page component-types
160
+ ```
161
+
162
+ ### contact - Address Book & Contacts
163
+ ```bash
164
+ hap contact search KEYWORDS [--project-id PID]
165
+ hap contact get ACCOUNT_ID
166
+ hap contact friends
167
+ hap contact add-friend ACCOUNT_ID
168
+ hap contact remove-friend ACCOUNT_ID [--yes]
169
+ hap contact friend-requests
170
+ hap contact accept-friend ACCOUNT_ID
171
+ hap contact reject-friend ACCOUNT_ID
172
+ ```
173
+
174
+ ### department - Department Management
175
+ ```bash
176
+ hap department list --project-id PID [--parent-id DID]
177
+ hap department tree --project-id PID DEPT_ID
178
+ hap department info DEPT_ID
179
+ hap department create --project-id PID --name N [--parent-id DID]
180
+ hap department update DEPT_ID [--name N]
181
+ hap department delete --project-id PID -d DID [-d ...]
182
+ hap department members --project-id PID DEPT_ID
183
+ hap department search --project-id PID KEYWORDS
184
+ hap department move DEPT_ID --target-id TARGET_DEPT_ID
185
+ ```
186
+
187
+ ### post - Feed & Post Management
188
+ ```bash
189
+ hap post list --project-id PID [--page-size N]
190
+ hap post get POST_ID
191
+ hap post create --project-id PID --type 1 --message TEXT
192
+ hap post update POST_ID --message TEXT
193
+ hap post delete POST_ID [--yes]
194
+ hap post comment POST_ID --message TEXT
195
+ hap post comments POST_ID
196
+ hap post like POST_ID
197
+ hap post top POST_ID [--remove]
198
+ ```
199
+
200
+ ### calendar - Calendar & Schedule
201
+ ```bash
202
+ hap calendar list --start START_DATE --end END_DATE [--project-id PID]
203
+ hap calendar get CALENDAR_ID
204
+ hap calendar create --name N --start START_DATE --end END_DATE
205
+ hap calendar update CALENDAR_ID [--name N] [--start S] [--end E]
206
+ hap calendar delete CALENDAR_ID [--yes]
207
+ hap calendar add-member CALENDAR_ID -m MEMBER_ID [-m ...]
208
+ hap calendar remove-member CALENDAR_ID MEMBER_ID
209
+ hap calendar categories
210
+ ```
211
+
212
+ ### chat - Chat & Messaging
213
+ ```bash
214
+ hap chat list
215
+ hap chat send -t ACCOUNT_ID [-t ...] --message TEXT
216
+ hap chat send-file GROUP_ID --file PATH
217
+ hap chat send-card GROUP_ID --card '{...}'
218
+ hap chat group-info GROUP_ID
219
+ hap chat group-files GROUP_ID
220
+ ```
221
+
222
+ ### group - Group Management
223
+ ```bash
224
+ hap group list --project-id PID [--page-size N]
225
+ hap group info GROUP_ID
226
+ hap group create --project-id PID --name N [--about A] [-m UID ...]
227
+ hap group delete GROUP_ID [--yes]
228
+ hap group members GROUP_ID
229
+ hap group remove-member GROUP_ID ACCOUNT_ID
230
+ hap group update GROUP_ID [--name N] [--about A]
231
+ ```
232
+
233
+ ### ai - AI Assistant & Service
234
+ ```bash
235
+ hap ai assistants --project-id PID
236
+ hap ai assistant-get ASSISTANT_ID
237
+ hap ai assistant-create --config '{...}'
238
+ hap ai assistant-delete ASSISTANT_ID [--yes]
239
+ hap ai assistant-status ASSISTANT_ID --status 1|0
240
+ hap ai knowledge-list --project-id PID
241
+ hap ai knowledge-get KB_ID
242
+ hap ai knowledge-create --config '{...}'
243
+ hap ai knowledge-delete KB_ID [--yes]
244
+ hap ai chatbot-config PROCESS_ID
245
+ hap ai chatbot-save PROCESS_ID --config '{...}'
246
+ hap ai service-status --project-id PID
247
+ hap ai models --project-id PID
248
+ ```
249
+
250
+ ### plugin - Plugin Management
251
+ ```bash
252
+ hap plugin list --project-id PID
253
+ hap plugin get PLUGIN_ID
254
+ hap plugin create --project-id PID --name N [--desc D]
255
+ hap plugin edit PLUGIN_ID [--name N] [--desc D]
256
+ hap plugin delete PLUGIN_ID [--yes]
257
+ hap plugin release PLUGIN_ID
258
+ hap plugin rollback PLUGIN_ID VERSION_ID
259
+ hap plugin history PLUGIN_ID
260
+ ```
261
+
262
+ ### repl - Interactive Mode
263
+ ```bash
264
+ hap repl
265
+ ```
266
+
267
+ ## JSON Output
268
+
269
+ Add `--json` before any command group:
270
+ ```bash
271
+ hap --json workflow list APP_ID
272
+ hap --json instance todo
273
+ hap --json node get PROCESS_ID NODE_ID
274
+ ```
275
+
276
+ ## Node Types Reference
277
+
278
+ | Type | Name | Description |
279
+ |------|------|-------------|
280
+ | 0 | Start | Start event |
281
+ | 1 | Branch | Conditional branch/gateway |
282
+ | 2 | BranchItem | Branch condition item |
283
+ | 3 | Fill | Fill-in form task |
284
+ | 4 | Approval | Approval task |
285
+ | 5 | CC | CC notification |
286
+ | **6** | **Action** | **Data processing: add/edit/delete record** |
287
+ | **7** | **Search** | **Get single record** |
288
+ | 8 | WebHook | HTTP request |
289
+ | 9 | Formula | Formula/calculation |
290
+ | 10 | Message | SMS notification |
291
+ | 11 | Email | Email notification |
292
+ | 12 | Delay | Timer/delay |
293
+ | **13** | **GetMoreRecord** | **Get multiple records / batch ops** |
294
+ | 14 | Code | Code block (JS/Python) |
295
+ | 15 | Link | Get record link |
296
+ | 16 | SubProcess | Sub-process call |
297
+ | 17 | Push | UI push notification |
298
+ | 18 | File | Print/PDF generation |
299
+ | 19 | Template | Template message |
300
+ | 20 | PBP | Packaged Business Process |
301
+ | 21 | JSONParse | JSON parser |
302
+ | 22 | Authentication | API auth |
303
+ | 25 | API | Integrated API call |
304
+ | 26 | ApprovalProcess | Initiate approval |
305
+ | 27 | Notice | Internal notice |
306
+ | 28 | Snapshot | Data snapshot |
307
+ | 29 | Loop | Loop processing |
308
+ | 31 | AIGC | AI text/object generation |
309
+ | 32 | Plugin | Plugin call |
310
+ | 33 | Agent | AI Agent |
311
+
312
+ ## Action IDs (for data processing nodes)
313
+
314
+ | Action | ID | Node | Description |
315
+ |--------|-----|------|-------------|
316
+ | ADD_RECORD | 1 | 6 | Add single record |
317
+ | EDIT_RECORD | 2 | 6 | Edit record fields |
318
+ | DELETE_RECORD | 3 | 6 | Delete record |
319
+ | RELATION | 20 | 6 | Get related record |
320
+ | WORKSHEET_FIND | 406 | 7 | Find one from worksheet |
321
+ | BATCH_FIND | 407 | 7 | Find one from multi-records |
322
+ | RECORD_UPDATE | 421 | 7 | Find and update |
323
+ | RECORD_DELETE | 422 | 7 | Find and delete |
324
+ | FROM_WORKSHEET | 400 | 13 | Get multi from worksheet |
325
+ | FROM_RECORD | 401 | 13 | Get multi from relation |
326
+ | BATCH_UPDATE | 412 | 13 | Batch update records |
327
+ | BATCH_DELETE | 413 | 13 | Batch delete records |
328
+
329
+ ## Instance Status Reference
330
+
331
+ | Status | Meaning |
332
+ |--------|---------|
333
+ | 1 | Running |
334
+ | 2 | Completed |
335
+ | 3 | Rejected |
336
+ | 4 | Failed/Terminated |
337
+
338
+ ## Todo Type Reference
339
+
340
+ | Type | Meaning |
341
+ |------|---------|
342
+ | -1 | All pending |
343
+ | 0 | Initiated by me |
344
+ | 3 | Pending fill |
345
+ | 4 | Pending approval |
346
+ | 5 | Pending view |
347
+
348
+ ## Agent Usage Notes
349
+
350
+ - **Authentication**: Use `config login` for browser-based login, or `config set --token` for manual token. Supports mingdao, nocoly, and self-hosted servers.
351
+ - **Workflow lifecycle**: create -> add nodes -> save node config -> publish -> trigger.
352
+ - **Node config**: Use `node get` to see current config, then modify and `node save`.
353
+ - **Testing nodes**: Use `test-code`, `test-webhook`, or `test-ai` before publishing.
354
+ - **Approvals**: Use `instance todo` to find tasks, then `approve`/`reject`/`forward`.
355
+ - **Batch operations**: `instance batch --action 4` for batch approve, `5` for batch reject.
356
+
357
+ ## Example: Build and Deploy a Workflow
358
+
359
+ ```bash
360
+ # 1. Create workflow
361
+ hap --json workflow create -c COMPANY_ID -n "Auto Approval" -a APP_ID
362
+
363
+ # 2. Get process nodes (has start node by default)
364
+ hap --json node list PROCESS_ID
365
+
366
+ # 3. Add approval node after start
367
+ hap --json node add PROCESS_ID --type 4 --name "Manager Approval" --after START_NODE_ID
368
+
369
+ # 4. Configure approval node
370
+ hap node save PROCESS_ID NODE_ID --type 4 --config '{"accounts":[{"accountId":"MGR_USER_ID"}]}'
371
+
372
+ # 5. Publish workflow
373
+ hap workflow publish PROCESS_ID
374
+
375
+ # 6. Trigger
376
+ hap --json workflow trigger PROCESS_ID --source-id ROW_ID
377
+
378
+ # 7. Check pending approvals
379
+ hap --json instance todo --type 4
380
+
381
+ # 8. Approve
382
+ hap instance approve INSTANCE_ID --opinion "Approved"
383
+ ```
File without changes
@@ -0,0 +1 @@
1
+ """Tests for hap-cli harness."""