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,112 @@
1
+ """Option set management for MingDAO HAP."""
2
+
3
+ from typing import Any, Optional
4
+
5
+ from hap_cli.core.session import Session
6
+
7
+
8
+ def get_collections(
9
+ session: Session,
10
+ app_id: str,
11
+ ) -> list[dict[str, Any]]:
12
+ """Get all option set collections for an application.
13
+
14
+ Args:
15
+ session: Active session
16
+ app_id: Application ID
17
+
18
+ Returns:
19
+ List of option set collections
20
+ """
21
+ return session.api_call(
22
+ "Worksheet", "GetCollectionsByAppId",
23
+ {"appId": app_id},
24
+ )
25
+
26
+
27
+ def get_collection(
28
+ session: Session,
29
+ collect_id: str,
30
+ ) -> dict[str, Any]:
31
+ """Get a single option set collection by ID.
32
+
33
+ Args:
34
+ session: Active session
35
+ collect_id: Collection ID
36
+
37
+ Returns:
38
+ Collection detail
39
+ """
40
+ return session.api_call(
41
+ "Worksheet", "GetCollectionByCollectId",
42
+ {"collectId": collect_id},
43
+ )
44
+
45
+
46
+ def save_collection(
47
+ session: Session,
48
+ app_id: str,
49
+ name: str,
50
+ options: list[dict[str, Any]],
51
+ collect_id: str = "",
52
+ ) -> dict[str, Any]:
53
+ """Create or update an option set collection.
54
+
55
+ Args:
56
+ session: Active session
57
+ app_id: Application ID
58
+ name: Collection name
59
+ options: List of option dicts
60
+ collect_id: Collection ID (empty for new)
61
+
62
+ Returns:
63
+ Saved collection info
64
+ """
65
+ data: dict[str, Any] = {
66
+ "appId": app_id,
67
+ "name": name,
68
+ "options": options,
69
+ }
70
+ if collect_id:
71
+ data["collectId"] = collect_id
72
+ return session.api_call("Worksheet", "SaveOptionsCollection", data)
73
+
74
+
75
+ def delete_collection(
76
+ session: Session,
77
+ collect_id: str,
78
+ ) -> dict[str, Any]:
79
+ """Delete an option set collection.
80
+
81
+ Args:
82
+ session: Active session
83
+ collect_id: Collection ID
84
+
85
+ Returns:
86
+ Deletion result
87
+ """
88
+ return session.api_call(
89
+ "Worksheet", "DeleteOptionsCollection",
90
+ {"collectId": collect_id},
91
+ )
92
+
93
+
94
+ def move_collection(
95
+ session: Session,
96
+ collect_id: str,
97
+ new_app_id: str,
98
+ ) -> dict[str, Any]:
99
+ """Move an option set collection to another application.
100
+
101
+ Args:
102
+ session: Active session
103
+ collect_id: Collection ID
104
+ new_app_id: Target application ID
105
+
106
+ Returns:
107
+ Move result
108
+ """
109
+ return session.api_call(
110
+ "Worksheet", "UpdateOptionsCollectionAppId",
111
+ {"collectId": collect_id, "appId": new_app_id},
112
+ )
hap_cli/core/page.py ADDED
@@ -0,0 +1,138 @@
1
+ """Custom page management for MingDAO HAP."""
2
+
3
+ from typing import Any, Optional
4
+
5
+ from hap_cli.core.session import Session
6
+
7
+ PAGE_COMPONENT_TYPES = {
8
+ "analysis": "Chart/Statistics",
9
+ "button": "Button",
10
+ "filter": "Filter",
11
+ "carousel": "Carousel",
12
+ "view": "View",
13
+ "richText": "Rich Text",
14
+ "image": "Image",
15
+ "embedUrl": "Embedded URL",
16
+ "tabs": "Tabs Container",
17
+ "card": "Card Container",
18
+ }
19
+
20
+
21
+ def copy_page(
22
+ session: Session,
23
+ app_id: str,
24
+ page_id: str,
25
+ page_name: str,
26
+ ) -> dict[str, Any]:
27
+ """Copy a custom page.
28
+
29
+ Args:
30
+ session: Active session
31
+ app_id: Application ID
32
+ page_id: Source page ID
33
+ page_name: Name for the copied page
34
+
35
+ Returns:
36
+ Copied page info
37
+ """
38
+ return session.api_call(
39
+ "AppManagement", "CopyCustomPage",
40
+ {"appId": app_id, "pageId": page_id, "pageName": page_name},
41
+ )
42
+
43
+
44
+ def add_authorize(
45
+ session: Session,
46
+ app_id: str,
47
+ page_id: str,
48
+ role_id: str,
49
+ ) -> dict[str, Any]:
50
+ """Add authorization for a role on a custom page.
51
+
52
+ Args:
53
+ session: Active session
54
+ app_id: Application ID
55
+ page_id: Page ID
56
+ role_id: Role ID to authorize
57
+
58
+ Returns:
59
+ Authorization result
60
+ """
61
+ return session.api_call(
62
+ "AppManagement", "AddAuthorize",
63
+ {"appId": app_id, "pageId": page_id, "roleId": role_id},
64
+ )
65
+
66
+
67
+ def get_authorizes(
68
+ session: Session,
69
+ app_id: str,
70
+ page_id: str,
71
+ ) -> list[dict[str, Any]]:
72
+ """Get authorizations for a custom page.
73
+
74
+ Args:
75
+ session: Active session
76
+ app_id: Application ID
77
+ page_id: Page ID
78
+
79
+ Returns:
80
+ List of authorization dicts
81
+ """
82
+ return session.api_call(
83
+ "AppManagement", "GetAuthorizes",
84
+ {"appId": app_id, "pageId": page_id},
85
+ )
86
+
87
+
88
+ def edit_authorize_status(
89
+ session: Session,
90
+ app_id: str,
91
+ page_id: str,
92
+ authorize_id: str,
93
+ status: int,
94
+ ) -> dict[str, Any]:
95
+ """Edit authorization status for a custom page.
96
+
97
+ Args:
98
+ session: Active session
99
+ app_id: Application ID
100
+ page_id: Page ID
101
+ authorize_id: Authorization ID
102
+ status: New status value
103
+
104
+ Returns:
105
+ Edit result
106
+ """
107
+ return session.api_call(
108
+ "AppManagement", "EditAuthorizeStatus",
109
+ {
110
+ "appId": app_id,
111
+ "pageId": page_id,
112
+ "authorizeId": authorize_id,
113
+ "status": status,
114
+ },
115
+ )
116
+
117
+
118
+ def delete_authorize(
119
+ session: Session,
120
+ app_id: str,
121
+ page_id: str,
122
+ authorize_id: str,
123
+ ) -> dict[str, Any]:
124
+ """Delete authorization for a custom page.
125
+
126
+ Args:
127
+ session: Active session
128
+ app_id: Application ID
129
+ page_id: Page ID
130
+ authorize_id: Authorization ID
131
+
132
+ Returns:
133
+ Deletion result
134
+ """
135
+ return session.api_call(
136
+ "AppManagement", "DeleteAuthorizeStatus",
137
+ {"appId": app_id, "pageId": page_id, "authorizeId": authorize_id},
138
+ )
hap_cli/core/plugin.py ADDED
@@ -0,0 +1,87 @@
1
+ """Plugin management for MingDAO HAP."""
2
+
3
+ from typing import Any, Optional
4
+
5
+ from hap_cli.core.session import Session
6
+
7
+
8
+ def get_plugins(
9
+ session: Session,
10
+ project_id: str,
11
+ page_index: int = 1,
12
+ page_size: int = 20,
13
+ ) -> dict[str, Any]:
14
+ """Get plugin list."""
15
+ return session.api_call(
16
+ "Plugin", "getList",
17
+ {"projectId": project_id, "pageIndex": page_index, "pageSize": page_size},
18
+ )
19
+
20
+
21
+ def get_plugin_detail(
22
+ session: Session,
23
+ plugin_id: str,
24
+ ) -> dict[str, Any]:
25
+ """Get plugin detail."""
26
+ return session.api_call("Plugin", "getDetail", {"id": plugin_id})
27
+
28
+
29
+ def create_plugin(
30
+ session: Session,
31
+ project_id: str,
32
+ name: str,
33
+ description: str = "",
34
+ ) -> dict[str, Any]:
35
+ """Create a new plugin."""
36
+ data: dict[str, Any] = {"projectId": project_id, "name": name}
37
+ if description:
38
+ data["description"] = description
39
+ return session.api_call("Plugin", "create", data)
40
+
41
+
42
+ def edit_plugin(
43
+ session: Session,
44
+ plugin_id: str,
45
+ name: str = "",
46
+ description: str = "",
47
+ ) -> dict[str, Any]:
48
+ """Edit plugin name and/or description."""
49
+ data: dict[str, Any] = {"id": plugin_id}
50
+ if name:
51
+ data["name"] = name
52
+ if description:
53
+ data["description"] = description
54
+ return session.api_call("Plugin", "edit", data)
55
+
56
+
57
+ def remove_plugin(
58
+ session: Session,
59
+ plugin_id: str,
60
+ ) -> dict[str, Any]:
61
+ """Delete a plugin."""
62
+ return session.api_call("Plugin", "remove", {"id": plugin_id})
63
+
64
+
65
+ def release_plugin(
66
+ session: Session,
67
+ plugin_id: str,
68
+ ) -> dict[str, Any]:
69
+ """Release a new version of a plugin."""
70
+ return session.api_call("Plugin", "release", {"id": plugin_id})
71
+
72
+
73
+ def rollback_plugin(
74
+ session: Session,
75
+ plugin_id: str,
76
+ version_id: str,
77
+ ) -> dict[str, Any]:
78
+ """Rollback a plugin to a specific version."""
79
+ return session.api_call("Plugin", "rollback", {"id": plugin_id, "versionId": version_id})
80
+
81
+
82
+ def get_release_history(
83
+ session: Session,
84
+ plugin_id: str,
85
+ ) -> dict[str, Any]:
86
+ """Get plugin release/version history."""
87
+ return session.api_call("Plugin", "getReleaseHistory", {"id": plugin_id})
hap_cli/core/post.py ADDED
@@ -0,0 +1,118 @@
1
+ """Feed/post management for MingDAO HAP."""
2
+
3
+ from typing import Any, Optional
4
+
5
+ from hap_cli.core.session import Session
6
+
7
+
8
+ def get_post_list(
9
+ session: Session,
10
+ project_id: str,
11
+ post_type: int = 0,
12
+ page_index: int = 1,
13
+ page_size: int = 20,
14
+ ) -> dict[str, Any]:
15
+ """Get feed/post list."""
16
+ return session.api_call(
17
+ "Post", "GetPostList",
18
+ {
19
+ "projectId": project_id,
20
+ "postType": post_type,
21
+ "pageIndex": page_index,
22
+ "pageSize": page_size,
23
+ },
24
+ )
25
+
26
+
27
+ def get_post_detail(
28
+ session: Session,
29
+ post_id: str,
30
+ ) -> dict[str, Any]:
31
+ """Get post detail."""
32
+ return session.api_call("Post", "GetPostDetail", {"postId": post_id})
33
+
34
+
35
+ def add_post(
36
+ session: Session,
37
+ project_id: str,
38
+ post_type: int,
39
+ message: str,
40
+ scope: int = 0,
41
+ ) -> dict[str, Any]:
42
+ """Create a new post/dynamic."""
43
+ return session.api_call(
44
+ "Post", "AddPost",
45
+ {
46
+ "projectId": project_id,
47
+ "postType": post_type,
48
+ "postMsg": message,
49
+ "scope": scope,
50
+ },
51
+ )
52
+
53
+
54
+ def edit_post(
55
+ session: Session,
56
+ post_id: str,
57
+ message: str,
58
+ ) -> dict[str, Any]:
59
+ """Edit a post."""
60
+ return session.api_call("Post", "EditPost", {"postId": post_id, "postMsg": message})
61
+
62
+
63
+ def remove_post(
64
+ session: Session,
65
+ post_id: str,
66
+ ) -> dict[str, Any]:
67
+ """Delete a post."""
68
+ return session.api_call("Post", "RemovePost", {"postId": post_id})
69
+
70
+
71
+ def add_comment(
72
+ session: Session,
73
+ post_id: str,
74
+ message: str,
75
+ reply_id: str = "",
76
+ ) -> dict[str, Any]:
77
+ """Add a comment to a post."""
78
+ data: dict[str, Any] = {"postId": post_id, "message": message}
79
+ if reply_id:
80
+ data["replyId"] = reply_id
81
+ return session.api_call("Post", "AddPostComment", data)
82
+
83
+
84
+ def get_comments(
85
+ session: Session,
86
+ post_id: str,
87
+ page_index: int = 1,
88
+ page_size: int = 20,
89
+ ) -> dict[str, Any]:
90
+ """Get comments for a post."""
91
+ return session.api_call(
92
+ "Post", "GetMorePostComments",
93
+ {"postId": post_id, "pageIndex": page_index, "pageSize": page_size},
94
+ )
95
+
96
+
97
+ def like_post(
98
+ session: Session,
99
+ post_id: str,
100
+ ) -> dict[str, Any]:
101
+ """Like or unlike a post."""
102
+ return session.api_call("Post", "Like", {"postId": post_id})
103
+
104
+
105
+ def add_top_post(
106
+ session: Session,
107
+ post_id: str,
108
+ ) -> dict[str, Any]:
109
+ """Pin a post to top."""
110
+ return session.api_call("Post", "AddTopPost", {"postId": post_id})
111
+
112
+
113
+ def remove_top_post(
114
+ session: Session,
115
+ post_id: str,
116
+ ) -> dict[str, Any]:
117
+ """Unpin a post from top."""
118
+ return session.api_call("Post", "RemoveTopPost", {"postId": post_id})