dwf-platform-cli 0.2.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.
- dwf_cli/__init__.py +3 -0
- dwf_cli/__main__.py +4 -0
- dwf_cli/api/__init__.py +3 -0
- dwf_cli/api/auth.py +46 -0
- dwf_cli/api/client.py +113 -0
- dwf_cli/api/datamodel.py +458 -0
- dwf_cli/api/formmodel.py +197 -0
- dwf_cli/api/funcmodel.py +436 -0
- dwf_cli/cli/__init__.py +69 -0
- dwf_cli/cli/_common.py +152 -0
- dwf_cli/cli/auth.py +197 -0
- dwf_cli/cli/config.py +200 -0
- dwf_cli/cli/datamodel.py +2270 -0
- dwf_cli/cli/formmodel.py +1007 -0
- dwf_cli/cli/funcmodel.py +2055 -0
- dwf_cli/cli/schema.py +210 -0
- dwf_cli/core/__init__.py +0 -0
- dwf_cli/core/config.py +177 -0
- dwf_cli/core/crypto.py +22 -0
- dwf_cli/core/errors.py +63 -0
- dwf_cli/core/output.py +6 -0
- dwf_cli/core/validator.py +129 -0
- dwf_cli/mcp/__init__.py +3 -0
- dwf_cli/mcp/server.py +411 -0
- dwf_cli/schemas/__init__.py +37 -0
- dwf_cli/schemas/datamodel/attribute_bind.schema.json +21 -0
- dwf_cli/schemas/datamodel/attribute_create.schema.json +24 -0
- dwf_cli/schemas/datamodel/attribute_update.schema.json +21 -0
- dwf_cli/schemas/datamodel/create.schema.json +27 -0
- dwf_cli/schemas/datamodel/excel_confirm.schema.json +65 -0
- dwf_cli/schemas/datamodel/external_create.schema.json +47 -0
- dwf_cli/schemas/datamodel/external_update.schema.json +47 -0
- dwf_cli/schemas/datamodel/object_create.schema.json +24 -0
- dwf_cli/schemas/datamodel/object_update.schema.json +17 -0
- dwf_cli/schemas/datamodel/relation_create.schema.json +34 -0
- dwf_cli/schemas/datamodel/relation_update.schema.json +34 -0
- dwf_cli/schemas/datamodel/update.schema.json +26 -0
- dwf_cli/schemas/funcmodel/app_create.schema.json +150 -0
- dwf_cli/schemas/funcmodel/app_update.schema.json +153 -0
- dwf_cli/schemas/funcmodel/language-package_create.schema.json +15 -0
- dwf_cli/schemas/funcmodel/operations_create.schema.json +77 -0
- dwf_cli/schemas/funcmodel/operations_update.schema.json +76 -0
- dwf_platform_cli-0.2.0.dist-info/METADATA +347 -0
- dwf_platform_cli-0.2.0.dist-info/RECORD +47 -0
- dwf_platform_cli-0.2.0.dist-info/WHEEL +4 -0
- dwf_platform_cli-0.2.0.dist-info/entry_points.txt +3 -0
- dwf_platform_cli-0.2.0.dist-info/licenses/LICENSE +190 -0
dwf_cli/api/formmodel.py
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING, Any
|
|
4
|
+
|
|
5
|
+
if TYPE_CHECKING:
|
|
6
|
+
from dwf_cli.api.client import APIClient
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def list_views(
|
|
10
|
+
client: APIClient,
|
|
11
|
+
class_name: str,
|
|
12
|
+
*,
|
|
13
|
+
need_v3_content: bool = False,
|
|
14
|
+
) -> Any:
|
|
15
|
+
return client.get(
|
|
16
|
+
f"/dwf/v1/meta/class/{class_name}/views",
|
|
17
|
+
params={
|
|
18
|
+
"needV3Content": str(need_v3_content).lower(),
|
|
19
|
+
},
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def create_views(
|
|
24
|
+
client: APIClient,
|
|
25
|
+
views: list[dict[str, Any]],
|
|
26
|
+
) -> Any:
|
|
27
|
+
return client.post(
|
|
28
|
+
"/dwf/v1/meta/views-create",
|
|
29
|
+
json=views,
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def update_view(
|
|
34
|
+
client: APIClient,
|
|
35
|
+
view: dict[str, Any],
|
|
36
|
+
*,
|
|
37
|
+
force_update: bool = False,
|
|
38
|
+
) -> Any:
|
|
39
|
+
return client.post(
|
|
40
|
+
"/dwf/v1/meta/view-update",
|
|
41
|
+
params={
|
|
42
|
+
"forceUpdate": str(force_update).lower(),
|
|
43
|
+
},
|
|
44
|
+
json=view,
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def delete_view(
|
|
49
|
+
client: APIClient,
|
|
50
|
+
oid: str,
|
|
51
|
+
) -> Any:
|
|
52
|
+
return client.post(f"/dwf/v1/meta/views-delete/{oid}")
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def copy_view(
|
|
56
|
+
client: APIClient,
|
|
57
|
+
oid: str,
|
|
58
|
+
*,
|
|
59
|
+
new_class_name: str = "",
|
|
60
|
+
new_view_name: str = "",
|
|
61
|
+
new_device_type: str = "actPc",
|
|
62
|
+
new_display_name: str = "",
|
|
63
|
+
new_note: str = "",
|
|
64
|
+
new_form_type: str = "PC",
|
|
65
|
+
) -> Any:
|
|
66
|
+
return client.post(
|
|
67
|
+
f"/dwf/v1/meta/views/{oid}/copy",
|
|
68
|
+
json={
|
|
69
|
+
"newClassName": new_class_name,
|
|
70
|
+
"newViewName": new_view_name,
|
|
71
|
+
"newDeviceType": new_device_type,
|
|
72
|
+
"newDisplayName": new_display_name,
|
|
73
|
+
"newNote": new_note,
|
|
74
|
+
"newFormType": new_form_type,
|
|
75
|
+
},
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def create_component_group(
|
|
80
|
+
client: APIClient,
|
|
81
|
+
name: str,
|
|
82
|
+
display_name: str = "",
|
|
83
|
+
) -> Any:
|
|
84
|
+
return client.post(
|
|
85
|
+
"/dwf/v1/meta/component/component-groups-create",
|
|
86
|
+
json={
|
|
87
|
+
"name": name,
|
|
88
|
+
"displayName": display_name,
|
|
89
|
+
},
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def get_component_tree(
|
|
94
|
+
client: APIClient,
|
|
95
|
+
*,
|
|
96
|
+
need_v3_content: bool = False,
|
|
97
|
+
form_type: str = "",
|
|
98
|
+
) -> Any:
|
|
99
|
+
params: dict[str, str] = {
|
|
100
|
+
"needV3Content": str(need_v3_content).lower(),
|
|
101
|
+
}
|
|
102
|
+
if form_type:
|
|
103
|
+
params["formType"] = form_type
|
|
104
|
+
return client.get(
|
|
105
|
+
"/dwf/v1/meta/component/get-tree",
|
|
106
|
+
params=params,
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def create_component(
|
|
111
|
+
client: APIClient,
|
|
112
|
+
component: list[dict[str, Any]],
|
|
113
|
+
) -> Any:
|
|
114
|
+
return client.post(
|
|
115
|
+
"/dwf/v1/meta/component/components-create",
|
|
116
|
+
json=component,
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def update_comp2compgroup(
|
|
121
|
+
client: APIClient,
|
|
122
|
+
*,
|
|
123
|
+
component_display_name: str = "",
|
|
124
|
+
component_group_oid: str = "",
|
|
125
|
+
component_icon: str = "",
|
|
126
|
+
component_note: str = "",
|
|
127
|
+
component_oid: str = "",
|
|
128
|
+
oid: str = "",
|
|
129
|
+
) -> Any:
|
|
130
|
+
return client.post(
|
|
131
|
+
"/dwf/v1/meta/component/comp2compgroup-update",
|
|
132
|
+
json={
|
|
133
|
+
"componentDisplayName": component_display_name,
|
|
134
|
+
"componentGroupOid": component_group_oid,
|
|
135
|
+
"componentIcon": component_icon,
|
|
136
|
+
"componentNote": component_note,
|
|
137
|
+
"componentOid": component_oid,
|
|
138
|
+
"oid": oid,
|
|
139
|
+
},
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def delete_component(
|
|
144
|
+
client: APIClient,
|
|
145
|
+
oid: str,
|
|
146
|
+
) -> Any:
|
|
147
|
+
return client.post(f"/dwf/v1/meta/component/component-delete/{oid}")
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def delete_component_group(
|
|
151
|
+
client: APIClient,
|
|
152
|
+
oid: str,
|
|
153
|
+
) -> Any:
|
|
154
|
+
return client.post(f"/dwf/v1/meta/component/component-groups-delete/{oid}")
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
def get_view_by_device_type(
|
|
158
|
+
client: APIClient,
|
|
159
|
+
class_name: str,
|
|
160
|
+
view_name: str,
|
|
161
|
+
device_type: str,
|
|
162
|
+
form_type: str,
|
|
163
|
+
) -> Any:
|
|
164
|
+
return client.get(
|
|
165
|
+
f"/dwf/v1/meta/class/{class_name}/views/{view_name}/devices/{device_type}/type/{form_type}",
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def list_library_files(
|
|
170
|
+
client: APIClient,
|
|
171
|
+
library_id: str = "picture_management",
|
|
172
|
+
) -> Any:
|
|
173
|
+
return client.get(f"/dwf/v1/libraries/{library_id}/files")
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
def upload_file(
|
|
177
|
+
client: APIClient,
|
|
178
|
+
file_content: bytes,
|
|
179
|
+
file_name: str,
|
|
180
|
+
*,
|
|
181
|
+
library_id: str = "",
|
|
182
|
+
) -> Any:
|
|
183
|
+
params: dict[str, str] = {}
|
|
184
|
+
if library_id:
|
|
185
|
+
params["libraryId"] = library_id
|
|
186
|
+
return client.post(
|
|
187
|
+
"/dwf/v1/files-upload",
|
|
188
|
+
params=params or None,
|
|
189
|
+
files={"file": (file_name, file_content)},
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
def delete_file(
|
|
194
|
+
client: APIClient,
|
|
195
|
+
file_oid: str,
|
|
196
|
+
) -> Any:
|
|
197
|
+
return client.post(f"/dwf/v1/files-delete/{file_oid}")
|
dwf_cli/api/funcmodel.py
ADDED
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from typing import TYPE_CHECKING, Any
|
|
5
|
+
|
|
6
|
+
import httpx
|
|
7
|
+
|
|
8
|
+
if TYPE_CHECKING:
|
|
9
|
+
from dwf_cli.api.client import APIClient
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
# ── Theme ──────────────────────────────────────────────────────────────
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def list_themes(client: APIClient) -> Any:
|
|
16
|
+
return client.get("/dwf/v1/theme-list")
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def create_theme(
|
|
20
|
+
client: APIClient,
|
|
21
|
+
*,
|
|
22
|
+
theme_name: str,
|
|
23
|
+
note: str | None = None,
|
|
24
|
+
file_path: str | Path,
|
|
25
|
+
) -> Any:
|
|
26
|
+
with open(file_path, "rb") as f:
|
|
27
|
+
files = {"file": f}
|
|
28
|
+
params: dict[str, str] = {"themeName": theme_name}
|
|
29
|
+
if note is not None:
|
|
30
|
+
params["note"] = note
|
|
31
|
+
return client.post("/dwf/v1/theme-create", params=params, files=files)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def update_theme(
|
|
35
|
+
client: APIClient,
|
|
36
|
+
oid: str,
|
|
37
|
+
*,
|
|
38
|
+
theme_name: str | None = None,
|
|
39
|
+
note: str | None = None,
|
|
40
|
+
file_path: str | Path | None = None,
|
|
41
|
+
) -> Any:
|
|
42
|
+
params: dict[str, str] = {}
|
|
43
|
+
if theme_name is not None:
|
|
44
|
+
params["themeName"] = theme_name
|
|
45
|
+
if note is not None:
|
|
46
|
+
params["note"] = note
|
|
47
|
+
|
|
48
|
+
kwargs: dict[str, Any] = {"params": params}
|
|
49
|
+
if file_path is not None:
|
|
50
|
+
with open(file_path, "rb") as f:
|
|
51
|
+
kwargs["files"] = {"file": f}
|
|
52
|
+
return client.post(f"/dwf/v1/theme-update/{oid}", **kwargs)
|
|
53
|
+
return client.post(f"/dwf/v1/theme-update/{oid}", **kwargs)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def delete_theme(client: APIClient, oid: str) -> Any:
|
|
57
|
+
return client.post(f"/dwf/v1/theme-delete/{oid}")
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
# ── App CRUD ───────────────────────────────────────────────────────────
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def list_apps(
|
|
64
|
+
client: APIClient,
|
|
65
|
+
*,
|
|
66
|
+
published_only: bool = False,
|
|
67
|
+
with_modeler_app: bool = True,
|
|
68
|
+
with_ext_config: bool = True,
|
|
69
|
+
app_type: str | None = None,
|
|
70
|
+
) -> Any:
|
|
71
|
+
params: dict[str, str] = {
|
|
72
|
+
"publishedOnly": str(published_only).lower(),
|
|
73
|
+
"withModelerApp": str(with_modeler_app).lower(),
|
|
74
|
+
"withExtConfig": str(with_ext_config).lower(),
|
|
75
|
+
}
|
|
76
|
+
if app_type is not None:
|
|
77
|
+
params["type"] = app_type
|
|
78
|
+
return client.get("/dwf/v1/apps", params=params)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def get_app_by_name(client: APIClient, name: str) -> Any:
|
|
82
|
+
return client.get(f"/dwf/v1/apps/{name}")
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def get_app_by_id(
|
|
86
|
+
client: APIClient, app_id: str, *, language: str | None = None
|
|
87
|
+
) -> Any:
|
|
88
|
+
params: dict[str, str] = {}
|
|
89
|
+
if language is not None:
|
|
90
|
+
params["language"] = language
|
|
91
|
+
return client.get(f"/dwf/v1/apps/id/{app_id}", params=params)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def get_default_app_by_type(
|
|
95
|
+
client: APIClient, app_type: str, *, language: str | None = None
|
|
96
|
+
) -> Any:
|
|
97
|
+
params: dict[str, str] = {}
|
|
98
|
+
if language is not None:
|
|
99
|
+
params["language"] = language
|
|
100
|
+
return client.get(f"/dwf/v1/apps/default-app/{app_type}", params=params)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def create_app(client: APIClient, data: dict[str, Any]) -> Any:
|
|
104
|
+
return client.post("/dwf/v1/apps-create", json=data)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def update_app(client: APIClient, data: dict[str, Any]) -> Any:
|
|
108
|
+
return client.post("/dwf/v1/apps-update", json=data)
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def delete_app(client: APIClient, app_id: str) -> Any:
|
|
112
|
+
return client.post(f"/dwf/v1/apps-delete/{app_id}")
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def set_default_app(client: APIClient, app_id: str, set_default: bool) -> Any:
|
|
116
|
+
return client.post(
|
|
117
|
+
f"/dwf/v1/app-set-default/{app_id}",
|
|
118
|
+
params={"setDefault": str(set_default).lower()},
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def publish_app(client: APIClient, app_id: str, publish: bool) -> Any:
|
|
123
|
+
return client.post(
|
|
124
|
+
f"/dwf/v1/app-publish/{app_id}",
|
|
125
|
+
params={"publish": str(publish).lower()},
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def reset_modeler_menus(client: APIClient) -> Any:
|
|
130
|
+
return client.post("/dwf/v1/apps/reset-modeler")
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
# ── Logo / Icon / CSS ──────────────────────────────────────────────────
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def upload_logo(client: APIClient, app_id: str, file_path: str | Path) -> Any:
|
|
137
|
+
with open(file_path, "rb") as f:
|
|
138
|
+
files = {"logo": f}
|
|
139
|
+
return client.post(f"/dwf/v1/apps/{app_id}/logo-upload", files=files)
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def upload_icon(client: APIClient, app_id: str, file_path: str | Path) -> Any:
|
|
143
|
+
with open(file_path, "rb") as f:
|
|
144
|
+
files = {"icon": f}
|
|
145
|
+
return client.post(f"/dwf/v1/apps/{app_id}/icon-upload", files=files)
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
def get_logo(client: APIClient, app_id: str) -> httpx.Response:
|
|
149
|
+
return client.download(f"/dwf/v1/apps/{app_id}/logo")
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def get_logo_base64(client: APIClient, app_id: str, img_type: str = "logoImg") -> Any:
|
|
153
|
+
return client.get(
|
|
154
|
+
f"/dwf/v1/apps/{app_id}/img-base64",
|
|
155
|
+
params={"imgType": img_type},
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def get_css_file(client: APIClient, app_id: str) -> httpx.Response:
|
|
160
|
+
return client.download(f"/dwf/v1/apps/{app_id}/css")
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
# ── Language Package ───────────────────────────────────────────────────
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def list_language_packages(client: APIClient, app_id: str) -> Any:
|
|
167
|
+
return client.get(f"/dwf/v1/apps/{app_id}/app-language-packages")
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def get_language_package_by_language(
|
|
171
|
+
client: APIClient, app_id: str, language: str
|
|
172
|
+
) -> Any:
|
|
173
|
+
return client.get(f"/dwf/v1/apps/{app_id}/app-language-package/{language}")
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
def get_language_package_file(
|
|
177
|
+
client: APIClient, app_id: str, language: str
|
|
178
|
+
) -> httpx.Response:
|
|
179
|
+
return client.download(
|
|
180
|
+
f"/dwf/v1/apps/{app_id}/app-language-package/{language}/get-file"
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
def get_language_package_json(
|
|
185
|
+
client: APIClient, app_id: str, language: str, *, is_frontend: bool = True
|
|
186
|
+
) -> Any:
|
|
187
|
+
return client.get(
|
|
188
|
+
f"/dwf/v1/app/{app_id}/app-language-package/{language}/get-json",
|
|
189
|
+
params={"isFrontend": str(is_frontend).lower()},
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
def create_language_package(
|
|
194
|
+
client: APIClient, app_language_package_do: str, file_path: str | Path
|
|
195
|
+
) -> Any:
|
|
196
|
+
with open(file_path, "rb") as f:
|
|
197
|
+
files = {"file": f}
|
|
198
|
+
return client.post(
|
|
199
|
+
"/dwf/v1/apps/apps-language-package-create",
|
|
200
|
+
params={"appLanguagePackageDO": app_language_package_do},
|
|
201
|
+
files=files,
|
|
202
|
+
)
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
def update_language_package(
|
|
206
|
+
client: APIClient, package_id: str, file_path: str | Path
|
|
207
|
+
) -> Any:
|
|
208
|
+
with open(file_path, "rb") as f:
|
|
209
|
+
files = {"file": f}
|
|
210
|
+
return client.post(
|
|
211
|
+
f"/dwf/v1/apps/apps-language-package-update/{package_id}",
|
|
212
|
+
files=files,
|
|
213
|
+
)
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
def delete_language_package(client: APIClient, package_id: str) -> Any:
|
|
217
|
+
return client.post(f"/dwf/v1/apps/apps-language-package-delete/{package_id}")
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
def delete_language_packages_by_app(client: APIClient, app_id: str) -> Any:
|
|
221
|
+
return client.post(f"/dwf/v1/apps/{app_id}/apps-language-package-delete")
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
def get_supported_language_types(
|
|
225
|
+
client: APIClient, *, mobile_only: bool = False
|
|
226
|
+
) -> Any:
|
|
227
|
+
return client.get(
|
|
228
|
+
"/dwf/v1/apps/app-language-types",
|
|
229
|
+
params={"mobileOnly": str(mobile_only).lower()},
|
|
230
|
+
)
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
def get_language_package_template_file(
|
|
234
|
+
client: APIClient, template_type: str = "PC"
|
|
235
|
+
) -> httpx.Response:
|
|
236
|
+
return client.download(
|
|
237
|
+
"/dwf/v1/apps/app-language-package/get-template",
|
|
238
|
+
params={"type": template_type},
|
|
239
|
+
)
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
def get_language_package_template_json(
|
|
243
|
+
client: APIClient, template_type: str = "PC", second_key: str | None = None
|
|
244
|
+
) -> Any:
|
|
245
|
+
params: dict[str, str] = {"type": template_type}
|
|
246
|
+
if second_key is not None:
|
|
247
|
+
params["secondKey"] = second_key
|
|
248
|
+
return client.get(
|
|
249
|
+
"/dwf/v1/app/app-language-package/get-template-json", params=params
|
|
250
|
+
)
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
# ── Operations ─────────────────────────────────────────────────────────
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
_OPERATION_TYPE_PATHS: dict[str, str] = {
|
|
257
|
+
"global": "/dwf/v1/meta/global-operations",
|
|
258
|
+
"entity": "/dwf/v1/meta/entities-operations",
|
|
259
|
+
"relation": "/dwf/v1/meta/relations-operations",
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
def list_operations(
|
|
264
|
+
client: APIClient,
|
|
265
|
+
operation_type: str,
|
|
266
|
+
*,
|
|
267
|
+
page: int = 0,
|
|
268
|
+
page_size: int = 25,
|
|
269
|
+
with_page_info: bool = True,
|
|
270
|
+
fuzzy_search: str | None = None,
|
|
271
|
+
) -> dict[str, Any]:
|
|
272
|
+
path = _OPERATION_TYPE_PATHS[operation_type]
|
|
273
|
+
if operation_type == "global":
|
|
274
|
+
body: dict[str, str] = {}
|
|
275
|
+
if fuzzy_search:
|
|
276
|
+
body["conType"] = fuzzy_search
|
|
277
|
+
body["displayName"] = fuzzy_search
|
|
278
|
+
body["name"] = fuzzy_search
|
|
279
|
+
body["action"] = fuzzy_search
|
|
280
|
+
return client.post(
|
|
281
|
+
path,
|
|
282
|
+
params={
|
|
283
|
+
"pageIndex": page,
|
|
284
|
+
"pageSize": page_size,
|
|
285
|
+
"withPageInfo": str(with_page_info).lower(),
|
|
286
|
+
},
|
|
287
|
+
json=body,
|
|
288
|
+
)
|
|
289
|
+
params: dict[str, Any] = {
|
|
290
|
+
"pageIndex": page,
|
|
291
|
+
"pageSize": page_size,
|
|
292
|
+
"withPageInfo": str(with_page_info).lower(),
|
|
293
|
+
}
|
|
294
|
+
if fuzzy_search:
|
|
295
|
+
params["fuzzySearch"] = fuzzy_search
|
|
296
|
+
return client.get(path, params=params)
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
def get_all_operations(client: APIClient) -> Any:
|
|
300
|
+
return client.get("/dwf/v1/meta/operations")
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
def get_operation_keywords(client: APIClient) -> Any:
|
|
304
|
+
return client.get("/dwf/v1/meta/operations-keywords")
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
def get_operation_by_id(client: APIClient, oid: str) -> Any:
|
|
308
|
+
return client.get(f"/dwf/v1/meta/queryoperations/{oid}")
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
def get_operations_by_ids(client: APIClient, ids: list[str]) -> Any:
|
|
312
|
+
return client.post("/dwf/v1/meta/queryoperations", json=ids)
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
def create_operation(
|
|
316
|
+
client: APIClient,
|
|
317
|
+
data: dict[str, Any],
|
|
318
|
+
*,
|
|
319
|
+
auto_generate_name: bool = False,
|
|
320
|
+
) -> Any:
|
|
321
|
+
return client.post(
|
|
322
|
+
"/dwf/v1/meta/queryoperations-create",
|
|
323
|
+
params={"autoGenerateName": str(auto_generate_name).lower()},
|
|
324
|
+
json=data,
|
|
325
|
+
)
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
def update_operation(
|
|
329
|
+
client: APIClient,
|
|
330
|
+
data: dict[str, Any],
|
|
331
|
+
*,
|
|
332
|
+
force_update: bool = False,
|
|
333
|
+
) -> Any:
|
|
334
|
+
return client.post(
|
|
335
|
+
"/dwf/v1/meta/queryoperations-update",
|
|
336
|
+
params={"forceUpdate": str(force_update).lower()},
|
|
337
|
+
json=data,
|
|
338
|
+
)
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
def delete_operation(client: APIClient, oid: str) -> Any:
|
|
342
|
+
return client.post(f"/dwf/v1/meta/queryoperations-delete/{oid}")
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
def move_operation(client: APIClient, oid: str, parent_id: str) -> Any:
|
|
346
|
+
return client.post(
|
|
347
|
+
f"/dwf/v1/meta/queryoperations/{oid}/move",
|
|
348
|
+
params={"parentId": parent_id},
|
|
349
|
+
)
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
def hide_operation(client: APIClient, oid: str, hide: bool) -> Any:
|
|
353
|
+
return client.post(
|
|
354
|
+
f"/dwf/v1/meta/queryoperations/{oid}/hide",
|
|
355
|
+
params={"hide": str(hide).lower()},
|
|
356
|
+
)
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
def check_operation_display_name(client: APIClient, data: dict[str, Any]) -> Any:
|
|
360
|
+
return client.post("/dwf/v1/meta/queryoperations-displayNameCheck", json=data)
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
def get_global_implement_scripts(
|
|
364
|
+
client: APIClient, *, is_client_script: bool = True
|
|
365
|
+
) -> Any:
|
|
366
|
+
return client.get(
|
|
367
|
+
"/dwf/v1/meta/global-implement-scripts",
|
|
368
|
+
params={"isClientScript": str(is_client_script).lower()},
|
|
369
|
+
)
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
# ── Modules ─────────────────────────────────────────────────────────────
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
def list_modules(
|
|
376
|
+
client: APIClient,
|
|
377
|
+
*,
|
|
378
|
+
app_id: str | None = None,
|
|
379
|
+
with_default_module: bool = False,
|
|
380
|
+
language: str | None = None,
|
|
381
|
+
) -> Any:
|
|
382
|
+
params: dict[str, str] = {
|
|
383
|
+
"withDefaultModule": str(with_default_module).lower(),
|
|
384
|
+
}
|
|
385
|
+
if app_id:
|
|
386
|
+
params["appId"] = app_id
|
|
387
|
+
if language:
|
|
388
|
+
params["language"] = language
|
|
389
|
+
return client.get("/dwf/v1/meta/modules", params=params)
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
def get_modules_operations_tree(
|
|
393
|
+
client: APIClient,
|
|
394
|
+
*,
|
|
395
|
+
app_id: str | None = None,
|
|
396
|
+
with_default_module: bool = False,
|
|
397
|
+
published_only: bool = True,
|
|
398
|
+
with_hidden: bool = False,
|
|
399
|
+
language: str | None = None,
|
|
400
|
+
) -> Any:
|
|
401
|
+
params: dict[str, str] = {
|
|
402
|
+
"withDefaultModule": str(with_default_module).lower(),
|
|
403
|
+
"publishedOnly": str(published_only).lower(),
|
|
404
|
+
"withHidden": str(with_hidden).lower(),
|
|
405
|
+
}
|
|
406
|
+
if app_id:
|
|
407
|
+
params["appId"] = app_id
|
|
408
|
+
if language:
|
|
409
|
+
params["language"] = language
|
|
410
|
+
return client.get("/dwf/v1/meta/modules-operations", params=params)
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
def get_module_operations(
|
|
414
|
+
client: APIClient,
|
|
415
|
+
module_name: str,
|
|
416
|
+
*,
|
|
417
|
+
with_hidden: bool = False,
|
|
418
|
+
language: str | None = None,
|
|
419
|
+
) -> Any:
|
|
420
|
+
params: dict[str, str] = {
|
|
421
|
+
"withHidden": str(with_hidden).lower(),
|
|
422
|
+
}
|
|
423
|
+
if language:
|
|
424
|
+
params["language"] = language
|
|
425
|
+
return client.get(f"/dwf/v1/meta/modules/{module_name}/operations", params=params)
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
def update_modules_tree_order(
|
|
429
|
+
client: APIClient,
|
|
430
|
+
app_id: str,
|
|
431
|
+
tree_data: list[dict[str, Any]],
|
|
432
|
+
) -> Any:
|
|
433
|
+
return client.post(
|
|
434
|
+
f"/dwf/v1/meta/modules-tree/{app_id}/update-order",
|
|
435
|
+
json=tree_data,
|
|
436
|
+
)
|
dwf_cli/cli/__init__.py
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Annotated
|
|
4
|
+
|
|
5
|
+
import typer
|
|
6
|
+
|
|
7
|
+
from dwf_cli.cli import auth, config, datamodel, formmodel, funcmodel, schema
|
|
8
|
+
from dwf_cli.cli._common import APIClient, ContextObj
|
|
9
|
+
from dwf_cli.core.config import Config
|
|
10
|
+
from dwf_cli.core.errors import DWFError
|
|
11
|
+
|
|
12
|
+
_HELP_CONTEXT_SETTINGS = {"help_option_names": ["-h", "--help"]}
|
|
13
|
+
|
|
14
|
+
__version__ = "0.2.0"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def _version_callback(value: bool) -> None:
|
|
18
|
+
if value:
|
|
19
|
+
typer.echo(f"dwf-cli {__version__}")
|
|
20
|
+
raise typer.Exit(code=0)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
app = typer.Typer(
|
|
24
|
+
name="dwf-cli",
|
|
25
|
+
help="DWF platform command-line tool.",
|
|
26
|
+
pretty_exceptions_show_locals=False,
|
|
27
|
+
rich_markup_mode="rich",
|
|
28
|
+
context_settings=_HELP_CONTEXT_SETTINGS,
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
app.add_typer(auth.app, name="auth")
|
|
32
|
+
app.add_typer(datamodel.app, name="datamodel")
|
|
33
|
+
app.add_typer(funcmodel.app, name="funcmodel")
|
|
34
|
+
app.add_typer(formmodel.app, name="formmodel")
|
|
35
|
+
app.add_typer(config.app, name="config")
|
|
36
|
+
app.add_typer(schema.app, name="schema")
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
@app.callback(invoke_without_command=True)
|
|
40
|
+
def main(
|
|
41
|
+
ctx: typer.Context,
|
|
42
|
+
version: Annotated[
|
|
43
|
+
bool | None,
|
|
44
|
+
typer.Option(
|
|
45
|
+
"--version",
|
|
46
|
+
"-V",
|
|
47
|
+
help="Show version and exit",
|
|
48
|
+
callback=_version_callback,
|
|
49
|
+
is_eager=True,
|
|
50
|
+
),
|
|
51
|
+
] = None,
|
|
52
|
+
) -> None:
|
|
53
|
+
if ctx.invoked_subcommand is None:
|
|
54
|
+
typer.echo(ctx.get_help())
|
|
55
|
+
raise typer.Exit(code=0)
|
|
56
|
+
|
|
57
|
+
try:
|
|
58
|
+
cfg = Config()
|
|
59
|
+
except DWFError:
|
|
60
|
+
cfg = Config.__new__(Config)
|
|
61
|
+
cfg._data = {}
|
|
62
|
+
client: APIClient | None = None
|
|
63
|
+
app_client: APIClient | None = None
|
|
64
|
+
if cfg.server and cfg.token:
|
|
65
|
+
client = APIClient(cfg.server, cfg.token)
|
|
66
|
+
app_url = cfg.app_server
|
|
67
|
+
if app_url and app_url != cfg.server:
|
|
68
|
+
app_client = APIClient(app_url, cfg.token)
|
|
69
|
+
ctx.obj = ContextObj(config=cfg, client=client, app_client=app_client)
|