Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ cmd/api/download.bin
app.log
/sidecar-server-demo
/server-demo

lark-env.sh
35 changes: 35 additions & 0 deletions shortcuts/base/base_dryrun_ops_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,3 +284,38 @@ func TestDryRunViewOps(t *testing.T) {

assertDryRunContains(t, dryRunViewGetProperty(listRT, "a/b"), "GET /open-apis/base/v3/bases/app_x/tables/tbl_1/views/viw_1/a%2Fb")
}

func TestDryRunFormSubmit(t *testing.T) {
ctx := context.Background()

// fields-only mode (share-token, no attachments)
shareTokenRT := newBaseTestRuntime(
map[string]string{
"share-token": "shrXXXX",
"json": `{"fields":{"服务评分":5,"评价内容":"服务态度好"}}`,
},
nil, nil,
)
assertDryRunContains(t,
dryRunFormSubmit(ctx, shareTokenRT),
"POST /open-apis/base/v3/bases/tables/forms/submit",
`"share_token":"shrXXXX"`,
`"服务评分":5`,
`"评价内容":"服务态度好"`)

// with attachments inside --json: { "fields": {...}, "attachments": { fieldName: [paths...] } }
withAttachmentsRT := newBaseTestRuntime(
map[string]string{
"base-token": "app_x",
"share-token": "shrXXXX",
"json": `{"fields":{"服务评分":5},"attachments":{"附件":["./report.pdf","./image.png"],"截图":["./screenshot.png"]}}`,
},
nil, nil,
)
assertDryRunContains(t,
dryRunFormSubmit(ctx, withAttachmentsRT),
"POST /open-apis/base/v3/bases/tables/forms/submit",
"Upload attachment for field \"附件\": report.pdf",
"Upload attachment for field \"附件\": image.png",
"Upload attachment for field \"截图\": screenshot.png")
}
44 changes: 44 additions & 0 deletions shortcuts/base/base_form_detail.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright (c) 2026 Lark Technologies Pte. Ltd.
// SPDX-License-Identifier: MIT

package base

import (
"context"

"github.com/larksuite/cli/shortcuts/common"
)

var BaseFormDetail = common.Shortcut{
Service: "base",
Command: "+form-detail",
Description: "Get form detail by share token",
Risk: "read",
Scopes: []string{"base:form:read"},
AuthTypes: []string{"user", "bot"},
HasFormat: true,
Flags: []common.Flag{
{Name: "share-token", Desc: "Form share token (share_token)", Required: true},
},
DryRun: func(ctx context.Context, runtime *common.RuntimeContext) *common.DryRunAPI {
return common.NewDryRunAPI().
POST("/open-apis/base/v3/bases/tables/forms/detail").
Body(map[string]interface{}{
"share_token": runtime.Str("share-token"),
})
},
Execute: func(ctx context.Context, runtime *common.RuntimeContext) error {
body := map[string]interface{}{
"share_token": runtime.Str("share-token"),
}

data, err := baseV3Call(runtime, "POST",
baseV3Path("bases", "tables", "forms", "detail"), nil, body)
if err != nil {
return err
}

runtime.Out(data, nil)
return nil
},
}
Loading
Loading