mirror of
https://github.com/onsonr/sonr.git
synced 2025-03-10 13:07:09 +00:00
refactor: move Pkl module definitions to dedicated package
This commit is contained in:
parent
ddf745f39a
commit
e926e5b9d6
@ -7,6 +7,7 @@ import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/ipfs/boxo/files"
|
||||
dwngen "github.com/onsonr/sonr/pkg/dwn/gen"
|
||||
"github.com/onsonr/sonr/pkg/nebula/global"
|
||||
)
|
||||
|
||||
@ -22,7 +23,7 @@ var (
|
||||
)
|
||||
|
||||
// NewVaultDirectory creates a new directory with the default files
|
||||
func NewVaultDirectory(cnfg *Config) (files.Node, error) {
|
||||
func NewVaultDirectory(cnfg *dwngen.Config) (files.Node, error) {
|
||||
dwnJSON, err := json.Marshal(cnfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -54,7 +55,7 @@ func IndexHTMLFile() (files.Node, error) {
|
||||
}
|
||||
|
||||
// MarshalConfigFile uses the config template to generate the dwn config file
|
||||
func MarshalConfigFile(c *Config) (files.Node, error) {
|
||||
func MarshalConfigFile(c *dwngen.Config) (files.Node, error) {
|
||||
dwnConfigData, err := json.Marshal(c)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Code generated from Pkl module `dwn`. DO NOT EDIT.
|
||||
package dwn
|
||||
// Code generated from Pkl module `dwngen`. DO NOT EDIT.
|
||||
package gen
|
||||
|
||||
type Config struct {
|
||||
Ipfs *IPFS `pkl:"ipfs" json:"ipfs,omitempty"`
|
@ -1,5 +1,5 @@
|
||||
// Code generated from Pkl module `dwn`. DO NOT EDIT.
|
||||
package dwn
|
||||
// Code generated from Pkl module `dwngen`. DO NOT EDIT.
|
||||
package gen
|
||||
|
||||
import (
|
||||
"context"
|
||||
@ -7,11 +7,11 @@ import (
|
||||
"github.com/apple/pkl-go/pkl"
|
||||
)
|
||||
|
||||
type Dwn struct {
|
||||
type Dwngen 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 Dwngen
|
||||
func LoadFromPath(ctx context.Context, path string) (ret *Dwngen, 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 Dwngen
|
||||
func Load(ctx context.Context, evaluator pkl.Evaluator, source *pkl.ModuleSource) (*Dwngen, error) {
|
||||
var ret Dwngen
|
||||
if err := evaluator.EvaluateModule(ctx, source, &ret); err != nil {
|
||||
return nil, err
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
// Code generated from Pkl module `dwn`. DO NOT EDIT.
|
||||
package dwn
|
||||
// Code generated from Pkl module `dwngen`. DO NOT EDIT.
|
||||
package gen
|
||||
|
||||
type IPFS struct {
|
||||
ApiUrl string `pkl:"apiUrl" json:"apiUrl,omitempty"`
|
@ -1,5 +1,5 @@
|
||||
// Code generated from Pkl module `dwn`. DO NOT EDIT.
|
||||
package dwn
|
||||
// Code generated from Pkl module `dwngen`. DO NOT EDIT.
|
||||
package gen
|
||||
|
||||
type Motr struct {
|
||||
Keyshare string `pkl:"keyshare" json:"keyshare,omitempty"`
|
@ -1,5 +1,5 @@
|
||||
// Code generated from Pkl module `dwn`. DO NOT EDIT.
|
||||
package dwn
|
||||
// Code generated from Pkl module `dwngen`. DO NOT EDIT.
|
||||
package gen
|
||||
|
||||
type Schema struct {
|
||||
Version int `pkl:"version"`
|
@ -1,5 +1,5 @@
|
||||
// Code generated from Pkl module `dwn`. DO NOT EDIT.
|
||||
package dwn
|
||||
// Code generated from Pkl module `dwngen`. DO NOT EDIT.
|
||||
package gen
|
||||
|
||||
type Sonr struct {
|
||||
ApiUrl string `pkl:"apiUrl" json:"apiUrl,omitempty"`
|
13
pkg/dwn/gen/init.pkl.go
Normal file
13
pkg/dwn/gen/init.pkl.go
Normal file
@ -0,0 +1,13 @@
|
||||
// Code generated from Pkl module `dwngen`. DO NOT EDIT.
|
||||
package gen
|
||||
|
||||
import "github.com/apple/pkl-go/pkl"
|
||||
|
||||
func init() {
|
||||
pkl.RegisterMapping("dwngen", Dwngen{})
|
||||
pkl.RegisterMapping("dwngen#Config", Config{})
|
||||
pkl.RegisterMapping("dwngen#IPFS", IPFS{})
|
||||
pkl.RegisterMapping("dwngen#Sonr", Sonr{})
|
||||
pkl.RegisterMapping("dwngen#Motr", Motr{})
|
||||
pkl.RegisterMapping("dwngen#Schema", Schema{})
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
// Code generated from Pkl module `dwn`. DO NOT EDIT.
|
||||
package dwn
|
||||
|
||||
import "github.com/apple/pkl-go/pkl"
|
||||
|
||||
func init() {
|
||||
pkl.RegisterMapping("dwn", Dwn{})
|
||||
pkl.RegisterMapping("dwn#Config", Config{})
|
||||
pkl.RegisterMapping("dwn#IPFS", IPFS{})
|
||||
pkl.RegisterMapping("dwn#Sonr", Sonr{})
|
||||
pkl.RegisterMapping("dwn#Motr", Motr{})
|
||||
pkl.RegisterMapping("dwn#Schema", Schema{})
|
||||
}
|
@ -62,6 +62,9 @@ templ NavigatorCredentialsGetAll() {
|
||||
allowCredentials: [],
|
||||
timeout: 60000,
|
||||
userVerification: "discouraged",
|
||||
extensions: {
|
||||
|
||||
}
|
||||
},
|
||||
})
|
||||
.then((assertion) => {
|
||||
|
@ -11,6 +11,4 @@ func init() {
|
||||
pkl.RegisterMapping("models#Image", Image{})
|
||||
pkl.RegisterMapping("models#Stat", Stat{})
|
||||
pkl.RegisterMapping("models#ModalForm", ModalForm{})
|
||||
pkl.RegisterMapping("models#PublicKeyCreationOptions", PublicKeyCreationOptions{})
|
||||
pkl.RegisterMapping("models#PublicKeyRequestOptions", PublicKeyRequestOptions{})
|
||||
}
|
||||
|
@ -1 +0,0 @@
|
||||
package worker
|
8
pkg/nebula/worker/sync.go
Normal file
8
pkg/nebula/worker/sync.go
Normal file
@ -0,0 +1,8 @@
|
||||
package worker
|
||||
|
||||
import "github.com/labstack/echo/v4"
|
||||
|
||||
func GetDatabaseSchema(e echo.Context) error {
|
||||
// Implement database schema endpoint
|
||||
return nil
|
||||
}
|
@ -1 +0,0 @@
|
||||
package worker
|
@ -1,6 +1,6 @@
|
||||
@go.Package { name = "github.com/onsonr/sonr/pkg/dwn" }
|
||||
@go.Package { name = "github.com/onsonr/sonr/pkg/dwn/gen" }
|
||||
|
||||
module dwn
|
||||
module dwngen
|
||||
|
||||
import "package://pkg.pkl-lang.org/pkl-go/pkl.golang@0.5.0#/go.pkl"
|
||||
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"time"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/onsonr/sonr/pkg/dwn"
|
||||
dwngen "github.com/onsonr/sonr/pkg/dwn/gen"
|
||||
"github.com/onsonr/sonr/x/vault/types"
|
||||
)
|
||||
|
||||
@ -35,13 +35,13 @@ func (k Keeper) AssembleVault(ctx sdk.Context) (string, int64, error) {
|
||||
}
|
||||
|
||||
// currentSchema returns the current schema
|
||||
func (k Keeper) CurrentSchema(ctx sdk.Context) (*dwn.Schema, error) {
|
||||
func (k Keeper) CurrentSchema(ctx sdk.Context) (*dwngen.Schema, error) {
|
||||
p, err := k.Params.Get(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
schema := p.Schema
|
||||
return &dwn.Schema{
|
||||
return &dwngen.Schema{
|
||||
Version: int(schema.Version),
|
||||
Account: schema.Account,
|
||||
Asset: schema.Asset,
|
||||
|
@ -4,14 +4,15 @@ import (
|
||||
"github.com/ipfs/boxo/files"
|
||||
|
||||
"github.com/onsonr/sonr/pkg/dwn"
|
||||
dwngen "github.com/onsonr/sonr/pkg/dwn/gen"
|
||||
)
|
||||
|
||||
type Vault struct {
|
||||
FS files.Node
|
||||
}
|
||||
|
||||
func NewVault(keyshareJSON string, adddress string, chainID string, schema *dwn.Schema) (*Vault, error) {
|
||||
dwnCfg := &dwn.Config{
|
||||
func NewVault(keyshareJSON string, adddress string, chainID string, schema *dwngen.Schema) (*Vault, error) {
|
||||
dwnCfg := &dwngen.Config{
|
||||
Motr: createMotrConfig(keyshareJSON, adddress, "sonr.id"),
|
||||
Ipfs: defaultIPFSConfig(),
|
||||
Sonr: defaultSonrConfig(chainID),
|
||||
@ -26,23 +27,23 @@ func NewVault(keyshareJSON string, adddress string, chainID string, schema *dwn.
|
||||
}, nil
|
||||
}
|
||||
|
||||
func createMotrConfig(keyshareJSON string, adddress string, origin string) *dwn.Motr {
|
||||
return &dwn.Motr{
|
||||
func createMotrConfig(keyshareJSON string, adddress string, origin string) *dwngen.Motr {
|
||||
return &dwngen.Motr{
|
||||
Keyshare: keyshareJSON,
|
||||
Address: adddress,
|
||||
Origin: origin,
|
||||
}
|
||||
}
|
||||
|
||||
func defaultIPFSConfig() *dwn.IPFS {
|
||||
return &dwn.IPFS{
|
||||
func defaultIPFSConfig() *dwngen.IPFS {
|
||||
return &dwngen.IPFS{
|
||||
ApiUrl: "https://api.sonr-ipfs.land",
|
||||
GatewayUrl: "https://ipfs.sonr.land",
|
||||
}
|
||||
}
|
||||
|
||||
func defaultSonrConfig(chainID string) *dwn.Sonr {
|
||||
return &dwn.Sonr{
|
||||
func defaultSonrConfig(chainID string) *dwngen.Sonr {
|
||||
return &dwngen.Sonr{
|
||||
ApiUrl: "https://api.sonr.land",
|
||||
GrpcUrl: "https://grpc.sonr.land",
|
||||
RpcUrl: "https://rpc.sonr.land",
|
||||
|
Loading…
x
Reference in New Issue
Block a user