feat: add PKL schema for message formats

This commit is contained in:
Prad Nukala
2024-09-30 19:44:16 -04:00
parent d9b1ac72a3
commit aa830517f3
58 changed files with 1201 additions and 133 deletions
+36
View File
@@ -0,0 +1,36 @@
// 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
}
+16
View File
@@ -0,0 +1,16 @@
// 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"`
}
+52
View File
@@ -0,0 +1,52 @@
// 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
}
+9
View File
@@ -0,0 +1,9 @@
// 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{})
}