Documentation
¶
Index ¶
- Constants
- func AllServiceNames() []string
- func BuildConsoleScopeURL(brand core.LarkBrand, appID, scope string) string
- func CollectScopesForProjects(catalog apicatalog.Catalog, projects []string, identity string) []string
- func DeclaredScopesForMethod(m meta.Method, identity string) []string
- func ExtractRequiredScopes(detail interface{}) []string
- func FilterForStrictMode(mode core.StrictMode) apicatalog.MethodFilter
- func GetAuthChildren(parent string) []string
- func GetAuthDomain(service string) string
- func GetRegistryDir() string
- func GetScopeScore(scope string) int
- func GetServiceDescription(name, lang string) string
- func GetServiceTitle(name, lang string) string
- func HasAuthDomain(service string) bool
- func LoadScopePriorities() map[string]int
- func SelectRecommendedScopeFromStrings(scopes []string, _ string) string
- type CommandEntry
- type Manifest
- type ManifestServiceEntry
- type Snapshot
Constants ¶
const DefaultScopeScore = 0
DefaultScopeScore is the score assigned to scopes not in the priorities table. Higher score = more recommended. Unscored scopes get 0 (least preferred).
Variables ¶
This section is empty.
Functions ¶
func AllServiceNames ¶ added in v1.0.90
func AllServiceNames() []string
AllServiceNames returns every configured service domain, sorted. It covers domains served only by typed or raw API commands, so it is a superset of the domains reachable through shortcuts.
func BuildConsoleScopeURL ¶ added in v1.0.40
BuildConsoleScopeURL returns the developer-console "apply scope" URL for the given app and scope, branded for feishu / lark. Returns "" when appID or scope is empty so callers can omit the field cleanly.
func CollectScopesForProjects ¶
func CollectScopesForProjects(catalog apicatalog.Catalog, projects []string, identity string) []string
CollectScopesForProjects collects the effective scopes for each API method in the specified from_meta projects. It uses DeclaredScopesForMethod so a method's full requiredScopes conjunction is honored (e.g. reading a mail message needs the subject/address/body scopes together, not just the umbrella readonly scope), falling back to the single recommended scope when a method declares no requiredScopes.
func DeclaredScopesForMethod ¶ added in v1.0.45
DeclaredScopesForMethod returns the scopes declared by a method for the given identity. Prefers the explicit `requiredScopes` field when present; otherwise returns the single recommended scope from `scopes` (or the first scope as a final fallback). Returns nil when the method has no scope information.
func ExtractRequiredScopes ¶ added in v1.0.40
func ExtractRequiredScopes(detail interface{}) []string
ExtractRequiredScopes pulls scope names out of the API error's permission_violations field. The detail argument is the raw `error` block that the platform returns alongside lark code 99991672 / 99991679 — typically shaped as:
{ "permission_violations": [ {"subject": "<scope>"}, ... ] }
Returns nil when the structure does not match or no non-empty subjects are present, so callers can branch on a simple len() == 0 check.
func FilterForStrictMode ¶ added in v1.0.54
func FilterForStrictMode(mode core.StrictMode) apicatalog.MethodFilter
FilterForStrictMode returns a method filter enforcing the strict-mode forced identity, or nil when strict mode is inactive (no filtering). The token/identity vocabulary (meta.TokenForIdentity) and the "no accessTokens = permissive" predicate (meta.Method.SupportsToken) both live in meta, so this only composes them — schema completion/render and service commands never re-derive identity semantics.
func GetAuthChildren ¶ added in v1.0.8
GetAuthChildren returns all service names whose auth_domain equals parent.
func GetAuthDomain ¶ added in v1.0.8
GetAuthDomain returns the auth_domain for a service, or "" if not set. When auth_domain is set, the service's scopes are collected under the parent domain during auth login.
func GetRegistryDir ¶
func GetRegistryDir() string
GetRegistryDir returns the filesystem path to the registry directory. Used for finding skills files etc.
func GetScopeScore ¶
GetScopeScore returns the priority score for a scope, or DefaultScopeScore if not found.
func GetServiceDescription ¶
GetServiceDescription returns the localized description for a service domain, suitable for --help output. Returns the description field directly. Returns empty string if not found in the config.
func GetServiceTitle ¶
GetServiceTitle returns the localized title for a service domain. Returns empty string if not found.
func HasAuthDomain ¶ added in v1.0.8
HasAuthDomain reports whether the service has an auth_domain configured.
func LoadScopePriorities ¶
LoadScopePriorities loads the scope priorities map from scope_priorities.json. Scores are stored as float strings (e.g. "52.42") and rounded to int.
func SelectRecommendedScopeFromStrings ¶ added in v1.0.40
SelectRecommendedScopeFromStrings returns the highest-priority (least-privilege) scope to surface to users, or "" for no scopes. Unknown scopes score DefaultScopeScore, so an all-unknown list yields the first entry. Priority is identity-independent; the parameter is kept for call-site clarity.
Types ¶
type CommandEntry ¶
type CommandEntry struct {
Command string // CLI label, e.g. "calendars create" or "+agenda"
Type string // "api" or "shortcut"
Scopes []string // effective scopes (requiredScopes if present, else [bestScope])
HTTPMethod string // e.g. "POST" (API only)
}
CommandEntry represents a CLI command (API method or shortcut) and its scopes.
func CollectCommandScopes ¶
func CollectCommandScopes(catalog apicatalog.Catalog, projects []string, identity string) []CommandEntry
CollectCommandScopes walks from_meta methods for the given projects and returns one CommandEntry per API method, sorted by command label.
Scope selection per method:
- If the method has a "requiredScopes" field, all of those scopes are needed (conjunction).
- Otherwise, only the highest-priority scope from "scopes" is shown (minimum privilege).
type Manifest ¶ added in v1.0.95
type Manifest struct {
SchemaVersion int `json:"schema_version"`
Services []ManifestServiceEntry `json:"services"`
}
Manifest describes the immutable service shards in a catalog snapshot.
type ManifestServiceEntry ¶ added in v1.0.95
type ManifestServiceEntry struct {
Name string `json:"name"`
File string `json:"file"`
Revision int `json:"revision"`
Size int64 `json:"size"`
SHA256 string `json:"sha256"`
}
ManifestServiceEntry records the identity and digest of one service shard.
type Snapshot ¶ added in v1.0.95
type Snapshot struct {
// contains filtered or unexported fields
}
Snapshot is an immutable manifest paired with its backing filesystem. It is the apicatalog.Loader behind the embedded catalog: opening it reads only the manifest, and a service body is validated and parsed the first time a Catalog navigates into it.
func OpenSnapshot ¶ added in v1.0.95
OpenSnapshot opens the catalog embedded in the binary.
func OpenSnapshotFS ¶ added in v1.0.95
OpenSnapshotFS validates a snapshot manifest and its exact service file set. It intentionally does not read any service file body.
func (*Snapshot) Catalog ¶ added in v1.0.95
func (s *Snapshot) Catalog() apicatalog.Catalog
Catalog returns a lazy navigation handle over every service in the snapshot. No shard is read until it is navigated; callers that must fail early for a corrupt shard use Catalog.Preload.
func (*Snapshot) Load ¶ added in v1.0.95
Load implements apicatalog.Loader: it validates one service shard against its manifest entry and parses it. Failures are typed catalog-integrity errors; a name absent from the manifest is apicatalog.ErrServiceNotFound.
func (*Snapshot) Names ¶ added in v1.0.95
Names implements apicatalog.Loader from the manifest alone.
func (*Snapshot) ServiceNames ¶ added in v1.0.95
ServiceNames returns the manifest's sorted service names as a new slice.