Adds internal/notion/ package with direct REST API client, field mapping, and tracker adapter. Adds bd notion init/connect/status/sync commands. Enhances tracker engine: conflict detection before pull, label sync, no-op skip, batch push interface, RFC3339Nano timestamps. Removed dead matchesFetchOptions function, added gosec nolint for Notion API client. Co-Authored-By: Osamu Okano <okano.osamu@gmail.com> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
39 lines
821 B
Go
39 lines
821 B
Go
package notion
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"strings"
|
|
|
|
"github.com/steveyegge/beads/internal/storage"
|
|
)
|
|
|
|
const configKeyToken = "notion.token"
|
|
|
|
type AuthSource string
|
|
|
|
const (
|
|
AuthSourceConfigToken AuthSource = "config_token"
|
|
AuthSourceEnv AuthSource = "env"
|
|
)
|
|
|
|
type ResolvedAuth struct {
|
|
Token string
|
|
Source AuthSource
|
|
}
|
|
|
|
func ResolveAuth(ctx context.Context, store storage.Storage) (*ResolvedAuth, error) {
|
|
if store != nil {
|
|
if token, err := store.GetConfig(ctx, configKeyToken); err == nil && strings.TrimSpace(token) != "" {
|
|
return &ResolvedAuth{
|
|
Token: strings.TrimSpace(token),
|
|
Source: AuthSourceConfigToken,
|
|
}, nil
|
|
}
|
|
}
|
|
|
|
if token := strings.TrimSpace(os.Getenv("NOTION_TOKEN")); token != "" {
|
|
return &ResolvedAuth{Token: token, Source: AuthSourceEnv}, nil
|
|
}
|
|
return nil, nil
|
|
}
|