use type config.Account in sherpa api for better typing, and update to latest sherpa lib

typescript now knows the full types, not just "any" for account config.
inline structs previously in config.Account are given their own type definition
so sherpa can generate types.

also update to latest sherpa lib that knows about time.Duration, to be used soon.
This commit is contained in:
Mechiel Lukkien
2024-04-14 17:18:20 +02:00
parent b7d6540d51
commit 4012b72d96
16 changed files with 911 additions and 123 deletions

View File

@ -1539,7 +1539,7 @@ func (Admin) Accounts(ctx context.Context) []string {
}
// Account returns the parsed configuration of an account.
func (Admin) Account(ctx context.Context, account string) (accountConfig map[string]any, diskUsage int64) {
func (Admin) Account(ctx context.Context, account string) (accountConfig config.Account, diskUsage int64) {
log := pkglog.WithContext(ctx)
acc, err := store.OpenAccount(log, account)
@ -1565,14 +1565,7 @@ func (Admin) Account(ctx context.Context, account string) (accountConfig map[str
xcheckf(ctx, err, "get disk usage")
})
// todo: should change sherpa to understand config.Account directly, with its anonymous structs.
buf, err := json.Marshal(ac)
xcheckf(ctx, err, "marshal to json")
r := map[string]any{}
err = json.Unmarshal(buf, &r)
xcheckf(ctx, err, "unmarshal from json")
return r, diskUsage
return ac, diskUsage
}
// ConfigFiles returns the paths and contents of the static and dynamic configuration files.