Files
sonr/pkl/ORM.pkl
T

275 lines
3.7 KiB
Plaintext
Raw Normal View History

@go.Package { name = "github.com/onsonr/sonr/internal/orm" }
2024-09-07 18:12:58 -04:00
2024-09-30 19:44:16 -04:00
module orm
2024-09-07 18:12:58 -04:00
import "package://pkg.pkl-lang.org/pkl-go/pkl.golang@0.5.0#/go.pkl"
2024-09-18 02:22:17 -04:00
typealias Base58 = String
typealias Base64 = String
2024-09-07 18:12:58 -04:00
2024-09-18 02:22:17 -04:00
typealias Bech32 = String
typealias Keccak = String
2024-09-07 18:12:58 -04:00
2024-09-18 02:22:17 -04:00
typealias ChainCode = UInt
typealias Scope = String
2024-09-07 18:12:58 -04:00
2024-09-18 02:22:17 -04:00
typealias Hex = String
2024-09-07 18:12:58 -04:00
2024-09-18 02:22:17 -04:00
class PrimaryKey extends go.Field {
2024-09-07 18:12:58 -04:00
structTags {
2024-09-18 02:22:17 -04:00
["json"] = "%{name},omitempty"
["query"] = "%{name}"
2024-09-07 18:12:58 -04:00
}
}
class JsonField extends go.Field {
structTags {
["json"] = "%{name},omitempty"
}
}
2024-09-19 02:04:22 -04:00
// Enums
typealias AssetType = "native"|"wrapped"|"staking"|"pool"|"ibc"|"cw20"
typealias DIDMethod = "ipfs"|"sonr"|"bitcoin"|"ethereum"|"ibc"|"webauthn"|"dwn"|"service"
typealias KeyAlgorithm = "es256"|"es384"|"es512"|"eddsa"|"es256k"|"ecdsa"
typealias KeyCurve = "p256"|"p384"|"p521"|"x25519"|"x448"|"ed25519"|"ed448"|"secp256k1"|"bls12381"|"keccak256"
typealias KeyEncoding = "raw"|"hex"|"multibase"
typealias KeyRole = "authentication"|"assertion"|"delegation"|"invocation"
typealias KeyType = "octet"|"elliptic"|"rsa"|"symmetric"|"hmac"|"mpc"|"zk"|"webauthn"|"bip32"
typealias KeyShareRole = "user"|"validator"
typealias PermissionGrant = "none"|"read"|"write"|"verify"|"broadcast"|"admin"
typealias PermissionScope = "profile"|"metadata"|"permissions"|"wallets"|"transactions"|"user"|"validator"
2024-09-11 15:10:54 -04:00
class Account {
2024-09-07 18:12:58 -04:00
@PrimaryKey
2024-10-01 18:55:02 -04:00
id: String
2024-09-07 18:12:58 -04:00
@JsonField
name: String
@JsonField
2024-09-18 02:22:17 -04:00
address: Bech32|Keccak|String
2024-09-07 18:12:58 -04:00
@JsonField
2024-09-18 02:22:17 -04:00
publicKey: Base58
@JsonField
chainCode: ChainCode
@JsonField
index: Int
@JsonField
controller: Bech32
2024-09-07 18:12:58 -04:00
@JsonField
createdAt: String?
}
2024-09-11 15:10:54 -04:00
class Asset {
2024-09-07 18:12:58 -04:00
@PrimaryKey
2024-10-01 18:55:02 -04:00
id: String
2024-09-07 18:12:58 -04:00
@JsonField
name: String
@JsonField
symbol: String
@JsonField
decimals: Int
@JsonField
2024-09-18 02:22:17 -04:00
chainCode: ChainCode
2024-09-07 18:12:58 -04:00
@JsonField
createdAt: String?
}
2024-09-11 15:10:54 -04:00
class Chain {
2024-09-07 18:12:58 -04:00
@PrimaryKey
2024-10-01 18:55:02 -04:00
id: String
2024-09-07 18:12:58 -04:00
@JsonField
name: String
@JsonField
networkId: String
2024-09-18 02:22:17 -04:00
@JsonField
chainCode: ChainCode
2024-09-07 18:12:58 -04:00
@JsonField
createdAt: String?
}
2024-09-11 15:10:54 -04:00
class Credential {
2024-09-07 18:12:58 -04:00
@PrimaryKey
2024-10-01 18:55:02 -04:00
id: String
2024-09-07 18:12:58 -04:00
@JsonField
subject: String
@JsonField
2024-09-18 02:22:17 -04:00
controller: Bech32
2024-09-07 18:12:58 -04:00
@JsonField
attestationType: String
@JsonField
origin: String
2024-09-19 02:04:22 -04:00
@JsonField
label: String?
@JsonField
deviceId: String?
2024-09-07 18:12:58 -04:00
@JsonField
2024-09-18 02:22:17 -04:00
credentialId: Base64
2024-09-07 18:12:58 -04:00
@JsonField
2024-09-18 02:22:17 -04:00
publicKey: Base64
2024-09-07 18:12:58 -04:00
@JsonField
2024-09-18 02:22:17 -04:00
transport: List<String>
2024-09-07 18:12:58 -04:00
@JsonField
signCount: UInt
@JsonField
userPresent: Boolean
@JsonField
userVerified: Boolean
@JsonField
backupEligible: Boolean
@JsonField
backupState: Boolean
@JsonField
cloneWarning: Boolean
@JsonField
createdAt: String?
@JsonField
updatedAt: String?
}
2024-10-01 18:55:02 -04:00
class DID {
@PrimaryKey
id: String
role: KeyRole
algorithm: KeyAlgorithm
encoding: KeyEncoding
curve: KeyCurve
key_type: KeyType
raw: Base64
jwk: JWK
}
2024-09-19 02:04:22 -04:00
class JWK {
@JsonField
kty: String
@JsonField
crv: String
@JsonField
x: String
@JsonField
y: String
@JsonField
n: String
@JsonField
e: String
}
2024-09-18 02:22:17 -04:00
class Grant {
2024-09-07 18:12:58 -04:00
@PrimaryKey
2024-09-18 02:22:17 -04:00
id: UInt
2024-09-07 18:12:58 -04:00
@JsonField
subject: String
@JsonField
2024-09-18 02:22:17 -04:00
controller: Bech32
2024-09-07 18:12:58 -04:00
@JsonField
2024-09-18 02:22:17 -04:00
origin: String
2024-09-07 18:12:58 -04:00
@JsonField
2024-09-18 02:22:17 -04:00
token: String
2024-09-07 18:12:58 -04:00
@JsonField
2024-09-18 02:22:17 -04:00
scopes: List<String>
2024-09-07 18:12:58 -04:00
@JsonField
createdAt: String?
@JsonField
updatedAt: String?
}
2024-09-18 02:22:17 -04:00
class Keyshare {
2024-09-07 18:12:58 -04:00
@PrimaryKey
2024-10-01 18:55:02 -04:00
id: String
2024-09-07 18:12:58 -04:00
@JsonField
2024-09-18 02:22:17 -04:00
data: Base64
2024-09-07 18:12:58 -04:00
@JsonField
2024-09-18 02:22:17 -04:00
role: Int
2024-09-07 18:12:58 -04:00
@JsonField
2024-09-18 02:22:17 -04:00
createdAt: String?
2024-09-07 18:12:58 -04:00
@JsonField
2024-09-18 02:22:17 -04:00
lastRefreshed: String?
2024-09-07 18:12:58 -04:00
}
2024-09-18 02:22:17 -04:00
class Profile {
@PrimaryKey
id: String
2024-09-07 18:12:58 -04:00
@JsonField
2024-09-18 02:22:17 -04:00
subject: String
2024-09-07 18:12:58 -04:00
@JsonField
2024-09-18 02:22:17 -04:00
controller: Bech32
2024-09-07 18:12:58 -04:00
@JsonField
2024-09-18 02:22:17 -04:00
originUri: String?
2024-09-07 18:12:58 -04:00
@JsonField
2024-09-18 02:22:17 -04:00
publicMetadata: String?
2024-09-07 18:12:58 -04:00
@JsonField
2024-09-18 02:22:17 -04:00
privateMetadata: String?
2024-09-07 18:12:58 -04:00
@JsonField
createdAt: String?
@JsonField
updatedAt: String?
}
2024-09-19 02:04:22 -04:00
db_name: String = "vault"
db_version: Int = 1