mirror of
https://github.com/onsonr/sonr.git
synced 2025-03-10 13:07:09 +00:00
feat: add Input and RegistrationForm models
This commit is contained in:
parent
ece8d85074
commit
de9b4bf72f
1
Makefile
1
Makefile
@ -317,7 +317,6 @@ nebula:
|
||||
pkl:
|
||||
@echo "(pkl) Building PKL"
|
||||
go run github.com/apple/pkl-go/cmd/pkl-gen-go ./pkl/dwn.pkl
|
||||
go run github.com/apple/pkl-go/cmd/pkl-gen-go ./pkl/fmt.pkl
|
||||
go run github.com/apple/pkl-go/cmd/pkl-gen-go ./pkl/orm.pkl
|
||||
go run github.com/apple/pkl-go/cmd/pkl-gen-go ./pkl/txns.pkl
|
||||
go run github.com/apple/pkl-go/cmd/pkl-gen-go ./pkl/uiux.pkl
|
||||
|
@ -1,36 +0,0 @@
|
||||
// Code generated from Pkl module `format`. DO NOT EDIT.
|
||||
package format
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/apple/pkl-go/pkl"
|
||||
)
|
||||
|
||||
type Format struct {
|
||||
}
|
||||
|
||||
// LoadFromPath loads the pkl module at the given path and evaluates it into a Format
|
||||
func LoadFromPath(ctx context.Context, path string) (ret *Format, err error) {
|
||||
evaluator, err := pkl.NewEvaluator(ctx, pkl.PreconfiguredOptions)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer func() {
|
||||
cerr := evaluator.Close()
|
||||
if err == nil {
|
||||
err = cerr
|
||||
}
|
||||
}()
|
||||
ret, err = Load(ctx, evaluator, pkl.FileSource(path))
|
||||
return ret, err
|
||||
}
|
||||
|
||||
// Load loads the pkl module at the given source and evaluates it with the given evaluator into a Format
|
||||
func Load(ctx context.Context, evaluator pkl.Evaluator, source *pkl.ModuleSource) (*Format, error) {
|
||||
var ret Format
|
||||
if err := evaluator.EvaluateModule(ctx, source, &ret); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &ret, nil
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
// Code generated from Pkl module `format`. DO NOT EDIT.
|
||||
package format
|
||||
|
||||
type Macaroon struct {
|
||||
Location string `pkl:"location" json:"location,omitempty"`
|
||||
|
||||
Originator string `pkl:"originator" json:"originator,omitempty"`
|
||||
|
||||
Identifier string `pkl:"identifier" json:"identifier,omitempty"`
|
||||
|
||||
FirstParty []string `pkl:"first_party" json:"first_party,omitempty"`
|
||||
|
||||
ThirdParty []string `pkl:"third_party" json:"third_party,omitempty"`
|
||||
|
||||
Expiration int `pkl:"expiration" json:"expiration,omitempty"`
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
// Code generated from Pkl module `format`. DO NOT EDIT.
|
||||
package didmethod
|
||||
|
||||
import (
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type DIDMethod string
|
||||
|
||||
const (
|
||||
Ipfs DIDMethod = "ipfs"
|
||||
Sonr DIDMethod = "sonr"
|
||||
Bitcoin DIDMethod = "bitcoin"
|
||||
Ethereum DIDMethod = "ethereum"
|
||||
Ibc DIDMethod = "ibc"
|
||||
Webauthn DIDMethod = "webauthn"
|
||||
Dwn DIDMethod = "dwn"
|
||||
Service DIDMethod = "service"
|
||||
)
|
||||
|
||||
// String returns the string representation of DIDMethod
|
||||
func (rcv DIDMethod) String() string {
|
||||
return string(rcv)
|
||||
}
|
||||
|
||||
var _ encoding.BinaryUnmarshaler = new(DIDMethod)
|
||||
|
||||
// UnmarshalBinary implements encoding.BinaryUnmarshaler for DIDMethod.
|
||||
func (rcv *DIDMethod) UnmarshalBinary(data []byte) error {
|
||||
switch str := string(data); str {
|
||||
case "ipfs":
|
||||
*rcv = Ipfs
|
||||
case "sonr":
|
||||
*rcv = Sonr
|
||||
case "bitcoin":
|
||||
*rcv = Bitcoin
|
||||
case "ethereum":
|
||||
*rcv = Ethereum
|
||||
case "ibc":
|
||||
*rcv = Ibc
|
||||
case "webauthn":
|
||||
*rcv = Webauthn
|
||||
case "dwn":
|
||||
*rcv = Dwn
|
||||
case "service":
|
||||
*rcv = Service
|
||||
default:
|
||||
return fmt.Errorf(`illegal: "%s" is not a valid DIDMethod`, str)
|
||||
}
|
||||
return nil
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
// Code generated from Pkl module `format`. DO NOT EDIT.
|
||||
package format
|
||||
|
||||
import "github.com/apple/pkl-go/pkl"
|
||||
|
||||
func init() {
|
||||
pkl.RegisterMapping("format", Format{})
|
||||
pkl.RegisterMapping("format#Macaroon", Macaroon{})
|
||||
}
|
18
pkg/nebula/models/Input.pkl.go
Normal file
18
pkg/nebula/models/Input.pkl.go
Normal file
@ -0,0 +1,18 @@
|
||||
// Code generated from Pkl module `models`. DO NOT EDIT.
|
||||
package models
|
||||
|
||||
type Input struct {
|
||||
Label string `pkl:"label"`
|
||||
|
||||
Type string `pkl:"type"`
|
||||
|
||||
Placeholder string `pkl:"placeholder"`
|
||||
|
||||
Value *string `pkl:"value"`
|
||||
|
||||
Error *string `pkl:"error"`
|
||||
|
||||
Help *string `pkl:"help"`
|
||||
|
||||
Required bool `pkl:"required"`
|
||||
}
|
14
pkg/nebula/models/RegistrationForm.pkl.go
Normal file
14
pkg/nebula/models/RegistrationForm.pkl.go
Normal file
@ -0,0 +1,14 @@
|
||||
// Code generated from Pkl module `models`. DO NOT EDIT.
|
||||
package models
|
||||
|
||||
import "github.com/onsonr/sonr/pkg/nebula/models/formstate"
|
||||
|
||||
type RegistrationForm struct {
|
||||
Title string `pkl:"title"`
|
||||
|
||||
Description string `pkl:"description"`
|
||||
|
||||
State formstate.FormState `pkl:"state"`
|
||||
|
||||
Inputs []*Input `pkl:"inputs"`
|
||||
}
|
@ -11,5 +11,7 @@ func init() {
|
||||
pkl.RegisterMapping("models#Stats", Stats{})
|
||||
pkl.RegisterMapping("models#Link", Link{})
|
||||
pkl.RegisterMapping("models#SocialLink", SocialLink{})
|
||||
pkl.RegisterMapping("models#Input", Input{})
|
||||
pkl.RegisterMapping("models#Footer", Footer{})
|
||||
pkl.RegisterMapping("models#RegistrationForm", RegistrationForm{})
|
||||
}
|
||||
|
37
pkl/fmt.pkl
37
pkl/fmt.pkl
@ -1,37 +0,0 @@
|
||||
@go.Package { name = "github.com/onsonr/sonr/pkg/format" }
|
||||
|
||||
module format
|
||||
|
||||
import "package://pkg.pkl-lang.org/pkl-go/pkl.golang@0.5.0#/go.pkl"
|
||||
|
||||
class JsonField extends go.Field {
|
||||
structTags {
|
||||
["json"] = "%{name},omitempty"
|
||||
}
|
||||
}
|
||||
|
||||
typealias DID = String
|
||||
|
||||
typealias DIDMethod = "ipfs"|"sonr"|"bitcoin"|"ethereum"|"ibc"|"webauthn"|"dwn"|"service"
|
||||
|
||||
class Macaroon {
|
||||
@JsonField
|
||||
location: String
|
||||
|
||||
@JsonField
|
||||
originator: String
|
||||
|
||||
@JsonField
|
||||
identifier: String
|
||||
|
||||
@JsonField
|
||||
first_party: List<String>
|
||||
|
||||
@JsonField
|
||||
third_party: List<String>
|
||||
|
||||
@JsonField
|
||||
expiration: Int
|
||||
}
|
||||
|
||||
typealias MacaroonToken = String
|
Loading…
x
Reference in New Issue
Block a user