@josephyan/qingflow-app-builder-mcp 0.2.0-beta.69 → 0.2.0-beta.70
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.
- package/README.md +2 -2
- package/package.json +1 -1
- package/pyproject.toml +1 -1
- package/skills/qingflow-app-builder/SKILL.md +7 -3
- package/skills/qingflow-app-builder/references/tool-selection.md +3 -3
- package/skills/qingflow-app-builder-code-integrations/references/code-block.md +26 -0
- package/skills/qingflow-app-builder-code-integrations/references/q-linker.md +3 -0
- package/src/qingflow_mcp/backend_client.py +0 -1
- package/src/qingflow_mcp/builder_facade/models.py +34 -0
- package/src/qingflow_mcp/builder_facade/service.py +337 -17
- package/src/qingflow_mcp/cli/commands/builder.py +248 -1
- package/src/qingflow_mcp/cli/commands/common.py +15 -0
- package/src/qingflow_mcp/cli/commands/imports.py +12 -2
- package/src/qingflow_mcp/cli/commands/record.py +132 -32
- package/src/qingflow_mcp/cli/commands/workspace.py +1 -1
- package/src/qingflow_mcp/cli/formatters.py +52 -2
- package/src/qingflow_mcp/cli/main.py +7 -5
- package/src/qingflow_mcp/response_trim.py +668 -0
- package/src/qingflow_mcp/server_app_builder.py +136 -8
- package/src/qingflow_mcp/server_app_user.py +55 -11
- package/src/qingflow_mcp/tools/ai_builder_tools.py +270 -5
- package/src/qingflow_mcp/tools/app_tools.py +29 -0
- package/src/qingflow_mcp/tools/auth_tools.py +259 -1
- package/src/qingflow_mcp/tools/import_tools.py +59 -7
- package/src/qingflow_mcp/tools/qingbi_report_tools.py +23 -6
- package/src/qingflow_mcp/tools/record_tools.py +6 -12
- package/src/qingflow_mcp/tools/workspace_tools.py +124 -7
package/README.md
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
Install:
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
|
-
npm install @josephyan/qingflow-app-builder-mcp@0.2.0-beta.
|
|
6
|
+
npm install @josephyan/qingflow-app-builder-mcp@0.2.0-beta.70
|
|
7
7
|
```
|
|
8
8
|
|
|
9
9
|
Run:
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
-
npx -y -p @josephyan/qingflow-app-builder-mcp@0.2.0-beta.
|
|
12
|
+
npx -y -p @josephyan/qingflow-app-builder-mcp@0.2.0-beta.70 qingflow-app-builder-mcp
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
Environment:
|
package/package.json
CHANGED
package/pyproject.toml
CHANGED
|
@@ -48,7 +48,7 @@ Default modeling rules:
|
|
|
48
48
|
|
|
49
49
|
- Authentication and workspace: `auth_*`, `workspace_*`
|
|
50
50
|
- File upload: `file_upload_local`
|
|
51
|
-
- Resource resolve/read: `package_list`, `package_resolve`, `package_create`, `builder_tool_contract`, `member_search`, `role_search`, `app_resolve`, `app_read_summary`, `app_read_fields`, `app_read_layout_summary`, `app_read_views_summary`, `app_read_flow_summary`, `app_read_charts_summary`, `portal_read_summary`
|
|
51
|
+
- Resource resolve/read: `package_list`, `package_resolve`, `package_create`, `builder_tool_contract`, `member_search`, `role_search`, `app_resolve`, `app_read_summary`, `app_read_fields`, `app_read_layout_summary`, `app_read_views_summary`, `app_read_flow_summary`, `app_read_charts_summary`, `portal_list`, `portal_get`, `portal_read_summary`, `view_get`, `chart_get`
|
|
52
52
|
- Resource patch: `app_schema_apply`, `app_layout_apply`, `app_flow_apply`, `app_views_apply`, `app_charts_apply`, `portal_apply`, `package_attach_app`, `app_release_edit_lock_if_mine`, `role_create`
|
|
53
53
|
- Publish and verify: `app_publish_verify`
|
|
54
54
|
|
|
@@ -60,7 +60,11 @@ Note:
|
|
|
60
60
|
- `app_charts_apply` is immediate-live and does not publish; it resolves targets by `chart_id` first and then exact unique chart name.
|
|
61
61
|
- `portal_apply` uses replace semantics for sections; remove a section by omitting it from the next full sections list. `publish=false` only guarantees draft/base-info updates, and `chart_ref/view_ref` resolve by `id/key` first and exact unique name second.
|
|
62
62
|
- `app_read_charts_summary` is the compact discovery path for current chart inventory; use it before `app_charts_apply` when you need exact `chart_id` values.
|
|
63
|
+
- `chart_get` returns one chart's base info, config, and concrete chart data; prefer it over low-level `qingbi_report_*` reads in public builder flows.
|
|
64
|
+
- `portal_list` is the discovery path for accessible portals.
|
|
63
65
|
- `portal_read_summary` is the compact discovery path for portal draft/live summaries; it returns section summaries, not the raw dash payload.
|
|
66
|
+
- `portal_get` returns portal-level detail plus a component inventory; it does not inline chart/view detail.
|
|
67
|
+
- `view_get` returns one view's definition detail only; use `record_list` separately when you need rows from that view.
|
|
64
68
|
- `app_schema_apply` / `app_layout_apply` / `app_flow_apply` / `app_views_apply` now perform planning, normalization, and dependency checks internally; when prechecks block, read the returned blocking issues and `suggested_next_call` directly from the apply result.
|
|
65
69
|
- If you are unsure about a public builder tool's keys, aliases, presets, or minimal legal shape, call `builder_tool_contract` instead of guessing.
|
|
66
70
|
- For views, always write the canonical key `columns`. Do not emit `column_names`; treat `fields` only as a tolerated legacy alias, not the preferred shape.
|
|
@@ -103,10 +107,10 @@ For builder work:
|
|
|
103
107
|
2. Decide whether the target is one app or a multi-app package:
|
|
104
108
|
- one app: continue with `app_resolve`
|
|
105
109
|
- multi-app package/system: create or resolve the package, then create each app separately before adding relations
|
|
106
|
-
3. Resolve the target app with `app_resolve` if the request is an update.
|
|
110
|
+
3. Resolve the target app with `app_resolve` if the request is an update. Use exactly one selector mode: `app_key`, or `app_name + package_tag_id`.
|
|
107
111
|
4. Read only the smallest summary you need: `app_read_summary`, `app_read_fields`, `app_read_layout_summary`, `app_read_views_summary`, `app_read_flow_summary`, `app_read_charts_summary`, `portal_read_summary`.
|
|
108
112
|
5. Use `app_schema_apply` for create/upsert/remove field work. It publishes by default after the patch lands; noop schema requests do not publish.
|
|
109
|
-
6. If the app must belong to a package, use `package_attach_app` explicitly after schema work unless readback already shows the target `tag_id`.
|
|
113
|
+
6. If the app must belong to a package, use `package_attach_app` explicitly after schema work with `tag_id + app_key` unless readback already shows the target `tag_id`.
|
|
110
114
|
7. Use `app_layout_apply` only when the user is explicitly changing layout. Prefer the default `mode=merge`; use `mode=replace` only when you intend to place every field explicitly. It publishes by default after the patch lands; noop layout requests do not publish.
|
|
111
115
|
8. Use `app_flow_apply` after schema exists. It publishes by default; pass `publish=false` when you only want draft/precheck behavior.
|
|
112
116
|
9. Use `app_views_apply` when the user wants explicit table/card/board/gantt views. It publishes by default after the patch lands; noop view requests do not publish.
|
|
@@ -27,7 +27,7 @@ If the user asks for multiple forms/modules that relate to each other, this is a
|
|
|
27
27
|
- `member_search`: resolve named people from the directory
|
|
28
28
|
- `role_search`: resolve reusable roles from the directory
|
|
29
29
|
- `role_create`: create a reusable role when the business owner wants role-based routing
|
|
30
|
-
- `app_resolve`: locate an existing app by `app_key
|
|
30
|
+
- `app_resolve`: locate an existing app by exactly one selector mode: `app_key`, or `app_name + package_tag_id`
|
|
31
31
|
|
|
32
32
|
## Summary reads
|
|
33
33
|
|
|
@@ -48,11 +48,11 @@ These execute normalized patches and publish by default unless `publish=false`.
|
|
|
48
48
|
- `app_flow_apply`: replace workflow
|
|
49
49
|
- `app_views_apply`: upsert or remove views
|
|
50
50
|
- `app_charts_apply`: upsert/remove/reorder QingBI charts; charts are immediate-live and do not publish; use `chart_id` when names are not unique
|
|
51
|
-
- `portal_apply`: create or replace-update portal pages; sections are replace-only and omission deletes old sections; `publish=false` only guarantees draft/base-info updates
|
|
51
|
+
- `portal_apply`: create or replace-update portal pages; use `dash_key` for update mode or `package_tag_id + dash_name` for create mode; sections are replace-only and omission deletes old sections; `publish=false` only guarantees draft/base-info updates
|
|
52
52
|
|
|
53
53
|
## Explicit post-apply tools
|
|
54
54
|
|
|
55
|
-
- `package_attach_app`: attach an app to a package
|
|
55
|
+
- `package_attach_app`: attach an app to a package with `tag_id + app_key`; do not assume create or publish attaches it
|
|
56
56
|
- `app_publish_verify`: explicit final publish verification when the user asks for live confirmation
|
|
57
57
|
|
|
58
58
|
## Decision shortcuts
|
|
@@ -31,6 +31,32 @@ Outputs:
|
|
|
31
31
|
- summary
|
|
32
32
|
- next follow date
|
|
33
33
|
|
|
34
|
+
## Target Field Rules
|
|
35
|
+
|
|
36
|
+
Required:
|
|
37
|
+
- every `outputs[*].target_field` must point to an existing field
|
|
38
|
+
|
|
39
|
+
Allowed target field types:
|
|
40
|
+
- text
|
|
41
|
+
- long text
|
|
42
|
+
- number
|
|
43
|
+
- amount
|
|
44
|
+
- date
|
|
45
|
+
- datetime
|
|
46
|
+
- single select
|
|
47
|
+
- multi select
|
|
48
|
+
- boolean
|
|
49
|
+
|
|
50
|
+
Do not bind code block outputs to:
|
|
51
|
+
- q_linker
|
|
52
|
+
- code_block
|
|
53
|
+
- relation
|
|
54
|
+
- subtable
|
|
55
|
+
- attachment
|
|
56
|
+
- member
|
|
57
|
+
- department
|
|
58
|
+
- address
|
|
59
|
+
|
|
34
60
|
## Safe Verification
|
|
35
61
|
|
|
36
62
|
- `app_read_fields`
|
|
@@ -1382,6 +1382,11 @@ class AppChartsReadResponse(StrictModel):
|
|
|
1382
1382
|
chart_count: int = 0
|
|
1383
1383
|
|
|
1384
1384
|
|
|
1385
|
+
class PortalListResponse(StrictModel):
|
|
1386
|
+
items: list[dict[str, Any]] = Field(default_factory=list)
|
|
1387
|
+
total: int = 0
|
|
1388
|
+
|
|
1389
|
+
|
|
1385
1390
|
class PortalReadSummaryResponse(StrictModel):
|
|
1386
1391
|
dash_key: str
|
|
1387
1392
|
being_draft: bool = True
|
|
@@ -1395,6 +1400,35 @@ class PortalReadSummaryResponse(StrictModel):
|
|
|
1395
1400
|
sections: list[dict[str, Any]] = Field(default_factory=list)
|
|
1396
1401
|
|
|
1397
1402
|
|
|
1403
|
+
class PortalGetResponse(StrictModel):
|
|
1404
|
+
dash_key: str
|
|
1405
|
+
being_draft: bool = True
|
|
1406
|
+
dash_name: str | None = None
|
|
1407
|
+
package_tag_ids: list[int] = Field(default_factory=list)
|
|
1408
|
+
dash_icon: str | None = None
|
|
1409
|
+
hide_copyright: bool | None = None
|
|
1410
|
+
auth: dict[str, Any] = Field(default_factory=dict)
|
|
1411
|
+
config: dict[str, Any] = Field(default_factory=dict)
|
|
1412
|
+
dash_global_config: dict[str, Any] = Field(default_factory=dict)
|
|
1413
|
+
component_count: int = 0
|
|
1414
|
+
components: list[dict[str, Any]] = Field(default_factory=list)
|
|
1415
|
+
|
|
1416
|
+
|
|
1417
|
+
class ViewGetResponse(StrictModel):
|
|
1418
|
+
viewgraph_key: str
|
|
1419
|
+
base_info: dict[str, Any] = Field(default_factory=dict)
|
|
1420
|
+
config: dict[str, Any] = Field(default_factory=dict)
|
|
1421
|
+
questions: list[dict[str, Any]] = Field(default_factory=list)
|
|
1422
|
+
associations: list[dict[str, Any]] = Field(default_factory=list)
|
|
1423
|
+
|
|
1424
|
+
|
|
1425
|
+
class ChartGetResponse(StrictModel):
|
|
1426
|
+
chart_id: str
|
|
1427
|
+
base: dict[str, Any] = Field(default_factory=dict)
|
|
1428
|
+
config: dict[str, Any] = Field(default_factory=dict)
|
|
1429
|
+
data: dict[str, Any] = Field(default_factory=dict)
|
|
1430
|
+
|
|
1431
|
+
|
|
1398
1432
|
class SchemaPlanRequest(StrictModel):
|
|
1399
1433
|
app_key: str = ""
|
|
1400
1434
|
package_tag_id: int | None = None
|
|
@@ -34,8 +34,8 @@ from .models import (
|
|
|
34
34
|
AppChartsReadResponse,
|
|
35
35
|
AppFieldsReadResponse,
|
|
36
36
|
AppFlowReadResponse,
|
|
37
|
+
ChartGetResponse,
|
|
37
38
|
AppLayoutReadResponse,
|
|
38
|
-
PortalReadSummaryResponse,
|
|
39
39
|
AppReadSummaryResponse,
|
|
40
40
|
AppViewsReadResponse,
|
|
41
41
|
ChartApplyRequest,
|
|
@@ -53,6 +53,9 @@ from .models import (
|
|
|
53
53
|
LayoutSectionPatch,
|
|
54
54
|
LayoutPreset,
|
|
55
55
|
PortalApplyRequest,
|
|
56
|
+
PortalGetResponse,
|
|
57
|
+
PortalListResponse,
|
|
58
|
+
PortalReadSummaryResponse,
|
|
56
59
|
PortalSectionPatch,
|
|
57
60
|
PublicFieldType,
|
|
58
61
|
PublicRelationMode,
|
|
@@ -65,6 +68,7 @@ from .models import (
|
|
|
65
68
|
ViewButtonBindingPatch,
|
|
66
69
|
ViewUpsertPatch,
|
|
67
70
|
ViewFilterOperator,
|
|
71
|
+
ViewGetResponse,
|
|
68
72
|
ViewsPlanRequest,
|
|
69
73
|
ViewsPreset,
|
|
70
74
|
FlowPreset,
|
|
@@ -114,6 +118,18 @@ FIELD_TYPE_TO_QUESTION_TYPE: dict[str, int] = {
|
|
|
114
118
|
FieldType.relation.value: 25,
|
|
115
119
|
}
|
|
116
120
|
|
|
121
|
+
INTEGRATION_OUTPUT_TARGET_FIELD_TYPES: tuple[str, ...] = (
|
|
122
|
+
FieldType.text.value,
|
|
123
|
+
FieldType.long_text.value,
|
|
124
|
+
FieldType.number.value,
|
|
125
|
+
FieldType.amount.value,
|
|
126
|
+
FieldType.date.value,
|
|
127
|
+
FieldType.datetime.value,
|
|
128
|
+
FieldType.single_select.value,
|
|
129
|
+
FieldType.multi_select.value,
|
|
130
|
+
FieldType.boolean.value,
|
|
131
|
+
)
|
|
132
|
+
|
|
117
133
|
MATCH_TYPE_ACCURACY = 1
|
|
118
134
|
JUDGE_EQUAL = 0
|
|
119
135
|
JUDGE_UNEQUAL = 1
|
|
@@ -2261,6 +2277,38 @@ class AiBuilderFacade:
|
|
|
2261
2277
|
**response.model_dump(mode="json"),
|
|
2262
2278
|
}
|
|
2263
2279
|
|
|
2280
|
+
def portal_list(self, *, profile: str) -> JSONObject:
|
|
2281
|
+
try:
|
|
2282
|
+
raw_items = self.portals.portal_list(profile=profile).get("items") or []
|
|
2283
|
+
except (QingflowApiError, RuntimeError) as error:
|
|
2284
|
+
api_error = _coerce_api_error(error)
|
|
2285
|
+
return _failed_from_api_error(
|
|
2286
|
+
"PORTAL_LIST_FAILED",
|
|
2287
|
+
api_error,
|
|
2288
|
+
normalized_args={},
|
|
2289
|
+
details={},
|
|
2290
|
+
suggested_next_call=None,
|
|
2291
|
+
)
|
|
2292
|
+
items = _normalize_portal_list_items(raw_items)
|
|
2293
|
+
response = PortalListResponse(items=items, total=len(items))
|
|
2294
|
+
return {
|
|
2295
|
+
"status": "success",
|
|
2296
|
+
"error_code": None,
|
|
2297
|
+
"recoverable": False,
|
|
2298
|
+
"message": "list accessible portals",
|
|
2299
|
+
"normalized_args": {},
|
|
2300
|
+
"missing_fields": [],
|
|
2301
|
+
"allowed_values": {},
|
|
2302
|
+
"details": {},
|
|
2303
|
+
"request_id": None,
|
|
2304
|
+
"suggested_next_call": None,
|
|
2305
|
+
"noop": False,
|
|
2306
|
+
"warnings": [],
|
|
2307
|
+
"verification": {"portal_list_loaded": True},
|
|
2308
|
+
"verified": True,
|
|
2309
|
+
**response.model_dump(mode="json"),
|
|
2310
|
+
}
|
|
2311
|
+
|
|
2264
2312
|
def _load_chart_list_for_builder(self, *, profile: str, app_key: str) -> tuple[list[dict[str, Any]], str]:
|
|
2265
2313
|
try:
|
|
2266
2314
|
sorted_items = self.charts.qingbi_report_list_sorted(profile=profile, app_key=app_key, page_num=1, page_size=500).get("items") or []
|
|
@@ -2271,6 +2319,57 @@ class AiBuilderFacade:
|
|
|
2271
2319
|
fallback_items = self.charts.qingbi_report_list(profile=profile, app_key=app_key).get("items") or []
|
|
2272
2320
|
return list(fallback_items) if isinstance(fallback_items, list) else [], "fallback"
|
|
2273
2321
|
|
|
2322
|
+
def portal_get(self, *, profile: str, dash_key: str, being_draft: bool = True) -> JSONObject:
|
|
2323
|
+
try:
|
|
2324
|
+
result = self.portals.portal_get(profile=profile, dash_key=dash_key, being_draft=being_draft).get("result") or {}
|
|
2325
|
+
except (QingflowApiError, RuntimeError) as error:
|
|
2326
|
+
api_error = _coerce_api_error(error)
|
|
2327
|
+
return _failed_from_api_error(
|
|
2328
|
+
"PORTAL_GET_FAILED",
|
|
2329
|
+
api_error,
|
|
2330
|
+
normalized_args={"dash_key": dash_key, "being_draft": being_draft},
|
|
2331
|
+
details={"dash_key": dash_key, "being_draft": being_draft},
|
|
2332
|
+
suggested_next_call={"tool_name": "portal_get", "arguments": {"profile": profile, "dash_key": dash_key, "being_draft": being_draft}},
|
|
2333
|
+
)
|
|
2334
|
+
response = PortalGetResponse(
|
|
2335
|
+
dash_key=dash_key,
|
|
2336
|
+
being_draft=being_draft,
|
|
2337
|
+
dash_name=str(result.get("dashName") or "").strip() or None,
|
|
2338
|
+
package_tag_ids=[
|
|
2339
|
+
tag_id
|
|
2340
|
+
for tag_id in (
|
|
2341
|
+
_coerce_positive_int((item or {}).get("tagId"))
|
|
2342
|
+
for item in (result.get("tags") or [])
|
|
2343
|
+
if isinstance(item, dict)
|
|
2344
|
+
)
|
|
2345
|
+
if tag_id is not None
|
|
2346
|
+
],
|
|
2347
|
+
dash_icon=str(result.get("dashIcon") or "").strip() or None,
|
|
2348
|
+
hide_copyright=bool(result.get("hideCopyright")) if "hideCopyright" in result else None,
|
|
2349
|
+
auth=deepcopy(result.get("auth")) if isinstance(result.get("auth"), dict) else {},
|
|
2350
|
+
config=deepcopy(result.get("config")) if isinstance(result.get("config"), dict) else {},
|
|
2351
|
+
dash_global_config=deepcopy(result.get("dashGlobalConfig")) if isinstance(result.get("dashGlobalConfig"), dict) else {},
|
|
2352
|
+
component_count=len(result.get("components") or []) if isinstance(result.get("components"), list) else 0,
|
|
2353
|
+
components=_normalize_portal_components(result.get("components")),
|
|
2354
|
+
)
|
|
2355
|
+
return {
|
|
2356
|
+
"status": "success",
|
|
2357
|
+
"error_code": None,
|
|
2358
|
+
"recoverable": False,
|
|
2359
|
+
"message": "read portal detail",
|
|
2360
|
+
"normalized_args": {"dash_key": dash_key, "being_draft": being_draft},
|
|
2361
|
+
"missing_fields": [],
|
|
2362
|
+
"allowed_values": {},
|
|
2363
|
+
"details": {},
|
|
2364
|
+
"request_id": None,
|
|
2365
|
+
"suggested_next_call": None,
|
|
2366
|
+
"noop": False,
|
|
2367
|
+
"warnings": [],
|
|
2368
|
+
"verification": {"portal_exists": True, "being_draft": being_draft},
|
|
2369
|
+
"verified": True,
|
|
2370
|
+
**response.model_dump(mode="json"),
|
|
2371
|
+
}
|
|
2372
|
+
|
|
2274
2373
|
def portal_read_summary(self, *, profile: str, dash_key: str, being_draft: bool = True) -> JSONObject:
|
|
2275
2374
|
try:
|
|
2276
2375
|
result = self.portals.portal_get(profile=profile, dash_key=dash_key, being_draft=being_draft).get("result") or {}
|
|
@@ -2321,6 +2420,151 @@ class AiBuilderFacade:
|
|
|
2321
2420
|
**response.model_dump(mode="json"),
|
|
2322
2421
|
}
|
|
2323
2422
|
|
|
2423
|
+
def view_get(self, *, profile: str, viewgraph_key: str) -> JSONObject:
|
|
2424
|
+
try:
|
|
2425
|
+
config = self.views.view_get_config(profile=profile, viewgraph_key=viewgraph_key).get("result") or {}
|
|
2426
|
+
except (QingflowApiError, RuntimeError) as error:
|
|
2427
|
+
api_error = _coerce_api_error(error)
|
|
2428
|
+
return _failed_from_api_error(
|
|
2429
|
+
"VIEW_GET_FAILED",
|
|
2430
|
+
api_error,
|
|
2431
|
+
normalized_args={"viewgraph_key": viewgraph_key},
|
|
2432
|
+
details={"viewgraph_key": viewgraph_key},
|
|
2433
|
+
suggested_next_call={"tool_name": "view_get", "arguments": {"profile": profile, "viewgraph_key": viewgraph_key}},
|
|
2434
|
+
)
|
|
2435
|
+
|
|
2436
|
+
warnings: list[dict[str, Any]] = []
|
|
2437
|
+
verification = {
|
|
2438
|
+
"view_exists": True,
|
|
2439
|
+
"base_info_verified": True,
|
|
2440
|
+
"questions_verified": True,
|
|
2441
|
+
"associations_verified": True,
|
|
2442
|
+
}
|
|
2443
|
+
|
|
2444
|
+
base_info: dict[str, Any] = {}
|
|
2445
|
+
try:
|
|
2446
|
+
base_info_payload = self.views.view_get_base_info(profile=profile, viewgraph_key=viewgraph_key, passcode=None).get("result") or {}
|
|
2447
|
+
if isinstance(base_info_payload, dict):
|
|
2448
|
+
base_info = deepcopy(base_info_payload)
|
|
2449
|
+
except (QingflowApiError, RuntimeError):
|
|
2450
|
+
verification["base_info_verified"] = False
|
|
2451
|
+
warnings.append(_warning("VIEW_BASE_INFO_UNAVAILABLE", "view base info readback is unavailable"))
|
|
2452
|
+
|
|
2453
|
+
questions: list[dict[str, Any]] = []
|
|
2454
|
+
try:
|
|
2455
|
+
questions_payload = self.views.view_list_questions(profile=profile, viewgraph_key=viewgraph_key).get("result") or []
|
|
2456
|
+
if isinstance(questions_payload, list):
|
|
2457
|
+
questions = [deepcopy(item) for item in questions_payload if isinstance(item, dict)]
|
|
2458
|
+
except (QingflowApiError, RuntimeError):
|
|
2459
|
+
verification["questions_verified"] = False
|
|
2460
|
+
warnings.append(_warning("VIEW_QUESTIONS_UNAVAILABLE", "view question list readback is unavailable"))
|
|
2461
|
+
|
|
2462
|
+
associations: list[dict[str, Any]] = []
|
|
2463
|
+
try:
|
|
2464
|
+
associations_payload = self.views.view_list_associations(profile=profile, viewgraph_key=viewgraph_key).get("result") or []
|
|
2465
|
+
if isinstance(associations_payload, list):
|
|
2466
|
+
associations = [deepcopy(item) for item in associations_payload if isinstance(item, dict)]
|
|
2467
|
+
except (QingflowApiError, RuntimeError):
|
|
2468
|
+
verification["associations_verified"] = False
|
|
2469
|
+
warnings.append(_warning("VIEW_ASSOCIATIONS_UNAVAILABLE", "view association list readback is unavailable"))
|
|
2470
|
+
|
|
2471
|
+
response = ViewGetResponse(
|
|
2472
|
+
viewgraph_key=viewgraph_key,
|
|
2473
|
+
base_info=base_info,
|
|
2474
|
+
config=deepcopy(config) if isinstance(config, dict) else {},
|
|
2475
|
+
questions=questions,
|
|
2476
|
+
associations=associations,
|
|
2477
|
+
)
|
|
2478
|
+
return {
|
|
2479
|
+
"status": "success",
|
|
2480
|
+
"error_code": None,
|
|
2481
|
+
"recoverable": False,
|
|
2482
|
+
"message": "read view detail",
|
|
2483
|
+
"normalized_args": {"viewgraph_key": viewgraph_key},
|
|
2484
|
+
"missing_fields": [],
|
|
2485
|
+
"allowed_values": {},
|
|
2486
|
+
"details": {},
|
|
2487
|
+
"request_id": None,
|
|
2488
|
+
"suggested_next_call": None,
|
|
2489
|
+
"noop": False,
|
|
2490
|
+
"warnings": warnings,
|
|
2491
|
+
"verification": verification,
|
|
2492
|
+
"verified": all(bool(value) for value in verification.values()),
|
|
2493
|
+
**response.model_dump(mode="json"),
|
|
2494
|
+
}
|
|
2495
|
+
|
|
2496
|
+
def chart_get(
|
|
2497
|
+
self,
|
|
2498
|
+
*,
|
|
2499
|
+
profile: str,
|
|
2500
|
+
chart_id: str,
|
|
2501
|
+
data_payload: dict[str, Any] | None = None,
|
|
2502
|
+
page_num: int | None = None,
|
|
2503
|
+
page_size: int | None = None,
|
|
2504
|
+
page_num_y: int | None = None,
|
|
2505
|
+
page_size_y: int | None = None,
|
|
2506
|
+
) -> JSONObject:
|
|
2507
|
+
normalized_payload = deepcopy(data_payload) if isinstance(data_payload, dict) else {}
|
|
2508
|
+
try:
|
|
2509
|
+
base = self.charts.qingbi_report_get_base(profile=profile, chart_id=chart_id).get("result") or {}
|
|
2510
|
+
config = self.charts.qingbi_report_get_config(profile=profile, chart_id=chart_id).get("result") or {}
|
|
2511
|
+
data = self.charts.qingbi_report_get_data(
|
|
2512
|
+
profile=profile,
|
|
2513
|
+
chart_id=chart_id,
|
|
2514
|
+
payload=normalized_payload,
|
|
2515
|
+
page_num=page_num,
|
|
2516
|
+
page_size=page_size,
|
|
2517
|
+
page_num_y=page_num_y,
|
|
2518
|
+
page_size_y=page_size_y,
|
|
2519
|
+
).get("result") or {}
|
|
2520
|
+
except (QingflowApiError, RuntimeError) as error:
|
|
2521
|
+
api_error = _coerce_api_error(error)
|
|
2522
|
+
return _failed_from_api_error(
|
|
2523
|
+
"CHART_GET_FAILED",
|
|
2524
|
+
api_error,
|
|
2525
|
+
normalized_args={
|
|
2526
|
+
"chart_id": chart_id,
|
|
2527
|
+
"data_payload": normalized_payload,
|
|
2528
|
+
"page_num": page_num,
|
|
2529
|
+
"page_size": page_size,
|
|
2530
|
+
"page_num_y": page_num_y,
|
|
2531
|
+
"page_size_y": page_size_y,
|
|
2532
|
+
},
|
|
2533
|
+
details={"chart_id": chart_id},
|
|
2534
|
+
suggested_next_call={"tool_name": "chart_get", "arguments": {"profile": profile, "chart_id": chart_id}},
|
|
2535
|
+
)
|
|
2536
|
+
|
|
2537
|
+
response = ChartGetResponse(
|
|
2538
|
+
chart_id=chart_id,
|
|
2539
|
+
base=deepcopy(base) if isinstance(base, dict) else {},
|
|
2540
|
+
config=deepcopy(config) if isinstance(config, dict) else {},
|
|
2541
|
+
data=deepcopy(data) if isinstance(data, dict) else {"value": data},
|
|
2542
|
+
)
|
|
2543
|
+
return {
|
|
2544
|
+
"status": "success",
|
|
2545
|
+
"error_code": None,
|
|
2546
|
+
"recoverable": False,
|
|
2547
|
+
"message": "read chart detail",
|
|
2548
|
+
"normalized_args": {
|
|
2549
|
+
"chart_id": chart_id,
|
|
2550
|
+
"data_payload": normalized_payload,
|
|
2551
|
+
"page_num": page_num,
|
|
2552
|
+
"page_size": page_size,
|
|
2553
|
+
"page_num_y": page_num_y,
|
|
2554
|
+
"page_size_y": page_size_y,
|
|
2555
|
+
},
|
|
2556
|
+
"missing_fields": [],
|
|
2557
|
+
"allowed_values": {},
|
|
2558
|
+
"details": {},
|
|
2559
|
+
"request_id": None,
|
|
2560
|
+
"suggested_next_call": None,
|
|
2561
|
+
"noop": False,
|
|
2562
|
+
"warnings": [],
|
|
2563
|
+
"verification": {"chart_exists": True, "chart_data_loaded": True},
|
|
2564
|
+
"verified": True,
|
|
2565
|
+
**response.model_dump(mode="json"),
|
|
2566
|
+
}
|
|
2567
|
+
|
|
2324
2568
|
def app_schema_plan(self, *, profile: str, request: SchemaPlanRequest) -> JSONObject:
|
|
2325
2569
|
normalized_args = request.model_dump(mode="json")
|
|
2326
2570
|
target = self._preview_target_app(
|
|
@@ -8842,8 +9086,9 @@ def _compile_code_block_binding_fields(
|
|
|
8842
9086
|
selector_payload=target_payload,
|
|
8843
9087
|
location=f"code_block_binding.outputs[{output_index}].target_field",
|
|
8844
9088
|
)
|
|
8845
|
-
|
|
8846
|
-
|
|
9089
|
+
target_type = str(target_field.get("type") or "")
|
|
9090
|
+
if not _integration_output_target_type_supported(target_type):
|
|
9091
|
+
raise ValueError(_integration_output_target_type_error("code_block", str(target_field.get("name") or ""), target_type))
|
|
8847
9092
|
target_que_ref = _coerce_positive_int(target_field.get("que_id"))
|
|
8848
9093
|
if target_que_ref is None:
|
|
8849
9094
|
target_que_ref = _coerce_any_int(target_field.get("que_temp_id"))
|
|
@@ -9040,18 +9285,17 @@ def _overlay_code_block_binding_fields(*, target_fields: list[dict[str, Any]], s
|
|
|
9040
9285
|
field["code_block_binding"] = binding
|
|
9041
9286
|
|
|
9042
9287
|
|
|
9043
|
-
def
|
|
9044
|
-
return field_type in
|
|
9045
|
-
|
|
9046
|
-
|
|
9047
|
-
|
|
9048
|
-
|
|
9049
|
-
|
|
9050
|
-
|
|
9051
|
-
|
|
9052
|
-
|
|
9053
|
-
|
|
9054
|
-
}
|
|
9288
|
+
def _integration_output_target_type_supported(field_type: str) -> bool:
|
|
9289
|
+
return field_type in INTEGRATION_OUTPUT_TARGET_FIELD_TYPES
|
|
9290
|
+
|
|
9291
|
+
|
|
9292
|
+
def _integration_output_target_type_error(binding_kind: str, field_name: str, field_type: str) -> str:
|
|
9293
|
+
allowed = ", ".join(INTEGRATION_OUTPUT_TARGET_FIELD_TYPES)
|
|
9294
|
+
rendered_type = field_type or "unknown"
|
|
9295
|
+
return (
|
|
9296
|
+
f"{binding_kind} output target field '{field_name}' uses unsupported field type '{rendered_type}'. "
|
|
9297
|
+
f"Allowed target field types: {allowed}"
|
|
9298
|
+
)
|
|
9055
9299
|
|
|
9056
9300
|
|
|
9057
9301
|
def _compile_q_linker_binding_fields(
|
|
@@ -9215,8 +9459,8 @@ def _compile_q_linker_binding_fields(
|
|
|
9215
9459
|
location=f"q_linker_binding.outputs[{output_index}].target_field",
|
|
9216
9460
|
)
|
|
9217
9461
|
target_type = str(target_field.get("type") or "")
|
|
9218
|
-
if not
|
|
9219
|
-
raise ValueError(
|
|
9462
|
+
if not _integration_output_target_type_supported(target_type):
|
|
9463
|
+
raise ValueError(_integration_output_target_type_error("q_linker", str(target_field.get("name") or ""), target_type))
|
|
9220
9464
|
target_ref = _coerce_positive_int(target_field.get("que_id"))
|
|
9221
9465
|
if target_ref is None:
|
|
9222
9466
|
target_ref = _coerce_any_int(target_field.get("que_temp_id"))
|
|
@@ -10986,6 +11230,38 @@ def _summarize_charts(result: Any) -> list[dict[str, Any]]:
|
|
|
10986
11230
|
return items
|
|
10987
11231
|
|
|
10988
11232
|
|
|
11233
|
+
def _normalize_portal_list_items(raw_items: Any) -> list[dict[str, Any]]:
|
|
11234
|
+
if not isinstance(raw_items, list):
|
|
11235
|
+
return []
|
|
11236
|
+
items: list[dict[str, Any]] = []
|
|
11237
|
+
for item in raw_items:
|
|
11238
|
+
if not isinstance(item, dict):
|
|
11239
|
+
continue
|
|
11240
|
+
dash_key = str(item.get("dashKey") or "").strip()
|
|
11241
|
+
dash_name = str(item.get("dashName") or "").strip()
|
|
11242
|
+
dash_icon = str(item.get("dashIcon") or "").strip() or None
|
|
11243
|
+
package_tag_ids = [
|
|
11244
|
+
tag_id
|
|
11245
|
+
for tag_id in (
|
|
11246
|
+
_coerce_positive_int((tag or {}).get("tagId"))
|
|
11247
|
+
for tag in (item.get("tags") or [])
|
|
11248
|
+
if isinstance(tag, dict)
|
|
11249
|
+
)
|
|
11250
|
+
if tag_id is not None
|
|
11251
|
+
]
|
|
11252
|
+
if not any((dash_key, dash_name, dash_icon, package_tag_ids)):
|
|
11253
|
+
continue
|
|
11254
|
+
items.append(
|
|
11255
|
+
{
|
|
11256
|
+
"dash_key": dash_key or None,
|
|
11257
|
+
"dash_name": dash_name or None,
|
|
11258
|
+
"dash_icon": dash_icon,
|
|
11259
|
+
"package_tag_ids": package_tag_ids,
|
|
11260
|
+
}
|
|
11261
|
+
)
|
|
11262
|
+
return items
|
|
11263
|
+
|
|
11264
|
+
|
|
10989
11265
|
def _summarize_portal_sections(components: Any) -> list[dict[str, Any]]:
|
|
10990
11266
|
if not isinstance(components, list):
|
|
10991
11267
|
return []
|
|
@@ -11020,6 +11296,50 @@ def _summarize_portal_sections(components: Any) -> list[dict[str, Any]]:
|
|
|
11020
11296
|
return items
|
|
11021
11297
|
|
|
11022
11298
|
|
|
11299
|
+
def _normalize_portal_components(components: Any) -> list[dict[str, Any]]:
|
|
11300
|
+
if not isinstance(components, list):
|
|
11301
|
+
return []
|
|
11302
|
+
items: list[dict[str, Any]] = []
|
|
11303
|
+
config_key_map = {
|
|
11304
|
+
"grid": "gridConfig",
|
|
11305
|
+
"link": "linkConfig",
|
|
11306
|
+
"text": "textConfig",
|
|
11307
|
+
"filter": "filterConfig",
|
|
11308
|
+
"chart": "chartConfig",
|
|
11309
|
+
"view": "viewgraphConfig",
|
|
11310
|
+
}
|
|
11311
|
+
for index, component in enumerate(components):
|
|
11312
|
+
if not isinstance(component, dict):
|
|
11313
|
+
continue
|
|
11314
|
+
source_type = _normalize_portal_component_source_type(component.get("type"))
|
|
11315
|
+
title = _extract_portal_component_title(component, source_type=source_type)
|
|
11316
|
+
summary: dict[str, Any] = {
|
|
11317
|
+
"order": index,
|
|
11318
|
+
"source_type": source_type,
|
|
11319
|
+
"title": title,
|
|
11320
|
+
}
|
|
11321
|
+
position = component.get("position")
|
|
11322
|
+
if isinstance(position, dict):
|
|
11323
|
+
summary["position"] = deepcopy(position)
|
|
11324
|
+
config_key = config_key_map.get(source_type, "")
|
|
11325
|
+
config = component.get(config_key) if isinstance(component.get(config_key), dict) else {}
|
|
11326
|
+
if source_type == "chart":
|
|
11327
|
+
summary["chart_ref"] = {
|
|
11328
|
+
"chart_id": str(config.get("biChartId") or "").strip() or None,
|
|
11329
|
+
"chart_name": str(config.get("chartComponentTitle") or title or "").strip() or None,
|
|
11330
|
+
}
|
|
11331
|
+
elif source_type == "view":
|
|
11332
|
+
summary["view_ref"] = {
|
|
11333
|
+
"app_key": str(config.get("appKey") or "").strip() or None,
|
|
11334
|
+
"view_key": str(config.get("viewgraphKey") or "").strip() or None,
|
|
11335
|
+
"view_name": str(config.get("viewgraphName") or title or "").strip() or None,
|
|
11336
|
+
}
|
|
11337
|
+
elif source_type in {"grid", "link", "text", "filter"} and config:
|
|
11338
|
+
summary["config"] = deepcopy(config)
|
|
11339
|
+
items.append(summary)
|
|
11340
|
+
return items
|
|
11341
|
+
|
|
11342
|
+
|
|
11023
11343
|
def _normalize_portal_component_source_type(value: Any) -> str:
|
|
11024
11344
|
raw = str(value or "").strip()
|
|
11025
11345
|
mapping = {
|