feature/driver indexed db (#12)
* fix: update commitizen version * feat: add WASM build tags to db actions * feat: Update all actions to follow `AddAsset` for error handling * feat: remove database dependency in dwn and motr commands * feat: add basic info form to registration view * feat: implement basic browser navigation component * refactor: move database related files to middleware * fix: remove unused test command * fix: update source directory for buf-publish workflow
This commit is contained in:
1 parent
7bdf6c3eb4
commit
8022428e37
118 files changed
+383
-1002
No files matched your search
@@ -7,11 +7,11 @@ delay = 1000
|
||||
cmd = "devbox run build:motr"
|
||||
exclude_dir = ["assets", "tmp", "vendor", "testdata"]
|
||||
exclude_file = []
|
||||
exclude_regex = ["_test.go"]
|
||||
exclude_regex = ["_test.go", ".pk.go", "_templ.go", ".pb.go"]
|
||||
exclude_unchanged = true
|
||||
follow_symlink = false
|
||||
full_bin = "bunx wrangler -c ./cmd/motr/wrangler.toml dev"
|
||||
include_dir = ["cmd/dwn", "cmd/motr", "internal", "models", "pkl"]
|
||||
full_bin = "bunx wrangler -c ./web/wrangler.toml dev"
|
||||
include_dir = ["web", "internal/dwn", "pkl"]
|
||||
include_ext = ["go", "templ", "html", "pkl", "js", "mjs"]
|
||||
include_file = [
|
||||
"wrangler.toml",
|
||||
@@ -26,7 +26,7 @@ log = "build-errors.log"
|
||||
poll = false
|
||||
poll_interval = 0
|
||||
post_cmd = []
|
||||
pre_cmd = ["templ generate"]
|
||||
pre_cmd = ["templ generate", "devbox run gen:pkl"]
|
||||
rerun = false
|
||||
rerun_delay = 500
|
||||
send_interrupt = false
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
name = "cz_conventional_commits"
|
||||
tag_format = "v$version"
|
||||
version_scheme = "semver"
|
||||
version = "0.1.1"
|
||||
version = "v0.1.0"
|
||||
update_changelog_on_bump = true
|
||||
major_version_zero = true
|
||||
@@ -32,5 +32,5 @@ jobs:
|
||||
r2-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }}
|
||||
r2-secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }}
|
||||
r2-bucket: pkljar
|
||||
source-dir: pkl
|
||||
source-dir: config/pkl
|
||||
destination-dir: .
|
||||
@@ -86,8 +86,4 @@ WORKDIR /opt
|
||||
# rest server, tendermint p2p, tendermint rpc
|
||||
EXPOSE 1317 26656 26657 6060
|
||||
|
||||
<<<<<<< HEAD
|
||||
CMD ["test_node.sh"]
|
||||
=======
|
||||
ENTRYPOINT ["/usr/bin/sonrd"]
|
||||
>>>>>>> master
|
||||
@@ -303,11 +303,11 @@ sh-testnet: mod-tidy
|
||||
|
||||
dwn:
|
||||
@echo "(dwn) Building dwn.wasm -> IPFS Vault"
|
||||
GOOS=js GOARCH=wasm go build -o ./internal/vfs/dwn.wasm ./cmd/dwn
|
||||
GOOS=js GOARCH=wasm go build -o ./internal/vfs/dwn.wasm ./internal/dwn/dwn.go
|
||||
|
||||
motr:
|
||||
@echo "(motr) Building app.wasm -> Deploy to Cloudflare Workers"
|
||||
GOOS=js GOARCH=wasm go build -o ./cmd/motr/build/app.wasm ./cmd/motr/main.go
|
||||
@echo "(web) Building app.wasm -> Deploy to Cloudflare Workers"
|
||||
GOOS=js GOARCH=wasm go build -o ./web/build/app.wasm ./web/main.go
|
||||
|
||||
###############################################################################
|
||||
### help ###
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
//go:build js && wasm
|
||||
// +build js,wasm
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/onsonr/sonr/internal/vfs/wasm"
|
||||
|
||||
"github.com/onsonr/sonr/internal/db"
|
||||
)
|
||||
|
||||
var dwn *DWN
|
||||
|
||||
type DWN struct {
|
||||
*echo.Echo
|
||||
DB *db.DB
|
||||
}
|
||||
|
||||
func main() {
|
||||
dwn = initRails()
|
||||
wasm.Serve(dwn.Echo)
|
||||
}
|
||||
|
||||
// initRails initializes the Rails application
|
||||
func initRails() *DWN {
|
||||
// Open the database
|
||||
e := echo.New()
|
||||
db, err := db.New()
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
db.ServeEcho(e.Group("/dwn"))
|
||||
|
||||
// Initialize the htmx handler
|
||||
return &DWN{
|
||||
Echo: e,
|
||||
DB: db,
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
@go.Package { name = "github.com/onsonr/sonr/internal/db/orm" }
|
||||
@go.Package { name = "github.com/onsonr/sonr/internal/dwn/models" }
|
||||
|
||||
module orm
|
||||
module models
|
||||
|
||||
import "package://pkg.pkl-lang.org/pkl-go/pkl.golang@0.5.0#/go.pkl"
|
||||
|
||||
@@ -225,3 +225,52 @@ class Permission {
|
||||
updatedAt: String?
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
class DiscoveryDocument {
|
||||
@JsonField
|
||||
issuer: String
|
||||
|
||||
@JsonField
|
||||
authorization_endpoint: String
|
||||
|
||||
@JsonField
|
||||
token_endpoint: String
|
||||
|
||||
@JsonField
|
||||
userinfo_endpoint: String
|
||||
|
||||
@JsonField
|
||||
jwks_uri: String
|
||||
|
||||
@JsonField
|
||||
registration_endpoint: String
|
||||
|
||||
@JsonField
|
||||
scopes_supported: List<String>
|
||||
|
||||
@JsonField
|
||||
response_types_supported: List<String>
|
||||
|
||||
@JsonField
|
||||
response_modes_supported: List<String>
|
||||
|
||||
@JsonField
|
||||
subject_types_supported: List<String>
|
||||
|
||||
@JsonField
|
||||
id_token_signing_alg_values_supported: List<String>
|
||||
|
||||
@JsonField
|
||||
claims_supported: List<String>
|
||||
|
||||
@JsonField
|
||||
grant_types_supported: List<String>
|
||||
|
||||
@JsonField
|
||||
acr_values_supported: List<String>
|
||||
|
||||
@JsonField
|
||||
token_endpoint_auth_methods_supported: List<String>
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
@go.Package { name = "github.com/onsonr/sonr/x/did/types/txns" }
|
||||
@go.Package { name = "github.com/onsonr/sonr/internal/dwn/txns" }
|
||||
|
||||
module txns
|
||||
|
||||
+5
-5
@@ -3,8 +3,6 @@
|
||||
"packages": [
|
||||
"go@1.22",
|
||||
"templ@latest",
|
||||
"go-task@latest",
|
||||
"templ@latest",
|
||||
"bun@latest",
|
||||
"ipfs-cluster@latest",
|
||||
"air@latest",
|
||||
@@ -39,9 +37,11 @@
|
||||
"make proto-gen"
|
||||
],
|
||||
"gen:pkl": [
|
||||
"go run github.com/apple/pkl-go/cmd/pkl-gen-go ./pkl/oidc.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 ./config/pkl/orm.pkl",
|
||||
"go run github.com/apple/pkl-go/cmd/pkl-gen-go ./config/pkl/txns.pkl"
|
||||
],
|
||||
"gen:templ": [
|
||||
"templ generate"
|
||||
],
|
||||
"dev": [
|
||||
"air"
|
||||
|
||||
@@ -73,10 +73,8 @@ require (
|
||||
github.com/joho/godotenv v1.5.1
|
||||
github.com/labstack/echo/v4 v4.10.2
|
||||
github.com/mr-tron/base58 v1.2.0
|
||||
github.com/ncruces/go-sqlite3 v0.18.2
|
||||
github.com/ncruces/go-sqlite3/gormlite v0.18.0
|
||||
github.com/nlepage/go-js-promise v1.0.0
|
||||
github.com/onsonr/crypto v1.29.0
|
||||
github.com/onsonr/crypto v1.30.0
|
||||
github.com/segmentio/ksuid v1.0.4
|
||||
github.com/spf13/cast v1.6.0
|
||||
github.com/spf13/cobra v1.8.0
|
||||
@@ -93,8 +91,6 @@ require (
|
||||
google.golang.org/protobuf v1.34.2
|
||||
gopkg.in/macaroon-bakery.v2 v2.3.0
|
||||
gopkg.in/macaroon.v2 v2.1.0
|
||||
gorm.io/gorm v1.25.11
|
||||
lukechampine.com/adiantum v1.1.1
|
||||
lukechampine.com/blake3 v1.3.0
|
||||
)
|
||||
|
||||
@@ -236,8 +232,6 @@ require (
|
||||
github.com/ipld/go-codec-dagpb v1.6.0 // indirect
|
||||
github.com/ipld/go-ipld-prime v0.21.0 // indirect
|
||||
github.com/jbenet/goprocess v0.1.4 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
github.com/jmespath/go-jmespath v0.4.0 // indirect
|
||||
github.com/jmhodges/levigo v1.0.0 // indirect
|
||||
github.com/klauspost/compress v1.17.9 // indirect
|
||||
@@ -286,7 +280,6 @@ require (
|
||||
github.com/multiformats/go-multihash v0.2.3 // indirect
|
||||
github.com/multiformats/go-multistream v0.5.0 // indirect
|
||||
github.com/multiformats/go-varint v0.0.7 // indirect
|
||||
github.com/ncruces/julianday v1.0.0 // indirect
|
||||
github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect
|
||||
github.com/oklog/run v1.1.0 // indirect
|
||||
github.com/onsi/ginkgo v1.16.5 // indirect
|
||||
@@ -318,7 +311,6 @@ require (
|
||||
github.com/subosito/gotenv v1.6.0 // indirect
|
||||
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
|
||||
github.com/tendermint/go-amino v0.16.0 // indirect
|
||||
github.com/tetratelabs/wazero v1.8.0 // indirect
|
||||
github.com/tidwall/btree v1.7.0 // indirect
|
||||
github.com/ulikunitz/xz v0.5.11 // indirect
|
||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||
|
||||
@@ -1590,10 +1590,6 @@ github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M
|
||||
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
|
||||
github.com/jhump/protoreflect v1.15.3 h1:6SFRuqU45u9hIZPJAoZ8c28T3nK64BNdp9w6jFonzls=
|
||||
github.com/jhump/protoreflect v1.15.3/go.mod h1:4ORHmSBmlCW8fh3xHmJMGyul1zNqZK4Elxc8qKP+p1k=
|
||||
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
||||
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
||||
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
|
||||
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
|
||||
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
|
||||
@@ -1830,12 +1826,6 @@ github.com/nats-io/nats.go v1.30.2/go.mod h1:dcfhUgmQNN4GJEfIb2f9R7Fow+gzBF4emzD
|
||||
github.com/nats-io/nkeys v0.4.4/go.mod h1:XUkxdLPTufzlihbamfzQ7mw/VGx6ObUs+0bN5sNvt64=
|
||||
github.com/nats-io/nkeys v0.4.5/go.mod h1:XUkxdLPTufzlihbamfzQ7mw/VGx6ObUs+0bN5sNvt64=
|
||||
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
|
||||
github.com/ncruces/go-sqlite3 v0.18.2 h1:m7QXhBWIwXsp84HE11t+ze0n1v3LRU+zGFg4uHjBeFA=
|
||||
github.com/ncruces/go-sqlite3 v0.18.2/go.mod h1:4sZHOm+b/FM8FJRVGN4TemkPPDq5JXGK/1EHIEWxsYo=
|
||||
github.com/ncruces/go-sqlite3/gormlite v0.18.0 h1:KqP9a9wlX/Ba+yG+aeVX4pnNBNdaSO6xHdNDWzPxPnk=
|
||||
github.com/ncruces/go-sqlite3/gormlite v0.18.0/go.mod h1:RXeT1hknrz3A0tBDL6IfluDHuNkHdJeImn5TBMQg9zc=
|
||||
github.com/ncruces/julianday v1.0.0 h1:fH0OKwa7NWvniGQtxdJRxAgkBMolni2BjDHaWTxqt7M=
|
||||
github.com/ncruces/julianday v1.0.0/go.mod h1:Dusn2KvZrrovOMJuOt0TNXL6tB7U2E8kvza5fFc9G7g=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||
github.com/nlepage/go-js-promise v1.0.0 h1:K7OmJ3+0BgWJ2LfXchg2sI6RDr7AW/KWR8182epFwGQ=
|
||||
github.com/nlepage/go-js-promise v1.0.0/go.mod h1:bdOP0wObXu34euibyK39K1hoBCtlgTKXGc56AGflaRo=
|
||||
@@ -1861,8 +1851,8 @@ github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7J
|
||||
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
||||
github.com/onsi/gomega v1.33.1 h1:dsYjIxxSR755MDmKVsaFQTE22ChNBcuuTWgkUDSubOk=
|
||||
github.com/onsi/gomega v1.33.1/go.mod h1:U4R44UsT+9eLIaYRB2a5qajjtQYn0hauxvRm16AVYg0=
|
||||
github.com/onsonr/crypto v1.29.0 h1:ontCN/XNNmpWv23N8VB6vsirLXcjxZaA67lLX9RNj0c=
|
||||
github.com/onsonr/crypto v1.29.0/go.mod h1:NSfeCO6XoyQeSDEp6Jy42UGG5047GvzG6lW9lRnjrR0=
|
||||
github.com/onsonr/crypto v1.30.0 h1:1zSKy/zZR0r1iT7d6bwy6/EiiWKNIb7ZhdoRp1tLirU=
|
||||
github.com/onsonr/crypto v1.30.0/go.mod h1:NSfeCO6XoyQeSDEp6Jy42UGG5047GvzG6lW9lRnjrR0=
|
||||
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
|
||||
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
|
||||
github.com/opencontainers/image-spec v1.1.0-rc5 h1:Ygwkfw9bpDvs+c9E34SdgGOj41dX/cbdlwvlWt0pnFI=
|
||||
@@ -2083,8 +2073,6 @@ github.com/syumai/workers v0.26.3 h1:AF+IBaRccbR4JIj2kNJLJblruPFMD/pAbzkopejGcP8
|
||||
github.com/syumai/workers v0.26.3/go.mod h1:ZnqmdiHNBrbxOLrZ/HJ5jzHy6af9cmiNZk10R9NrIEA=
|
||||
github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E=
|
||||
github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME=
|
||||
github.com/tetratelabs/wazero v1.8.0 h1:iEKu0d4c2Pd+QSRieYbnQC9yiFlMS9D+Jr0LsRmcF4g=
|
||||
github.com/tetratelabs/wazero v1.8.0/go.mod h1:yAI0XTsMBhREkM/YDAK/zNou3GoiAce1P6+rp/wQhjs=
|
||||
github.com/tidwall/btree v1.7.0 h1:L1fkJH/AuEh5zBnnBbmTwQ5Lt+bRJ5A8EWecslvo9iI=
|
||||
github.com/tidwall/btree v1.7.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY=
|
||||
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
|
||||
@@ -3074,8 +3062,6 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gorm.io/gorm v1.25.11 h1:/Wfyg1B/je1hnDx3sMkX+gAlxrlZpn6X0BXRlwXlvHg=
|
||||
gorm.io/gorm v1.25.11/go.mod h1:xh7N7RHfYlNc5EmcI/El95gXusucDrQnHXe0+CgWcLQ=
|
||||
gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU=
|
||||
gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
@@ -3086,8 +3072,6 @@ honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt
|
||||
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
honnef.co/go/tools v0.1.3/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las=
|
||||
lukechampine.com/adiantum v1.1.1 h1:4fp6gTxWCqpEbLy40ExiYDDED3oUNWx5cTqBCtPdZqA=
|
||||
lukechampine.com/adiantum v1.1.1/go.mod h1:LrAYVnTYLnUtE/yMp5bQr0HstAf060YUF8nM0B6+rUw=
|
||||
lukechampine.com/blake3 v1.3.0 h1:sJ3XhFINmHSrYCgl958hscfIa3bw8x4DqMP3u1YvoYE=
|
||||
lukechampine.com/blake3 v1.3.0/go.mod h1:0OFRp7fBtAylGVCO40o87sbupkyIGgbpv1+M1k1LM6k=
|
||||
lukechampine.com/uint128 v1.1.1/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk=
|
||||
|
||||
@@ -1,330 +0,0 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/onsonr/sonr/internal/db/orm"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// createInitialTables creates the initial tables in the database.
|
||||
func createInitialTables(db *gorm.DB) (*DB, error) {
|
||||
err := db.AutoMigrate(
|
||||
&orm.Account{},
|
||||
&orm.Asset{},
|
||||
&orm.Credential{},
|
||||
&orm.Keyshare{},
|
||||
&orm.Permission{},
|
||||
&orm.Profile{},
|
||||
&orm.Property{},
|
||||
)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create table: %w", err)
|
||||
}
|
||||
|
||||
return &DB{db}, nil
|
||||
}
|
||||
|
||||
// AddAccount adds a new account to the database
|
||||
func (db *DB) AddAccount(account *orm.Account) error {
|
||||
tx := db.Create(account)
|
||||
if tx.Error != nil {
|
||||
return fmt.Errorf("failed to add account: %w", tx.Error)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetAccount gets an account from the database
|
||||
func (db *DB) GetAccount(account *orm.Account) error {
|
||||
tx := db.First(account)
|
||||
if tx.Error != nil {
|
||||
return fmt.Errorf("failed to get account: %w", tx.Error)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// UpdateAccount updates an existing account in the database
|
||||
func (db *DB) UpdateAccount(account *orm.Account) error {
|
||||
tx := db.Save(account)
|
||||
if tx.Error != nil {
|
||||
return fmt.Errorf("failed to update account: %w", tx.Error)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeleteAccount deletes an existing account from the database
|
||||
func (db *DB) DeleteAccount(account *orm.Account) error {
|
||||
tx := db.Delete(account)
|
||||
if tx.Error != nil {
|
||||
return fmt.Errorf("failed to delete account: %w", tx.Error)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// AddAsset adds a new asset to the database
|
||||
func (db *DB) AddAsset(asset *orm.Asset) error {
|
||||
tx := db.Create(asset)
|
||||
|
||||
if tx.Error != nil {
|
||||
return fmt.Errorf("failed to add asset: %w", tx.Error)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetAsset gets an asset from the database
|
||||
func (db *DB) GetAsset(asset *orm.Asset) error {
|
||||
tx := db.First(asset)
|
||||
|
||||
if tx.Error != nil {
|
||||
return fmt.Errorf("failed to get asset: %w", tx.Error)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// UpdateAsset updates an existing asset in the database
|
||||
func (db *DB) UpdateAsset(asset *orm.Asset) error {
|
||||
tx := db.Save(asset)
|
||||
|
||||
if tx.Error != nil {
|
||||
return fmt.Errorf("failed to update asset: %w", tx.Error)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeleteAsset deletes an existing asset from the database
|
||||
func (db *DB) DeleteAsset(asset *orm.Asset) error {
|
||||
tx := db.Delete(asset)
|
||||
|
||||
if tx.Error != nil {
|
||||
return fmt.Errorf("failed to delete asset: %w", tx.Error)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// AddCredential adds a new credential to the database
|
||||
func (db *DB) AddCredential(credential *orm.Credential) error {
|
||||
tx := db.Create(credential)
|
||||
|
||||
if tx.Error != nil {
|
||||
return fmt.Errorf("failed to add credential: %w", tx.Error)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetCredential gets an credential from the database
|
||||
func (db *DB) GetCredential(credential *orm.Credential) error {
|
||||
tx := db.First(credential)
|
||||
|
||||
if tx.Error != nil {
|
||||
return fmt.Errorf("failed to get credential: %w", tx.Error)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// UpdateCredential updates an existing credential in the database
|
||||
func (db *DB) UpdateCredential(credential *orm.Credential) error {
|
||||
tx := db.Save(credential)
|
||||
|
||||
if tx.Error != nil {
|
||||
return fmt.Errorf("failed to update credential: %w", tx.Error)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeleteCredential deletes an existing credential from the database
|
||||
func (db *DB) DeleteCredential(credential *orm.Credential) error {
|
||||
tx := db.Delete(credential)
|
||||
|
||||
if tx.Error != nil {
|
||||
return fmt.Errorf("failed to delete credential: %w", tx.Error)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// AddKeyshare adds a new keyshare to the database
|
||||
func (db *DB) AddKeyshare(keyshare *orm.Keyshare) error {
|
||||
tx := db.Create(keyshare)
|
||||
|
||||
if tx.Error != nil {
|
||||
return fmt.Errorf("failed to add keyshare: %w", tx.Error)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetKeyshare gets an keyshare from the database
|
||||
func (db *DB) GetKeyshare(keyshare *orm.Keyshare) error {
|
||||
tx := db.First(keyshare)
|
||||
|
||||
if tx.Error != nil {
|
||||
return fmt.Errorf("failed to get keyshare: %w", tx.Error)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// UpdateKeyshare updates an existing keyshare in the database
|
||||
func (db *DB) UpdateKeyshare(keyshare *orm.Keyshare) error {
|
||||
tx := db.Save(keyshare)
|
||||
|
||||
if tx.Error != nil {
|
||||
return fmt.Errorf("failed to update keyshare: %w", tx.Error)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeleteKeyshare deletes an existing keyshare from the database
|
||||
func (db *DB) DeleteKeyshare(keyshare *orm.Keyshare) error {
|
||||
tx := db.Delete(keyshare)
|
||||
|
||||
if tx.Error != nil {
|
||||
return fmt.Errorf("failed to delete keyshare: %w", tx.Error)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// AddPermission adds a new permission to the database
|
||||
func (db *DB) AddPermission(permission *orm.Permission) error {
|
||||
tx := db.Create(permission)
|
||||
|
||||
if tx.Error != nil {
|
||||
return fmt.Errorf("failed to add permission: %w", tx.Error)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetPermission gets an permission from the database
|
||||
func (db *DB) GetPermission(permission *orm.Permission) error {
|
||||
tx := db.First(permission)
|
||||
|
||||
if tx.Error != nil {
|
||||
return fmt.Errorf("failed to get permission: %w", tx.Error)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// UpdatePermission updates an existing permission in the database
|
||||
func (db *DB) UpdatePermission(permission *orm.Permission) error {
|
||||
tx := db.Save(permission)
|
||||
|
||||
if tx.Error != nil {
|
||||
return fmt.Errorf("failed to update permission: %w", tx.Error)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeletePermission deletes an existing permission from the database
|
||||
func (db *DB) DeletePermission(permission *orm.Permission) error {
|
||||
tx := db.Delete(permission)
|
||||
|
||||
if tx.Error != nil {
|
||||
return fmt.Errorf("failed to delete permission: %w", tx.Error)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// AddProfile adds a new profile to the database
|
||||
func (db *DB) AddProfile(profile *orm.Profile) error {
|
||||
tx := db.Create(profile)
|
||||
|
||||
if tx.Error != nil {
|
||||
return fmt.Errorf("failed to add profile: %w", tx.Error)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetProfile gets an profile from the database
|
||||
func (db *DB) GetProfile(profile *orm.Profile) error {
|
||||
tx := db.First(profile)
|
||||
|
||||
if tx.Error != nil {
|
||||
return fmt.Errorf("failed to get profile: %w", tx.Error)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// UpdateProfile updates an existing profile in the database
|
||||
func (db *DB) UpdateProfile(profile *orm.Profile) error {
|
||||
tx := db.Save(profile)
|
||||
|
||||
if tx.Error != nil {
|
||||
return fmt.Errorf("failed to update profile: %w", tx.Error)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeleteProfile deletes an existing profile from the database
|
||||
func (db *DB) DeleteProfile(profile *orm.Profile) error {
|
||||
tx := db.Delete(profile)
|
||||
|
||||
if tx.Error != nil {
|
||||
return fmt.Errorf("failed to delete profile: %w", tx.Error)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// AddProperty adds a new property to the database
|
||||
func (db *DB) AddProperty(property *orm.Property) error {
|
||||
tx := db.Create(property)
|
||||
|
||||
if tx.Error != nil {
|
||||
return fmt.Errorf("failed to add property: %w", tx.Error)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetProperty gets an property from the database
|
||||
func (db *DB) GetProperty(property *orm.Property) error {
|
||||
tx := db.First(property)
|
||||
|
||||
if tx.Error != nil {
|
||||
return fmt.Errorf("failed to get property: %w", tx.Error)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// UpdateProperty updates an existing property in the database
|
||||
func (db *DB) UpdateProperty(property *orm.Property) error {
|
||||
tx := db.Save(property)
|
||||
|
||||
if tx.Error != nil {
|
||||
return fmt.Errorf("failed to update property: %w", tx.Error)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeleteProperty deletes an existing property from the database
|
||||
func (db *DB) DeleteProperty(property *orm.Property) error {
|
||||
tx := db.Delete(property)
|
||||
|
||||
if tx.Error != nil {
|
||||
return fmt.Errorf("failed to delete property: %w", tx.Error)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
|
||||
"github.com/ncruces/go-sqlite3/gormlite"
|
||||
"golang.org/x/crypto/argon2"
|
||||
"gorm.io/gorm"
|
||||
"lukechampine.com/adiantum/hbsh"
|
||||
"lukechampine.com/adiantum/hpolyc"
|
||||
)
|
||||
|
||||
type DB struct {
|
||||
*gorm.DB
|
||||
}
|
||||
|
||||
func New(opts ...DBOption) (*DB, error) {
|
||||
config := &DBConfig{
|
||||
fileName: "vault.db",
|
||||
}
|
||||
for _, opt := range opts {
|
||||
opt(config)
|
||||
}
|
||||
gormdb, err := gorm.Open(gormlite.Open(config.ConnectionString()))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
db, err := createInitialTables(gormdb)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return db, nil
|
||||
}
|
||||
|
||||
// HBSH creates an HBSH cipher given a key.
|
||||
func (c *DB) HBSH(key []byte) *hbsh.HBSH {
|
||||
if len(key) != 32 {
|
||||
// Key is not appropriate, return nil.
|
||||
return nil
|
||||
}
|
||||
return hpolyc.New(key)
|
||||
}
|
||||
|
||||
// KDF gets a key from a secret.
|
||||
func (c *DB) KDF(secret string) []byte {
|
||||
if secret == "" {
|
||||
// No secret is given, generate a random key.
|
||||
key := make([]byte, 32)
|
||||
n, _ := rand.Read(key)
|
||||
return key[:n]
|
||||
}
|
||||
// Hash the secret with a KDF.
|
||||
return argon2.IDKey([]byte(secret), []byte("hpolyc"), 3, 64*1024, 4, 32)
|
||||
}
|
||||
@@ -1,195 +0,0 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/onsonr/sonr/internal/db/orm"
|
||||
)
|
||||
|
||||
func (db *DB) ServeEcho(e *echo.Group) {
|
||||
e.GET("/accounts", db.HandleAccount)
|
||||
e.GET("/assets", db.HandleAsset)
|
||||
e.GET("/credentials", db.HandleCredential)
|
||||
e.GET("/keyshares", db.HandleKeyshare)
|
||||
e.GET("/permissions", db.HandlePermission)
|
||||
e.GET("/profiles", db.HandleProfile)
|
||||
e.GET("/properties", db.HandleProperty)
|
||||
}
|
||||
|
||||
func (db *DB) HandleAccount(c echo.Context) error {
|
||||
data := new(orm.Account)
|
||||
if err := c.Bind(data); err != nil {
|
||||
return err
|
||||
}
|
||||
// Check the method for GET, POST, PUT, DELETE
|
||||
switch c.Request().Method {
|
||||
case echo.POST:
|
||||
|
||||
if err := db.AddAccount(data); err != nil {
|
||||
return err
|
||||
}
|
||||
return c.JSON(200, "OK")
|
||||
case echo.PUT:
|
||||
|
||||
if err := db.UpdateAccount(data); err != nil {
|
||||
return err
|
||||
}
|
||||
return c.JSON(200, "OK")
|
||||
case echo.DELETE:
|
||||
if err := db.DeleteAccount(data); err != nil {
|
||||
return err
|
||||
}
|
||||
return c.JSON(200, nil)
|
||||
}
|
||||
return c.JSON(200, data)
|
||||
}
|
||||
|
||||
func (db *DB) HandleAsset(c echo.Context) error {
|
||||
data := new(orm.Asset)
|
||||
if err := c.Bind(data); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
switch c.Request().Method {
|
||||
case echo.POST:
|
||||
if err := db.AddAsset(data); err != nil {
|
||||
return err
|
||||
}
|
||||
return c.JSON(200, "OK")
|
||||
case echo.PUT:
|
||||
if err := db.UpdateAsset(data); err != nil {
|
||||
return err
|
||||
}
|
||||
return c.JSON(200, "OK")
|
||||
case echo.DELETE:
|
||||
if err := db.DeleteAsset(data); err != nil {
|
||||
return err
|
||||
}
|
||||
return c.JSON(200, "OK")
|
||||
}
|
||||
return c.JSON(200, data)
|
||||
}
|
||||
|
||||
func (db *DB) HandleCredential(c echo.Context) error {
|
||||
data := new(orm.Credential)
|
||||
if err := c.Bind(data); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
switch c.Request().Method {
|
||||
case echo.POST:
|
||||
if err := db.AddCredential(data); err != nil {
|
||||
return err
|
||||
}
|
||||
return c.JSON(200, "OK")
|
||||
case echo.PUT:
|
||||
if err := db.UpdateCredential(data); err != nil {
|
||||
return err
|
||||
}
|
||||
return c.JSON(200, "OK")
|
||||
case echo.DELETE:
|
||||
if err := db.DeleteCredential(data); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return c.JSON(200, data)
|
||||
}
|
||||
|
||||
func (db *DB) HandleKeyshare(c echo.Context) error {
|
||||
data := new(orm.Keyshare)
|
||||
if err := c.Bind(data); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
switch c.Request().Method {
|
||||
case echo.POST:
|
||||
if err := db.AddKeyshare(data); err != nil {
|
||||
return err
|
||||
}
|
||||
return c.JSON(200, "OK")
|
||||
case echo.PUT:
|
||||
if err := db.UpdateKeyshare(data); err != nil {
|
||||
return err
|
||||
}
|
||||
return c.JSON(200, "OK")
|
||||
case echo.DELETE:
|
||||
if err := db.DeleteKeyshare(data); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return c.JSON(200, data)
|
||||
}
|
||||
|
||||
func (db *DB) HandlePermission(c echo.Context) error {
|
||||
data := new(orm.Permission)
|
||||
if err := c.Bind(data); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
switch c.Request().Method {
|
||||
case echo.POST:
|
||||
if err := db.AddPermission(data); err != nil {
|
||||
return err
|
||||
}
|
||||
return c.JSON(200, "OK")
|
||||
case echo.PUT:
|
||||
if err := db.UpdatePermission(data); err != nil {
|
||||
return err
|
||||
}
|
||||
return c.JSON(200, "OK")
|
||||
case echo.DELETE:
|
||||
if err := db.DeletePermission(data); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return c.JSON(200, data)
|
||||
}
|
||||
|
||||
func (db *DB) HandleProfile(c echo.Context) error {
|
||||
data := new(orm.Profile)
|
||||
if err := c.Bind(data); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
switch c.Request().Method {
|
||||
case echo.POST:
|
||||
if err := db.AddProfile(data); err != nil {
|
||||
return err
|
||||
}
|
||||
return c.JSON(200, "OK")
|
||||
case echo.PUT:
|
||||
if err := db.UpdateProfile(data); err != nil {
|
||||
return err
|
||||
}
|
||||
return c.JSON(200, "OK")
|
||||
case echo.DELETE:
|
||||
if err := db.DeleteProfile(data); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return c.JSON(200, data)
|
||||
}
|
||||
|
||||
func (db *DB) HandleProperty(c echo.Context) error {
|
||||
data := new(orm.Property)
|
||||
if err := c.Bind(data); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
switch c.Request().Method {
|
||||
case echo.POST:
|
||||
if err := db.AddProperty(data); err != nil {
|
||||
return err
|
||||
}
|
||||
return c.JSON(200, "OK")
|
||||
case echo.PUT:
|
||||
if err := db.UpdateProperty(data); err != nil {
|
||||
return err
|
||||
}
|
||||
return c.JSON(200, "OK")
|
||||
case echo.DELETE:
|
||||
if err := db.DeleteProperty(data); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return c.JSON(200, data)
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
_ "github.com/ncruces/go-sqlite3/embed"
|
||||
"github.com/onsonr/sonr/internal/db/orm"
|
||||
)
|
||||
|
||||
type DBOption func(config *DBConfig)
|
||||
|
||||
func WitDir(dir string) DBOption {
|
||||
return func(config *DBConfig) {
|
||||
config.Dir = dir
|
||||
}
|
||||
}
|
||||
|
||||
func WithSecretKey(secretKey string) DBOption {
|
||||
return func(config *DBConfig) {
|
||||
config.SecretKey = secretKey
|
||||
}
|
||||
}
|
||||
|
||||
type DBConfig struct {
|
||||
Dir string
|
||||
SecretKey string
|
||||
|
||||
fileName string
|
||||
initialAccounts []*orm.Account
|
||||
initialAssets []*orm.Asset
|
||||
initialCredentials []*orm.Credential
|
||||
initialKeyshares []*orm.Keyshare
|
||||
initialPermissions []*orm.Permission
|
||||
initialProfiles []*orm.Profile
|
||||
initialProperties []*orm.Property
|
||||
}
|
||||
|
||||
func (config *DBConfig) ConnectionString() string {
|
||||
connStr := "file:"
|
||||
connStr += config.fileName
|
||||
return connStr
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
// Code generated from Pkl module `orm`. DO NOT EDIT.
|
||||
package orm
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/apple/pkl-go/pkl"
|
||||
)
|
||||
|
||||
type Orm struct {
|
||||
}
|
||||
|
||||
// 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) {
|
||||
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 Orm
|
||||
func Load(ctx context.Context, evaluator pkl.Evaluator, source *pkl.ModuleSource) (*Orm, error) {
|
||||
var ret Orm
|
||||
if err := evaluator.EvaluateModule(ctx, source, &ret); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &ret, nil
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
// Code generated from Pkl module `orm`. DO NOT EDIT.
|
||||
package orm
|
||||
|
||||
import "github.com/apple/pkl-go/pkl"
|
||||
|
||||
func init() {
|
||||
pkl.RegisterMapping("orm", Orm{})
|
||||
pkl.RegisterMapping("orm#Account", Account{})
|
||||
pkl.RegisterMapping("orm#Asset", Asset{})
|
||||
pkl.RegisterMapping("orm#Chain", Chain{})
|
||||
pkl.RegisterMapping("orm#Credential", Credential{})
|
||||
pkl.RegisterMapping("orm#Profile", Profile{})
|
||||
pkl.RegisterMapping("orm#Property", Property{})
|
||||
pkl.RegisterMapping("orm#Keyshare", Keyshare{})
|
||||
pkl.RegisterMapping("orm#Permission", Permission{})
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
//go:build js && wasm
|
||||
// +build js,wasm
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/onsonr/sonr/internal/dwn/wasm"
|
||||
|
||||
svc "github.com/onsonr/sonr/internal/dwn/handlers"
|
||||
mdw "github.com/onsonr/sonr/internal/dwn/middleware"
|
||||
"github.com/onsonr/sonr/internal/dwn/views"
|
||||
)
|
||||
|
||||
func main() {
|
||||
e := New()
|
||||
wasm.Serve(e)
|
||||
}
|
||||
|
||||
func registerFrontend(e *echo.Echo) {
|
||||
// Add Public Pages
|
||||
e.GET("/", views.HomeView)
|
||||
e.GET("/login", views.LoginView)
|
||||
e.POST("/login/:identifier", svc.HandleCredentialAssertion)
|
||||
e.GET("/register", views.RegisterView)
|
||||
e.POST("/register/:subject", svc.HandleCredentialCreation)
|
||||
e.POST("/register/:subject/check", svc.CheckSubjectIsValid)
|
||||
e.GET("/profile", views.ProfileView)
|
||||
}
|
||||
|
||||
func registerOpenID(g *echo.Group) {
|
||||
// Add Authenticated Pages
|
||||
g.Use(mdw.MacaroonMiddleware("test", "test"))
|
||||
g.GET("/", views.AuthorizeView)
|
||||
g.GET("/discovery", svc.GetDiscovery)
|
||||
g.GET("/jwks", svc.GetJWKS)
|
||||
g.GET("/token", svc.GetToken)
|
||||
g.POST("/:origin/grant/:subject", svc.GrantAuthorization)
|
||||
}
|
||||
|
||||
func New() *echo.Echo {
|
||||
e := echo.New()
|
||||
e.Use(mdw.UseSession)
|
||||
registerFrontend(e)
|
||||
registerOpenID(e.Group("/authorize"))
|
||||
return e
|
||||
}
|
||||
File renamed without changes.
@@ -53,7 +53,7 @@ func alertElement(attrs templ.Attributes, title, message string, icon templ.Comp
|
||||
var templ_7745c5c3_Var2 string
|
||||
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(title)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gui/elements/alert.templ`, Line: 10, Col: 66}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/elements/alert.templ`, Line: 10, Col: 66}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -66,7 +66,7 @@ func alertElement(attrs templ.Attributes, title, message string, icon templ.Comp
|
||||
var templ_7745c5c3_Var3 string
|
||||
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(message)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gui/elements/alert.templ`, Line: 11, Col: 43}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/elements/alert.templ`, Line: 11, Col: 43}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+2
-2
@@ -92,7 +92,7 @@ func breadcrumbItem(title string, active bool) templ.Component {
|
||||
var templ_7745c5c3_Var3 string
|
||||
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(title)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gui/elements/breadcrumbs.templ`, Line: 23, Col: 126}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/elements/breadcrumbs.templ`, Line: 23, Col: 126}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -110,7 +110,7 @@ func breadcrumbItem(title string, active bool) templ.Component {
|
||||
var templ_7745c5c3_Var4 string
|
||||
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(title)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gui/elements/breadcrumbs.templ`, Line: 25, Col: 118}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/elements/breadcrumbs.templ`, Line: 25, Col: 118}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
File renamed without changes.
@@ -151,7 +151,7 @@ func renderHxGetButton(c *button, attrs templ.Attributes) templ.Component {
|
||||
var templ_7745c5c3_Var3 string
|
||||
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(c.hxGet)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gui/elements/button.templ`, Line: 86, Col: 25}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/elements/button.templ`, Line: 86, Col: 25}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -164,7 +164,7 @@ func renderHxGetButton(c *button, attrs templ.Attributes) templ.Component {
|
||||
var templ_7745c5c3_Var4 string
|
||||
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(c.hxTarget)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gui/elements/button.templ`, Line: 86, Col: 69}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/elements/button.templ`, Line: 86, Col: 69}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -177,7 +177,7 @@ func renderHxGetButton(c *button, attrs templ.Attributes) templ.Component {
|
||||
var templ_7745c5c3_Var5 string
|
||||
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(c.hxTrigger)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gui/elements/button.templ`, Line: 86, Col: 96}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/elements/button.templ`, Line: 86, Col: 96}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -190,7 +190,7 @@ func renderHxGetButton(c *button, attrs templ.Attributes) templ.Component {
|
||||
var templ_7745c5c3_Var6 string
|
||||
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(c.hxSwap)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gui/elements/button.templ`, Line: 86, Col: 117}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/elements/button.templ`, Line: 86, Col: 117}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -245,7 +245,7 @@ func renderHxPostButton(c *button, attrs templ.Attributes) templ.Component {
|
||||
var templ_7745c5c3_Var8 string
|
||||
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(c.hxPost)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gui/elements/button.templ`, Line: 92, Col: 27}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/elements/button.templ`, Line: 92, Col: 27}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -258,7 +258,7 @@ func renderHxPostButton(c *button, attrs templ.Attributes) templ.Component {
|
||||
var templ_7745c5c3_Var9 string
|
||||
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(c.hxTarget)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gui/elements/button.templ`, Line: 92, Col: 52}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/elements/button.templ`, Line: 92, Col: 52}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -271,7 +271,7 @@ func renderHxPostButton(c *button, attrs templ.Attributes) templ.Component {
|
||||
var templ_7745c5c3_Var10 string
|
||||
templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(c.hxTrigger)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gui/elements/button.templ`, Line: 92, Col: 79}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/elements/button.templ`, Line: 92, Col: 79}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -284,7 +284,7 @@ func renderHxPostButton(c *button, attrs templ.Attributes) templ.Component {
|
||||
var templ_7745c5c3_Var11 string
|
||||
templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(c.hxSwap)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gui/elements/button.templ`, Line: 92, Col: 100}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/elements/button.templ`, Line: 92, Col: 100}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
File renamed without changes.
@@ -37,7 +37,7 @@ func renderCard(id string, attrs templ.Attributes) templ.Component {
|
||||
var templ_7745c5c3_Var2 string
|
||||
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(id)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gui/elements/card.templ`, Line: 8, Col: 13}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/elements/card.templ`, Line: 8, Col: 13}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
File renamed without changes.
@@ -19,15 +19,15 @@ func Text(content string) templ.Component {
|
||||
templ renderText(level int, text string) {
|
||||
switch level {
|
||||
case 1:
|
||||
<h1 class="text-2xl lg:text-3xl font-bold">
|
||||
<h1 class="text-2xl lg:text-3xl font-bold pb-3">
|
||||
{ text }
|
||||
</h1>
|
||||
case 2:
|
||||
<h2 class="text-xl lg:text-2xl font-bold">
|
||||
<h2 class="text-xl lg:text-2xl font-bold pb-2">
|
||||
{ text }
|
||||
</h2>
|
||||
case 3:
|
||||
<h3 class="text-md lg:text-xl font-semibold">
|
||||
<h3 class="text-md lg:text-xl font-semibold pb-1">
|
||||
{ text }
|
||||
</h3>
|
||||
default:
|
||||
@@ -44,14 +44,14 @@ func renderText(level int, text string) templ.Component {
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
switch level {
|
||||
case 1:
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<h1 class=\"text-2xl lg:text-3xl font-bold\">")
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<h1 class=\"text-2xl lg:text-3xl font-bold pb-3\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var2 string
|
||||
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(text)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gui/elements/fonts.templ`, Line: 23, Col: 10}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/elements/fonts.templ`, Line: 23, Col: 10}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -62,14 +62,14 @@ func renderText(level int, text string) templ.Component {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
case 2:
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<h2 class=\"text-xl lg:text-2xl font-bold\">")
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<h2 class=\"text-xl lg:text-2xl font-bold pb-2\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var3 string
|
||||
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(text)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gui/elements/fonts.templ`, Line: 27, Col: 10}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/elements/fonts.templ`, Line: 27, Col: 10}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -80,14 +80,14 @@ func renderText(level int, text string) templ.Component {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
case 3:
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<h3 class=\"text-md lg:text-xl font-semibold\">")
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<h3 class=\"text-md lg:text-xl font-semibold pb-1\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var4 string
|
||||
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(text)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gui/elements/fonts.templ`, Line: 31, Col: 10}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/elements/fonts.templ`, Line: 31, Col: 10}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -105,7 +105,7 @@ func renderText(level int, text string) templ.Component {
|
||||
var templ_7745c5c3_Var5 string
|
||||
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(text)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gui/elements/fonts.templ`, Line: 35, Col: 10}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/elements/fonts.templ`, Line: 35, Col: 10}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -153,7 +153,7 @@ func renderLink(attrs templ.Attributes, text string) templ.Component {
|
||||
var templ_7745c5c3_Var7 string
|
||||
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(text)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gui/elements/fonts.templ`, Line: 42, Col: 8}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/elements/fonts.templ`, Line: 42, Col: 8}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -200,7 +200,7 @@ func renderStrong(attrs templ.Attributes, text string) templ.Component {
|
||||
var templ_7745c5c3_Var9 string
|
||||
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(text)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gui/elements/fonts.templ`, Line: 48, Col: 8}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/elements/fonts.templ`, Line: 48, Col: 8}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -247,7 +247,7 @@ func renderEmphasis(attrs templ.Attributes, text string) templ.Component {
|
||||
var templ_7745c5c3_Var11 string
|
||||
templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(text)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gui/elements/fonts.templ`, Line: 54, Col: 8}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/elements/fonts.templ`, Line: 54, Col: 8}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -294,7 +294,7 @@ func renderCode(attrs templ.Attributes, text string) templ.Component {
|
||||
var templ_7745c5c3_Var13 string
|
||||
templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(text)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gui/elements/fonts.templ`, Line: 60, Col: 8}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/elements/fonts.templ`, Line: 60, Col: 8}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
File renamed without changes.
@@ -41,7 +41,7 @@ func Layout(title string) templ.Component {
|
||||
var templ_7745c5c3_Var2 string
|
||||
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(title)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gui/elements/global.templ`, Line: 8, Col: 17}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/elements/global.templ`, Line: 8, Col: 17}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -43,7 +43,7 @@ func TextInput(state InputState, label string, placeholder string) templ.Compone
|
||||
var templ_7745c5c3_Var2 string
|
||||
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(label)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gui/elements/inputs.templ`, Line: 15, Col: 128}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/elements/inputs.templ`, Line: 15, Col: 128}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -61,7 +61,7 @@ func TextInput(state InputState, label string, placeholder string) templ.Compone
|
||||
var templ_7745c5c3_Var3 string
|
||||
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(label)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gui/elements/inputs.templ`, Line: 20, Col: 128}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/elements/inputs.templ`, Line: 20, Col: 128}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -79,7 +79,7 @@ func TextInput(state InputState, label string, placeholder string) templ.Compone
|
||||
var templ_7745c5c3_Var4 string
|
||||
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(label)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/gui/elements/inputs.templ`, Line: 25, Col: 128}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/elements/inputs.templ`, Line: 25, Col: 128}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -0,0 +1,6 @@
|
||||
package elements
|
||||
|
||||
import "github.com/labstack/echo/v4"
|
||||
|
||||
templ Panel(c echo.Context, id string) {
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.2.771
|
||||
package elements
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
|
||||
import "github.com/a-h/templ"
|
||||
import templruntime "github.com/a-h/templ/runtime"
|
||||
|
||||
import "github.com/labstack/echo/v4"
|
||||
|
||||
func Panel(c echo.Context, id string) templ.Component {
|
||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var1 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var1 == nil {
|
||||
templ_7745c5c3_Var1 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
|
||||
var _ = templruntime.GeneratedTemplate
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
oidc "github.com/onsonr/sonr/x/did/types/oidc"
|
||||
oidc "github.com/onsonr/sonr/internal/dwn/models"
|
||||
)
|
||||
|
||||
func GrantAuthorization(e echo.Context) error {
|
||||
File renamed without changes.
@@ -1,4 +1,4 @@
|
||||
package forms
|
||||
package islands
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@@ -1,4 +1,4 @@
|
||||
package forms
|
||||
package islands
|
||||
|
||||
import "github.com/labstack/echo/v4"
|
||||
|
||||
@@ -18,8 +18,8 @@ templ BasicInfo(c echo.Context, state FormState) {
|
||||
}
|
||||
}
|
||||
|
||||
templ CreateCredentials(state FormState) {
|
||||
templ CreateCredentials(c echo.Context, state FormState) {
|
||||
}
|
||||
|
||||
templ PrivacyTerms(state FormState) {
|
||||
templ PrivacyTerms(c echo.Context, state FormState) {
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.2.771
|
||||
package forms
|
||||
package islands
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
|
||||
@@ -39,7 +39,7 @@ func BasicInfo(c echo.Context, state FormState) templ.Component {
|
||||
})
|
||||
}
|
||||
|
||||
func CreateCredentials(state FormState) templ.Component {
|
||||
func CreateCredentials(c echo.Context, state FormState) templ.Component {
|
||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
@@ -61,7 +61,7 @@ func CreateCredentials(state FormState) templ.Component {
|
||||
})
|
||||
}
|
||||
|
||||
func PrivacyTerms(state FormState) templ.Component {
|
||||
func PrivacyTerms(c echo.Context, state FormState) templ.Component {
|
||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
File renamed without changes.
@@ -0,0 +1,28 @@
|
||||
//go:build js && wasm
|
||||
// +build js,wasm
|
||||
|
||||
package mdw
|
||||
|
||||
import (
|
||||
"github.com/donseba/go-htmx"
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
type Browser struct {
|
||||
echo.Context
|
||||
isMobile bool
|
||||
userAgent string
|
||||
width int
|
||||
olc string
|
||||
ksuid string
|
||||
|
||||
// HTMX Specific
|
||||
htmx *htmx.HTMX
|
||||
|
||||
// WebAPIs
|
||||
credentials CredentialsAPI
|
||||
indexedDB IndexedDBAPI
|
||||
localStorage LocalStorageAPI
|
||||
push PushAPI
|
||||
sessionStorage SessionStorageAPI
|
||||
}
|
||||
File renamed without changes.
@@ -0,0 +1,6 @@
|
||||
//go:build js && wasm
|
||||
// +build js,wasm
|
||||
|
||||
package mdw
|
||||
|
||||
type CredentialsAPI interface{}
|
||||
@@ -1,7 +1,7 @@
|
||||
//go:build js && wasm
|
||||
// +build js,wasm
|
||||
|
||||
package idb
|
||||
package mdw
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -12,6 +12,8 @@ import (
|
||||
"github.com/hack-pad/go-indexeddb/idb"
|
||||
)
|
||||
|
||||
type IndexedDBAPI interface{}
|
||||
|
||||
// Model is an interface that must be implemented by types used with Table
|
||||
type Model interface {
|
||||
Table() string
|
||||
@@ -27,12 +29,11 @@ type Table[T Model] struct {
|
||||
// NewTable creates a new Table instance
|
||||
func NewTable[T Model](dbName string, version uint, keyPath string) (*Table[T], error) {
|
||||
ctx := context.Background()
|
||||
factory := idb.Global()
|
||||
|
||||
var model T
|
||||
tableName := model.Table()
|
||||
|
||||
openRequest, err := factory.Open(ctx, dbName, version, func(db *idb.Database, oldVersion, newVersion uint) error {
|
||||
openRequest, err := idb.Global().Open(ctx, dbName, version, func(db *idb.Database, oldVersion, newVersion uint) error {
|
||||
_, err := db.CreateObjectStore(tableName, idb.ObjectStoreOptions{
|
||||
KeyPath: js.ValueOf(keyPath),
|
||||
})
|
||||
@@ -107,6 +108,36 @@ func (t *Table[T]) Query(key interface{}) (T, error) {
|
||||
return result, err
|
||||
}
|
||||
|
||||
// First retrieves the first record from the table
|
||||
func (t *Table[T]) First(data T) error {
|
||||
tx, err := t.db.Transaction(idb.TransactionReadOnly, data.Table())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer tx.Commit()
|
||||
|
||||
objectStore, err := tx.ObjectStore(data.Table())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
request, err := objectStore.Get(js.ValueOf(t.keyPath))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
value, err := request.Await(context.Background())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if value.IsUndefined() || value.IsNull() {
|
||||
return errors.New("record not found")
|
||||
}
|
||||
|
||||
err = json.Unmarshal([]byte(value.String()), &data)
|
||||
return err
|
||||
}
|
||||
|
||||
// Delete removes a record from the table based on a key
|
||||
func (t *Table[T]) Delete(key interface{}) error {
|
||||
var model T
|
||||
@@ -125,6 +156,28 @@ func (t *Table[T]) Delete(key interface{}) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// Save updates a record in the table based on a key
|
||||
func (t *Table[T]) Save(data T) error {
|
||||
tx, err := t.db.Transaction(idb.TransactionReadWrite, data.Table())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer tx.Commit()
|
||||
|
||||
objectStore, err := tx.ObjectStore(data.Table())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
jsonData, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = objectStore.Put(js.ValueOf(string(jsonData)))
|
||||
return err
|
||||
}
|
||||
|
||||
// Close closes the database connection
|
||||
func (t *Table[T]) Close() error {
|
||||
return t.db.Close()
|
||||
File renamed without changes.
@@ -0,0 +1,6 @@
|
||||
//go:build js && wasm
|
||||
// +build js,wasm
|
||||
|
||||
package mdw
|
||||
|
||||
type PushAPI interface{}
|
||||
@@ -6,14 +6,12 @@ import (
|
||||
|
||||
"github.com/donseba/go-htmx"
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/onsonr/sonr/internal/db"
|
||||
"github.com/segmentio/ksuid"
|
||||
)
|
||||
|
||||
type Session struct {
|
||||
echo.Context
|
||||
htmx *htmx.HTMX
|
||||
dB *db.DB
|
||||
}
|
||||
|
||||
// GetSession returns the current Session
|
||||
@@ -31,10 +29,6 @@ func UseSession(next echo.HandlerFunc) echo.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Session) DB() *db.DB {
|
||||
return c.dB
|
||||
}
|
||||
|
||||
func (c *Session) Htmx() *htmx.HTMX {
|
||||
return c.htmx
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
//go:build js && wasm
|
||||
// +build js,wasm
|
||||
|
||||
package mdw
|
||||
|
||||
type LocalStorageAPI interface{}
|
||||
|
||||
type SessionStorageAPI interface{}
|
||||
@@ -1,5 +1,5 @@
|
||||
// Code generated from Pkl module `orm`. DO NOT EDIT.
|
||||
package orm
|
||||
// Code generated from Pkl module `models`. DO NOT EDIT.
|
||||
package models
|
||||
|
||||
type Account struct {
|
||||
Id uint `pkl:"id" gorm:"primaryKey,autoIncrement" json:"id,omitempty" query:"id"`
|
||||
@@ -1,5 +1,5 @@
|
||||
// Code generated from Pkl module `orm`. DO NOT EDIT.
|
||||
package orm
|
||||
// Code generated from Pkl module `models`. DO NOT EDIT.
|
||||
package models
|
||||
|
||||
type Asset struct {
|
||||
Id uint `pkl:"id" gorm:"primaryKey,autoIncrement" json:"id,omitempty" query:"id"`
|
||||
@@ -1,5 +1,5 @@
|
||||
// Code generated from Pkl module `orm`. DO NOT EDIT.
|
||||
package orm
|
||||
// Code generated from Pkl module `models`. DO NOT EDIT.
|
||||
package models
|
||||
|
||||
type Chain struct {
|
||||
Id uint `pkl:"id" gorm:"primaryKey,autoIncrement" json:"id,omitempty" query:"id"`
|
||||
@@ -1,5 +1,5 @@
|
||||
// Code generated from Pkl module `orm`. DO NOT EDIT.
|
||||
package orm
|
||||
// Code generated from Pkl module `models`. DO NOT EDIT.
|
||||
package models
|
||||
|
||||
type Credential struct {
|
||||
Id uint `pkl:"id" gorm:"primaryKey,autoIncrement" json:"id,omitempty" query:"id"`
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
// Code generated from Pkl module `oidc`. DO NOT EDIT.
|
||||
package oidc
|
||||
// Code generated from Pkl module `models`. DO NOT EDIT.
|
||||
package models
|
||||
|
||||
type DiscoveryDocument struct {
|
||||
Issuer string `pkl:"issuer" json:"issuer,omitempty" param:"issuer"`
|
||||
@@ -1,5 +1,5 @@
|
||||
// Code generated from Pkl module `orm`. DO NOT EDIT.
|
||||
package orm
|
||||
// Code generated from Pkl module `models`. DO NOT EDIT.
|
||||
package models
|
||||
|
||||
type Keyshare struct {
|
||||
Id uint `pkl:"id" gorm:"primaryKey,autoIncrement" json:"id,omitempty" query:"id"`
|
||||
@@ -1,5 +1,5 @@
|
||||
// Code generated from Pkl module `oidc`. DO NOT EDIT.
|
||||
package oidc
|
||||
// Code generated from Pkl module `models`. DO NOT EDIT.
|
||||
package models
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -7,11 +7,11 @@ import (
|
||||
"github.com/apple/pkl-go/pkl"
|
||||
)
|
||||
|
||||
type Oidc struct {
|
||||
type Models struct {
|
||||
}
|
||||
|
||||
// LoadFromPath loads the pkl module at the given path and evaluates it into a Oidc
|
||||
func LoadFromPath(ctx context.Context, path string) (ret *Oidc, 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
|
||||
@@ -26,9 +26,9 @@ func LoadFromPath(ctx context.Context, path string) (ret *Oidc, err error) {
|
||||
return ret, err
|
||||
}
|
||||
|
||||
// Load loads the pkl module at the given source and evaluates it with the given evaluator into a Oidc
|
||||
func Load(ctx context.Context, evaluator pkl.Evaluator, source *pkl.ModuleSource) (*Oidc, error) {
|
||||
var ret Oidc
|
||||
// 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,5 +1,5 @@
|
||||
// Code generated from Pkl module `orm`. DO NOT EDIT.
|
||||
package orm
|
||||
// Code generated from Pkl module `models`. DO NOT EDIT.
|
||||
package models
|
||||
|
||||
type Permission struct {
|
||||
Id uint `pkl:"id" gorm:"primaryKey,autoIncrement" json:"id,omitempty" query:"id"`
|
||||
@@ -1,5 +1,5 @@
|
||||
// Code generated from Pkl module `orm`. DO NOT EDIT.
|
||||
package orm
|
||||
// Code generated from Pkl module `models`. DO NOT EDIT.
|
||||
package models
|
||||
|
||||
type Profile struct {
|
||||
Id string `pkl:"id" gorm:"primaryKey,autoIncrement" json:"id,omitempty" query:"id"`
|
||||
@@ -1,5 +1,5 @@
|
||||
// Code generated from Pkl module `orm`. DO NOT EDIT.
|
||||
package orm
|
||||
// Code generated from Pkl module `models`. DO NOT EDIT.
|
||||
package models
|
||||
|
||||
type Property struct {
|
||||
Id uint `pkl:"id" gorm:"primaryKey,autoIncrement" json:"id,omitempty" query:"id"`
|
||||
@@ -0,0 +1,17 @@
|
||||
// Code generated from Pkl module `models`. DO NOT EDIT.
|
||||
package models
|
||||
|
||||
import "github.com/apple/pkl-go/pkl"
|
||||
|
||||
func init() {
|
||||
pkl.RegisterMapping("models", Models{})
|
||||
pkl.RegisterMapping("models#Account", Account{})
|
||||
pkl.RegisterMapping("models#Asset", Asset{})
|
||||
pkl.RegisterMapping("models#Chain", Chain{})
|
||||
pkl.RegisterMapping("models#Credential", Credential{})
|
||||
pkl.RegisterMapping("models#Profile", Profile{})
|
||||
pkl.RegisterMapping("models#Property", Property{})
|
||||
pkl.RegisterMapping("models#Keyshare", Keyshare{})
|
||||
pkl.RegisterMapping("models#Permission", Permission{})
|
||||
pkl.RegisterMapping("models#DiscoveryDocument", DiscoveryDocument{})
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package orm
|
||||
package models
|
||||
|
||||
func (a *Account) Table() string {
|
||||
return "accounts"
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -2,7 +2,7 @@ package views
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/onsonr/sonr/internal/gui/elements"
|
||||
"github.com/onsonr/sonr/internal/dwn/elements"
|
||||
)
|
||||
|
||||
func HomeView(c echo.Context) error {
|
||||
@@ -10,7 +10,7 @@ import templruntime "github.com/a-h/templ/runtime"
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/onsonr/sonr/internal/gui/elements"
|
||||
"github.com/onsonr/sonr/internal/dwn/elements"
|
||||
)
|
||||
|
||||
func HomeView(c echo.Context) error {
|
||||
@@ -2,7 +2,7 @@ package views
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/onsonr/sonr/internal/gui/elements"
|
||||
"github.com/onsonr/sonr/internal/dwn/elements"
|
||||
)
|
||||
|
||||
func LoginView(c echo.Context) error {
|
||||
@@ -10,7 +10,7 @@ import templruntime "github.com/a-h/templ/runtime"
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/onsonr/sonr/internal/gui/elements"
|
||||
"github.com/onsonr/sonr/internal/dwn/elements"
|
||||
)
|
||||
|
||||
func LoginView(c echo.Context) error {
|
||||
@@ -2,7 +2,7 @@ package views
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/onsonr/sonr/internal/gui/elements"
|
||||
"github.com/onsonr/sonr/internal/dwn/elements"
|
||||
)
|
||||
|
||||
func AuthorizeView(c echo.Context) error {
|
||||
Loaded 100 of 118 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user