mirror of
https://github.com/larksuite/cli.git
synced 2026-09-14 18:42:53 +08:00
79b8647196
Co-authored-by: yballul-bytedance <273011618+yballul-bytedance@users.noreply.github.com> Co-authored-by: TRAE CLI <noreply@bytedance.com>
50 lines
1.3 KiB
Go
50 lines
1.3 KiB
Go
// Copyright (c) 2026 Lark Technologies Pte. Ltd.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package base
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
|
|
"github.com/larksuite/cli/shortcuts/common"
|
|
)
|
|
|
|
const templateReadScope = "base:template:read"
|
|
|
|
func templatePaginationFlags() []common.Flag {
|
|
return []common.Flag{
|
|
{Name: "limit", Aliases: []string{"page-size"}, Type: "int", Default: "10", Desc: "pagination size, range 1-100"},
|
|
{Name: "offset", Desc: "pagination cursor from the previous response"},
|
|
}
|
|
}
|
|
|
|
func validateTemplatePagination(_ context.Context, runtime *common.RuntimeContext) error {
|
|
_, err := common.ValidatePageSizeTyped(runtime, "limit", 10, 1, 100)
|
|
return err
|
|
}
|
|
|
|
func templatePaginationParams(runtime *common.RuntimeContext) map[string]interface{} {
|
|
params := map[string]interface{}{
|
|
"limit": runtime.Int("limit"),
|
|
}
|
|
if offset := strings.TrimSpace(runtime.Str("offset")); offset != "" {
|
|
params["offset"] = offset
|
|
}
|
|
return params
|
|
}
|
|
|
|
func projectTemplateCategoriesResponse(data map[string]interface{}) map[string]interface{} {
|
|
return map[string]interface{}{
|
|
"categories": data["categories"],
|
|
}
|
|
}
|
|
|
|
func projectTemplateListResponse(data map[string]interface{}) map[string]interface{} {
|
|
return map[string]interface{}{
|
|
"templates": data["templates"],
|
|
"has_more": data["has_more"],
|
|
"offset": data["offset"],
|
|
}
|
|
}
|