Skip to content

Commit

Permalink
Merge branch 'main' of github.com:TrueBlocks/trueblocks-sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
tjayrush committed Oct 29, 2024
2 parents 4f93f42 + db33738 commit 91d91b9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
7 changes: 7 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ func (opts *ConfigOptions) ConfigPaths() ([]types.CacheItem, *types.MetaData, er
return queryConfig[types.CacheItem](in)
}

// ConfigSession implements the chifra config --session command.
func (opts *ConfigOptions) ConfigSession() ([]types.Session, *types.MetaData, error) {
in := opts.toInternal()
in.Session = true
return queryConfig[types.Session](in)
}

type ConfigMode int

const (
Expand Down
4 changes: 3 additions & 1 deletion config_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
type configOptionsInternal struct {
Mode ConfigMode `json:"mode,omitempty"`
Paths bool `json:"paths,omitempty"`
Session bool `json:"session,omitempty"`
RenderCtx *output.RenderCtx `json:"-"`
Globals
}
Expand Down Expand Up @@ -83,7 +84,8 @@ func GetConfigOptions(args []string) (*configOptionsInternal, error) {
}

type configGeneric interface {
types.CacheItem
types.CacheItem |
types.Session
}

func queryConfig[T configGeneric](opts *configOptionsInternal) ([]T, *types.MetaData, error) {
Expand Down
4 changes: 2 additions & 2 deletions typescript/src/paths/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/

import * as ApiCallers from '../lib/api_callers';
import { CacheItem } from '../types';
import { CacheItem, Session } from '../types';

export function getConfig(
parameters?: {
Expand All @@ -21,7 +21,7 @@ export function getConfig(
},
options?: RequestInit,
) {
return ApiCallers.fetch<CacheItem[]>(
return ApiCallers.fetch<CacheItem[] | Session[]>(
{ endpoint: '/config', method: 'get', parameters, options },
);
}

0 comments on commit 91d91b9

Please sign in to comment.