-
Notifications
You must be signed in to change notification settings - Fork 492
feat(base): support record share link #466
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
yballul-bytedance
wants to merge
1
commit into
main
Choose a base branch
from
feat/record-share-cli
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| // Copyright (c) 2026 Lark Technologies Pte. Ltd. | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| package base | ||
|
|
||
| import ( | ||
| "context" | ||
|
|
||
| "github.com/larksuite/cli/shortcuts/common" | ||
| ) | ||
|
|
||
| const maxShareBatchSize = 100 | ||
|
|
||
| var BaseRecordShareLinkBatchCreate = common.Shortcut{ | ||
| Service: "base", | ||
| Command: "+record-share-link-batch-create", | ||
| Description: "Batch generate record share links (max 100 records per request)", | ||
| Risk: "read", | ||
| Scopes: []string{"base:record:read"}, | ||
| AuthTypes: authTypes(), | ||
| Flags: []common.Flag{ | ||
| baseTokenFlag(true), | ||
| tableRefFlag(true), | ||
| {Name: "record-ids", Type: "string_slice", Desc: "record IDs to generate share links for (comma-separated or repeatable, max 100)", Required: true}, | ||
| }, | ||
| Tips: []string{ | ||
| `Example: --base-token xxx --table-id tblxxx --record-ids rec001,rec002,rec003`, | ||
| }, | ||
| Validate: func(ctx context.Context, runtime *common.RuntimeContext) error { | ||
| return validateRecordShareBatch(runtime) | ||
| }, | ||
| DryRun: dryRunRecordShareBatch, | ||
| Execute: func(ctx context.Context, runtime *common.RuntimeContext) error { | ||
| return executeRecordShareBatch(runtime) | ||
| }, | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| // Copyright (c) 2026 Lark Technologies Pte. Ltd. | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| package base | ||
|
|
||
| import ( | ||
| "context" | ||
|
|
||
| "github.com/larksuite/cli/shortcuts/common" | ||
| ) | ||
|
|
||
| var BaseRecordShareLinkCreate = common.Shortcut{ | ||
| Service: "base", | ||
| Command: "+record-share-link-create", | ||
| Description: "Generate a share link for a single record", | ||
| Risk: "read", | ||
| Scopes: []string{"base:record:read"}, | ||
| AuthTypes: authTypes(), | ||
| Flags: []common.Flag{ | ||
| baseTokenFlag(true), | ||
| tableRefFlag(true), | ||
| recordRefFlag(true), | ||
| }, | ||
| Tips: []string{ | ||
| `Example: --base-token xxx --table-id tblxxx --record-id recxxx`, | ||
| }, | ||
| DryRun: dryRunRecordShare, | ||
| Execute: func(ctx context.Context, runtime *common.RuntimeContext) error { | ||
| return executeRecordShare(runtime) | ||
| }, | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
skills/lark-base/references/lark-base-record-share-link-batch-create.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| # base +record-share-link-batch-create | ||
|
|
||
| > **前置条件:** 先阅读 [`../lark-shared/SKILL.md`](../../lark-shared/SKILL.md) 了解认证、全局参数和安全规则。 | ||
|
|
||
| 批量生成记录分享链接(单次调用最多传入 100 条)。 | ||
|
|
||
| ## 适用场景(重点) | ||
|
|
||
| - 适合需要一次性获取多条记录分享链接的场景,例如批量导出分享链接、批量发送通知等。 | ||
| - 当需要处理的记录数超过 100 条时,需分批调用。 | ||
|
|
||
| ## 推荐命令 | ||
|
|
||
| ```bash | ||
| # 请使用“,”来分隔多个 record id | ||
| lark-cli base +record-share-link-batch-create \ | ||
| --base-token xxx \ | ||
| --table-id tbl_xxx \ | ||
| --record-ids rec001,rec002,rec003 | ||
| ``` | ||
|
|
||
| ## 参数 | ||
|
|
||
| | 参数 | 必填 | 说明 | | ||
| |------|------|----| | ||
| | `--base-token <token>` | 是 | Base Token | | ||
| | `--table-id <id>` | 是 | 表 ID | | ||
| | `--record-ids <ids...>` | 是 | 记录 ID 列表,需要使用逗号分隔,最多 100 条 | | ||
|
|
||
| ## API 入参详情 | ||
|
|
||
| **HTTP 方法和路径:** | ||
|
|
||
| ```http | ||
| POST /open-apis/base/v3/bases/:base_token/tables/:table_id/records/share_links/batch | ||
| ``` | ||
|
|
||
| **请求体:** | ||
|
|
||
| ```json | ||
| { | ||
| "records": ["rec001", "rec002", "rec003"] | ||
| } | ||
| ``` | ||
|
|
||
| > CLI 会自动对 `--record-ids` 去重后再调用接口。 | ||
|
|
||
| ## 返回重点 | ||
|
|
||
| - 成功时直接返回接口 `data` 字段内容,包含 `record_share_links` 映射(key 为 record_id,value 为分享链接)。结构如下: | ||
|
|
||
| ```json | ||
| { | ||
| "record_share_links": { | ||
| "rec001": "https://example.feishu.cn/record/TW2wrdbkoeoYXYcwvyIczJ2ZnFb", | ||
| "rec002": "https://example.feishu.cn/record/aB3xKmNpQrStUvWxYz123456789", | ||
| "rec003": "https://example.feishu.cn/record/cD4yLmNoPqRsTuVwXz987654321" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## 坑点 | ||
|
|
||
| - ⚠️ 单次最多 100 条记录,超出会被 CLI 校验拦截。 | ||
| - ⚠️ 重复的 record_id 会在调用前自动去重。 | ||
| - ⚠️ `--record-ids` 为空时会被校验拦截。 | ||
|
|
||
| ## 参考 | ||
|
|
||
| - [lark-base-record.md](lark-base-record.md) — record 索引页 | ||
| - [lark-base-record-share-link-create.md](lark-base-record-share-link-create.md) — 单条生成分享链接 |
44 changes: 44 additions & 0 deletions
44
skills/lark-base/references/lark-base-record-share-link-create.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # base +record-share-link-create | ||
|
|
||
| > **前置条件:** 先阅读 [`../lark-shared/SKILL.md`](../../lark-shared/SKILL.md) 了解认证、全局参数和安全规则。 | ||
|
|
||
| 为单条记录生成分享链接。 | ||
|
|
||
| ## 推荐命令 | ||
|
|
||
| ```bash | ||
| lark-cli base +record-share-link-create \ | ||
| --base-token xxx \ | ||
| --table-id tbl_xxx \ | ||
| --record-id rec_xxx | ||
| ``` | ||
|
|
||
| ## 参数 | ||
|
|
||
| | 参数 | 必填 | 说明 | | ||
| |------|------|------| | ||
| | `--base-token <token>` | 是 | Base Token | | ||
| | `--table-id <id>` | 是 | 表 ID | | ||
| | `--record-id <id>` | 是 | 记录 ID | | ||
|
|
||
| ## API 入参详情 | ||
|
|
||
| **HTTP 方法和路径:** | ||
|
|
||
| ``` | ||
| POST /open-apis/base/v3/bases/:base_token/tables/:table_id/records/:record_id/share_links | ||
| ``` | ||
|
|
||
| ## 返回重点 | ||
|
|
||
| - 成功时直接返回接口 `data` 字段内容,包含该记录的分享链接信息。结构如下: | ||
| ```json | ||
| { | ||
| "record_share_link": "https://example.feishu.cn/record/TW2wrdbkoeoYXYcwvyIczJ2ZnFb" | ||
| } | ||
| ``` | ||
|
|
||
| ## 参考 | ||
|
|
||
| - [lark-base-record.md](lark-base-record.md) — record 索引页 | ||
| - [lark-base-record-share-link-batch-create.md](lark-base-record-share-link-batch-create.md) — 批量生成分享链接 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validate normalized record IDs, not raw slice length.
Line 133 checks the raw slice length, but Lines 143-153 later drop empty values. Inputs like
--record-ids ,can pass validation and still send an emptyrecordspayload.Proposed fix
func validateRecordShareBatch(runtime *common.RuntimeContext) error { - recordIDs := runtime.StrSlice("record-ids") + recordIDs := deduplicateRecordIDs(runtime) if len(recordIDs) == 0 { return common.FlagErrorf("--record-ids is required and must not be empty") } if len(recordIDs) > maxShareBatchSize { return common.FlagErrorf("--record-ids exceeds maximum limit of %d (got %d)", maxShareBatchSize, len(recordIDs)) } return nil } func deduplicateRecordIDs(runtime *common.RuntimeContext) []string { raw := runtime.StrSlice("record-ids") seen := make(map[string]bool, len(raw)) result := make([]string, 0, len(raw)) for _, id := range raw { - if id != "" && !seen[id] { + id = strings.TrimSpace(id) + if id != "" && !seen[id] { seen[id] = true result = append(result, id) } } return result }📝 Committable suggestion
🤖 Prompt for AI Agents