mirror of
https://github.com/onsonr/sonr.git
synced 2025-03-10 04:57:08 +00:00
refactor: migrate to new configuration system and model definitions
This commit is contained in:
parent
40f50bf37a
commit
0502f52ec0
14
Makefile
14
Makefile
@ -308,15 +308,13 @@ sh-testnet: mod-tidy
|
||||
###############################################################################
|
||||
.PHONY: gen-pkl gen-templ
|
||||
|
||||
gen-pkl:
|
||||
go install github.com/apple/pkl-go/cmd/pkl-gen-go@latest
|
||||
pkl-gen-go pkl/sonr.motr/ATN.pkl
|
||||
pkl-gen-go pkl/sonr.hway/Env.pkl
|
||||
pkl-gen-go pkl/sonr.motr/DWN.pkl
|
||||
pkl-gen-go pkl/sonr.hway/ORM.pkl
|
||||
gen-pkl: init-env
|
||||
pkl-gen-go pkl/sonr.orm/UCAN.pkl
|
||||
pkl-gen-go pkl/sonr.orm/Models.pkl
|
||||
pkl-gen-go pkl/sonr.conf/Hway.pkl
|
||||
pkl-gen-go pkl/sonr.conf/Motr.pkl
|
||||
|
||||
gen-templ:
|
||||
@go install github.com/a-h/templ/cmd/templ@latest
|
||||
gen-templ: init-env
|
||||
templ generate
|
||||
|
||||
|
||||
|
@ -10,8 +10,8 @@ import (
|
||||
"github.com/labstack/echo/v4/middleware"
|
||||
"github.com/onsonr/sonr/crypto/ucan"
|
||||
"github.com/onsonr/sonr/internal/gateway"
|
||||
"github.com/onsonr/sonr/internal/gateway/config"
|
||||
"github.com/onsonr/sonr/pkg/common/ipfs"
|
||||
config "github.com/onsonr/sonr/pkg/config/hway"
|
||||
"github.com/onsonr/sonr/pkg/database/sessions"
|
||||
"github.com/onsonr/sonr/pkg/didauth/producer"
|
||||
"github.com/spf13/cobra"
|
||||
@ -60,13 +60,13 @@ func rootCmd() *cobra.Command {
|
||||
return cmd
|
||||
}
|
||||
|
||||
func loadEnvImplFromArgs(args []string) (config.Env, error) {
|
||||
func loadEnvImplFromArgs(args []string) (config.Hway, error) {
|
||||
cmd := rootCmd()
|
||||
if err := cmd.ParseFlags(args); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
env := &config.EnvImpl{
|
||||
env := &config.HwayImpl{
|
||||
ServePort: servePort,
|
||||
ConfigDir: configDir,
|
||||
SqliteFile: sqliteFile,
|
||||
@ -80,7 +80,7 @@ func loadEnvImplFromArgs(args []string) (config.Env, error) {
|
||||
}
|
||||
|
||||
// setupServer sets up the server
|
||||
func setupServer(env config.Env) (*echo.Echo, error) {
|
||||
func setupServer(env config.Hway) (*echo.Echo, error) {
|
||||
ipc, err := ipfs.NewClient()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Code generated from Pkl module `sonr.motr.ATN`. DO NOT EDIT.
|
||||
// Code generated from Pkl module `sonr.orm.UCAN`. DO NOT EDIT.
|
||||
package attns
|
||||
|
||||
import (
|
||||
@ -7,11 +7,11 @@ import (
|
||||
"github.com/apple/pkl-go/pkl"
|
||||
)
|
||||
|
||||
type ATN struct {
|
||||
type UCAN struct {
|
||||
}
|
||||
|
||||
// LoadFromPath loads the pkl module at the given path and evaluates it into a ATN
|
||||
func LoadFromPath(ctx context.Context, path string) (ret *ATN, err error) {
|
||||
// LoadFromPath loads the pkl module at the given path and evaluates it into a UCAN
|
||||
func LoadFromPath(ctx context.Context, path string) (ret *UCAN, err error) {
|
||||
evaluator, err := pkl.NewEvaluator(ctx, pkl.PreconfiguredOptions)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -26,9 +26,9 @@ func LoadFromPath(ctx context.Context, path string) (ret *ATN, err error) {
|
||||
return ret, err
|
||||
}
|
||||
|
||||
// Load loads the pkl module at the given source and evaluates it with the given evaluator into a ATN
|
||||
func Load(ctx context.Context, evaluator pkl.Evaluator, source *pkl.ModuleSource) (*ATN, error) {
|
||||
var ret ATN
|
||||
// Load loads the pkl module at the given source and evaluates it with the given evaluator into a UCAN
|
||||
func Load(ctx context.Context, evaluator pkl.Evaluator, source *pkl.ModuleSource) (*UCAN, error) {
|
||||
var ret UCAN
|
||||
if err := evaluator.EvaluateModule(ctx, source, &ret); err != nil {
|
||||
return nil, err
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
// Code generated from Pkl module `sonr.motr.ATN`. DO NOT EDIT.
|
||||
// Code generated from Pkl module `sonr.orm.UCAN`. DO NOT EDIT.
|
||||
package capability
|
||||
|
||||
import (
|
||||
|
@ -1,8 +1,8 @@
|
||||
// Code generated from Pkl module `sonr.motr.ATN`. DO NOT EDIT.
|
||||
// Code generated from Pkl module `sonr.orm.UCAN`. DO NOT EDIT.
|
||||
package attns
|
||||
|
||||
import "github.com/apple/pkl-go/pkl"
|
||||
|
||||
func init() {
|
||||
pkl.RegisterMapping("sonr.motr.ATN", ATN{})
|
||||
pkl.RegisterMapping("sonr.orm.UCAN", UCAN{})
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Code generated from Pkl module `sonr.motr.ATN`. DO NOT EDIT.
|
||||
// Code generated from Pkl module `sonr.orm.UCAN`. DO NOT EDIT.
|
||||
package policytype
|
||||
|
||||
import (
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Code generated from Pkl module `sonr.motr.ATN`. DO NOT EDIT.
|
||||
// Code generated from Pkl module `sonr.orm.UCAN`. DO NOT EDIT.
|
||||
package resourcetype
|
||||
|
||||
import (
|
||||
|
@ -1,8 +0,0 @@
|
||||
// Code generated from Pkl module `sonr.hway.Env`. DO NOT EDIT.
|
||||
package config
|
||||
|
||||
import "github.com/apple/pkl-go/pkl"
|
||||
|
||||
func init() {
|
||||
pkl.RegisterMapping("sonr.hway.Env", EnvImpl{})
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
// Code generated from Pkl module `sonr.motr.DWN`. DO NOT EDIT.
|
||||
package config
|
||||
|
||||
import "github.com/apple/pkl-go/pkl"
|
||||
|
||||
func init() {
|
||||
pkl.RegisterMapping("sonr.motr.DWN", DWN{})
|
||||
pkl.RegisterMapping("sonr.motr.DWN#Config", Config{})
|
||||
pkl.RegisterMapping("sonr.motr.DWN#Schema", Schema{})
|
||||
pkl.RegisterMapping("sonr.motr.DWN#Environment", Environment{})
|
||||
}
|
@ -5,8 +5,8 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
config "github.com/onsonr/sonr/pkg/config/motr"
|
||||
|
||||
"github.com/onsonr/sonr/internal/vault/types"
|
||||
"github.com/onsonr/sonr/pkg/common"
|
||||
)
|
||||
|
||||
@ -33,7 +33,7 @@ func Get(c echo.Context) (SessionCtx, error) {
|
||||
}
|
||||
|
||||
// WebNodeMiddleware establishes a Session Cookie.
|
||||
func Middleware(config *types.Config) echo.MiddlewareFunc {
|
||||
func Middleware(config *config.Config) echo.MiddlewareFunc {
|
||||
return func(next echo.HandlerFunc) echo.HandlerFunc {
|
||||
return func(c echo.Context) error {
|
||||
err := injectConfig(c, config)
|
||||
@ -46,7 +46,7 @@ func Middleware(config *types.Config) echo.MiddlewareFunc {
|
||||
}
|
||||
}
|
||||
|
||||
func injectConfig(c echo.Context, config *types.Config) error {
|
||||
func injectConfig(c echo.Context, config *config.Config) error {
|
||||
common.HeaderWrite(c, common.SonrAPIURL, config.SonrApiUrl)
|
||||
common.HeaderWrite(c, common.SonrRPCURL, config.SonrRpcUrl)
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
package config
|
||||
package embed
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/ipfs/boxo/files"
|
||||
"github.com/onsonr/sonr/internal/vault/embed"
|
||||
config "github.com/onsonr/sonr/pkg/config/motr"
|
||||
)
|
||||
|
||||
const SchemaVersion = 1
|
||||
@ -17,7 +17,7 @@ const (
|
||||
)
|
||||
|
||||
// spawnVaultDirectory creates a new directory with the default files
|
||||
func NewVaultFS(cfg *Config) (files.Directory, error) {
|
||||
func NewVaultFS(cfg *config.Config) (files.Directory, error) {
|
||||
manifestBz, err := newWebManifestBytes()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -29,15 +29,15 @@ func NewVaultFS(cfg *Config) (files.Directory, error) {
|
||||
return files.NewMapDirectory(map[string]files.Node{
|
||||
AppManifestFileName: files.NewBytesFile(manifestBz),
|
||||
DWNConfigFileName: files.NewBytesFile(cnfBz),
|
||||
IndexHTMLFileName: files.NewBytesFile(embed.IndexHTML),
|
||||
MainJSFileName: files.NewBytesFile(embed.MainJS),
|
||||
ServiceWorkerFileName: files.NewBytesFile(embed.WorkerJS),
|
||||
IndexHTMLFileName: files.NewBytesFile(IndexHTML),
|
||||
MainJSFileName: files.NewBytesFile(MainJS),
|
||||
ServiceWorkerFileName: files.NewBytesFile(WorkerJS),
|
||||
}), nil
|
||||
}
|
||||
|
||||
// NewVaultConfig returns the default vault config
|
||||
func NewVaultConfig(addr string, ucanCID string) *Config {
|
||||
return &Config{
|
||||
func NewVaultConfig(addr string, ucanCID string) *config.Config {
|
||||
return &config.Config{
|
||||
MotrToken: ucanCID,
|
||||
MotrAddress: addr,
|
||||
IpfsGatewayUrl: "http://localhost:80",
|
@ -1,4 +1,4 @@
|
||||
package config
|
||||
package embed
|
||||
|
||||
import "encoding/json"
|
||||
|
@ -1,15 +1,16 @@
|
||||
package config
|
||||
package embed
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"github.com/onsonr/sonr/pkg/common/models"
|
||||
config "github.com/onsonr/sonr/pkg/config/motr"
|
||||
)
|
||||
|
||||
// DefaultSchema returns the default schema
|
||||
func DefaultSchema() *Schema {
|
||||
return &Schema{
|
||||
func DefaultSchema() *config.Schema {
|
||||
return &config.Schema{
|
||||
Version: SchemaVersion,
|
||||
Account: getSchema(&models.Account{}),
|
||||
Asset: getSchema(&models.Asset{}),
|
@ -1,4 +1,4 @@
|
||||
// Code generated from Pkl module `sonr.motr.ORM`. DO NOT EDIT.
|
||||
// Code generated from Pkl module `sonr.orm.Models`. DO NOT EDIT.
|
||||
package models
|
||||
|
||||
type Account struct {
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Code generated from Pkl module `sonr.motr.ORM`. DO NOT EDIT.
|
||||
// Code generated from Pkl module `sonr.orm.Models`. DO NOT EDIT.
|
||||
package models
|
||||
|
||||
type Asset struct {
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Code generated from Pkl module `sonr.motr.ORM`. DO NOT EDIT.
|
||||
// Code generated from Pkl module `sonr.orm.Models`. DO NOT EDIT.
|
||||
package models
|
||||
|
||||
type Chain struct {
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Code generated from Pkl module `sonr.motr.ORM`. DO NOT EDIT.
|
||||
// Code generated from Pkl module `sonr.orm.Models`. DO NOT EDIT.
|
||||
package models
|
||||
|
||||
type Credential struct {
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Code generated from Pkl module `sonr.motr.ORM`. DO NOT EDIT.
|
||||
// Code generated from Pkl module `sonr.orm.Models`. DO NOT EDIT.
|
||||
package models
|
||||
|
||||
import (
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Code generated from Pkl module `sonr.motr.ORM`. DO NOT EDIT.
|
||||
// Code generated from Pkl module `sonr.orm.Models`. DO NOT EDIT.
|
||||
package models
|
||||
|
||||
type Grant struct {
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Code generated from Pkl module `sonr.motr.ORM`. DO NOT EDIT.
|
||||
// Code generated from Pkl module `sonr.orm.Models`. DO NOT EDIT.
|
||||
package models
|
||||
|
||||
type JWK struct {
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Code generated from Pkl module `sonr.motr.ORM`. DO NOT EDIT.
|
||||
// Code generated from Pkl module `sonr.orm.Models`. DO NOT EDIT.
|
||||
package models
|
||||
|
||||
type Keyshare struct {
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Code generated from Pkl module `sonr.motr.ORM`. DO NOT EDIT.
|
||||
// Code generated from Pkl module `sonr.orm.Models`. DO NOT EDIT.
|
||||
package models
|
||||
|
||||
import (
|
||||
@ -7,14 +7,14 @@ import (
|
||||
"github.com/apple/pkl-go/pkl"
|
||||
)
|
||||
|
||||
type ORM struct {
|
||||
type Models struct {
|
||||
DbName string `pkl:"db_name"`
|
||||
|
||||
DbVersion int `pkl:"db_version"`
|
||||
}
|
||||
|
||||
// LoadFromPath loads the pkl module at the given path and evaluates it into a ORM
|
||||
func LoadFromPath(ctx context.Context, path string) (ret *ORM, err error) {
|
||||
// LoadFromPath loads the pkl module at the given path and evaluates it into a Models
|
||||
func LoadFromPath(ctx context.Context, path string) (ret *Models, err error) {
|
||||
evaluator, err := pkl.NewEvaluator(ctx, pkl.PreconfiguredOptions)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -29,9 +29,9 @@ func LoadFromPath(ctx context.Context, path string) (ret *ORM, err error) {
|
||||
return ret, err
|
||||
}
|
||||
|
||||
// Load loads the pkl module at the given source and evaluates it with the given evaluator into a ORM
|
||||
func Load(ctx context.Context, evaluator pkl.Evaluator, source *pkl.ModuleSource) (*ORM, error) {
|
||||
var ret ORM
|
||||
// Load loads the pkl module at the given source and evaluates it with the given evaluator into a Models
|
||||
func Load(ctx context.Context, evaluator pkl.Evaluator, source *pkl.ModuleSource) (*Models, error) {
|
||||
var ret Models
|
||||
if err := evaluator.EvaluateModule(ctx, source, &ret); err != nil {
|
||||
return nil, err
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
// Code generated from Pkl module `sonr.motr.ORM`. DO NOT EDIT.
|
||||
// Code generated from Pkl module `sonr.orm.Models`. DO NOT EDIT.
|
||||
package models
|
||||
|
||||
type Profile struct {
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Code generated from Pkl module `sonr.motr.ORM`. DO NOT EDIT.
|
||||
// Code generated from Pkl module `sonr.orm.Models`. DO NOT EDIT.
|
||||
package assettype
|
||||
|
||||
import (
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Code generated from Pkl module `sonr.motr.ORM`. DO NOT EDIT.
|
||||
// Code generated from Pkl module `sonr.orm.Models`. DO NOT EDIT.
|
||||
package didmethod
|
||||
|
||||
import (
|
||||
|
@ -1,17 +1,17 @@
|
||||
// Code generated from Pkl module `sonr.motr.ORM`. DO NOT EDIT.
|
||||
// Code generated from Pkl module `sonr.orm.Models`. DO NOT EDIT.
|
||||
package models
|
||||
|
||||
import "github.com/apple/pkl-go/pkl"
|
||||
|
||||
func init() {
|
||||
pkl.RegisterMapping("sonr.motr.ORM", ORM{})
|
||||
pkl.RegisterMapping("sonr.motr.ORM#Account", Account{})
|
||||
pkl.RegisterMapping("sonr.motr.ORM#Asset", Asset{})
|
||||
pkl.RegisterMapping("sonr.motr.ORM#Chain", Chain{})
|
||||
pkl.RegisterMapping("sonr.motr.ORM#Credential", Credential{})
|
||||
pkl.RegisterMapping("sonr.motr.ORM#DID", DID{})
|
||||
pkl.RegisterMapping("sonr.motr.ORM#JWK", JWK{})
|
||||
pkl.RegisterMapping("sonr.motr.ORM#Grant", Grant{})
|
||||
pkl.RegisterMapping("sonr.motr.ORM#Keyshare", Keyshare{})
|
||||
pkl.RegisterMapping("sonr.motr.ORM#Profile", Profile{})
|
||||
pkl.RegisterMapping("sonr.orm.Models", Models{})
|
||||
pkl.RegisterMapping("sonr.orm.Models#Account", Account{})
|
||||
pkl.RegisterMapping("sonr.orm.Models#Asset", Asset{})
|
||||
pkl.RegisterMapping("sonr.orm.Models#Chain", Chain{})
|
||||
pkl.RegisterMapping("sonr.orm.Models#Credential", Credential{})
|
||||
pkl.RegisterMapping("sonr.orm.Models#DID", DID{})
|
||||
pkl.RegisterMapping("sonr.orm.Models#JWK", JWK{})
|
||||
pkl.RegisterMapping("sonr.orm.Models#Grant", Grant{})
|
||||
pkl.RegisterMapping("sonr.orm.Models#Keyshare", Keyshare{})
|
||||
pkl.RegisterMapping("sonr.orm.Models#Profile", Profile{})
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Code generated from Pkl module `sonr.motr.ORM`. DO NOT EDIT.
|
||||
// Code generated from Pkl module `sonr.orm.Models`. DO NOT EDIT.
|
||||
package keyalgorithm
|
||||
|
||||
import (
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Code generated from Pkl module `sonr.motr.ORM`. DO NOT EDIT.
|
||||
// Code generated from Pkl module `sonr.orm.Models`. DO NOT EDIT.
|
||||
package keycurve
|
||||
|
||||
import (
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Code generated from Pkl module `sonr.motr.ORM`. DO NOT EDIT.
|
||||
// Code generated from Pkl module `sonr.orm.Models`. DO NOT EDIT.
|
||||
package keyencoding
|
||||
|
||||
import (
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Code generated from Pkl module `sonr.motr.ORM`. DO NOT EDIT.
|
||||
// Code generated from Pkl module `sonr.orm.Models`. DO NOT EDIT.
|
||||
package keyrole
|
||||
|
||||
import (
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Code generated from Pkl module `sonr.motr.ORM`. DO NOT EDIT.
|
||||
// Code generated from Pkl module `sonr.orm.Models`. DO NOT EDIT.
|
||||
package keysharerole
|
||||
|
||||
import (
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Code generated from Pkl module `sonr.motr.ORM`. DO NOT EDIT.
|
||||
// Code generated from Pkl module `sonr.orm.Models`. DO NOT EDIT.
|
||||
package keytype
|
||||
|
||||
import (
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Code generated from Pkl module `sonr.motr.ORM`. DO NOT EDIT.
|
||||
// Code generated from Pkl module `sonr.orm.Models`. DO NOT EDIT.
|
||||
package permissiongrant
|
||||
|
||||
import (
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Code generated from Pkl module `sonr.motr.ORM`. DO NOT EDIT.
|
||||
// Code generated from Pkl module `sonr.orm.Models`. DO NOT EDIT.
|
||||
package permissionscope
|
||||
|
||||
import (
|
||||
|
@ -4,16 +4,17 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/apple/pkl-go/pkl"
|
||||
hwayconfig "github.com/onsonr/sonr/pkg/config/hway"
|
||||
)
|
||||
|
||||
// LoadFromBytes loads the environment from the given bytes
|
||||
func LoadFromBytes(data []byte) (Env, error) {
|
||||
func LoadHwayFromBytes(data []byte) (hwayconfig.Hway, error) {
|
||||
text := string(data)
|
||||
return LoadFromString(text)
|
||||
return LoadHwayFromString(text)
|
||||
}
|
||||
|
||||
// LoadFromString loads the environment from the given string
|
||||
func LoadFromString(text string) (Env, error) {
|
||||
func LoadHwayFromString(text string) (hwayconfig.Hway, error) {
|
||||
evaluator, err := pkl.NewEvaluator(context.Background(), pkl.PreconfiguredOptions)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -24,12 +25,12 @@ func LoadFromString(text string) (Env, error) {
|
||||
err = cerr
|
||||
}
|
||||
}()
|
||||
ret, err := Load(context.Background(), evaluator, pkl.TextSource(text))
|
||||
ret, err := hwayconfig.Load(context.Background(), evaluator, pkl.TextSource(text))
|
||||
return ret, err
|
||||
}
|
||||
|
||||
// LoadFromURL loads the environment from the given URL
|
||||
func LoadFromURL(url string) (Env, error) {
|
||||
func LoadFromURL(url string) (hwayconfig.Hway, error) {
|
||||
evaluator, err := pkl.NewEvaluator(context.Background(), pkl.PreconfiguredOptions)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -40,6 +41,6 @@ func LoadFromURL(url string) (Env, error) {
|
||||
err = cerr
|
||||
}
|
||||
}()
|
||||
ret, err := Load(context.Background(), evaluator, pkl.UriSource(url))
|
||||
ret, err := hwayconfig.Load(context.Background(), evaluator, pkl.UriSource(url))
|
||||
return ret, err
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
// Code generated from Pkl module `sonr.hway.Env`. DO NOT EDIT.
|
||||
package config
|
||||
// Code generated from Pkl module `sonr.conf.Hway`. DO NOT EDIT.
|
||||
package hway
|
||||
|
||||
import (
|
||||
"context"
|
||||
@ -7,7 +7,7 @@ import (
|
||||
"github.com/apple/pkl-go/pkl"
|
||||
)
|
||||
|
||||
type Env interface {
|
||||
type Hway interface {
|
||||
GetServePort() int
|
||||
|
||||
GetConfigDir() string
|
||||
@ -25,9 +25,9 @@ type Env interface {
|
||||
GetSonrRpcUrl() string
|
||||
}
|
||||
|
||||
var _ Env = (*EnvImpl)(nil)
|
||||
var _ Hway = (*HwayImpl)(nil)
|
||||
|
||||
type EnvImpl struct {
|
||||
type HwayImpl struct {
|
||||
ServePort int `pkl:"servePort"`
|
||||
|
||||
ConfigDir string `pkl:"configDir"`
|
||||
@ -45,40 +45,40 @@ type EnvImpl struct {
|
||||
SonrRpcUrl string `pkl:"sonrRpcUrl"`
|
||||
}
|
||||
|
||||
func (rcv *EnvImpl) GetServePort() int {
|
||||
func (rcv *HwayImpl) GetServePort() int {
|
||||
return rcv.ServePort
|
||||
}
|
||||
|
||||
func (rcv *EnvImpl) GetConfigDir() string {
|
||||
func (rcv *HwayImpl) GetConfigDir() string {
|
||||
return rcv.ConfigDir
|
||||
}
|
||||
|
||||
func (rcv *EnvImpl) GetSqliteFile() string {
|
||||
func (rcv *HwayImpl) GetSqliteFile() string {
|
||||
return rcv.SqliteFile
|
||||
}
|
||||
|
||||
func (rcv *EnvImpl) GetChainId() string {
|
||||
func (rcv *HwayImpl) GetChainId() string {
|
||||
return rcv.ChainId
|
||||
}
|
||||
|
||||
func (rcv *EnvImpl) GetIpfsGatewayUrl() string {
|
||||
func (rcv *HwayImpl) GetIpfsGatewayUrl() string {
|
||||
return rcv.IpfsGatewayUrl
|
||||
}
|
||||
|
||||
func (rcv *EnvImpl) GetSonrApiUrl() string {
|
||||
func (rcv *HwayImpl) GetSonrApiUrl() string {
|
||||
return rcv.SonrApiUrl
|
||||
}
|
||||
|
||||
func (rcv *EnvImpl) GetSonrGrpcUrl() string {
|
||||
func (rcv *HwayImpl) GetSonrGrpcUrl() string {
|
||||
return rcv.SonrGrpcUrl
|
||||
}
|
||||
|
||||
func (rcv *EnvImpl) GetSonrRpcUrl() string {
|
||||
func (rcv *HwayImpl) GetSonrRpcUrl() string {
|
||||
return rcv.SonrRpcUrl
|
||||
}
|
||||
|
||||
// LoadFromPath loads the pkl module at the given path and evaluates it into a Env
|
||||
func LoadFromPath(ctx context.Context, path string) (ret Env, err error) {
|
||||
// LoadFromPath loads the pkl module at the given path and evaluates it into a Hway
|
||||
func LoadFromPath(ctx context.Context, path string) (ret Hway, err error) {
|
||||
evaluator, err := pkl.NewEvaluator(ctx, pkl.PreconfiguredOptions)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -93,9 +93,9 @@ func LoadFromPath(ctx context.Context, path string) (ret Env, err error) {
|
||||
return ret, err
|
||||
}
|
||||
|
||||
// Load loads the pkl module at the given source and evaluates it with the given evaluator into a Env
|
||||
func Load(ctx context.Context, evaluator pkl.Evaluator, source *pkl.ModuleSource) (Env, error) {
|
||||
var ret EnvImpl
|
||||
// Load loads the pkl module at the given source and evaluates it with the given evaluator into a Hway
|
||||
func Load(ctx context.Context, evaluator pkl.Evaluator, source *pkl.ModuleSource) (Hway, error) {
|
||||
var ret HwayImpl
|
||||
if err := evaluator.EvaluateModule(ctx, source, &ret); err != nil {
|
||||
return nil, err
|
||||
}
|
8
pkg/config/hway/init.pkl.go
Normal file
8
pkg/config/hway/init.pkl.go
Normal file
@ -0,0 +1,8 @@
|
||||
// Code generated from Pkl module `sonr.conf.Hway`. DO NOT EDIT.
|
||||
package hway
|
||||
|
||||
import "github.com/apple/pkl-go/pkl"
|
||||
|
||||
func init() {
|
||||
pkl.RegisterMapping("sonr.conf.Hway", HwayImpl{})
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
// Code generated from Pkl module `sonr.motr.DWN`. DO NOT EDIT.
|
||||
package config
|
||||
// Code generated from Pkl module `sonr.conf.Motr`. DO NOT EDIT.
|
||||
package motr
|
||||
|
||||
type Config struct {
|
||||
IpfsGatewayUrl string `pkl:"ipfsGatewayUrl" json:"ipfsGatewayUrl,omitempty"`
|
@ -1,5 +1,5 @@
|
||||
// Code generated from Pkl module `sonr.motr.DWN`. DO NOT EDIT.
|
||||
package config
|
||||
// Code generated from Pkl module `sonr.conf.Motr`. DO NOT EDIT.
|
||||
package motr
|
||||
|
||||
type Environment struct {
|
||||
IsDevelopment bool `pkl:"isDevelopment" json:"isDevelopment,omitempty"`
|
@ -1,5 +1,5 @@
|
||||
// Code generated from Pkl module `sonr.motr.DWN`. DO NOT EDIT.
|
||||
package config
|
||||
// Code generated from Pkl module `sonr.conf.Motr`. DO NOT EDIT.
|
||||
package motr
|
||||
|
||||
import (
|
||||
"context"
|
||||
@ -7,11 +7,11 @@ import (
|
||||
"github.com/apple/pkl-go/pkl"
|
||||
)
|
||||
|
||||
type DWN struct {
|
||||
type Motr struct {
|
||||
}
|
||||
|
||||
// LoadFromPath loads the pkl module at the given path and evaluates it into a DWN
|
||||
func LoadFromPath(ctx context.Context, path string) (ret *DWN, err error) {
|
||||
// LoadFromPath loads the pkl module at the given path and evaluates it into a Motr
|
||||
func LoadFromPath(ctx context.Context, path string) (ret *Motr, err error) {
|
||||
evaluator, err := pkl.NewEvaluator(ctx, pkl.PreconfiguredOptions)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -26,9 +26,9 @@ func LoadFromPath(ctx context.Context, path string) (ret *DWN, err error) {
|
||||
return ret, err
|
||||
}
|
||||
|
||||
// Load loads the pkl module at the given source and evaluates it with the given evaluator into a DWN
|
||||
func Load(ctx context.Context, evaluator pkl.Evaluator, source *pkl.ModuleSource) (*DWN, error) {
|
||||
var ret DWN
|
||||
// Load loads the pkl module at the given source and evaluates it with the given evaluator into a Motr
|
||||
func Load(ctx context.Context, evaluator pkl.Evaluator, source *pkl.ModuleSource) (*Motr, error) {
|
||||
var ret Motr
|
||||
if err := evaluator.EvaluateModule(ctx, source, &ret); err != nil {
|
||||
return nil, err
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
// Code generated from Pkl module `sonr.motr.DWN`. DO NOT EDIT.
|
||||
package config
|
||||
// Code generated from Pkl module `sonr.conf.Motr`. DO NOT EDIT.
|
||||
package motr
|
||||
|
||||
type Schema struct {
|
||||
Version int `pkl:"version"`
|
11
pkg/config/motr/init.pkl.go
Normal file
11
pkg/config/motr/init.pkl.go
Normal file
@ -0,0 +1,11 @@
|
||||
// Code generated from Pkl module `sonr.conf.Motr`. DO NOT EDIT.
|
||||
package motr
|
||||
|
||||
import "github.com/apple/pkl-go/pkl"
|
||||
|
||||
func init() {
|
||||
pkl.RegisterMapping("sonr.conf.Motr", Motr{})
|
||||
pkl.RegisterMapping("sonr.conf.Motr#Config", Config{})
|
||||
pkl.RegisterMapping("sonr.conf.Motr#Schema", Schema{})
|
||||
pkl.RegisterMapping("sonr.conf.Motr#Environment", Environment{})
|
||||
}
|
@ -1,275 +0,0 @@
|
||||
module ipfs.net.Config
|
||||
|
||||
API: API
|
||||
|
||||
Addresses: Addresses
|
||||
|
||||
AutoNAT: Dynamic
|
||||
|
||||
Bootstrap: Listing
|
||||
|
||||
DNS: DNS
|
||||
|
||||
Datastore: Datastore
|
||||
|
||||
Discovery: Discovery
|
||||
|
||||
Experimental: Experimental
|
||||
|
||||
Gateway: Gateway
|
||||
|
||||
Identity: Identity
|
||||
|
||||
Internal: Dynamic
|
||||
|
||||
Ipns: Ipns
|
||||
|
||||
Migration: Migration
|
||||
|
||||
Mounts: Mounts
|
||||
|
||||
Peering: Peering
|
||||
|
||||
Pinning: Pinning
|
||||
|
||||
Plugins: Plugins
|
||||
|
||||
Provider: Provider
|
||||
|
||||
Pubsub: Pubsub
|
||||
|
||||
Reprovider: Reprovider
|
||||
|
||||
Routing: Routing
|
||||
|
||||
Swarm: Swarm
|
||||
|
||||
class API {
|
||||
HTTPHeaders: HTTPHeaders
|
||||
}
|
||||
|
||||
class HTTPHeaders {
|
||||
`Access-Control-Allow-Origin`: Listing
|
||||
}
|
||||
|
||||
class Addresses {
|
||||
API: String
|
||||
|
||||
Announce: Listing<Any>
|
||||
|
||||
AppendAnnounce: Listing<Any>
|
||||
|
||||
Gateway: String
|
||||
|
||||
NoAnnounce: Listing<Any>
|
||||
|
||||
Swarm: Listing
|
||||
}
|
||||
|
||||
class DNS {
|
||||
Resolvers: Dynamic
|
||||
}
|
||||
|
||||
class Datastore {
|
||||
BloomFilterSize: Int
|
||||
|
||||
GCPeriod: String
|
||||
|
||||
HashOnRead: Boolean
|
||||
|
||||
Spec: Spec
|
||||
|
||||
StorageGCWatermark: Int
|
||||
|
||||
StorageMax: String
|
||||
}
|
||||
|
||||
class Spec {
|
||||
mounts: Listing
|
||||
|
||||
type: String
|
||||
}
|
||||
|
||||
class MountsItem0 {
|
||||
child: Child
|
||||
|
||||
mountpoint: String
|
||||
|
||||
prefix: String
|
||||
|
||||
type: String
|
||||
}
|
||||
|
||||
class Child {
|
||||
path: String
|
||||
|
||||
shardFunc: String
|
||||
|
||||
sync: Boolean
|
||||
|
||||
type: String
|
||||
}
|
||||
|
||||
class MountsItem1 {
|
||||
child: MountsItem1Child
|
||||
|
||||
mountpoint: String
|
||||
|
||||
prefix: String
|
||||
|
||||
type: String
|
||||
}
|
||||
|
||||
class MountsItem1Child {
|
||||
compression: String
|
||||
|
||||
path: String
|
||||
|
||||
type: String
|
||||
}
|
||||
|
||||
class Discovery {
|
||||
MDNS: MDNS
|
||||
}
|
||||
|
||||
class MDNS {
|
||||
Enabled: Boolean
|
||||
}
|
||||
|
||||
class Experimental {
|
||||
AcceleratedDHTClient: Boolean
|
||||
|
||||
FilestoreEnabled: Boolean
|
||||
|
||||
GraphsyncEnabled: Boolean
|
||||
|
||||
Libp2pStreamMounting: Boolean
|
||||
|
||||
P2pHttpProxy: Boolean
|
||||
|
||||
StrategicProviding: Boolean
|
||||
|
||||
UrlstoreEnabled: Boolean
|
||||
}
|
||||
|
||||
class Gateway {
|
||||
APICommands: Listing<Any>
|
||||
|
||||
HTTPHeaders: GatewayHTTPHeaders
|
||||
|
||||
NoDNSLink: Boolean
|
||||
|
||||
NoFetch: Boolean
|
||||
|
||||
PathPrefixes: Listing<Any>
|
||||
|
||||
PublicGateways: Any
|
||||
|
||||
RootRedirect: String
|
||||
|
||||
Writable: Boolean
|
||||
}
|
||||
|
||||
class GatewayHTTPHeaders {
|
||||
`Access-Control-Allow-Headers`: Listing
|
||||
|
||||
`Access-Control-Allow-Methods`: Listing
|
||||
|
||||
`Access-Control-Allow-Origin`: Listing
|
||||
}
|
||||
|
||||
class Identity {
|
||||
PeerID: String
|
||||
|
||||
PrivKey: String
|
||||
}
|
||||
|
||||
class Ipns {
|
||||
RecordLifetime: String
|
||||
|
||||
RepublishPeriod: String
|
||||
|
||||
ResolveCacheSize: Int
|
||||
}
|
||||
|
||||
class Migration {
|
||||
DownloadSources: Listing<Any>
|
||||
|
||||
Keep: String
|
||||
}
|
||||
|
||||
class Mounts {
|
||||
FuseAllowOther: Boolean
|
||||
|
||||
IPFS: String
|
||||
|
||||
IPNS: String
|
||||
}
|
||||
|
||||
class Peering {
|
||||
Peers: Listing
|
||||
}
|
||||
|
||||
class PeersItem11 {
|
||||
Addrs: Listing
|
||||
|
||||
ID: String
|
||||
}
|
||||
|
||||
class Pinning {
|
||||
RemoteServices: Dynamic
|
||||
}
|
||||
|
||||
class Plugins {
|
||||
Plugins: Any
|
||||
}
|
||||
|
||||
class Provider {
|
||||
Strategy: String
|
||||
}
|
||||
|
||||
class Pubsub {
|
||||
DisableSigning: Boolean
|
||||
|
||||
Router: String
|
||||
}
|
||||
|
||||
class Reprovider {
|
||||
Interval: String
|
||||
|
||||
Strategy: String
|
||||
}
|
||||
|
||||
class Routing {
|
||||
Methods: Any
|
||||
|
||||
Routers: Any
|
||||
|
||||
Type: String
|
||||
}
|
||||
|
||||
class Swarm {
|
||||
AddrFilters: Any
|
||||
|
||||
ConnMgr: Dynamic
|
||||
|
||||
DisableBandwidthMetrics: Boolean
|
||||
|
||||
DisableNatPortMap: Boolean
|
||||
|
||||
RelayClient: Dynamic
|
||||
|
||||
RelayService: Dynamic
|
||||
|
||||
ResourceMgr: Dynamic
|
||||
|
||||
Transports: Transports
|
||||
}
|
||||
|
||||
class Transports {
|
||||
Multiplexers: Dynamic
|
||||
|
||||
Network: Dynamic
|
||||
|
||||
Security: Dynamic
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//===----------------------------------------------------------------------===//
|
||||
/// Configuration files for integrating the Matrix service
|
||||
amends "../basePklProject.pkl"
|
||||
|
||||
package {
|
||||
name = "ipfs.net"
|
||||
version = "0.0.4"
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
@go.Package { name = "github.com/onsonr/sonr/internal/gateway/config" }
|
||||
@go.Package { name = "github.com/onsonr/sonr/pkg/config/hway" }
|
||||
|
||||
|
||||
open module sonr.hway.Env
|
||||
open module sonr.conf.Hway
|
||||
|
||||
import "package://pkg.pkl-lang.org/pkl-go/pkl.golang@0.5.0#/go.pkl"
|
||||
|
@ -1,6 +1,6 @@
|
||||
@go.Package { name = "github.com/onsonr/sonr/internal/vault/config" }
|
||||
@go.Package { name = "github.com/onsonr/sonr/pkg/config/motr" }
|
||||
|
||||
module sonr.motr.DWN
|
||||
module sonr.conf.Motr
|
||||
|
||||
import "package://pkg.pkl-lang.org/pkl-go/pkl.golang@0.5.0#/go.pkl"
|
||||
|
@ -17,6 +17,6 @@
|
||||
amends "../basePklProject.pkl"
|
||||
|
||||
package {
|
||||
name = "sonr.motr"
|
||||
name = "sonr.conf"
|
||||
version = "0.0.1"
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"resolvedDependencies": {}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
@go.Package { name = "github.com/onsonr/sonr/pkg/common/models" }
|
||||
|
||||
module sonr.motr.ORM
|
||||
module sonr.orm.Models
|
||||
|
||||
import "package://pkg.pkl-lang.org/pkl-go/pkl.golang@0.5.0#/go.pkl"
|
||||
|
@ -17,6 +17,6 @@
|
||||
amends "../basePklProject.pkl"
|
||||
|
||||
package {
|
||||
name = "sonr.hway"
|
||||
version = "0.0.3"
|
||||
name = "sonr.orm"
|
||||
version = "0.0.1"
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
@go.Package { name = "github.com/onsonr/sonr/crypto/ucan/attns" }
|
||||
|
||||
module sonr.motr.ATN
|
||||
module sonr.orm.UCAN
|
||||
|
||||
import "package://pkg.pkl-lang.org/pkl-go/pkl.golang@0.5.0#/go.pkl"
|
||||
|
@ -32,3 +32,15 @@ if [ ! -f "$ROOT_DIR/bin/process-compose" ]; then
|
||||
sh -c "$(curl --location https://raw.githubusercontent.com/F1bonacc1/process-compose/main/scripts/get-pc.sh)" -- -d -b $ROOT_DIR/bin
|
||||
fi
|
||||
|
||||
# Check if pkl-gen-go is installed to $GOPATH/bin
|
||||
if [ ! -f "$GOPATH/bin/pkl-gen-go" ]; then
|
||||
echo "pkl-gen-go not found. Installing..."
|
||||
go install github.com/apple/pkl-go/cmd/pkl-gen-go@latest
|
||||
fi
|
||||
|
||||
# Check if templ is installed to $GOPATH/bin
|
||||
if [ ! -f "$GOPATH/bin/templ" ]; then
|
||||
echo "templ not found. Installing..."
|
||||
go install github.com/a-h/templ/cmd/templ@latest
|
||||
fi
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user