@amaster.ai/pi-lark 0.1.8 → 0.1.10
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 +1 -3
- package/package.json +2 -2
- package/skills/lark-apps/SKILL.md +3 -1
- package/skills/lark-apps/references/lark-apps-cache.md +38 -5
- package/skills/lark-apps/references/lark-apps-db.md +130 -2
- package/skills/lark-apps/references/lark-apps-user-id-convert.md +63 -0
- package/skills/lark-base/SKILL.md +172 -167
- package/skills/lark-base/references/{lark-base-role-guide.md → lark-base-advanced-permission-and-role.md} +5 -5
- package/skills/lark-base/references/lark-base-app-block-data-config.md +122 -0
- package/skills/lark-base/references/lark-base-app.md +243 -0
- package/skills/lark-base/references/lark-base-cell-value.md +26 -19
- package/skills/lark-base/references/{dashboard-block-data-config.md → lark-base-dashboard-block-config.md} +65 -6
- package/skills/lark-base/references/lark-base-dashboard-block-get-data.md +1 -1
- package/skills/lark-base/references/lark-base-dashboard.md +38 -20
- package/skills/lark-base/references/lark-base-data-analysis-pandas.md +93 -0
- package/skills/lark-base/references/lark-base-data-analysis-python-stdlib.md +120 -0
- package/skills/lark-base/references/lark-base-data-query.md +8 -11
- package/skills/lark-base/references/lark-base-field-create.md +7 -50
- package/skills/lark-base/references/{formula-field-guide.md → lark-base-field-formula.md} +1 -1
- package/skills/lark-base/references/{lookup-field-guide.md → lark-base-field-lookup.md} +1 -1
- package/skills/lark-base/references/{lark-base-field-json.md → lark-base-field-schema.md} +25 -101
- package/skills/lark-base/references/lark-base-field-update.md +13 -51
- package/skills/lark-base/references/lark-base-filter-condition.md +19 -31
- package/skills/lark-base/references/lark-base-form-questions-create.md +36 -5
- package/skills/lark-base/references/lark-base-record-batch-create.md +5 -1
- package/skills/lark-base/references/lark-base-record-batch-update.md +5 -2
- package/skills/lark-base/references/lark-base-record-history-list.md +19 -2
- package/skills/lark-base/references/lark-base-record-query-and-analysis-cloud-sop.md +145 -0
- package/skills/lark-base/references/lark-base-record-query-and-analysis-sop.md +233 -0
- package/skills/lark-base/references/{role-config.md → lark-base-role-config.md} +2 -2
- package/skills/lark-base/references/lark-base-template-center.md +195 -0
- package/skills/lark-base/references/lark-base-view-set-filter.md +1 -1
- package/skills/lark-base/references/lark-base-workflow-schema.md +2 -2
- package/skills/lark-base/references/{lark-base-workflow-guide.md → lark-base-workflow.md} +1 -1
- package/skills/lark-calendar/SKILL.md +11 -6
- package/skills/lark-calendar/references/lark-calendar-create.md +4 -3
- package/skills/lark-calendar/references/lark-calendar-transfer.md +89 -0
- package/skills/lark-doc/SKILL.md +3 -3
- package/skills/lark-doc/references/lark-doc-fetch.md +9 -4
- package/skills/lark-doc/references/lark-doc-update.md +12 -8
- package/skills/lark-drive/SKILL.md +5 -3
- package/skills/lark-drive/references/lark-drive-add-comment.md +2 -2
- package/skills/lark-drive/references/lark-drive-download.md +27 -1
- package/skills/lark-drive/references/lark-drive-export.md +1 -0
- package/skills/lark-drive/references/lark-drive-member-remove.md +59 -0
- package/skills/lark-drive/references/lark-drive-preview.md +21 -2
- package/skills/lark-drive/references/lark-drive-push.md +5 -1
- package/skills/lark-drive/references/lark-drive-search.md +2 -0
- package/skills/lark-im/SKILL.md +14 -3
- package/skills/lark-im/references/lark-im-message-read-status.md +96 -0
- package/skills/lark-mail/references/lark-mail-draft-create.md +12 -12
- package/skills/lark-mail/references/lark-mail-forward.md +17 -17
- package/skills/lark-mail/references/lark-mail-reply-all.md +8 -8
- package/skills/lark-mail/references/lark-mail-reply.md +6 -6
- package/skills/lark-mail/references/lark-mail-send.md +20 -20
- package/skills/lark-mail/references/lark-mail-template-create.md +7 -6
- package/skills/lark-mail/references/lark-mail-template-update.md +7 -6
- package/skills/lark-meeting/SKILL.md +146 -0
- package/skills/lark-meeting/references/lark-minutes-apply-permission.md +92 -0
- package/skills/lark-meeting/references/lark-minutes-detail.md +52 -0
- package/skills/{lark-minutes → lark-meeting}/references/lark-minutes-download.md +7 -7
- package/skills/{lark-minutes → lark-meeting}/references/lark-minutes-search.md +4 -34
- package/skills/{lark-minutes → lark-meeting}/references/lark-minutes-speaker-replace.md +3 -4
- package/skills/{lark-minutes → lark-meeting}/references/lark-minutes-summary.md +2 -5
- package/skills/{lark-minutes → lark-meeting}/references/lark-minutes-todo.md +5 -15
- package/skills/{lark-minutes → lark-meeting}/references/lark-minutes-update.md +2 -3
- package/skills/lark-meeting/references/lark-minutes-upload.md +65 -0
- package/skills/lark-meeting/references/lark-note-detail.md +15 -0
- package/skills/{lark-note → lark-meeting}/references/lark-note-transcript.md +5 -9
- package/skills/{lark-vc-agent → lark-meeting}/references/lark-vc-agent-meeting-join.md +4 -55
- package/skills/{lark-vc-agent → lark-meeting}/references/lark-vc-agent-meeting-leave.md +2 -41
- package/skills/lark-meeting/references/lark-vc-detail.md +31 -0
- package/skills/{lark-vc-agent/references/lark-vc-agent-meeting-events.md → lark-meeting/references/lark-vc-meeting-events.md} +120 -109
- package/skills/{lark-vc-agent/references/lark-vc-agent-meeting-list-active.md → lark-meeting/references/lark-vc-meeting-list-active.md} +4 -29
- package/skills/{lark-vc-agent/references/lark-vc-agent-meeting-message-send.md → lark-meeting/references/lark-vc-meeting-message-send.md} +3 -5
- package/skills/{lark-vc → lark-meeting}/references/lark-vc-recording.md +5 -64
- package/skills/{lark-vc → lark-meeting}/references/lark-vc-search.md +9 -28
- package/skills/lark-meeting/scenes/create-and-edit-minutes.md +125 -0
- package/skills/lark-meeting/scenes/live-meeting-attend.md +107 -0
- package/skills/lark-meeting/scenes/live-meeting-interact.md +72 -0
- package/skills/lark-meeting/scenes/query-meeting-and-artifacts.md +90 -0
- package/skills/lark-meeting/scenes/query-minutes-and-artifacts.md +70 -0
- package/skills/lark-meeting/scenes/query-note-and-artifacts.md +127 -0
- package/skills/lark-minutes/SKILL.md +5 -197
- package/skills/lark-note/SKILL.md +5 -84
- package/skills/lark-shared/SKILL.md +25 -188
- package/skills/lark-shared/references/lark-shared-config-init.md +12 -0
- package/skills/lark-shared/references/lark-shared-high-risk-approval.md +38 -0
- package/skills/lark-shared/references/lark-shared-identity-and-permissions.md +105 -0
- package/skills/lark-shared/references/lark-shared-output-contract.md +17 -0
- package/skills/lark-shared/references/lark-shared-update-notice.md +23 -0
- package/skills/lark-slides/SKILL.md +56 -54
- package/skills/lark-slides/references/cli/lark-slides-add-slide.md +92 -0
- package/skills/lark-slides/references/cli/lark-slides-create.md +176 -0
- package/skills/lark-slides/references/cli/lark-slides-delete-slide.md +65 -0
- package/skills/lark-slides/references/cli/lark-slides-history.md +132 -0
- package/skills/lark-slides/references/cli/lark-slides-media-upload.md +103 -0
- package/skills/lark-slides/references/cli/lark-slides-replace-slide.md +259 -0
- package/skills/lark-slides/references/cli/lark-slides-screenshot.md +115 -0
- package/skills/lark-slides/references/{lark-slides-update-slide.md → cli/lark-slides-update-slide.md} +21 -4
- package/skills/lark-slides/references/cli/lark-slides-xml-presentation-slide-get.md +110 -0
- package/skills/lark-slides/references/cli/lark-slides-xml-presentation-slide-replace.md +188 -0
- package/skills/lark-slides/references/cli/lark-slides-xml-presentations-get.md +157 -0
- package/skills/lark-slides/references/iconpark-index.json +5 -41901
- package/skills/lark-slides/references/iconpark.md +3 -44
- package/skills/lark-slides/references/lark-slides-add-slide.md +3 -90
- package/skills/lark-slides/references/lark-slides-create.md +3 -174
- package/skills/lark-slides/references/lark-slides-delete-slide.md +3 -63
- package/skills/lark-slides/references/lark-slides-edit-workflows.md +3 -141
- package/skills/lark-slides/references/lark-slides-history.md +3 -130
- package/skills/lark-slides/references/lark-slides-media-upload.md +3 -102
- package/skills/lark-slides/references/lark-slides-pptx-template-workflows.md +3 -83
- package/skills/lark-slides/references/lark-slides-replace-slide.md +3 -256
- package/skills/lark-slides/references/lark-slides-screenshot.md +3 -113
- package/skills/lark-slides/references/lark-slides-xml-presentation-slide-get.md +3 -108
- package/skills/lark-slides/references/lark-slides-xml-presentation-slide-replace.md +3 -186
- package/skills/lark-slides/references/lark-slides-xml-presentations-get.md +3 -155
- package/skills/lark-slides/references/planning-layer.md +1 -1
- package/skills/lark-slides/references/slides_chart_demo.xml +5 -1415
- package/skills/lark-slides/references/slides_xml_schema_definition.xml +3 -3512
- package/skills/lark-slides/references/troubleshooting.md +3 -60
- package/skills/lark-slides/references/validation-checklist.md +3 -154
- package/skills/lark-slides/references/workflow/error-handling.md +62 -0
- package/skills/lark-slides/references/workflow/slides-editing.md +143 -0
- package/skills/lark-slides/references/workflow/template-editing.md +85 -0
- package/skills/lark-slides/references/workflow/validation-xml.md +156 -0
- package/skills/lark-slides/references/xml/iconpark-index.json +37458 -0
- package/skills/lark-slides/references/xml/iconpark.md +46 -0
- package/skills/lark-slides/references/xml/slides_chart_demo.xml +1415 -0
- package/skills/lark-slides/references/xml/slides_xml_schema_definition.xml +3601 -0
- package/skills/lark-slides/references/xml/xml-schema-quick-ref.md +497 -0
- package/skills/lark-slides/references/xml-schema-quick-ref.md +3 -495
- package/skills/lark-slides/scripts/iconpark_tool.py +1 -1
- package/skills/lark-slides/scripts/xml_lint.py +2989 -0
- package/skills/lark-slides/scripts/xml_lint_test.py +4720 -0
- package/skills/lark-slides/scripts/xml_text_overlap_lint.py +3 -2975
- package/skills/lark-slides/scripts/xml_text_overlap_lint_test.py +5 -4712
- package/skills/lark-task/SKILL.md +13 -1
- package/skills/lark-task/references/lark-task-create.md +3 -1
- package/skills/lark-vc/SKILL.md +5 -195
- package/skills/lark-vc-agent/SKILL.md +5 -191
- package/skills/lark-wiki/SKILL.md +3 -1
- package/skills/lark-wiki/references/lark-wiki-node-copy.md +5 -19
- package/skills/lark-wiki/references/lark-wiki-node-create.md +19 -2
- package/skills/lark-wiki/references/lark-wiki-node-get.md +15 -0
- package/skills/lark-wiki/references/lark-wiki-node-list.md +1 -1
- package/skills/lark-workflow-meeting-summary/SKILL.md +20 -13
- package/skills/lark-base/references/lark-base-data-analysis-sop.md +0 -210
- package/skills/lark-base/references/lark-base-data-query-guide.md +0 -69
- package/skills/lark-base/references/lark-base-record-upsert.md +0 -63
- package/skills/lark-minutes/references/lark-minutes-detail.md +0 -62
- package/skills/lark-minutes/references/lark-minutes-upload.md +0 -104
- package/skills/lark-note/references/lark-note-detail.md +0 -26
- package/skills/lark-vc/references/lark-vc-detail.md +0 -44
- package/skills/lark-vc/references/vc-domain-boundaries.md +0 -196
|
@@ -54,6 +54,22 @@ lark-cli slides +update-slide --as user \
|
|
|
54
54
|
|
|
55
55
|
一次请求就能同时做完改样式、插入、删除、换备注、换背景——这是 `+replace-slide` 逐元素 part 做不到的(它没法寻址背景,也没有 move 操作)。
|
|
56
56
|
|
|
57
|
+
## 本地图片:`@路径` 占位符
|
|
58
|
+
|
|
59
|
+
`--content` 的 XML 里写 `<img src="@./chart.png" .../>`,CLI 会:先把每个不重复的本地文件上传到这份演示文稿(`parent_type=slide_file`),再把 `src` 替换成返回的 `file_token`,最后才整页写回。
|
|
60
|
+
|
|
61
|
+
占位符路径按**执行命令时的 CWD** 解析,跟 `--content @file` 所在目录无关;`@./assets/x.png` 找的是 `$PWD/assets/x.png`。
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
lark-cli slides +update-slide --as user \
|
|
65
|
+
--presentation "$PRES" --slide-id "$SLIDE" \
|
|
66
|
+
--content '<slide xmlns="https://www.larkoffice.com/sml/2.0"><data><img src="@./chart.png" topLeftX="100" topLeftY="100" width="320" height="180"/></data></slide>'
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
- 文件不存在、不是普通文件、超过 20 MB,都在**调用任何接口之前**报错,不会留下半成品。
|
|
70
|
+
- 去重只在**单次调用内**生效:多页共用同一张图时,逐页更新会把它每页重传一次。这种图先用 [`+media-upload`](lark-slides-media-upload.md) 传一次,把 `file_token` 写进各页的 `src`。
|
|
71
|
+
- 整页只发一个 part,所以上传是这条命令里**唯一不可逆的一半**:图先落进演示文稿的 media store,若随后 replace 失败,报错 hint 会告诉你已经传了几张,直接重试会再传一份。先 `--dry-run` 可提前看到 `images_to_upload` 和上传步骤。
|
|
72
|
+
|
|
57
73
|
## 标准读-改-写流程
|
|
58
74
|
|
|
59
75
|
```bash
|
|
@@ -97,7 +113,7 @@ lark-cli slides +update-slide --as user \
|
|
|
97
113
|
和其他整页写入一样,把 `--content` 存成本地文件后先跑版式 lint。先取得当前已加载 `lark-slides/SKILL.md` 的父目录,记为 `<lark-slides-skill-dir>`;不要猜测全局安装路径:
|
|
98
114
|
|
|
99
115
|
```bash
|
|
100
|
-
python3 "<lark-slides-skill-dir>/scripts/
|
|
116
|
+
python3 "<lark-slides-skill-dir>/scripts/xml_lint.py" --input page.xml
|
|
101
117
|
```
|
|
102
118
|
|
|
103
119
|
`summary.error_count` 必须为 0 才调接口;`warning_count > 0` 时写完要截图复核。
|
|
@@ -109,7 +125,7 @@ lark-cli slides +xml-get --as user \
|
|
|
109
125
|
--presentation "$PRES" --output readback.xml
|
|
110
126
|
```
|
|
111
127
|
|
|
112
|
-
按当前已加载 `lark-slides/SKILL.md` 指向的 [validation-
|
|
128
|
+
按当前已加载 `lark-slides/SKILL.md` 指向的 [validation-xml.md](../workflow/validation-xml.md) 完成验证:核对总页数、目标页和关键元素(包括需要保留的 ID、文本、背景与备注),并对回读 XML 运行同一版式 lint;发现差异时先停止后续写入并重新基于最新版处理。
|
|
113
129
|
|
|
114
130
|
## 成功输出
|
|
115
131
|
|
|
@@ -130,6 +146,7 @@ lark-cli slides +xml-get --as user \
|
|
|
130
146
|
| `xml_presentation_id` | 实际写入的演示文稿 ID |
|
|
131
147
|
| `slide_id` | 与传入相同——整页覆盖不换页 id |
|
|
132
148
|
| `revision_id` | 写入后的新版本号 |
|
|
149
|
+
| `images_uploaded` | 仅当 `--content` 带 `@` 占位符时出现:本次去重后实际上传的图片张数 |
|
|
133
150
|
|
|
134
151
|
服务端拒绝这次写入时(`failed_reason` 非空)**不会**返回成功输出,而是报错并带上原因——单个 part 承载整页,任何失败都意味着页面没被写入。
|
|
135
152
|
|
|
@@ -141,6 +158,6 @@ lark-cli slides +xml-get --as user \
|
|
|
141
158
|
| 现象 | 原因 | 解决 |
|
|
142
159
|
|------|------|------|
|
|
143
160
|
| 3350001,原因包含 `not found` | `--presentation` 不匹配,或 `--slide-id` 对应的页面已被删除 | 检查 `--presentation` 和 `--slide-id`,再用 `slides +xml-get` 回读当前页面 ID |
|
|
144
|
-
| 3350001,其他 invalid param | `--content` 的 XML 结构有问题(如 `<shape>` 缺 `<content/>`、包含服务端不支持的元素) | 按 [
|
|
161
|
+
| 3350001,其他 invalid param | `--content` 的 XML 结构有问题(如 `<shape>` 缺 `<content/>`、包含服务端不支持的元素) | 按 [error-handling.md](../workflow/error-handling.md) 检查 `--content` 的 XML 结构 |
|
|
145
162
|
| 3350002 not found | `--revision-id` 传了不存在的版本号 | 用 `-1` 或真实存在的 `revision_id` |
|
|
146
|
-
| 1061004 / 403 | 当前身份对这份 PPT 没有编辑权限 | 检查是否拥有 `slides:presentation:update` 或 `slides:presentation:write_only` scope;wiki 链接另需 `wiki:node:read`;`--as bot` 还要求该 bot 对目标 PPT 有编辑权限 |
|
|
163
|
+
| 1061004 / 403 | 当前身份对这份 PPT 没有编辑权限 | 检查是否拥有 `slides:presentation:update` 或 `slides:presentation:write_only` scope;wiki 链接另需 `wiki:node:read`,`@` 占位符另需 `docs:document.media:upload`;`--as bot` 还要求该 bot 对目标 PPT 有编辑权限 |
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# lark-slides xml_presentation.slide get
|
|
2
|
+
|
|
3
|
+
## 用途
|
|
4
|
+
|
|
5
|
+
按 `slide_id` 拉取指定演示文稿单页的 XML 内容(可指定历史版本)。常用于"读-改-写"编辑闭环的第一步。
|
|
6
|
+
|
|
7
|
+
## 命令
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
lark-cli slides xml_presentation.slide get --as user --params '<json_params>'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## 参数说明
|
|
14
|
+
|
|
15
|
+
| 参数 | 类型 | 必需 | 说明 |
|
|
16
|
+
|------|------|------|------|
|
|
17
|
+
| `--params` | JSON string | 是 | 路径参数与查询参数 |
|
|
18
|
+
|
|
19
|
+
### params JSON 结构
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"xml_presentation_id": "slides_example_presentation_id",
|
|
24
|
+
"slide_id": "slide_example_id",
|
|
25
|
+
"revision_id": -1
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
| 字段 | 类型 | 必需 | 说明 |
|
|
30
|
+
|------|------|------|------|
|
|
31
|
+
| `xml_presentation_id` | string | 是 | 目标演示文稿唯一标识 |
|
|
32
|
+
| `slide_id` | string | 是 | 目标页面唯一标识 |
|
|
33
|
+
| `revision_id` | integer | 否 | 版本号,`-1` 表示最新版(默认)|
|
|
34
|
+
|
|
35
|
+
## 使用示例
|
|
36
|
+
|
|
37
|
+
### 读最新版本
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
lark-cli slides xml_presentation.slide get --as user --params '{
|
|
41
|
+
"xml_presentation_id": "slides_example_presentation_id",
|
|
42
|
+
"slide_id": "slide_example_id"
|
|
43
|
+
}'
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### 只提取 XML 内容
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
lark-cli slides xml_presentation.slide get --as user \
|
|
50
|
+
--params '{"xml_presentation_id":"slides_example_presentation_id","slide_id":"slide_example_id"}' \
|
|
51
|
+
--jq '.data.slide.content'
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### 读指定历史版本
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
lark-cli slides xml_presentation.slide get --as user --params '{
|
|
58
|
+
"xml_presentation_id": "slides_example_presentation_id",
|
|
59
|
+
"slide_id": "slide_example_id",
|
|
60
|
+
"revision_id": 42
|
|
61
|
+
}'
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## 返回值
|
|
65
|
+
|
|
66
|
+
```json
|
|
67
|
+
{
|
|
68
|
+
"ok": true,
|
|
69
|
+
"identity": "user",
|
|
70
|
+
"data": {
|
|
71
|
+
"slide": {
|
|
72
|
+
"slide_id": "slide_example_id",
|
|
73
|
+
"content": "<slide id=\"slide_example_id\"><style/><data>...</data></slide>"
|
|
74
|
+
},
|
|
75
|
+
"revision_id": 100
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
| 字段 | 类型 | 说明 |
|
|
81
|
+
|------|------|------|
|
|
82
|
+
| `data.slide.slide_id` | string | 页面唯一标识 |
|
|
83
|
+
| `data.slide.content` | string | 页面完整 XML(`<slide>` 根节点,不含 xmlns)|
|
|
84
|
+
| `data.revision_id` | integer | 此次读到的版本号,可用于后续 replace 的乐观锁 |
|
|
85
|
+
|
|
86
|
+
## 常见错误
|
|
87
|
+
|
|
88
|
+
| 错误码 | 含义 | 解决方案 |
|
|
89
|
+
|--------|------|----------|
|
|
90
|
+
| 404 | 演示文稿或页面不存在 | 检查 `xml_presentation_id` / `slide_id` |
|
|
91
|
+
| 403 | 权限不足 | 需要 `slides:presentation:read` scope,并对该 PPT 有访问权限 |
|
|
92
|
+
| 400 | `revision_id` 不存在 | 传了无效版本号,用 `-1` 或真实存在的版本号 |
|
|
93
|
+
|
|
94
|
+
## 注意事项
|
|
95
|
+
|
|
96
|
+
1. **执行前必做**:`lark-cli schema slides.xml_presentation.slide.get` 查看最新参数结构
|
|
97
|
+
2. **block_id 提取**:返回 XML 里每个顶层块(shape、img、table、chart 等)的 `id` 属性即为 `block_id`,通常是 3 字符短码,例如 `<shape id="bUn" ...>`。用以下命令列出当前页所有 block_id:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
lark-cli slides xml_presentation.slide get --as user \
|
|
101
|
+
--params "{\"xml_presentation_id\":\"$PID\",\"slide_id\":\"$SID\"}" \
|
|
102
|
+
--jq '.data.slide.content' | grep -oE 'id="[^"]+"' | sed 's/id="//;s/"//'
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## 相关命令
|
|
106
|
+
|
|
107
|
+
- [slides +replace-slide](lark-slides-replace-slide.md) — 块级替换 shortcut(推荐)
|
|
108
|
+
- [xml_presentation.slide replace](lark-slides-xml-presentation-slide-replace.md) — 底层 replace API 参考
|
|
109
|
+
- [slides +xml-get](lark-slides-xml-presentations-get.md) — 读整个 PPT 并保存到本地文件
|
|
110
|
+
- [slides-editing.md](../workflow/slides-editing.md) — 读-改-写闭环
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
# lark-slides xml_presentation.slide replace
|
|
2
|
+
|
|
3
|
+
## 用途
|
|
4
|
+
|
|
5
|
+
对单页做**块级局部替换**:不覆盖整页,按 patch 列表做 `block_replace`(整块替换)或 `block_insert`(整块插入)。适合"只想加 / 换一个元素、不动其他元素"的场景。
|
|
6
|
+
|
|
7
|
+
> **推荐**:优先使用 [`+replace-slide`](lark-slides-replace-slide.md) Shortcut——它会自动注入 `id` 和 `<content/>`,直接调本 API 需自己处理这两个约束(见注意事项 5、6)。
|
|
8
|
+
|
|
9
|
+
## 命令
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
lark-cli slides xml_presentation.slide replace --as user --params '<json_params>' --data '<json_data>'
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## 参数说明
|
|
16
|
+
|
|
17
|
+
| 参数 | 类型 | 必需 | 说明 |
|
|
18
|
+
|------|------|------|------|
|
|
19
|
+
| `--params` | JSON string | 是 | 路径参数与查询参数 |
|
|
20
|
+
| `--data` | JSON string | 是 | patch 列表 |
|
|
21
|
+
|
|
22
|
+
### params JSON 结构
|
|
23
|
+
|
|
24
|
+
```json
|
|
25
|
+
{
|
|
26
|
+
"xml_presentation_id": "slides_example_presentation_id",
|
|
27
|
+
"slide_id": "slide_example_id",
|
|
28
|
+
"revision_id": -1,
|
|
29
|
+
"tid": "idMock"
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
| 字段 | 类型 | 必需 | 说明 |
|
|
34
|
+
|------|------|------|------|
|
|
35
|
+
| `xml_presentation_id` | string | 是 | 演示文稿唯一标识 |
|
|
36
|
+
| `slide_id` | string | 是 | 页面唯一标识 |
|
|
37
|
+
| `revision_id` | integer | 否 | 默认 `-1`(以最新版为基准);传具体版本号做乐观锁 |
|
|
38
|
+
| `tid` | string | 否 | 事务 ID,一般留空 |
|
|
39
|
+
|
|
40
|
+
### data JSON 结构
|
|
41
|
+
|
|
42
|
+
```json
|
|
43
|
+
{
|
|
44
|
+
"parts": [
|
|
45
|
+
{ "action": "block_replace", "block_id": "bab", "replacement": "<shape .../>" },
|
|
46
|
+
{ "action": "block_insert", "insertion": "<img .../>", "insert_before_block_id": "baa" }
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
| 字段 | 类型 | 必需 | 说明 |
|
|
52
|
+
|------|------|------|------|
|
|
53
|
+
| `parts` | array | 是 | patch 列表,长度 1~200,顺序执行 |
|
|
54
|
+
|
|
55
|
+
### parts[] 字段(按 action 不同)
|
|
56
|
+
|
|
57
|
+
本期 CLI 文档化两种 action:
|
|
58
|
+
|
|
59
|
+
#### action = "block_replace" — 整块替换
|
|
60
|
+
|
|
61
|
+
| 字段 | 必填 | 说明 |
|
|
62
|
+
|------|------|------|
|
|
63
|
+
| `action` | 是 | 固定 `block_replace` |
|
|
64
|
+
| `block_id` | 是 | 目标块的 3 位 short element ID(从 `slide.get` 返回的 XML 里读到) |
|
|
65
|
+
| `replacement` | 是 | 新 XML 片段,替换整个目标块 |
|
|
66
|
+
|
|
67
|
+
#### action = "block_insert" — 整块插入
|
|
68
|
+
|
|
69
|
+
| 字段 | 必填 | 说明 |
|
|
70
|
+
|------|------|------|
|
|
71
|
+
| `action` | 是 | 固定 `block_insert` |
|
|
72
|
+
| `insertion` | 是 | 要插入的完整 XML 片段 |
|
|
73
|
+
| `insert_before_block_id` | 否 | 插到这个块之前;省略则追加到页面末尾 |
|
|
74
|
+
|
|
75
|
+
## 使用示例
|
|
76
|
+
|
|
77
|
+
### block_replace:换一个 shape 的整体内容
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
lark-cli slides xml_presentation.slide replace --as user --params '{
|
|
81
|
+
"xml_presentation_id": "slides_example_presentation_id",
|
|
82
|
+
"slide_id": "slide_example_id"
|
|
83
|
+
}' --data '{
|
|
84
|
+
"parts": [
|
|
85
|
+
{
|
|
86
|
+
"action": "block_replace",
|
|
87
|
+
"block_id": "bab",
|
|
88
|
+
"replacement": "<shape type=\"text\" topLeftX=\"80\" topLeftY=\"80\" width=\"800\" height=\"120\"><content textType=\"title\"><p>新标题</p></content></shape>"
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
}'
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### block_insert:在已有页上加一张图
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
# 先拿 file_token
|
|
98
|
+
TOKEN=$(lark-cli slides +media-upload --file ./pic.png --presentation "$PID" --as user --jq '.data.file_token')
|
|
99
|
+
|
|
100
|
+
lark-cli slides xml_presentation.slide replace --as user --params "{
|
|
101
|
+
\"xml_presentation_id\": \"$PID\",
|
|
102
|
+
\"slide_id\": \"$SID\"
|
|
103
|
+
}" --data "$(jq -n --arg token "$TOKEN" '{
|
|
104
|
+
parts: [
|
|
105
|
+
{
|
|
106
|
+
action: "block_insert",
|
|
107
|
+
insertion: ("<img src=\"" + $token + "\" topLeftX=\"500\" topLeftY=\"100\" width=\"200\" height=\"150\"/>")
|
|
108
|
+
}
|
|
109
|
+
]
|
|
110
|
+
}')"
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### 多条 parts 原子执行
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
lark-cli slides xml_presentation.slide replace --as user --params '{
|
|
117
|
+
"xml_presentation_id": "slides_example_presentation_id",
|
|
118
|
+
"slide_id": "slide_example_id"
|
|
119
|
+
}' --data '{
|
|
120
|
+
"parts": [
|
|
121
|
+
{"action":"block_replace","block_id":"bab","replacement":"<shape type=\"text\" topLeftX=\"80\" topLeftY=\"80\" width=\"800\" height=\"120\"><content textType=\"title\"><p>新标题</p></content></shape>"},
|
|
122
|
+
{"action":"block_insert","insertion":"<img src=\"<file_token>\" topLeftX=\"700\" topLeftY=\"400\" width=\"180\" height=\"100\"/>"}
|
|
123
|
+
]
|
|
124
|
+
}'
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## 返回值
|
|
128
|
+
|
|
129
|
+
### 成功
|
|
130
|
+
|
|
131
|
+
```json
|
|
132
|
+
{
|
|
133
|
+
"ok": true,
|
|
134
|
+
"identity": "user",
|
|
135
|
+
"data": {
|
|
136
|
+
"revision_id": 105
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### 失败(任一 part 失败,整批不生效)
|
|
142
|
+
|
|
143
|
+
失败时命令以非零退出码结束,stderr 返回类型化错误信封(`error.code`(如 3350001)/ `error.message` / `error.hint`),stdout 不会打印后端原始响应:
|
|
144
|
+
|
|
145
|
+
```json
|
|
146
|
+
{
|
|
147
|
+
"ok": false,
|
|
148
|
+
"identity": "user",
|
|
149
|
+
"error": {
|
|
150
|
+
"type": "api",
|
|
151
|
+
"subtype": "...",
|
|
152
|
+
"code": 3350001,
|
|
153
|
+
"message": "...",
|
|
154
|
+
"hint": "..."
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
| 字段 | 类型 | 说明 |
|
|
160
|
+
|------|------|------|
|
|
161
|
+
| `data.revision_id` | integer | 成功时返回更新后最新版本号 |
|
|
162
|
+
|
|
163
|
+
## 常见错误
|
|
164
|
+
|
|
165
|
+
| 错误码 | 含义 | 解决方案 |
|
|
166
|
+
|--------|------|----------|
|
|
167
|
+
| 3350001 | `block_id` 在当前页不存在,或 XML 格式 / 结构错误 | 重新 `slide.get` 拿最新 XML,确认 `block_id` 存在;检查 `replacement` / `insertion` 是否合法 XML |
|
|
168
|
+
| 400 | `parts` 长度超过 200 | 拆多次调用 |
|
|
169
|
+
| 3350002 | `revision_id` 不存在(超过当前版本号) | 用 `-1` 或实际存在的 `revision_id` |
|
|
170
|
+
| 400 | XML 格式错误 | `replacement` / `insertion` 必须为合法的 XML 片段,标签闭合 + 属性引号 |
|
|
171
|
+
| 403 | 权限不足 | 需要 `slides:presentation:update` 或 `slides:presentation:write_only` |
|
|
172
|
+
|
|
173
|
+
## 注意事项
|
|
174
|
+
|
|
175
|
+
1. **parts 原子事务**:任一条失败整批回滚,不会出现"前几条成功、后几条失败"的中间态。
|
|
176
|
+
2. **block_id 的获取**:`slide.get` 返回的 XML 里每个块(shape、img、table、chart 等)会带 3 位 short element ID,用这个值填 `block_id` / `insert_before_block_id`。
|
|
177
|
+
3. **`<img>` 必须用 file_token**:不能用外链 URL——先 [`slides +media-upload`](lark-slides-media-upload.md) 拿 token。
|
|
178
|
+
4. **不能字段级 patch**:要改一个块的某个属性(比如只改 `topLeftX`),得写整块新 XML 走 `block_replace`;API 不支持"只改一个字段"。
|
|
179
|
+
5. **`block_replace` 要求 `replacement` 根元素带 `id="<block_id>"`**:底层 API 的硬约束,缺失会返回 3350001。推荐走 shortcut [`+replace-slide`](lark-slides-replace-slide.md)——它会自动把 `id` 注入到 `replacement` 根元素上,用户写 XML 时不用自己加。
|
|
180
|
+
6. **`<shape>` 必须有 `<content/>` 子元素**:SML 2.0 schema 要求,缺失同样触发 3350001。shortcut [`+replace-slide`](lark-slides-replace-slide.md) 会自动注入 `<content/>`,直接调底层 API 需要自己加。
|
|
181
|
+
7. **执行前必做**:`lark-cli schema slides.xml_presentation.slide.replace` 查看最新参数结构。
|
|
182
|
+
|
|
183
|
+
## 相关命令
|
|
184
|
+
|
|
185
|
+
- [slides +replace-slide](lark-slides-replace-slide.md) — 块级替换 shortcut(推荐,自动注入 id)
|
|
186
|
+
- [xml_presentation.slide get](lark-slides-xml-presentation-slide-get.md) — 读原页拿 block short ID
|
|
187
|
+
- [slides +media-upload](lark-slides-media-upload.md) — 上传图片拿 file_token
|
|
188
|
+
- [slides-editing.md](../workflow/slides-editing.md) — 读-改-写闭环 + 决策树
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# lark-slides xml_presentations get
|
|
2
|
+
|
|
3
|
+
## 用途
|
|
4
|
+
|
|
5
|
+
读取飞书幻灯片(PPT)的完整演示文稿 XML,或通过 `--slide-id` / `--slide-number` 读取指定单页 XML。
|
|
6
|
+
|
|
7
|
+
## Shortcut
|
|
8
|
+
|
|
9
|
+
使用 `slides +xml-get` shortcut,可以把 XML 保存到本地文件,避免终端输出被截断。
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
lark-cli slides +xml-get --as user \
|
|
13
|
+
--presentation "slides_example_presentation_id" \
|
|
14
|
+
--output .lark-slides/plan/slides_example_presentation_id/readback.xml \
|
|
15
|
+
--json
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### 参数说明
|
|
19
|
+
|
|
20
|
+
| 参数 | 类型 | 必需 | 说明 |
|
|
21
|
+
|------|------|------|------|
|
|
22
|
+
| `--presentation` | string | 是 | 演示文稿的唯一标识符 |
|
|
23
|
+
| `--revision-id` | integer | 否 | 版本号,`-1` 表示最新版本 |
|
|
24
|
+
| `--output` | string | 否 | XML 保存路径,必须使用相对路径;省略时 XML 在 stdout 的 JSON envelope 中返回 |
|
|
25
|
+
| `--raw` | flag | 否 | 直接把 XML 输出到 stdout,不包 JSON envelope;不能与 `--output`、`--jq` 或非 JSON `--format` 同时使用 |
|
|
26
|
+
| `--slide-id` | string | 否 | 只读取指定 `slide_id` 的单页 XML;不能与 `--slide-number` 或 `--remove-attr-id` 同时使用 |
|
|
27
|
+
| `--slide-number` | integer | 否 | 只读取指定的 1-based 页码;不能与 `--slide-id` 或 `--remove-attr-id` 同时使用 |
|
|
28
|
+
| `--remove-attr-id` | flag | 否 | 仅全文读取可用;移除 XML id 属性后读取,不适合后续精确块编辑 |
|
|
29
|
+
| `--json` | flag | 否 | `--format json` 的简写,json 为默认输出格式 |
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
### 基础示例
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
lark-cli slides +xml-get --as user \
|
|
36
|
+
--presentation "slides_example_presentation_id" \
|
|
37
|
+
--output .lark-slides/plan/slides_example_presentation_id/readback.xml \
|
|
38
|
+
--json
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### 读取单页并保存
|
|
42
|
+
|
|
43
|
+
按页面 ID 和按页码二选一:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
lark-cli slides +xml-get --as user \
|
|
47
|
+
--presentation "slides_example_presentation_id" \
|
|
48
|
+
--slide-id "slide_example_id" \
|
|
49
|
+
--output .lark-slides/plan/slides_example_presentation_id/slide.xml \
|
|
50
|
+
--json
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### 直接输出 XML 到管道
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
lark-cli slides +xml-get --as user \
|
|
57
|
+
--presentation "slides_example_presentation_id" \
|
|
58
|
+
--slide-number 1 \
|
|
59
|
+
--raw
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### 指定版本读取
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
lark-cli slides +xml-get --as user \
|
|
66
|
+
--presentation "slides_example_presentation_id" \
|
|
67
|
+
--revision-id 10 \
|
|
68
|
+
--output .lark-slides/plan/slides_example_presentation_id/readback-r10.xml \
|
|
69
|
+
--json
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### 移除 XML id 属性后读取
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
lark-cli slides +xml-get --as user \
|
|
76
|
+
--presentation "slides_example_presentation_id" \
|
|
77
|
+
--remove-attr-id \
|
|
78
|
+
--output .lark-slides/plan/slides_example_presentation_id/readback-no-id.xml \
|
|
79
|
+
--json
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
## 底层原生命令形态
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
lark-cli slides xml_presentations get --as user --params '<json_params>'
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### 参数说明
|
|
90
|
+
|
|
91
|
+
| 参数 | 类型 | 必需 | 说明 |
|
|
92
|
+
|------|------|------|------|
|
|
93
|
+
| `--params` | JSON string | 是 | 路径参数与查询参数,结构以 schema 为准 |
|
|
94
|
+
|
|
95
|
+
### params JSON 结构
|
|
96
|
+
|
|
97
|
+
```json
|
|
98
|
+
{
|
|
99
|
+
"xml_presentation_id": "slides_example_presentation_id",
|
|
100
|
+
"revision_id": -1
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
| 字段 | 类型 | 必需 | 说明 |
|
|
105
|
+
|------|------|------|------|
|
|
106
|
+
| `xml_presentation_id` | string | 是 | 演示文稿的唯一标识符 |
|
|
107
|
+
| `revision_id` | integer | 否 | 版本号,`-1` 表示最新版本 |
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
### 返回值
|
|
111
|
+
|
|
112
|
+
成功时返回演示文稿的完整信息:
|
|
113
|
+
|
|
114
|
+
```json
|
|
115
|
+
{
|
|
116
|
+
"ok": true,
|
|
117
|
+
"identity": "user",
|
|
118
|
+
"data": {
|
|
119
|
+
"xml_presentation": {
|
|
120
|
+
"presentation_id": "slides_example_presentation_id",
|
|
121
|
+
"revision_id": 1,
|
|
122
|
+
"content": "<presentation xmlns=\"https://www.larkoffice.com/sml/2.0\" height=\"540\" width=\"960\">...</presentation>"
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### 返回字段说明
|
|
129
|
+
|
|
130
|
+
| 字段 | 类型 | 说明 |
|
|
131
|
+
|------|------|------|
|
|
132
|
+
| `data.xml_presentation.presentation_id` | string | 演示文稿唯一标识 |
|
|
133
|
+
| `data.xml_presentation.revision_id` | integer | 版本号 |
|
|
134
|
+
| `data.xml_presentation.content` | string | XML 格式的完整内容 |
|
|
135
|
+
|
|
136
|
+
### 常见错误
|
|
137
|
+
|
|
138
|
+
| 错误码 | 含义 | 解决方案 |
|
|
139
|
+
|--------|------|----------|
|
|
140
|
+
| 404 | 演示文稿不存在 | 检查 `xml_presentation_id` 是否正确 |
|
|
141
|
+
| 403 | 权限不足 | 检查是否拥有 `slides:presentation:read` scope,或是否有访问权限 |
|
|
142
|
+
| 400 | 参数格式错误 | 确保 `--params` 是合法的 JSON 字符串 |
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
### 注意事项
|
|
146
|
+
|
|
147
|
+
1. lark-slides 工作流默认使用 `slides +xml-get`;只有必须直接调底层 API 时,才使用
|
|
148
|
+
2. 直接调用底层 API 前,使用 `lark-cli schema slides.xml_presentations.get` 查看最新的参数结构
|
|
149
|
+
3. 返回的 XML 在 `data.xml_presentation.content` 字段中
|
|
150
|
+
4. 如果只需要部分信息,可以使用 `jq` 等工具过滤返回结果
|
|
151
|
+
5. 不要在普通工作流中把完整 XML 打到终端;用 `slides +xml-get --output` 保存文件
|
|
152
|
+
|
|
153
|
+
## 相关命令
|
|
154
|
+
|
|
155
|
+
- [slides +create](lark-slides-create.md) - 创建空白 PPT
|
|
156
|
+
- [slides +add-slide](lark-slides-add-slide.md) - 添加幻灯片页面
|
|
157
|
+
- [slides +delete-slide](lark-slides-delete-slide.md) - 删除幻灯片页面
|